parameters

how to pass/transfer out parameter as reflection? - visual studio extensibility c#

家住魔仙堡 提交于 2019-12-12 09:45:12
问题 I have an out parameter. Is it possible to transfer it as reflection? Can you give me some examples how to do that? 回答1: I'm not sure what this has to do with VS extensibility, but it's certainly possible to invoke a method with an out parameter by reflection and find out the out parameter's value afterwards: using System; using System.Reflection; class Test { static void Main() { MethodInfo method = typeof(int).GetMethod ("TryParse", new Type[] { typeof(string), typeof(int).MakeByRefType() }

Rails 5.1 API - how to permit params for nested JSON object's attributes

纵饮孤独 提交于 2019-12-12 09:34:15
问题 There are at least 10 questions on this topic but none of them answer this particular issue. Many of the questions relate to Rails forms like this, which I don't have, or to json structures that are more complicated, like this or this. EDIT regarding the accepted answer and why this is not an exact duplicate The linked question in the answer from @CarlosRoque initially looks to be the same problem but it only solves the Rails side of this particular issue. If you read all the comments you

XSLT stylesheet parameters in imported stylesheets

五迷三道 提交于 2019-12-12 09:31:57
问题 Is it possible to assign a value to a parameter of an imported stylesheet? I was expecting something like <xsl:import ... > <xsl:with-param ... </xsl:import> but that is not allowed. Also tunnel="yes" is forbidden in stylesheet parameters. 回答1: Try this: main.xsl <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:import href="import.xsl"/> <xsl:variable name="param" select="'some-value'"/> <xsl:template match="/"> <xsl:call-template name="foo"/> </xsl

Retrieve file and parameters in jsp from POST request

柔情痞子 提交于 2019-12-12 09:27:49
问题 I have the following form inside a modal: <div id="sazModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="sazModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3 id="sazModalLabel">Upload a Test</h3> </div> <div class="modal-body"> <form method=POST id='sazForm' class="form-horizontal" action="upload.jsp" enctype='multipart/form-data'> <div class="control-group"> <label

Basic Syntax for passing a Scanner object as a Parameter in a Function

倾然丶 夕夏残阳落幕 提交于 2019-12-12 09:08:48
问题 Here is what I wrote which is pretty basic : import java.util.Scanner; public class Projet { /** * @param args * @param Scanner */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Enter a digit"); Scanner in = new Scanner(System.in); getChoice(Scanner); in.close(); } public static int getChoice(Scanner n){ n = in.nextInt(); return n; } } What seems to be wrong here ? I had it working earlier, I had to pass the Scanner type and argument name as a

Why C# allows that only the last parameter of a method is of “variable length”

喜夏-厌秋 提交于 2019-12-12 08:49:18
问题 From what I know, C# allows that only the last parameter of a method is of "variable length", for example: T f(A a, params B[] b) allows that if you have A r; .... B x, y, z; .... you can call f like f (r, x, y, z) . Why C# doesn't also define something like: T f(params A[] a, params B[] b) 回答1: Because how would the compiler know when the variable arguments for the first parameter stop? Pleas tell me what argOne and argTwo should contain inside of the method body: void Foo( params object[]

Django how to validate POST Parameters

旧时模样 提交于 2019-12-12 08:08:25
问题 I pass some parameters to django by a POST request. How can I validate if a parameter is an integer, a String and also that there is no unsecure stuff like code injection inside? Is there a django function I can use? For example: if request.method == 'POST': print request.POST.get('user_comment') How can I check if the POST parameter contains a non dangerous String for my system? Something like request.POST.get('user_comment').is_valid() Thanks. 回答1: For checking if POST data is safe, have

Key value pairs in C# Params

假如想象 提交于 2019-12-12 07:39:03
问题 I'm looking for a way to have a function such as: myFunction({"Key", value}, {"Key2", value}); I'm sure there's something with anonymous types that would be pretty easy, but I'm not seeing it. The only solution I can think of is to have a params KeyValuePair<String, object>[] pairs parameter, but that ends up being something similar to: myFunction(new KeyValuePair<String, object>("Key", value), new KeyValuePair<String, object>("Key2", value)); Which is, admittedly, much uglier. EDIT: To

How do I set parameter default values that rely on other parameters?

旧城冷巷雨未停 提交于 2019-12-12 07:24:25
问题 The following code compiles and works as expected. #include <vector> void function(std::vector<int> vec, int size=1); int main(){ std::vector<int> vec = {1,2,3}; function(vec); } void function(std::vector<int> vec, int size){ //code.. return; } However, I would like the size parameter's default value to be deduced based on a previous parameter. So for example: void function(std::vector<int> vec, int size=vec.size()); But this however results in: error: local variable ‘vec’ may not appear in

Best practice for parameter: IEnumerable vs. IList vs. IReadOnlyCollection

拜拜、爱过 提交于 2019-12-12 07:10:43
问题 I get when one would return an IEnumerable from a method—when there's value in deferred execution. And returning a List or IList should pretty much be only when the result is going to be modified, otherwise I'd return an IReadOnlyCollection , so the caller knows what he's getting isn't intended for modification (and this lets the method even reuse objects from other callers). However, on the parameter input side, I'm a little less clear. I could take an IEnumerable , but what if I need to