Evaluate() 공개 메소드

public Evaluate ( IScriptContext context ) : void
context IScriptContext
리턴 void
예제 #1
0
        public override void Evaluate(IScriptContext context)
        {
            if (TypeExpr == null && GenericsPostfix == null)
            {
                context.Result = RuntimeHost.GetType(Identifier);
                return;
            }

            if (TypeExpr != null)
            {
                string name = string.Format("{0}.{1}", EvaluateName(TypeExpr), Identifier);
                Type   type = null;

                if (GenericsPostfix != null)
                {
                    Type genericType = RuntimeHost.GetType(GenericsPostfix.GetGenericTypeName(name));
                    GenericsPostfix.Evaluate(context);
                    type = genericType.MakeGenericType((Type[])context.Result);
                }
                else
                {
                    type = RuntimeHost.GetType(name);
                }

                context.Result = type;
            }
            else
            {
                Type genericType = RuntimeHost.GetType(Identifier);
                GenericsPostfix.Evaluate(context);
                context.Result = genericType.MakeGenericType((Type[])context.Result);
            }
        }
예제 #2
0
        private void EvaluateGenericType(IScriptContext context)
        {
            ScriptGenericsPostfix genericPostfix = (ScriptGenericsPostfix)Modifiers.First();

            Type genericType = GetIndentifierValue(context, genericPostfix.GetGenericTypeName(Identifier)) as Type;

            if (genericType == null || !genericType.IsGenericType)
            {
                throw new ScriptException("Given type is not generic");
            }

            genericPostfix.Evaluate(context);
            context.Result = genericType.MakeGenericType((Type[])context.Result);
        }