arguments

How can I pass an argument to a C# plug-in being loaded through Assembly.CreateInstance?

大憨熊 提交于 2020-01-02 04:12:09
问题 What I have now (which successfully loads the plug-in) is this: Assembly myDLL = Assembly.LoadFrom("my.dll"); IMyClass myPluginObject = myDLL.CreateInstance("MyCorp.IMyClass") as IMyClass; This only works for a class that has a constructor with no arguments. How do I pass in an argument to a constructor? 回答1: You cannot. Instead use Activator.CreateInstance as shown in the example below (note that the Client namespace is in one DLL and the Host in another. Both must be found in the same

R: deep copy a function argument

痞子三分冷 提交于 2020-01-02 03:37:09
问题 Consider the following code i = 3 j = i i = 4 # j != i However, what I want is i = 3 f <- function(x, j=i) x * j i = 4 f(4) # 16, but i want it to be 12 In case you are wondering why I want to do this you could consider this code - the application is a multiple decrements model. The diagonals of a transition matrix are the sum of the other decrements in that row. I would like to define the decrements I need than calculate the other functions using those decrements. In this case, I only need

Javascript: Forwarding function calls that take variable number of arguments [duplicate]

折月煮酒 提交于 2020-01-02 01:13:17
问题 This question already has answers here : Passing arguments forward to another javascript function [duplicate] (3 answers) Closed 2 years ago . I think I need something like ruby's splat * here. function foo() { var result = ''; for (var i = 0; i < arguments.length; i++) { result += arguments[i]; } return result; } function bar() { return foo(arguments) // this line doesn't work as I expect } bar(1, 2, 3); I want this to return "123" , but instead I get "[object Arguments]" . Which makes sense

Pass argument to AsyncCallback function?

你离开我真会死。 提交于 2020-01-02 01:12:12
问题 I'm learning socket programming and I have the following function: public void OnDataReceived(IAsyncResult asyn) and this is how the callback gets set: pfnWorkerCallBack = new AsyncCallback(OnDataReceived); The problem is I need to pass another argument to OnDataReceived callback function, how can I do this? I'm trying to make a simple tcp server and I need to track from which client the data is coming from. Any tips? Thanks! 回答1: I'm going to presume you're using System.Net.Sockets.Socket

calling rsync from python subprocess.call

我的梦境 提交于 2020-01-02 00:54:11
问题 I'm trying to execute rsync over ssh from a subprocess in a python script to copy images from one server to another. I have a function defined as: def rsyncBookContent(bookIds, serverEnv): bookPaths = "" if len(bookIds) > 1: bookPaths = "{" + ",".join(("book_"+str(x)) for x in bookIds) + "}" else: bookPaths = "book_" + str(bookIds[0]) for host in serverEnv['content.hosts']: args = ["rsync", "-avz", "--include='*/'", "--include='*.jpg'", "--exclude='*'", "-e", "ssh", options.bookDestDir + "/"

Is that one argument or none for a Perl 6 block?

风格不统一 提交于 2020-01-01 09:43:12
问题 What is the Perl 6 way to tell the difference between an argument and no argument in a block with no explicit signature? I don't have any practical use for this, but I'm curious. A block with no explicit signature puts the value into $_ : my &block := { put "The argument was $_" }; The signature is actually ;; $_? is raw . That's one optional argument. The @_ variable isn't defined in the block because there is no explicit signature. There's the no argument, where $_ will be undefined: &block

rails check_box_tag set checked with default value

老子叫甜甜 提交于 2020-01-01 07:33:06
问题 I currently have a rails check_box_tag call that looks like check_box_tag #{name} I want to include a checked attribute, which I know I can do with check_box_tag name, value, checked But what if I want to set it to checked without explicitly specifying value (I just want to use the default). Or similarly, what if I wanted to specify html options without specifying the checked attribute. Is there a way to do this? 回答1: Just wanted to update this. The third parameter for check_box_tag is a

Passing expressions to functions?

独自空忆成欢 提交于 2019-12-31 12:23:08
问题 I'm not quite sure what I mean here, so please bear with me.. In SQLAlchemy, it appears I'm supposed to pass an expression to filter() in certain cases. When I try to implement something like this myself, I end up with: >>> def someFunc(value): ... print(value) >>> someFunc(5 == 5) True How do I get the values passed to == from inside the function? I'm trying to achieve something like this >>> def magic(left, op, right): ... print(left+" "+op+" "+right) >>> magic(5 == 5) 5 == 5 What about if

How do I pass multiple string parameters to a PowerShell script?

纵然是瞬间 提交于 2019-12-31 09:10:12
问题 I am trying to do some string concatenation/formatting, but it's putting all the parameters into the first placeholder. Code function CreateAppPoolScript([string]$AppPoolName, [string]$AppPoolUser, [string]$AppPoolPass) { # Command to create an IIS application pool $AppPoolScript = "cscript adsutil.vbs CREATE ""w3svc/AppPools/$AppPoolName"" IIsApplicationPool`n" $AppPoolScript += "cscript adsutil.vbs SET ""w3svc/AppPools/$AppPoolName/WamUserName"" ""$AppPoolUser""`n" $AppPoolScript +=

Is There a way to use the Parameter Names from a typedef

一曲冷凌霜 提交于 2019-12-31 05:42:47
问题 So given a typedef that defines a function pointer with parameter names like this: typedef void(*FOO)(const int arg); Is there a way that I can just use this function pointer to define the signature of my function? Obviously this won't work, but I'd like to somehow use the typedef to specify a function signature with a corresponding type: FOO foo { cout << arg << endl; } Again, I know this doesn't work, and is bad syntax. It will just give the error: error: arg was not declared in this scope