Search Results

Search found 205 results on 9 pages for 'yang'.

Page 3/9 | < Previous Page | 1 2 3 4 5 6 7 8 9  | Next Page >

  • MVC moq unit test the object before RedirecToAction()

    - by Daoming Yang
    I want to test the data inside the "item" object before it redirect to another action. public ActionResult WebPageEdit(WebPage item, FormCollection form) { if (ModelState.IsValid) { item.Description = Utils.CrossSiteScriptingAttackCheck(item.Description); item.Content = Utils.CrossSiteScriptingAttackCheck(item.Content); item.Title = item.Title.Trim(); item.DateUpdated = DateTime.Now; // Other logic stuff here webPagesRepository.Save(item); return RedirectToAction("WebPageList"); } Here is my Test method: [Test] public void Admin_WebPageEdit_Save() { var controller = new AdminController(); controller.webPagesRepository = DataMock.WebPageDataInit(); controller.categoriesRepository = DataMock.WebPageCategoryDataInit(); FormCollection form = DataMock.CreateWebPageFormCollection(); RedirectToRouteResult actionResult = (RedirectToRouteResult)controller.WebPageEdit(webPagesRepository.Get(1), form); Assert.IsNotNull(actionResult); Assert.AreEqual("WebPageList", actionResult.RouteValues["action"]); var item = ((ViewResult)controller.WebPageEdit(webPagesRepository.Get(1), form)).ViewData.Model as WebPage; Assert.NotNull(item); Assert.AreEqual(2, item.CategoryID); } It failed at this line: var item = ((ViewResult)controller.WebPageEdit(webPagesRepository.Get(1), form)).ViewData.Model as WebPage; I am thinking about is there any ways to test the "item" object before it redirect to other actions?

    Read the article

  • Windows Form: showing child object value in the DataGridView

    - by Daoming Yang
    I have a productVariant object which has child product object. I want to show the value in the DataGridView, can anyone let me know how to do this? Here is the structure of the object. I tried to bind "ProductVariant.Product.Name" to the DataProptertyName in the DataGridView, however, it did not not showing any value. Can anyone help with this? Many thanks.

    Read the article

  • Adding an attribute to a class by using properties editor

    - by Fred Yang
    Visual studio allows you to design component visually. For example, you are designing a windows form. You change its property in the properties editor. The IDE will generate the code in a partial class in xx.designer.cs file. We can customize this behavior by changing the UITypeEditor for the properties. The question now is , Can we extend this code generation behavior? for example, we change a setting in property window, and then the IDE will add an .net Attribute to the class? Thanks

    Read the article

  • What is purpuse of T4 Generator in T4toolbox

    - by Fred Yang
    I am using T4toolbox, I am confused what the generator is for. I can run the following public class Generator1 : Generator { protected override void RunCore() { Template1 t = new Template1(); t.Output.File = "t3.txt"; t.Render(); } } or I can run t4 script directly like the following. Template1 t = new Template1(); t.Output.File = "t3.txt"; t.Render(); But I can do the same using t4 script without generator as well. So I mean can do the same thing with two approach "script -- generator -- template" and "script -- template", am I missing something? Thanks

    Read the article

  • something about sql-dump

    - by Yang
    hi, guys, i know that sql dump is a series of insert sql statement which reflects all the records inside the database. but may i know what is it used for? why should we dump the database records? is every database supports dumping function? Any additional background information is welcomed! Thanks in advance!

    Read the article

  • Is there any better IDOMImplementation other than MSXML?

    - by Chau Chee Yang
    There are 3 IDOMImplementation available in Delphi: MSXML Xerces XML ADOM XML v4 MSXML is the default IDOMImplementation. My test is count the time need to load a 10MB xml file. I use a Delphi unit generated from a XSD using XML data binding to load the xml file. This unit has 3 common function: function Getmenubar(Doc: IXMLDocument): IXMLMenubarType; function Loadmenubar(const FileName: WideString): IXMLMenubarType; function Newmenubar: IXMLMenubarType; I learn from the web that some comment that MSXML's overhead is high that it doesn't perform if compare to other XML parser. However, my study shows that MSXML is the best among others. Xerces XML 2nd and ADOM XML v4 the worst: MSXML - 0.6410 seconds Xerces XML - 2.4220 seconds ADOM XML v4 - 67.50 seconds I also come across with OmniXML that claim to have much better performance compare to MSXML but I never success using it with the unit generated by XML data binding. Is there any other vendor that implement IDOMImplementation of Delphi that work much better than MSXML? I am using Delphi 2010 and Windows 7.

    Read the article

  • Studying MySQL, SQLite source code to learn about RDBMS implementation

    - by Yang
    I know implementing database is a huge topic, but I want to have a basic understanding of how database systems work (e.g. memory management, binary tree, transaction, sql parsing, multi-threading, partitions, etc) by investigating the source code of the database. Since there are a few already proven very robust open source databases like mysql, sqlite and so on. However, the code are very complicated and I have no clue where to start. Also I find that the old school database textbooks are only explaining the theory, not the implementation details. Can anyone suggest how I should get started and if there are any books that emphasis on the technology and techniques of building dbms used in modern database industry?

    Read the article

  • Most efficient way of creating tree from adjacency list

    - by Jeff Meatball Yang
    I have an adjacency list of objects (rows loaded from SQL database with the key and it's parent key) that I need to use to build an unordered tree. It's guaranteed to not have cycles. This is taking wayyy too long (processed only ~3K out of 870K nodes in about 5 minutes). Running on my workstation Core 2 Duo with plenty of RAM. Any ideas on how to make this faster? public class StampHierarchy { private StampNode _root; private SortedList<int, StampNode> _keyNodeIndex; // takes a list of nodes and builds a tree // starting at _root private void BuildHierarchy(List<StampNode> nodes) { Stack<StampNode> processor = new Stack<StampNode>(); _keyNodeIndex = new SortedList<int, StampNode>(nodes.Count); // find the root _root = nodes.Find(n => n.Parent == 0); // find children... processor.Push(_root); while (processor.Count != 0) { StampNode current = processor.Pop(); // keep a direct link to the node via the key _keyNodeIndex.Add(current.Key, current); // add children current.Children.AddRange(nodes.Where(n => n.Parent == current.Key)); // queue the children foreach (StampNode child in current.Children) { processor.Push(child); nodes.Remove(child); // thought this might help the Where above } } } } public class StampNode { // properties: int Key, int Parent, string Name, List<StampNode> Children }

    Read the article

  • UDF call in entity framework is cached

    - by Fred Yang
    I am doing a test after reading an article http://blogs.msdn.com/alexj/archive/2009/08/07/tip-30-how-to-use-a-custom-store-function.aspx about udf function called. When I use a function with objectContext.Entities.Where( t= udf(para1, para2) == 1), here the Entities is not ObjectQuery, but an ObjectSet, the first time I call the method, it runs correctly, if I reuse the objectContext,and run it again but with different para1, para2, then the previous parameter values still cached, and the result is same as previous one, which is wrong. The sql profiler shows that both query hit the database, but the t-sql is the same. Am I missing something? And the ObjectSet does not support .where(esql_string). How to get udf working with ObjectSet? Thanks Fred

    Read the article

  • How to group a complex list of objects using LINQ?

    - by Daoming Yang
    I want to select and group the products, and rank them by the number of times they occur. For example, I have an OrderList each of order object has a OrderProductVariantList(OrderLineList), and each of OrderProductVariant object has ProductVariant, and then the ProductVariant object will have a Product object which contains product information. A friend helped me with the following code. It could be compiled, but it did not return any value/result. I used the watch window for the query and it gave me "The name 'query' does not exist in the current context". Can anyone help me? Many thanks. var query = orderList.SelectMany( o => o.OrderLineList ) // results in IEnumerable<OrderProductVariant> .Select( opv => opv.ProductVariant ) .Select( pv => p.Product ) .GroupBy( p => p ) .Select( g => new { Product = g.Key, Count = g.Count() });

    Read the article

  • FileReference.load() does not as excepted

    - by Yang Bo
    I used Flash player 10, and Flex SDK 3.4. The code as followings: // Following comes callbacks function imageLoadOpenCallback(evt:Event):void { trace("in--open"); } function imageLoadCompleteCallback(evt:Event):void { trace("in--load"); var fr:FileReference = evt.target as FileReference; trace(fr.data); } function imageLoadErrorCallback(evt:IOErrorEvent):void { trace("in--ioerror"); } function imageSelectCancelCallback(evt:Event):void { trace("in cancel"); } function imageSelectCallback(evt:Event):void { trace("in -- select"); for (var i:int=0; i<frl.fileList.length; i++) { frl.fileList[i].addEventListener(Event.OPEN, imageLoadOpenCallback); frl.fileList[i].addEventListener(Event.COMPLETE, imageLoadCompleteCallback); frl.fileList[i].addEventListener(IOErrorEvent.IO_ERROR, imageLoadErrorCallback); frl.fileList[i].load(); trace(frl.fileList[i]); trace(frl.fileList[i].creationDate); trace(frl.fileList[i].creator); trace(frl.fileList[i].data); trace(frl.fileList[i].name); } } // Following comes UI handlers function onAddPictures():void { var imageFilter:FileFilter = new FileFilter("Images", "*.jpg;*.png"); frl.addEventListener(Event.SELECT, imageSelectCallback); frl.addEventListener(Event.CANCEL, imageSelectCancelCallback); frl.browse([imageFilter]); } Only the imageSelectCancelCallback handler get called when I select some files in the dialog. But no load/open/io_error handler get called at all. I have Google some code example, in which it used FileReference instead of FileReferenceList. I don't know the reason, could you please help me?

    Read the article

  • Javscript closure questions

    - by Shuchun Yang
    While I was reading the book Javascript: The Good Parts. I can not understand the piece of code bellow: We can generalize this by making a function that helps us make memoized functions. The memoizer function will take an initial memo array and the fundamental function. It returns a shell function that manages the memo store and that calls the fundamental function as needed. We pass the shell function and the function's parameters to the fundamental function: var memoizer = function (memo, fundamental) { var shell = function (n) { var result = memo[n]; if (typeof result !== 'number') { result = fundamental(shell, n); memo[n] = result; } return result; }; return shell; }; We can now define fibonacci with the memoizer, providing the initial memo array and fundamental function: var fibonacci = memoizer([0, 1], function (test, n) { return test(n - 1) + test(n - 2); }); My question is what is the test function? When does it get defined and invoked? It seems very confusing to me. Also I think this statement: memo[n] = result; is useless. Please correct if I am wrong.

    Read the article

  • Visual Modeler in VS 6

    - by Yogi Yang 007
    Till date I have used only VB6 Professional for developing apps. But recently I have joined a company which owns VS 6 Enterprise (or some such version) I was just exploring what is available in VS 6 Ent. and I found Visual Modeler. The tutorial provided with it is not good enough. I was wondering if there is any detailed tutorial(s) for Visual Modeler? Is Visual Modeler a cut down version of Rational Rose? I have never used such a tool for developing apps. What are the benefits of developing apps like this? The document claims that one can speed up development and modifications of VB6 & VC++ 6 applications. How true is this claim? My company also has Ration Rose 6. Which is better Rational Rose 6 or Visual Modeler that comes with VS 6 Ent.?

    Read the article

  • Java Regex Matcher Question

    - by Yang
    How do I match an URL string like this: img src = "http://stackoverflow.com/a/b/c/d/someimage.jpg" where only the domain name and the file extension (jpg) is fixed while others are variables? The following code does not seem working: Pattern p = Pattern.compile("<img src=\"http://stachoverflow.com/.*jpg"); // Create a matcher with an input string Matcher m = p.matcher(url); while (m.find()) { String s = m.toString(); }

    Read the article

  • ASP with Crystal Report 9 hangs on .NET framework 3.5

    - by Chris Yang
    We have an ASP (not ASP.NET) application running on Windows 2003 server. One of the functions of the application is to generate reports using Crystal Report 9. It has been working without any problem with .NET Framework 2.0 and now it is required to install .NET Framework 3.5 SP1 on the server but after we installed the 3.5 SP1, every time we run the application the Crystal report is not generated and the web page hangs so we have to recycle the application pool in IIS to get the application back going. Does anyone have any idea/solution to this problem? Any help will be greatly appreciate.

    Read the article

  • Makefile error: Unexpected end of line seen

    - by Winston C. Yang
    Trying to install Git, I ran configure and make, but got the following error message: make: Fatal error in reader: Makefile, line 221: Unexpected end of line seen The Makefile looks like: 218: GIT-VERSION-FILE: FORCE 219: @$(SHELL_PATH) ./GIT-VERSION-GEN 220: -include GIT-VERSION-FILE 221: 222: uname_S := $(shell sh -c 'uname -s 2>/dev/null øø echo not') What's causing the error? The following information may or may not be relevant: I tried to install Git 1.7.0.3 on SunOS 5.9 (Solaris 9) in a directory in my account. The gcc version is 3.4.2 (older then the version of 3.4.6 stated by sunfreeware.com). I don't have root privileges.

    Read the article

  • understanding json

    - by Yang
    JSON stands for JavaScript Object Notation. But how come languages like php, java, c etc can also communication each other with json. What I want to know is that, am i correct to say that json is not limited to js only, but served as a protocol for applications to communicate with each other over the network, which is the same purpose as XML?

    Read the article

  • Reading Foxpro database date field using PHP

    - by Bill Yang
    I've wrote a PHP script to export a Foxpro database to other formats by using ADODB (http://phplens.com/lens/adodb) library to access Foxpro OLE DB provider. Everything worked fine except the date fields are mangled and become like these: 11/17-/2-00 3/4/-20-08 By comparing to actual data I can guess that it is probably in the format of MM/DD/YYYY or m/d/YYYY. How can I properly export the date field?

    Read the article

  • mysql, sqlite database source code

    - by Yang
    hi guys, i know implementing database is a huge topic, but i want to have a basic understanding of how database systems works (e.g. memory management, binary tree, transaction, sql parsing, multi-threading, partitions, etc) by investigating the source code of the database, since there are a few already proven very robust open source databases like mysql, sqlite and so on. however, the code are very complicated and i have no clue where to start. also i find that the old school database textbooks are only explaining the theory, not the implementation details. Can anyone suggest how should i get started and is there any books that emphasis on the technology and techniques of building dbms used in modern database industry? Thank in advance!

    Read the article

  • Bloated PDF created by TCPDF

    - by Yogi Yang 007
    In a web app developed in PHP we are generating Quotations and Invoices (which are very simple and of single page) using TCPDF lib. The lib is working just great but it seems to generate very large PDF files. For example in our case it is generating PDF files as large as 4 MB (+/- a few KB). How to reduce this bloating of PDF files generated by TCPDF? Here is code snippet that I am using ob_start(); include('quote_view_bag_pdf.php'); //This file is valid HTML file with PHP code to insert data from DB $quote = ob_get_contents(); //Capture the content of 'quote_view_bag_pdf.php' file and store in variable ob_end_clean(); //Code to generate PDF file for this Quote //This line is to fix a few errors in tcpdf $k_path_url=''; require_once('tcpdf/config/lang/eng.php'); require_once('tcpdf/tcpdf.php'); // create new PDF document $pdf = new TCPDF(); // remove default header/footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // add a page $pdf->AddPage(); // print html formated text $pdf->writeHtml($quote, true, 0, true, 0); //Insert Variables contents here. //Build Out File Name $pdf_out_file = "pdf/Quote_".$_POST['quote_id']."_.pdf"; //Close and output PDF document $pdf->Output($pdf_out_file, 'F'); $pdf->Output($pdf_out_file, 'I'); /////////////// enter code here Hope this code fragment will give some idea?

    Read the article

  • Face detection in 100% pure PHP

    - by Yogi Yang 007
    I am looking for PHP script that will detect face in a uploaded photo and automatically crop it accordingly. The code should be in pure PHP without depending on any third party API's or Libs. This code will be a part of our existing code for processing images. In fact this is the only part that is missing! I would prefer to have code in PHP version 5.x not PHP 6.x.

    Read the article

  • Accessing Arguments, Workflow Variables from custom activities

    - by yang
    I have a workflow composed of many custom activities. All these activities need to access startup arguments of the workflow itself. I can define InArgument inside all these custom activities and bind the workflow arguments to custom activity arguments but I am not comfortable with this solution. What is the best way to access workflow level argument and variable declarations from custom activities. Can I get them from ActivityContext? Thanks.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9  | Next Page >