CSE.Exps.TempIdentifierExp.Lookup C# (CSharp) Method

Lookup() public static method

Looks up temporary identifier of the given name and returns it
public static Lookup ( string name ) : CseObject
name string Identifier name to look up
return CseObject
		public static CseObject Lookup(string name) {
			CseObject result;
			tempIdents.TryGetValue(name, out result);

			return result;
		}

Usage Example

Example #1
0
        ///
        /// <summary>
        ///		Parses identifiers (fields or properties)
        /// </summary>
        ///
        /// <param name="environment">The environment containing the field or property</param>
        /// <param name="data">The name of the field or property</param>
        ///
        /// <returns>An CseObject containing the value of the identifier or containing null if identifier cannot be found</returns>
        ///
        /// <exception cref="CseLogicExceptionType.IDENT_NOT_FOUND" />
        ///
        internal static CseObject Parse(CseObject environment, string data)
        {
            if (data[0].Equals('@'))
            {
                data = data.Remove(0, 1);
            }

            LiteralExp.ParseEscSeqs(ref data, false);

            CseObject result       = null;
            Type      instanceType = TypeExp.GetTypeObj(environment.Value);

            if (!instanceType.IsEnum)
            {
                if (environment == CsEval.EvalEnvironment)
                {
                    CseObject tempLookup = TempIdentifierExp.Lookup(data);
                    if (tempLookup != null)
                    {
                        return(tempLookup);
                    }
                }

                FieldInfo fieldInfo = instanceType.GetField(data, defaultFlags | BindingFlags.GetField);
                if (fieldInfo != null)
                {
                    result = new CseObject(fieldInfo.GetValue(environment.Value));
                    result.CompileTimeType = fieldInfo.FieldType;
                }
                else
                {
                    PropertyInfo propertyInfo = instanceType.GetProperty(data, defaultFlags | BindingFlags.GetProperty);
                    if (propertyInfo != null)
                    {
                        result = new CseObject(propertyInfo.GetValue(environment.Value, null));
                        result.CompileTimeType = propertyInfo.PropertyType;
                    }
                    else
                    {
                        Type t = TypeExp.GetType(data);
                        if (t != null)
                        {
                            result = new CseObject(t);
                            result.CompileTimeType = t.GetType();
                        }
                        else
                        {
                            throw new CseLogicException(CseLogicExceptionType.IDENT_NOT_FOUND, data);
                        }
                    }
                }
            }
            else
            {
                dynamic resultObj = Enum.Parse(instanceType, data);
                result = new CseObject(resultObj);
                result.CompileTimeType = resultObj.GetType();
            }

            return(result);
        }
All Usage Examples Of CSE.Exps.TempIdentifierExp::Lookup