コード例 #1
0
        private Expression UsingAll(IList <string> namespaceList, ParserRuleContext context)
        {
            var result = new UsingExpression(namespaceList, null, context);

            if (!this.NamespaceLookup.TryGetNamespace(result.Namespace, out ImportedNamespace types))
            {
                this.AddSyntaxError($"Could not locate the namespace {result.Namespace}.", context);
                return(null);
            }

            foreach (var item in types)
            {
                this.UsingTypes.Add(item.Key, item.Value);
            }

            return(result);
        }
コード例 #2
0
        public static UsingExpression Create(
            AphidExpressionContext context_aphidExpressionContext,
            AphidExpression disposable_aphidExpression,
            List <AphidExpression> body_list,
            int value_i,
            int value_i1
            )
        {
            UsingExpression usingExpression = new UsingExpression
                                                  (context_aphidExpressionContext, disposable_aphidExpression, body_list);

            ((AphidExpression)usingExpression).Index  = value_i;
            ((AphidExpression)usingExpression).Length = value_i1;
            return(usingExpression);

            // TODO: Edit factory method of UsingExpression
            // This method should be able to configure the object in all possible ways.
            // Add as many parameters as needed,
            // and assign their values to each field by using the API.
        }
コード例 #3
0
        private Expression Using(IList <string> namespaceList, IList <string> typeList, ParserRuleContext context)
        {
            var result = new UsingExpression(namespaceList, typeList, context);

            if (!this.NamespaceLookup.TryGetNamespace(result.Namespace, out ImportedNamespace types))
            {
                this.AddSyntaxError($"Could not locate the namespace {result.Namespace}.", context);
                return(null);
            }

            foreach (var item in typeList)
            {
                var type = types.GetType(item);
                if (type == null)
                {
                    this.AddSyntaxError($"Could not locate the type '{item}' in the namespace '{result.Namespace}'.", context);
                }

                this.UsingTypes.Add("item", type);
            }

            return(result);
        }