Is it possible to get get name of variable that was passed as parameter?  As you asked me to explain why I need this, here is my explain. I'm building a testing framweork using selenium. Here is example where I need that name of variable that was passed as parameter.  I have a page object with field:  [FindsBy(How = How.CssSelector, Using = "input[name='sample']")] private IWebElement SampleButton { get; set; }   I'm clicking it like:  Click(SampleButton, nameof(SampleButton));   Here is a body of Click function that u see above:  public void Click(IWebElement element, string elementName)         {             element.Click();             Logger.Log("Click: '{0}'", elementName);         }   Result: Button that was passed to function was clicked and in log file I have "Click: SampleButton"  Now I'm looking how to change Click function that it woul be call like:  Click(SampleButton)   It would look like:  public void Click(IWebElement element)         {             element.Click();             Logger.Log("Click: '{0}'", getNameOfVariableThatWasPassedToThisParameter(element));         }   Expected result of getNameOfVariableThatWasPassedToThisParameter(element) will be string = "SampleButton"  I'm am using things like SendKeys(SampleInput, nameof(SampleInput), valueToSet) and it set value and log where it was set. So I just want to get rid of that nameof(SampleInput). I want to reduce amount of variables than need to be passed to function.
37233
Let me use the following example to explain my question: public string ExampleFunction(string Variable) {     return something; }  string WhatIsMyName = &quot;Hello World&quot;; string Hello = ExampleFunction(WhatIsMyName);  When I pass the variable WhatIsMyName to the ExampleFunction, I want to be able to get a string of the original variable's name. Perhaps something like: Variable.OriginalName.ToString()  Is there any way to do this?
49686
Sometimes when I am debugging code in Eclipse it happens that although I can see and inspect class member variables without any difficulty I am unable to inspect the values of variables declared locally within functions. As an aside, any parameters to the current function lose their 'real' names and instead one sees their values listed in the Variables window as arg0, arg1, arg2, etc but at least the values are visible.  This is occurring at present in relation to classes defined within the core JDK. I have verified that the installed and current JRE is a JDK.  Is anybody able to shed some light on this behaviour?
90873
I have an Enumerable&lt;T&gt; and am looking for a method that allows me to execute an action for each element, kind of like Select but then for side-effects. Something like:  string[] Names = ...; Names.each(s =&gt; Console.Writeline(s));   or   Names.each(s =&gt; GenHTMLOutput(s));    // (where GenHTMLOutput cannot for some reason receive the enumerable itself as a parameter)   I did try Select(s=&gt; { Console.WriteLine(s); return s; }), but it wasn't printing anything.
120233
I would like to be able to pass aarguments to operators that I am calling from panels/buttons but I do not know how to do that. At the moment I use "global" variables but they tend to make the code a bit like a puzzle since I need to constantly update them.  See the code below, in that example I would like to pass an argument (like ARG) to "object.simple_operator" when the button is clicked.  import bpy     def DO_SOMETHING(arg):      print(arg)  return  class SimpleOperator(bpy.types.Operator):     """Tooltip"""     bl_idname = "object.simple_operator"     bl_label = "Simple Object Operator"      @classmethod     def poll(cls, context):         return context.active_object is not None      def execute(self, context):         DO_SOMETHING(ARG)         return {'FINISHED'}    class MyPanel(bpy.types.Panel):      bl_label = "mypanel"     bl_idname = "OBJECT_PT_MyPanel"      def draw(self, context):          layout = self.layout          wm = context.window_manager          obj = context.object          row = layout.row()         row.operator('object.simple_operator')
529
Im working in a site, And I need to present many fields to be filled and the page, so accoding to a selecction before, I have all the field but I have the Api Name, and the object name, but, With this api object field name, how can I get the label????  Example. I have "Student__c", I need to present "Student" to the user.  Thanks a lot for ur help!    Ok, thanks for ur answuers but I think I did not explain well this situation.   I have a list of string, where I have the information but in Api's name.  I present this fields in a table, so the user is filling the fields but with an inputText and not with an inputfield!.. So, in this moment, I dont know what is the label of each field.  My question basically, if by means of a query I could know the label of a field, if I know the api field name and the object name.. My question is if there is a way to consult this info!...  I know if I have the object is enough using an inputfield, But I cant do that. Neither set the label with HTML directly 'cause this is something dynamic.   Anyone knows how can I know, or consult, I guess by means of a query, how to get this label names???
37684
I'm trying create a Map using a name field as key.  Sample code:  Set&lt;String&gt; priceBooksNames = new Set&lt;String&gt;(); priceBooksNames.add('LN-200'); priceBooksNames.add('LN-100');  Map&lt;string,PriceBook2&gt; priceBooks = new Map&lt;string,PriceBook2&gt;([SELECT name,id FROM PriceBook2 WHERE name=:priceBooksNames ]); system.debug(priceBooks.get('LN-100')); //this is returning NULL   I can see on console that setId on map is not getting the name field value.  VARIABLE_ASSIGNMENT [5]|priceBooks|{"serId":1,"value":{"01sb0000000hiqQAAQ":{"serId":2,"value":{"Name":"LN-100 ADULTOS","Id":"01sb0000000hiqQAAQ"}},"01sb0000000hiqGAAQ":{"serId":3,"value":{"Name":"LN-200 EMPRESAS","Id":"01sb0000000hiqGAAQ"}}}}   What I'm going wrong?
28627
String fieldSetName = 'Account_FieldSet'; String ObjectName = 'Account';   I wanted get list of all fields from this fieldset.  I know if fieldset name is hardcoded in the apex then following syntax works -   SObjectType.Account.FieldSets.Account_FieldSet.getFields();   But here main issue is Object name and fieldset name will come at runtime.
5575
I have the name of a function in JavaScript as a string. How do I convert that into a function pointer so I can call it later?  Depending on the circumstances, I may need to pass various arguments into the method too.  Some of the functions may take the form of namespace.namespace.function(args[...]).
80088
When referencing class variables, why do people prepend it with this? I'm not talking about the case when this is used to disambiguate from method parameters, but rather when it seems unnecessary.  Example:  public class Person {             private String name;      public String toString() {         return this.name;     } }   In toString, why not just reference name as name?  return name;   What does this.name buy?   a stackoverflow question whose code has this pre-pending.
115022
I am trying to access settings in my config file, which is a series of xml elements listed as such:  &lt;databases&gt; &lt;database name="DatabaseOne" Value="[value]" /&gt; &lt;database name="DatabaseTwo" Value="[value]" /&gt; &lt;/databases&gt;   Now I want to access it. I have set up classes like so:  Public Class DatabaseConfigurationHandler     Inherits ConfigurationSection      &lt;ConfigurationProperty("Databases", IsDefaultCollection:=True)&gt; _    Public ReadOnly Property Databases() As DatabaseCollection         Get             Return CType(Me("Databases"), DatabaseCollection)         End Get     End Property End Class  Public Class DatabaseCollection     Inherits ConfigurationElementCollection      Protected Overloads Overrides Function CreateNewElement() As ConfigurationElement         Return (New Database())     End Function      Protected Overloads Overrides Function GetElementKey(ByVal element As ConfigurationElement) As Object         Return (CType(element, Database).DatabaseName)     End Function  End Class  Public Class Database     Inherits ConfigurationElement      &lt;ConfigurationProperty("name", IsKey:=True, IsRequired:=True)&gt; _        Public Property DatabaseName() As String         Get             Return Me("name").ToString()         End Get         Set(ByVal Value As String)             Me("name") = Value         End Set     End Property       &lt;ConfigurationProperty("value", IsRequired:=True)&gt; _ Public Property DatabaseValue() As String         Get             Return Me("value").ToString()         End Get         Set(ByVal Value As String)             Me("value") = Value         End Set     End Property  End Class   I want to be able get the element by it's name and return the value but I can't see to do that:  Dim config As New DatabaseConfigurationHandler                 config = System.Configuration.ConfigurationManager.GetSection("databases/database")                 Return config.Databases("DatabaseOne")   Am I missing some code, what am I doing wrong? Any other errors in the above?  Thanks.
18114
I have a method with an out parameter that tries to do a type conversion. Basically:  public void GetParameterValue(out object destination) {     object paramVal = "I want to return this. could be any type, not just string.";      destination = null; // default out param to null     destination = Convert.ChangeType(paramVal, destination.GetType()); }   The problem is that usually someone would call this like:  string output; GetParameterValue(output);   This will fail because of:  destination.GetType()   destination is null, so we can't call .GetType() on it. We also can not call:  typeof(destination)   because destination is a variable name not a type name.  So is there any way to get the type of an object that is set to null? I would think there would have to be a way to know what type a storage location is without it being assigned anything.    Just to give a bit more info, I am trying to make a utility method that will grab the output parameters of an Oracle stored procedure. The issue is that DbParameter.Value is of type object.  What would be ideal would be for the developers to do something like:  string val = GetParameterValue("parameterName");   The notable thing is that there is no casting of types. In practice, you don't know the lparam of the "equals", so I went with:  string val; GetParameterValue("parameterName", out val);   And figured within the method, I would know the destination type of the output variable. I guess that was a bad assumption. As an alternative, I also wrote the method:  public T GetParameterValue&lt;T&gt;(string paramName)   So the developers can do:  string val = GetParameterValue&lt;string&gt;("parameterName");   I find the explicit "string" declaration to be repetitive, especially since in practice, the destination if probably an object property and the oracle data type could change (think ORM):  MyObj.SomeProp = GetParameterValue&lt;MyObj.SomeProp.GetType()&gt;("parameterName");   But again, if MyObj.SomeProp is null, that .GetType() call fails. The VM has to know the type of MyObj.SomeProp, even when its null, right? or else how would it catch cast exceptions?    To partially solve my own problem, I can do:  MyObj.SomeProp = GetParameterValue&lt;typeof(MyObj).GetField("SomeProp").GetType()&gt;("parameterName");   The whole idea was to not have to explicitly use the Type in more than one place, so that if the data type changes, it only has to be changed in the destination object (MyObj.SomeProp) and in the DB. There has to be a better way...
58840
I have a model that passes a variable to a python script. The script uses that variable to query some directories and return a list of paths. What I want to know is:    How can I then use each of those paths as the parameter in a subsequent operation? Is the bridge between python and ModelBuilder a one-way street?
10955
Is there any way to access controller variable set in a Method in Javascript. In the example above the value is set in constructor. But when I set it in a method it is showing as NULL in Javascript  In controller:  public class abc {     public string varA { get;set; }     public void fn(){         varA='hello';     } }   In VFPage:  function hello(){     var bool = '{!varA}';     alert(bool); }   The alert statement in the VF Page(i.e bool) is displayed as null. Can you please help how to access a variable set from a method instead of constructor?
108170
I want to avoid calling a lot of isinstance() functions, so I'm looking for a way to get the concrete class name for an instance variable as a string.  Any ideas?
42604
here is my code in which i am trying to get the product name from opportunity line item but its returning back NULL value. can anyone please help me to get that product name. I can get id from product2 but i want the name of product so that i can abbreviate it and can store it in Order_Name__c field of orderItem. After adding the product only i am firing this trigger.     public class Procuct_Adding_To_Order{  public static void productOrder(List&lt;OpportunityLineItem&gt; oli){     system.debug('-----------------------');      set&lt;id&gt; prodset = new set&lt;Id&gt;(); for(OpportunityLineItem item : oli) {   prodSet.add(item.product2id); } // collect products Map&lt;Id, product2&gt; prodMap = new Map&lt;Id, Product2&gt;([select name from product2 where id in :prodSet]);   // create a map for OLIid &amp; corresponding Product Name Map&lt;Id, string&gt; OLIprodMap = new Map&lt;Id, string&gt;();  for(OpportunityLineItem item : oli) {  OLIprodMap.put(item.id, OLIprodMap.get(oli.product2id).name); //getting Error in this line. }      set&lt;Id&gt; setOppId = new set&lt;Id&gt;();      for(OpportunityLineItem obj: oli){          setOppId.add(obj.OpportunityId);      }      list&lt;opportunity&gt; needed = [Select Master_Opportunity__c from opportunity Where Opportunity.id =: setOppId];         List&lt;OrderItem&gt; orderIt = new List&lt;OrderItem&gt;();     for(Order ord: [Select id from Order where opportunityId =: needed[0].Master_Opportunity__c])       {        for(OpportunityLineItem o : oli)        {           OrderItem op = new OrderItem();          op.Opportunity_del__c = needed[0].Master_Opportunity__c;          op.orderId = ord.id;         op.Order_Name__c = o.product2Id;         system.debug('-----------------------3333333333333333333333'+ o.Product2Id);         op.PriceBookEntryId = o.PriceBookEntryId;         op.Quantity = o.Quantity;         op.UnitPrice = 100;         orderIt.add(op);            }          }     upsert orderIt;  } }
48842
I'm creating my first full framework using Selenium and TestNG and recently implemented the ability to have logging enabled which will track every action (before and after).  public class CustomLogs {     //Set Logging_Level to "Debug" to enable logging     public String Logging_Level = "OFF";      public void Log(String message) {         if (Logging_Level == "Debug")         {System.out.println(message);         } else {         }     } }   Then, in my page objects, EVERY action method has a log statement before and after EVERY action.  public class LoginPage extends BrowserConfig {      final WebDriver driver;     private static CustomLogs customlogs = new CustomLogs();      //Elements on Page     @FindBy(id = "userId")     private WebElement userNameField;      //Constructor     public LoginPage(WebDriver driver) {         this.driver = driver;     }      //Fill Username     public void FillUsername(String userNameEntry) {         userNameField.clear();         customlogs.Log("Entering Username: "+userNameEntry+"...");         userNameField.sendKeys(userNameEntry);         customlogs.Log("Username entered.");   It seems like this is very beneficial, not only for debugging, but also because you can now print out every single action step, so keeping records or showing others what steps were completed is very straightforward.  But I can also see how this is cluttering the page object code.  Is this a good idea?  And/or is there a better way to do this?
1855
I am working on a simple game project, and have a problem. The problem is accessing the variable from one script to another.   For example :-   I have 2 Scenes (Game Scene and Game Over Scene), Game Scene has a Player Game Object , who has a int Variable Score.   using UnityEngine; using System.Collections;  public class Game_Scene_Script : MonoBehaviour  {      private int Score ;       // Use this for initialization      void Start ()       {           Score = 0 ;      }       // Update is called once per frame      void Update ()       {           // Let us assume some one played the game           // And Now the Score is 207           Score = 207 ;       } }   Now I want to access that int Variable Score in Game Over Scene which a Game Object.  So how can I access that int Variable from that script?   I searched for, but couldn't find any proper answer I wanted. Even-though some answers are in JavaScript , some are in Unity 4.x etc.