Exemple #1
0
 private static void RegisterBasicType(IExcuter context, Expression expression)
 {
     context.Register(expression);
     context.RegisterStaticMember(GLOBAL_STATIC_TYPES.ToArray());
     context.RegisterType(GLOBAL_TYPES.ToArray());
     context.RegisterGlobalVariable(GLOBAL_EPXRESSION_NAME, expression);
 }
        public static void Register(this IExcuter context, Expression expression)
        {
            var expressions = expression.Releateds;

            if (expressions == null || !expressions.Any())
            {
                return;
            }

            foreach (var ex in expressions.Where(e => e.Mode != TypeMode.Expression))
            {
                if (string.IsNullOrEmpty(ex.Data))
                {
                    continue;
                }

                Type type;
                if (typeDict.TryGetValue(ex.Data, out type) == false)
                {
                    lock (typeDict)
                    {
                        type = typeDict.FetchType(ex.Data);
                    }
                }

                if (type == null)
                {
                    continue;
                }

                switch (ex.Mode)
                {
                case TypeMode.ReleatedType:
                    context.RegisterType(type);
                    break;

                case TypeMode.Static:
                    context.RegisterStaticMember(type);
                    break;
                }
            }
        }