GetGenericTypeName() public method

public GetGenericTypeName ( string name ) : string
name string
return string
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 public ScriptTypeExpr(AstNodeArgs args)
     : base(args)
 {
     if (ChildNodes.Count == 2 && ChildNodes[1].ChildNodes.Count == 0)
       {
     Identifier = ((Token)ChildNodes[0]).Text;
       }
       else
     if (ChildNodes[0] is ScriptTypeExpr)
     {
       TypeExpr = ChildNodes[0] as ScriptTypeExpr;
       Identifier = (ChildNodes[2].ChildNodes[0] as Token).Text;
       GenericsPostfix = ChildNodes[2].ChildNodes[1] as ScriptGenericsPostfix;
     }
     else
     {
       GenericsPostfix = (ScriptGenericsPostfix)ChildNodes[1];
       Identifier = GenericsPostfix.GetGenericTypeName(((Token)ChildNodes[0]).Text);
     }
 }
Ejemplo n.º 4
0
 public ScriptTypeExpr(AstNodeArgs args)
     : base(args)
 {
     if (ChildNodes.Count == 2 && ChildNodes[1].ChildNodes.Count == 0)
     {
         Identifier = ((Token)ChildNodes[0]).Text;
     }
     else
     if (ChildNodes[0] is ScriptTypeExpr)
     {
         TypeExpr        = ChildNodes[0] as ScriptTypeExpr;
         Identifier      = (ChildNodes[2].ChildNodes[0] as Token).Text;
         GenericsPostfix = ChildNodes[2].ChildNodes[1] as ScriptGenericsPostfix;
     }
     else
     {
         GenericsPostfix = (ScriptGenericsPostfix)ChildNodes[1];
         Identifier      = GenericsPostfix.GetGenericTypeName(((Token)ChildNodes[0]).Text);
     }
 }