parameter-passing

How pass multiple body parameters in wcf rest using webinvoke method(Post or PUT)

大兔子大兔子 提交于 2019-12-05 03:52:48
I have written a REST Service in WCF in which I have created a method(PUT) to update a user. for this method I need to pass multiple body parameters [WebInvoke(Method = "PUT", UriTemplate = "users/user",BodyStyle=WebMessageBodyStyle.WrappedRequest)] [OperationContract] public bool UpdateUserAccount(User user,int friendUserID) { //do something return restult; } Although I can pass an XML entity of user class if there is only one parameter. as following: var myRequest = (HttpWebRequest)WebRequest.Create(serviceUrl); myRequest.Method = "PUT"; myRequest.ContentType = "application/xml"; byte[] data

If CancellationToken is a struct and is passed by Value, how is it updated?

风格不统一 提交于 2019-12-05 03:41:41
I see that CancellationToken is a struct https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken?view=netframework-4.7.1 If I pass a struct to a new function by value, it shouldn't be modified in the caller. So if i'm passing a CancellationTokenSource (by value), then I call cts.cancel(), how does the method that has a copy of that token is notified that it has been canceled? Shouldn't it work only if we pass by reference? For example: public static void Main() { var cts = new CancellationTokenSource(); SomeCancellableOperation(cts.Token); cts.cancel(); } public void

Passing a method's name as a parameter

独自空忆成欢 提交于 2019-12-05 03:33:43
private void Method1() { //Do something Log("Something","Method1"); } private void Method2() { //Do something Log("Something","Method2"); } private void Log(string message, string method) { //Write to a log file Trace.TraceInformation(message + "happened at " + method); } I have several methods like Method1 and Method2 above, and i would like some way pass the method's name as a parameter, without manually editing the code. Is that possible? Excellent answer from Jon Skeet. However, if you don't use .NET 4.5 , you can try reflection . How ever you should know that reflection must be used only

Command line passing quotes within quotes

孤者浪人 提交于 2019-12-05 02:06:22
I've been searching for a solution to this but couldn't find one. Not sure if its possible. Can I pass into command-line execution that passes a in a bat file which has an input file as its arguments? So from the command-line it'll look like this: C:\run.exe "C:\space folder\run.bat "C:\space folder\input.txt"" The problem is with the folders that has spaces so the quotes are required to be in there. Try this: C:\run.exe "C:\space folder\run.bat \"C:\space folder\input.txt\"" And here is a link that you can see all escape characters http://www.robvanderwoude.com/escapechars.php I know it's an

How can parameters/settings be passed to a Scala macro?

╄→гoц情女王★ 提交于 2019-12-05 01:52:39
How can parameters/settings be passed to a Scala macro? These settings should not be global, but per macro invocation. What I would like to have is something similar to this: def a(param: Int) = macro internalMacro("setting 1") def b(param: Int) = macro internalMacro("setting 2") whereas setting 1 and setting 2 should then be constant values, accessible from within the macro, so I can make the internal behavior dependent on them. The parameter lists of your method and the macro definition have to line up exactly, with the macro definition method having an extra initial parameter list for the

Multiple projects sharing a jenkinsfile

放肆的年华 提交于 2019-12-05 01:38:08
问题 I have multiple projects with similar build steps and I am looking into reusing a Jenkinsfile pipeline across these projects. I am having a hard time to find documentation on how to implement such an standard (to my opinion) setup. Here are my requirements : 1) a Jenkinsfile is stored in repo, shared across multiple projects 2) Each project has its own parameter : the project location in the repo. 3) Each project should be independent in Jenkins from a user perspective at least, meaning for

Out parameters in C

非 Y 不嫁゛ 提交于 2019-12-05 01:35:11
void swap(int &first, int &second){ int temp = first; first = second; second = temp; } ////// int a=3,b=2; swap(a,b); In the above example, the C compiler complaints that "void swap(int &first, int &second)" has a syntax error like missing "&" before "( / {". I don't understand why? Doesn't C support this feature? C doesn't support passing by reference. So you will need to use pointers to do what you are trying to achieve: void swap(int *first, int *second){ int temp = *first; *first = *second; *second = temp; } int a=3,b=2; swap(&a,&b); I do NOT recommend this: But I'll add it for

Are php resources passed by reference?

ぐ巨炮叔叔 提交于 2019-12-05 00:38:49
I discovered today that in addition to objects and primitives, PHP has resources . The documentation states that by default php passes names by value . But we know that in PHP 5, objects are referenced by handle , and so while the handle is passed by value, you can treat the handles as references themselves, neatly avoiding the question. But what about resources ? Are they, like objects, just handles to be treated as references themselves, or are they actually values that get copied when they're passed? For example: /** * Close the ftp connection and throw an exception. * * @hack Because php

Pass-by-value (StringBuilder vs String) [duplicate]

三世轮回 提交于 2019-12-05 00:37:32
This question already has an answer here: Is Java “pass-by-reference” or “pass-by-value”? 86 answers I do not understand why System.out.println(name) outputs Sam without being affected by the method's concat function, while System.out.println(names) outputs Sam4 as a result of the method's append method. Why is StringBuilder affected and not String? Normally, calling methods on a reference to an object affects the caller, so I do not understand why the String result remains unchanged. Thanks in advance public static String speak(String name) { name = name.concat("4"); return name; } public

how to pass method name as a parameter in python class

余生颓废 提交于 2019-12-04 20:23:45
This is my code, my intention is to pass the method name as a parameter when I initialize the object and I want to run the method 'num' (second argument) of times. Basically get n number of results (as mentioned in 2nd argument). class Foo(object): faker = Faker() def __init__(self, custom_method, num=1): self.values = [] self.custom_method = custom_method self.num = num for x in self.num: self.custom_method = self.values.append(custom_method) def random_first_name(self): self.custom_method = self.faker.first.name() return self.custom_method def random_phone(self): self.custom_method = self