Exemplo n.º 1
0
        public void AddType(Type t, string ns)
        {
            Utility.AssertNotNull(t, "t");
            Utility.AssertNotNull(ns, "namespace");

            MyContext.AssertTypeIsAccessible(t);

            NamespaceImport import = this.GetImport(ns);

            import.Add(new TypeImport(t, BindingFlags.Public | BindingFlags.Static, false));
        }
Exemplo n.º 2
0
        private IVariable CreateVariable(Type variableValueType, object variableValue)
        {
            Type variableType = default(Type);

            // Is the variable value an expression?
            IExpression       expression = variableValue as IExpression;
            ExpressionOptions options    = null;

            if (expression != null)
            {
                options = expression.Context.Options;
                // Get its result type
                variableValueType = options.ResultType;
            }

            if (expression != null)
            {
                // Create a variable that wraps the expression

                if (options.IsGeneric == false)
                {
                    variableType = typeof(DynamicExpressionVariable <>);
                }
                else
                {
                    variableType = typeof(GenericExpressionVariable <>);
                }
            }
            else
            {
                // Create a variable for a regular value
                _myContext.AssertTypeIsAccessible(variableValueType);
                variableType = typeof(GenericVariable <>);
            }

            // Create the generic variable instance
            variableType = variableType.MakeGenericType(variableValueType);
            IVariable v = (IVariable)Activator.CreateInstance(variableType);

            return(v);
        }