Search Results

Search found 15081 results on 604 pages for 'passing by reference'.

Page 27/604 | < Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >

  • How do I mock a method with an open array parameter in PascalMock?

    - by Oliver Giesen
    I'm currently in the process of getting started with unit testing and mocking for good and I stumbled over the following method that I can't seem to fabricate a working mock implementation for: function GetInstance(const AIID: TGUID; out AInstance; const AArgs: array of const; const AContextID: TImplContextID = CID_DEFAULT): Boolean; (TImplContextID is just an alias for Integer) I thought it would have to look something like this: function TImplementationProviderMock.GetInstance( const AIID: TGUID; out AInstance; const AArgs: array of const; const AContextID: TImplContextID): Boolean; begin Result := AddCall('GetInstance') .WithParams([@AIID, AContextID]) .ReturnsOutParams([AInstance]) .ReturnValue; end; But the compiler complains about the .ReturnsOutParams([AInstance]) saying "Bad argument type in variable type array constructor.". Also I haven't found a way to specify the open array parameter AArgs at all. Also, is using the @-notation for the TGUID-typed parameter the right way to go? Is it possible to mock this method with the current version of PascalMock at all? Update: I now realize I got the purpose of ReturnsOutParams completely wrong: It's intended to be used for populating the values to be returned when defining the expectations rather than for mocking the call itself. I now think the correct syntax for mocking the out parameter would probably have to look more like this: function TImplementationProviderMock.GetInstance( const AIID: TGUID; out AInstance; const AArgs: array of const; const AContextID: TImplContextID): Boolean; var lCall: TMockMethod; begin lCall := AddCall('GetInstance').WithParams([@AIID, AContextID]); Pointer(AInstance) := lCall.OutParams[0]; Result := lCall.ReturnValue; end; The questions that remain are how to mock the open array parameter AArgs and whether passing the TGUID argument (i.e. a value type) by address will work out...

    Read the article

  • Assign click event to addon icon on navigation bar

    - by Charsee
    We have created a chrome extension for our app. Where we call a METHOD from a "js file" on CLICK event of the "extension icon" placed on the navigation bar. For this we use message passing between the app.js (file containing the METHOD to be called on icon click) and background.html (using a js file included in this html). The script used to pass message is:(from background.html) chrome.browserAction.onClicked.addListener(function (tab) { chrome.tabs.sendMessage(tab.id, "showPopup"); }); and to listen the message :(in app.js) chrome.extension.onMessage.addListener(function(request) { if (request === "showPopup") { showPopup(); } }); The click event works as expected. But now we want to do same thing in mozilla extension. and we can't pass message to app.js on the click of the icon,so that it can execute the containing methods. We have also added the app.js using pageMod, something like this exports.main = function(options, callbacks) { pageMod.PageMod({ include: ["*"], contentScriptWhen: 'start', contentScriptFile: [data.url('jquery-1.7.1.min.js'),data.url('app.js')] }); createAndAddNavBarButton(); }; function createAndAddNavBarButton() { var navBar = document.getElementById('nav-bar');//assume document has been defined if (!navBar){return;}; var nbBtn = document.createElement('navbaricon'); nbBtn.setAttribute('id', 'navButton'); nbBtn.setAttribute('image', data.url('icon_16.png')); nbBtn.onclick = function(){ showPopup(); return true; } navBar.appendChild(btn); } But the click event does nothing and showPopup() is undefined. When a new page loads event associated with it in the app.js executes without any error but the click event doesn't work. Is there a method from where we can assign click event directly to this icon, as we have done in the case of chrome extension.

    Read the article

  • Multithreading using pthread in C++ with shared variables

    - by Saviour Self
    I'm new to threading (and C/C++ for that matter), and I'm attempting to use multiple threads to access shared variables. In the main, I've created a variable char inputarray[100]; Thread 1: This thread will be reading data from stdin in 2 byte bursts, and appending them to the inputarray. (input by feeding a file in) Thread 2: This thread will be reading data 1 byte at a time, performing a calculation, and putting its data into an output array. Thread 3: This thread will be outputting data from the output array in 2 byte bursts. (stdout) I've attempted the input part and got it working by passing a struct, but would like to do it without using a struct, but it has been giving me problems. If I can get input down, I'm sure I'll be able to use a similar strategy to complete output. Any help would be greatly appreciated. Below is a rough template for the input thread. #include <stdio.h> #include <pthread.h> using namespace std; void* input(void* arg) { char reading[3]; fread(reading,1,2,stdin); //append to char inputarray[]..??? } int main() { char inputarray[100]; pthread_t t1; pthread_create(&t1, NULL, &input, &inputarray); void *result; pthread_join(t1,&result); return 0; }

    Read the article

  • iphone - creating a reference to a MPMoviePlayerController

    - by Mike
    At some point in my code I am creating a MPMoviePlayerController object and playing it. As I need to reference this object at some other methods in my code that runs asynchronously, I need to store a pointer to the movie object etc., so I can use that. Declaring MPMoviePlayerController * myMovie on the header file is out of question, because the compiler will give me an error saying "expected specifier-qualifier-list before 'MPMoviePlayerController'". If it was a view I could do something like [self.view viewWithTag:99]; to get the object, but the MPMoviePlayerController does not allow this. How can I obtain the movie object or store a reference to it, so I can call the object in other methods? thanks for any help.

    Read the article

  • Create a subarray reference in C# (using unsafe ?)

    - by Wam
    Hello there, I'm refactoring a library we currently use, and I'm faced with the following problem. We used to have the following stuff : class Blah { float[][] data; public float[] GetDataReference(int index) { return data[index]; } } For various reasons, I have replaced this jagged array version with a 1 dimensionnal array version, concatenating inner arrays. My question is : how can I still return a reference to a sub array of data ? class Blah { float[] data; int rows; public float[] GetDataReference(int index) { // Return a reference data from offset i to offset j; } } I was thinking that unsafe and pointers stuff may be of use, is it doable ?

    Read the article

  • How to change VS2010 Add Reference box filter ?

    - by rook
    I'm getting used to the new IDE (it's vc# express), but the first contact is somewhat confusing. When I open the Add Reference dialog and switch to the .NET tab, a label above the assembly list states: "Filtered to:.NET Framework 4". And it's true - I can reference .NET 4.0 assemblies only plus things like XNA 3.1. However I can't see older assemblies i.e. Managed DirectX libs, which are obviously installed on my computer as there was no trouble with adding a ref to them in vc#08. What is this? How to change the filter? The label is read-only. These sound like dull guy's questions, but I'm out of lack of finding an answer and there is no intuitive solution. Thanks in advance.

    Read the article

  • When adding WCF service reference, configuration details are not added to web.config

    - by Mikey Cee
    Hi, I am trying to add a WCF service reference to my web application using VS2010. It seems to add OK, but the web.config is not updated, meaning I get a runtime exception: Could not find default endpoint element that references contract 'CoolService.CoolService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element. Obviously, because the service is not defined in my web.config. Steps to reproduce: Right click solution Add New Project ASP.NET Empty Web Application. Right click Service References in the new web app Add Service Reference. Enter address of my service and click Go. My service is visible in the left-hand Services section, and I can see all its operations. Type a namespace for my service. Click OK. The service reference is generated correctly, and I can open the Reference.cs file, and it all looks OK. Open the web.config file. It is still empty! <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <bindings /> <client /> </system.serviceModel> Why is this happening? It also happens with a console application, or any other project type I try. Any help? Here is the app.config from my WCF service: <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" /> </system.web> <!-- When deploying the service library project, the content of the config file must be added to the host's app.config file. System.Configuration does not support config files for libraries. --> <system.serviceModel> <services> <service name="CoolSQL.Server.WCF.CoolService"> <endpoint address="" binding="webHttpBinding" contract="CoolSQL.Server.WCF.CoolService" behaviorConfiguration="SilverlightFaultBehavior"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="http://localhost:8732/Design_Time_Addresses/CoolSQL.Server.WCF/CoolService/" /> </baseAddresses> </host> </service> </services> <behaviors> <endpointBehaviors> <behavior name="webBehavior"> <webHttp /> </behavior> <behavior name="SilverlightFaultBehavior"> <silverlightFaults /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name=""> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> </serviceBehaviors> </behaviors> <bindings> <webHttpBinding> <binding name="DefaultBinding" bypassProxyOnLocal="true" useDefaultWebProxy="false" hostNameComparisonMode="WeakWildcard" sendTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:00:10" maxReceivedMessageSize="2147483647" transferMode="Streamed"> <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" /> </binding> </webHttpBinding> </bindings> <extensions> <behaviorExtensions> <add name="silverlightFaults" type="CoolSQL.Server.WCF.SilverlightFaultBehavior, CoolSQL.Server.WCF" /> </behaviorExtensions> </extensions> <diagnostics> <messageLogging logEntireMessage="true" logMalformedMessages="false" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="false" maxMessagesToLog="3000" maxSizeOfMessageToLog="2000" /> </diagnostics> </system.serviceModel> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /> </startup> <system.diagnostics> <sources> <source name="System.ServiceModel.MessageLogging" switchValue="Information, ActivityTracing"> <listeners> <add name="messages" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\messages.e2e" /> </listeners> </source> </sources> </system.diagnostics> </configuration>

    Read the article

  • CComPtr pass by reference

    - by Mahesh
    I have a situation where I need to pass a CComPtr<IXmlReader> to a function by reference. Does the called parameter takes the ownership from the callee parameter (or) the reference count is increased? void foo( CComPtr<IXmlReader> & pReader ) { // There is no reassignment of the CComPtr. // Just call the IXmlReader methods. } CComPtr<IXmlReader> pReader; foo( pReader ); // Is pReader still valid after the function return ? Thanks.

    Read the article

  • An Object reference is required for the non-static field

    - by Muhammad Akhtar
    I have make my existing method to static method to get access in javascript, like.. [WebMethod(EnableSession = true), ScriptMethod()] public static void Build(String ID) { Control releaseControl = LoadControl("~/Controls/MyControl.ascx"); //An Object reference is required for the non-static field, mthod or property // 'System.Web.UI.TemplateControl.LoadControl(string)' plc.Controls.Add(releaseControl); // where plc is place holder control //object reference is required for the nonstatic field, method, or property '_Default.pl' } When I build I am getting error and I have posted these in comments below each line before converted it to static method, it working perfectly. Please suggest me the solution of my issue. Thanks

    Read the article

  • Foreign key reference to a two-column primary key

    - by Adam Ernst
    One of my tables has a two-column primary key: CREATE TABLE tournament ( state CHAR(2) NOT NULL, year INT NOT NULL, etc..., PRIMARY KEY(state, year) ); I want a reference to the tournament table from another table, but I want this reference to be nullable. Here's how I might do it, imagining that a winner doesn't necessarily have a tournament: CREATE TABLE winner ( name VARCHAR NOT NULL, state CHAR(2) NULL, year INT NULL ); If state is null but year is not, or vice-versa, the table would be inconsistent. I believe the following FOREIGN KEY constraint fixes it: ALTER TABLE winner ADD CONSTRAINT FOREIGN KEY fk (name, state) REFERENCES tournament (name, state); Is this the proper way of enforcing consistency? Is this schema properly normalized?

    Read the article

  • Reference DLLs not loading in Visual Studio 2010

    - by Adam Haile
    I'm working on a C# 4.0 project in VS2010 and needed to use some older DLLs containing controls that were created in C# 3.5 on VS2008. When I first add the DLLs to the references, I was able to see the namespace via intellisense and create an instance of one of the controls, but when I go to build, it gives me the following error: The type or namespace name 'BCA' could not be found (are you missing a using directive or an assembly reference?) And I do have a using directive for that namespace already, which is now underlined in red, showing that VS cannot find it. And now, intellisense won't pick up that namespace at all. I even tried added the controls to the toolbox (which worked) but then when I drag them to the GUI, it says that it cannot locate the DLL reference, even though it obviously knows where it is. I even tried changing the target framework to 3.5, but still with the same results. Any thoughts as to why this could be happening?

    Read the article

  • VS2010 converted project invalid reference

    - by Nathan
    Opening a .Net 2 project in VS2010 it converts the project without any issues BUT when I attempt to build it fails. The reason is that in VS2005 a reference was added to System.Web.Extensions which is a .Net 3.5 assembly. Now VS2005 never complained at this and quite happily worked but VS2010 is far more strict and won't allow it. I've tried changing the targeted framework to .Net 3.5 but I get another situation there where the web page is never displayed, it simply hangs not even getting to Applicatin_OnStart. Any help either on adding the reference with .Net 2 as target framework (prefered option for time) or getting the .Net 3.5 version to work would be greatly appreciated.

    Read the article

  • Repeater itemdatabound event value type and reference type

    - by Sune
    Im trying to bind a list with datetime objects to my repeater. if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { DateTime actualDate = e.Item.DataItem as DateTime; } When I want access the itemdatabound event on the repeater Then I get an errormessage which says that DateTime is a valuetype and not a reference type. My solution is that a wrap the datetime in a custom object (reference type) and pass that to the repeater datasource instead of the datetime. But Im wondering if there are other solutions where the repeater takes valuetypes (DateTime objects)........

    Read the article

  • Microsoft.SqlServer.SqlTools.VSIntegration reference problem/oddities in Visual Studio 2010

    - by Sung Meister
    SQL Server Edition: 2008 Enterprise Visual Studio: 2010 w/ .NET 4.0 SSMS 2008 Addin - Data Scripter project source code on CodePlex references Microsoft.SqlServer.SqlTools.VSIntegration.dll I have referenced the DLL under <<Microsoft SQL Server install location>>\100\Tools\Binn\VSShell\Common7\IDE But here is the oddity. Microsoft.SqlServer.SqlTools.VSIntegration.dll contains a namespace Microsoft.SqlServer.Management.UI.VSIntegration, which in turn contains ServiceCache (public sealed). As soon as I add the reference, ServiceCache is highlighted (meaning there is no reference issue) But the problem arises when I compile the project and VS 2010 throws up an error that it cannot find ServiceCache. The name 'ServiceCache' does not exist in the current context Why is that ServiceCache is not visible during compile time but looks like it's available right after adding the assembly? And Reflector does show that ServiceCache is part of the assembly that the project is referencing, but Visual Studio intellisense fails to display it. Any had this kind of problem? [UPDATE] Some screenshots Reflector clearly shows ServiceCache But Visual Studio 2010 says, otherwise...

    Read the article

  • Trying to include a library, but keep getting 'undefined reference to' messages

    - by KU1
    I am attempting to use the libtommath library. I'm using the NetBeans IDE for my project on Ubuntu linux. I have downloaded and built the library, I have done a 'make install' to put the resulting .a file into /usr/lib/ and the .h files into /usr/include It appears to be finding the files appropriately (since I no longer get those errors, which I did before installing into the /usr directories). However, when I create a simple main making a call to mp_init (which is in the library), I get the following error when I attempt to make my project: mkdir -p build/Debug/GNU-Linux-x86 rm -f build/Debug/GNU-Linux-x86/main.o.d gcc -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.c mkdir -p dist/Debug/GNU-Linux-x86 gcc -o dist/Debug/GNU-Linux-x86/cproj1 build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/main.o: In function 'main': /home/[[myusername]]/NetBeansProjects/CProj1/main.c:18: undefined reference to `mp_init' collect2: ld returned 1 exit status make[2]: *** [dist/Debug/GNU-Linux-x86/cproj1] Error 1 So, it looks like the linker can't find the function within the library, however it IS there, so I just don't know what could be causing this. Any help would be appreciated. I get the same error if I type the gcc command directly and skip the makefile, I also made sure the static library got compiled with gcc as well. Edited to Add: I get these same errors if I do the compile directly and add the library with -l or -L: $ gcc -l /usr/lib/libtommath.a main.c /usr/bin/ld: cannot find -l/usr/lib/libtommath.a collect2: ld returned 1 exit status $ gcc -llibtommath.a main.c /usr/bin/ld: cannot find -llibtommath.a collect2: ld returned 1 exit status $ gcc -Llibtommath.a main.c /tmp/ccOxzclw.o: In function `main': main.c:(.text+0x18): undefined reference to `mp_init' collect2: ld returned 1 exit status $ gcc -Llibtommath.a main.c /tmp/ccOxzclw.o: In function `main': main.c:(.text+0x18): undefined reference to `mp_init' collect2: ld returned 1 exit status I am very rusty on this stuff, so I'm not sure I'm using the right command here, in the -L examples are the libraries being found? If the library isn't being found how on earth do I get it to find the library? It's in /usr/lib, I've tried it with the .a file in the current directory, etc. Is there an environment variable I need to set? If so, how, etc. Thanks so much for the help. I've tried a completely different library (GMP) and had the EXACT same problem. This has got to be some kind of Ubuntu environment issue? Anyone have any idea how to fix this?

    Read the article

  • JavaScript: Reference a functions local scope as an object

    - by eBusiness
    When I call a function, a local scope is erected for that call. Is there any way to directly reference that scope as an object? Just like window is a reference for the global scope object. Example: function test(foo){ var bar=1 //Now, can I access the object containing foo, bar, arguments and anything //else within the local scope like this: magicIdentifier.bar } Alternately, does anyone have a complete list of what is in the global scope on top of custom variables? Background: I'm trying to get down to a way of completely shifting to global scope from within a function call, the with statement is a joke, call works a little better, but it still breaks for anything declared in function scope but not in global scope, therefore I would declare these few cases in global scope, but that requires me to know what they are. The IE function execScript makes a complete shift, but that only solves the problem for IE. Note: To anyone loading JavaScript dynamically, setTimeout(code,1) is a simple effective hack to achieve global scope, but it will not execute immediately.

    Read the article

  • Ambiguous reference in Stream

    - by Sharpeye500
    This is the webservice method i have LoadImageFromDB(int ID, ref Stream streamReturnVal) I have this on the top of the section using Stream = System.IO.MemoryStream; Whenever i consume this method(update web reference) from a web application, i get this error 'Stream' is an ambiguous reference between 'System.IO.Stream' and 'WebReference.Stream' Any thoughts? In webservice class using Stream = System.IO.MemoryStream; LoadImageFromDB(int ID, ref Stream streamReturnVal); In web page where above webservice is consumed: using WebReference; Stream streamReturnVal = null; streamReturnVal = new MemoryStream(); WebserviceInstanceName.LoadImageFromDB(100,streamReturnVal ); PS: Stream - is from System.IO.Stream

    Read the article

  • Scala: working around the "illegal cyclic reference"

    - by Paul Milovanov
    Hi all, I'm trying to implement a HashMap-based tree that'd support O(1) subtree lookup for a given root key. To that goal, I'm trying to do the following: scala> type Q = HashMap[Char, Q] <console>:6: error: illegal cyclic reference involving type Q type Q = HashMap[Char, Q] ^ So the question is, is there a way for me to do something of the sort without resorting to the ugly HashMap[Char, Any] with subsequent casting of values to HashMap[Char, Any]? Now, I also see that I can use something like the following to avoid the cyclic-reference error, and it might even be cleaner -- but it'd be nice to find out how to correctly do it the first way, just for the educational value. import collections.mutable.HashMap class LTree { val children = new HashMap[Char, LTree] } Thanks a bunch.

    Read the article

  • Page Lifecycle - Using FindControl to reference a control created programatically during page load

    - by Jay Wilde
    Hi, I'm creating some text boxes on my form programatically which I need to reference later using FindControl. I've put the FindControl instruction in the page load method after the code which creates them but get an error: "Object reference not set to an instance of an object." I assume this is because the textbox controls are not created until later in the lifecycle and therefore cannot be referenced from within Page_Load. Can someone advise where in my code-behind I would need to place the FindControl instruction so that it can find these programatically created text boxes?

    Read the article

  • How to get a reference to node in DOM tree in Google Chrome debugger console

    - by .yahoo.co.jpaqwsykcj3aulh3h1k0cy6nzs3isj
    In the Google Chrome debugger, I often want to get a reference to a node in the DOM tree. I can click the "magnifying glass" button and then click the desired element in the browser window to select the corresponding node in the DOM tree displayed in the debugger. But how can I get a reference to that node in the console? If the element has an id, document.getElementById works, but if there is no id, is there a better alternative to XPath or manual traversal of the DOM tree using children? In case XPath is the best way, is there a better way than doing something like this: var evaluator = new XPathEvaluator(); var result = evaluator.evaluate("//div", document.documentElement, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); which is a pain to type out each time.

    Read the article

  • C# - Removing items from lists and all references to them.

    - by LiamV
    Hi there, I'm facing a situation where I have dependent objects and I would like to be able to remove an object and all references to it. Say I have an object structure like the code below, with a Branch type which references two Nodes. public class Node { // Has Some Data! } public class Branch { // Contains references to Nodes public Node NodeA public Node NodeB } public class Graph { public List<Node> Nodes; public List<Branch> Branches; } If I remove a Node from the Nodes list in the Graph class, it is still possible that one or more Branch objects still contains a reference to the removed Node, thus retaining it in memory, whereas really what I would quite like would be to set any references to the removed Node to null and let the garbage collection kick in. Other than enumerating through each Branch and checking each Node reference sequentially, are there any smart ideas on how I remove references to the Node in each Branch instance AND indeed any other class which reference the removed Node? Much appreciated, Liam

    Read the article

  • Pattern for managing reference count and object life

    - by Gopalakrishnan Subramani
    We have a serial port which is connected to hundreds of physical devices on the same wire. We have protocols like Modbus and Hart to handle the request and response between the application and devices. The question is related to managing the reference count of the channel. When no device is using the channel, the channel should be closed. public class SerialPortChannel { int refCount = 0; public void AddReference() { refCount++; } public void ReleaseReference() { refCount--; if (refCount <= 0) this.ReleasePort(); //This close the serial port } } For each device connected, we create a object for the device like device = new Device(); device.Attach(channel); //this calls channel.AddReference() When the device disconnect, device.Detach(channel); //this calls channel.ReleaseReference() I am not convinced by the reference count model. Are there any better way to handle this problem in .NET World?

    Read the article

  • Using Mapped Memory Files in C# to store reference types

    - by Khash
    I need to store a dictionary to a file as fast as possible. Both key and value are objects and not guaranteed to be marked as Serializable. Also I prefer a method faster than serializing thousands of objects. So I looked into Mapped Memory Files support in .NET 4. However, it seems MemoryMappedViewAccessor only allows storage of structs and not reference types. Is there a way of storing the memory used by a reference type of a file and reconstructing the object from that blob of memory (without binary serialization)?

    Read the article

< Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >