コード例 #1
0
ファイル: TerminalType.cs プロジェクト: Slesa/Lingua
        /// <summary>
        /// Initializes a new instance of the <see cref="TerminalType"/> class.
        /// </summary>
        /// <param name="type">The <see cref="Type"/> of the <see cref="Terminal"/> described by this <see cref="TerminalType"/>.</param>
        public TerminalType(Type type)
            : base(LanguageElementTypes.Terminal)
        {
            if (!type.IsSubclassOf(typeof(Terminal)))
            {
                throw new ArgumentException("Type must be a subclass of Terminal.", "type");
            }

            m_fullName = type.AssemblyQualifiedName;
            m_name = GetName(type);
            m_constructor = delegate() { return (Terminal)Activator.CreateInstance(type); };

            object[] attributes = type.GetCustomAttributes(typeof(TerminalAttribute), false);
            foreach (object attribute in attributes)
            {
                TerminalAttribute terminalAttribute = (TerminalAttribute)attribute;
                if (terminalAttribute.IsStop)
                {
                    m_isStop = true;
                }
                if (terminalAttribute.Ignore)
                {
                    m_ignore = true;
                }
                m_pattern = terminalAttribute.Pattern;
            }
        }
コード例 #2
0
 /// <summary>
 /// Creates a <c>Parameter</c> using the provided constructor
 /// and the XML annotation. The parameter produced contains all
 /// information related to the constructor parameter. It knows the
 /// name of the XML entity, as well as the type.
 /// </summary>
 /// <param name="method">
 /// this is the constructor the parameter exists in
 /// </param>
 /// <param name="label">
 /// represents the XML annotation for the contact
 /// </param>
 /// <returns>
 /// returns the parameter instantiated for the field
 /// </returns>
 public Parameter GetInstance(Constructor method, Annotation label, int index) {
    Constructor factory = GetConstructor(label);
    if(!factory.isAccessible()) {
       factory.setAccessible(true);
    }
    return (Parameter)factory.newInstance(method, label, index);
 }
コード例 #3
0
ファイル: JSBuiltinFunctionImp.cs プロジェクト: reshadi2/mcjs
 public JSBuiltinFunctionImp(mdr.DFuncImpInstance.JittedMethod m, Constructor c)
     : base(null, null) //base(m.Method.Name, null, null)
 {
     Name = m.Method.Name;
     _method = m;
     _construct = c;
 }
コード例 #4
0
ファイル: TerminalType.cs プロジェクト: Slesa/Lingua
        /// <summary>
        /// Initializes a new instance of the <see cref="TerminalType"/> class.
        /// </summary>
        /// <param name="type">The <see cref="Type"/> of the <see cref="Terminal"/> described by this <see cref="TerminalType"/>.</param>
        public TerminalType(Type type)
            : base(LanguageElementTypes.Terminal)
        {
            if (!type.IsSubclassOf(typeof(Terminal)))
            {
                throw new ArgumentException("Type must be a subclass of Terminal.", "type");
            }

            _fullName = type.AssemblyQualifiedName;
            _name = GetName(type);
            _constructor = () => (Terminal) Activator.CreateInstance(type);

            var attributes = type.GetCustomAttributes(typeof(TerminalAttribute), false);
            foreach (var terminalAttribute in attributes.Cast<TerminalAttribute>())
            {
                if (terminalAttribute.IsStop)
                {
                    IsStop = true;
                }
                if (terminalAttribute.Ignore)
                {
                    Ignore = true;
                }
                Pattern = terminalAttribute.Pattern;
            }
        }
コード例 #5
0
        private static InjectionPlan NewConstructor(string fullName, List<InjectionPlan> plans) 
        {
            Constructor cconstr = new Constructor();
            foreach (InjectionPlan p in plans)
            {
                cconstr.args.Add(p);
            }

            InjectionPlan plan = new InjectionPlan();
            plan.name = fullName;
            plan.constructor = cconstr;
            return plan;
        }
コード例 #6
0
ファイル: datatype.5.cs プロジェクト: ahorn/z3test
    public void Run()
    {
        Dictionary<string, string> cfg = new Dictionary<string, string>() {
            { "AUTO_CONFIG", "true" },
            { "MODEL", "true" } };

        using (Context ctx = new Context(cfg))
        {
            Constructor c_leaf = ctx.MkConstructor("leaf", "is_leaf", new string[] { "val" }, new Sort[] { ctx.IntSort });
            Constructor c_node = ctx.MkConstructor("node", "is_node", new string[] { "left", "right" }, new Sort[] { null, null }, new uint[] { 1, 1 });
            Constructor[] constr_1 = new Constructor[] { c_leaf, c_node };

            Constructor c_nil = ctx.MkConstructor("nil", "is_nil");
            Constructor c_cons = ctx.MkConstructor("cons", "is_cons", new string[] { "car", "cdr" }, new Sort[] { null, null }, new uint[] { 0, 1 });
            Constructor[] constr_2 = new Constructor[] { c_nil, c_cons };

            DatatypeSort[] ts = ctx.MkDatatypeSorts(new string[] { "Tree", "TreeList" },
                                                    new Constructor[][] { constr_1, constr_2 });

            DatatypeSort Tree = ts[0];
            DatatypeSort TreeList = ts[1];

            FuncDecl leaf = Tree.Constructors[0];
            FuncDecl node = Tree.Constructors[1];
            FuncDecl val = Tree.Accessors[0][0];

            FuncDecl nil = TreeList.Constructors[0];
            FuncDecl cons = TreeList.Constructors[1];

            Expr t1 = leaf[ctx.MkInt(10)];
            Expr tl1 = cons[t1, nil.Apply()];
            Expr t2 = node[tl1, nil.Apply()];

            Console.WriteLine(t2);
            Console.WriteLine(val.Apply(t1).Simplify());

            t1 = ctx.MkConst("t1", TreeList);
            t2 = ctx.MkConst("t2", TreeList);
            Expr t3 = ctx.MkConst("t3", TreeList);

            Solver s = ctx.MkSolver();
            s.Assert(ctx.MkDistinct(t1, t2, t3));
            Console.WriteLine(s.Check());
            Console.WriteLine(s.Model);
        }
    }
コード例 #7
0
ファイル: NonterminalType.cs プロジェクト: Slesa/Lingua
        /// <summary>
        /// Initializes a new instance of the <see cref="NonterminalType"/> class.
        /// </summary>
        /// <param name="type">The <see cref="Type"/> of the <see cref="Nonterminal"/> described by this <see cref="NonterminalType"/>.</param>
        public NonterminalType(Type type)
            : base(LanguageElementTypes.Nonterminal)
        {
            if (!type.IsSubclassOf(typeof(Nonterminal)))
            {
                throw new ArgumentException("Type must be a subclass of Nonterminal.", "type");
            }

            _fullName = type.AssemblyQualifiedName;
            _name = GetName(type);
            _constructor = () => (Nonterminal) Activator.CreateInstance(type);

            var attributes = type.GetCustomAttributes(typeof(NonterminalAttribute), false);
            foreach (var nonterminalAttribute in attributes.Cast<NonterminalAttribute>().Where(nonterminalAttribute => nonterminalAttribute.IsStart))
            {
                _isStart = true;
            }
        }
コード例 #8
0
ファイル: PoolBase.cs プロジェクト: Magicolo/PseudoFramework
        protected PoolBase(object reference, Type type, Constructor constructor, Destructor destructor, int startSize, bool initialize)
        {
            PoolUtility.InitializeJanitor();

            this.reference = reference;
            this.constructor = constructor ?? Construct;
            this.destructor = destructor ?? Destroy;
            this.startSize = startSize;

            Type = type;
            isPoolable = reference is IPoolable;
            hashedInstances = new HashSet<object>();

            if (ApplicationUtility.IsMultiThreaded)
                updater = new AsyncPoolUpdater();
            else
                updater = new SyncPoolUpdater();

            if (initialize)
                Initialize();
        }
コード例 #9
0
 /// <summary>
 /// This is used to create a <c>Parameter</c> object which is
 /// used to represent a parameter to a constructor. Each parameter
 /// contains an annotation an the index it appears in.
 /// </summary>
 /// <param name="factory">
 /// this is the constructor the parameter is in
 /// </param>
 /// <param name="label">
 /// this is the annotation used for the parameter
 /// </param>
 /// <param name="ordinal">
 /// this is the position the parameter appears at
 /// </param>
 /// <returns>
 /// this returns the parameter for the constructor
 /// </returns>
 public Parameter Create(Constructor factory, Annotation label, int ordinal) {
    Parameter value = ParameterFactory.getInstance(factory, label, ordinal);
    String name = value.getName();
    if(index.containsKey(name)) {
       Validate(value, name);
    }
    return value;
 }
コード例 #10
0
 public static bool CanBeCreated(this Type type)
 {
     return(type.IsConcrete() && Constructor.HasConstructors(type));
 }
コード例 #11
0
 /// <summary>
 /// This is used to build the <c>Builder</c> object that is
 /// to be used to instantiate the object. The builder contains
 /// the constructor at the parameters in the declaration order.
 /// </summary>
 /// <param name="factory">
 /// this is the constructor that is to be scanned
 /// </param>
 /// <param name="map">
 /// this is the parameter map that contains parameters
 /// </param>
 public void Build(Constructor factory, Index map) {
    Builder builder = new Builder(factory, map);
    if(builder.isDefault()) {
       primary = builder;
    }
    list.add(builder);
 }
コード例 #12
0
ファイル: Parser.cs プロジェクト: dbremner/dafny
        void MethodDecl(MemberModifiers mmod, bool allowConstructor, bool isWithinAbstractModule, out Method/*!*/ m)
        {
            Contract.Ensures(Contract.ValueAtReturn(out m) !=null);
            IToken/*!*/ id = Token.NoToken;
            bool hasName = false;  IToken keywordToken;
            Attributes attrs = null;
            List<TypeParameter/*!*/>/*!*/ typeArgs = new List<TypeParameter/*!*/>();
            List<Formal/*!*/> ins = new List<Formal/*!*/>();
            List<Formal/*!*/> outs = new List<Formal/*!*/>();
            List<MaybeFreeExpression/*!*/> req = new List<MaybeFreeExpression/*!*/>();
            List<FrameExpression/*!*/> mod = new List<FrameExpression/*!*/>();
            List<MaybeFreeExpression/*!*/> ens = new List<MaybeFreeExpression/*!*/>();
            List<Expression/*!*/> dec = new List<Expression/*!*/>();
            Attributes decAttrs = null;
            Attributes modAttrs = null;
            BlockStmt body = null;
            bool isLemma = false;
            bool isConstructor = false;
            bool isIndLemma = false;
            bool isCoLemma = false;
            IToken signatureEllipsis = null;
            IToken bodyStart = Token.NoToken;
            IToken bodyEnd = Token.NoToken;

            while (!(StartOf(10))) {SynErr(158); Get();}
            switch (la.kind) {
            case 84: {
            Get();
            break;
            }
            case 41: {
            Get();
            isLemma = true;
            break;
            }
            case 85: {
            Get();
            isCoLemma = true;
            break;
            }
            case 86: {
            Get();
            isCoLemma = true;
            errors.Warning(t, "the 'comethod' keyword has been deprecated; it has been renamed to 'colemma'");

            break;
            }
            case 40: {
            Get();
            Expect(41);
            isIndLemma = true;
            break;
            }
            case 87: {
            Get();
            if (allowConstructor) {
             isConstructor = true;
            } else {
             SemErr(t, "constructors are allowed only in classes");
            }

            break;
            }
            default: SynErr(159); break;
            }
            keywordToken = t;
            if (isLemma) {
             if (mmod.IsGhost) {
               SemErr(t, "lemmas cannot be declared 'ghost' (they are automatically 'ghost')");
             }
            } else if (isConstructor) {
             if (mmod.IsGhost) {
               SemErr(t, "constructors cannot be declared 'ghost'");
             }
             if (mmod.IsStatic) {
               SemErr(t, "constructors cannot be declared 'static'");
             }
            } else if (isIndLemma) {
             if (mmod.IsGhost) {
               SemErr(t, "inductive lemmas cannot be declared 'ghost' (they are automatically 'ghost')");
             }
            } else if (isCoLemma) {
             if (mmod.IsGhost) {
               SemErr(t, "colemmas cannot be declared 'ghost' (they are automatically 'ghost')");
             }
            }

            while (la.kind == 46) {
            Attribute(ref attrs);
            }
            if (la.kind == 1) {
            NoUSIdent(out id);
            hasName = true;
            }
            if (!hasName) {
             id = keywordToken;
             if (!isConstructor) {
               SemErr(la, "a method must be given a name (expecting identifier)");
             }
            }

            if (la.kind == 50 || la.kind == 52) {
            if (la.kind == 52) {
                GenericParameters(typeArgs);
            }
            Formals(true, !mmod.IsGhost, ins);
            if (la.kind == 83) {
                Get();
                if (isConstructor) { SemErr(t, "constructors cannot have out-parameters"); }
                Formals(false, !mmod.IsGhost, outs);
            }
            } else if (la.kind == 59) {
            Get();
            signatureEllipsis = t;
            } else SynErr(160);
            while (StartOf(11)) {
            MethodSpec(req, mod, ens, dec, ref decAttrs, ref modAttrs);
            }
            if (la.kind == 46) {
            BlockStmt(out body, out bodyStart, out bodyEnd);
            }
            if (!isWithinAbstractModule && DafnyOptions.O.DisallowSoundnessCheating && body == null && ens.Count > 0 && !Attributes.Contains(attrs, "axiom") && !Attributes.Contains(attrs, "imported") && !Attributes.Contains(attrs, "decl") && theVerifyThisFile) {
              SemErr(t, "a method with an ensures clause must have a body, unless given the :axiom attribute");
            }

            IToken tok = theVerifyThisFile ? id : new IncludeToken(id);
            if (isConstructor) {
             m = new Constructor(tok, hasName ? id.val : "_ctor", typeArgs, ins,
                             req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis);
            } else if (isIndLemma) {
             m = new InductiveLemma(tok, id.val, mmod.IsStatic, typeArgs, ins, outs,
                                req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis);
            } else if (isCoLemma) {
             m = new CoLemma(tok, id.val, mmod.IsStatic, typeArgs, ins, outs,
                         req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis);
            } else if (isLemma) {
             m = new Lemma(tok, id.val, mmod.IsStatic, typeArgs, ins, outs,
                       req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis);
            } else {
             m = new Method(tok, id.val, mmod.IsStatic, mmod.IsGhost, typeArgs, ins, outs,
                        req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis);
            }
            m.BodyStartTok = bodyStart;
            m.BodyEndTok = bodyEnd;
        }
コード例 #13
0
 public static void SetConstructor(Constructor c)
 {
     s_constructor = c;
 }
コード例 #14
0
ファイル: Tuples.cs プロジェクト: zhangf911/ql
 internal static void constructor_location(this TextWriter trapFile, Constructor constructor, Location location)
 {
     trapFile.WriteTuple("constructor_location", constructor, location);
 }
コード例 #15
0
ファイル: visit.cs プロジェクト: jj-jabb/mono
 public virtual void Visit(Constructor c)
 {
 }
コード例 #16
0
        private void EnumeratorConstructorMustCallReset()
        {
            Constructor constructor = _enumerator.ClassDefinition.GetConstructor(0);

            constructor.Body.Add(CreateMethodInvocation(_enumerator.ClassDefinition, "Reset"));
        }
コード例 #17
0
 override public void OnConstructor(Constructor method)
 {
     _current = method;
     Visit(_current.Body);
 }
コード例 #18
0
        private SourceCode GenerateApiEndpointClasses(List<VimeoApiEndpointInfo> apiList)
        {
            SourceCode sc = new SourceCode();
            sc.UsingNamespaces.Add("System");

            Namespace ns = new Namespace("HigLabo.Net.Vimeo.Api_3_2");
            sc.Namespaces.Add(ns);

            Class apiEndpointsClass = new Class(AccessModifier.Public, "ApiEndpoints");
            apiEndpointsClass.Modifier.Partial = true;
            ns.Classes.Add(apiEndpointsClass);

            foreach (var apiName1 in apiList.Select(el => el.Name1).Distinct())
            {
                apiEndpointsClass.Fields.Add(new Field("Api_" + apiName1, "_" + apiName1));
                var p = new Property("Api_" + apiName1, apiName1);
                p.Get.Body.Add(SourceCodeLanguage.CSharp, "if (_{0} == null) _{0} = new Api_{0}(this);", apiName1);
                p.Get.Body.Add(SourceCodeLanguage.CSharp, "return _{0};", apiName1);
                p.Set = null;
                apiEndpointsClass.Properties.Add(p);

                Class apiClass = new Class(AccessModifier.Public, "Api_" + apiName1);
                apiClass.Modifier.Partial = true;
                apiEndpointsClass.Classes.Add(apiClass);

                apiClass.Fields.Add(new Field("ApiEndpoints", "_ApiEndpoints"));
                var ct = new Constructor(AccessModifier.Public, "Api_" + apiName1);
                ct.Parameters.Add(new MethodParameter("ApiEndpoints", "apiEndpoints"));
                ct.Body.Add(SourceCodeLanguage.CSharp, "_ApiEndpoints = apiEndpoints;");
                apiClass.Constructors.Add(ct);

                foreach (var apiName2 in apiList.Where(el => el.Name1 == apiName1).Select(el => el.Name2))
                {
                    var apiInfo = apiList.Find(el => el.Name1 == apiName1 && el.Name2 == apiName2);
                    if (apiInfo.HasResult == false) { continue; }

                    apiClass.Methods.Add(this.CreateApiMethod(apiInfo));
                    if (apiInfo.CommandParameters.Count > 0)
                    {
                        apiClass.Methods.AddRange(this.CreateApiMethod1(apiInfo));
                    }
                }
            }
            return sc;
        }
コード例 #19
0
 /// <summary>
 /// Registers a new item constructor, keyed by a type key. ...
 /// </summary>
 public object registerType(JsString type, Constructor cls){return null;}
コード例 #20
0
ファイル: Parser.cs プロジェクト: ggrov/tacny
	void MethodDecl(DeclModifierData dmod, bool allowConstructor, bool isWithinAbstractModule, out Method/*!*/ m) {
		Contract.Ensures(Contract.ValueAtReturn(out m) !=null);
		IToken/*!*/ id = Token.NoToken;
		bool hasName = false;  IToken keywordToken;
		Attributes attrs = null;
		List<TypeParameter/*!*/>/*!*/ typeArgs = new List<TypeParameter/*!*/>();
		List<Formal/*!*/> ins = new List<Formal/*!*/>();
		List<Formal/*!*/> outs = new List<Formal/*!*/>();
		List<MaybeFreeExpression/*!*/> req = new List<MaybeFreeExpression/*!*/>();
		List<FrameExpression/*!*/> mod = new List<FrameExpression/*!*/>();
		List<MaybeFreeExpression/*!*/> ens = new List<MaybeFreeExpression/*!*/>();
		List<Expression/*!*/> dec = new List<Expression/*!*/>();
		Attributes decAttrs = null;
		Attributes modAttrs = null;
		BlockStmt body = null;
		bool isLemma = false;
		bool isConstructor = false;
		bool isIndLemma = false;
		bool isCoLemma = false;
		bool isTactic = false;
		IToken signatureEllipsis = null;
		IToken bodyStart = Token.NoToken;
		IToken bodyEnd = Token.NoToken;
		AllowedDeclModifiers allowed = AllowedDeclModifiers.None;
		string caption = "";
		
		while (!(StartOf(12))) {SynErr(172); Get();}
		switch (la.kind) {
		case 89: {
			Get();
			caption = "Methods";
			allowed = AllowedDeclModifiers.Ghost | AllowedDeclModifiers.Static 
			 | AllowedDeclModifiers.Extern; 
			break;
		}
		case 60: {
			Get();
			isTactic = true; caption = "Tactics"; 
			allowed = AllowedDeclModifiers.AlreadyGhost | AllowedDeclModifiers.Static 
			| AllowedDeclModifiers.Protected; 
			break;
		}
		case 41: {
			Get();
			isLemma = true; caption = "Lemmas";
			allowed = AllowedDeclModifiers.AlreadyGhost | AllowedDeclModifiers.Static 
			 | AllowedDeclModifiers.Protected; 
			break;
		}
		case 90: {
			Get();
			isCoLemma = true; caption = "Colemmas";
			allowed = AllowedDeclModifiers.AlreadyGhost | AllowedDeclModifiers.Static 
			 | AllowedDeclModifiers.Protected; 
			break;
		}
		case 91: {
			Get();
			isCoLemma = true; caption = "Comethods";
			allowed = AllowedDeclModifiers.AlreadyGhost | AllowedDeclModifiers.Static 
			 | AllowedDeclModifiers.Protected;
			errors.Warning(t, "the 'comethod' keyword has been deprecated; it has been renamed to 'colemma'");
			
			break;
		}
		case 40: {
			Get();
			Expect(41);
			isIndLemma = true;  caption = "Inductive lemmas";
			allowed = AllowedDeclModifiers.AlreadyGhost | AllowedDeclModifiers.Static;
			break;
		}
		case 92: {
			Get();
			if (allowConstructor) {
			 isConstructor = true;
			} else {
			 SemErr(t, "constructors are allowed only in classes");
			} 
			caption = "Constructors";
			allowed = AllowedDeclModifiers.None;
			
			break;
		}
		default: SynErr(173); break;
		}
		keywordToken = t; 
		CheckDeclModifiers(dmod, caption, allowed); 
		while (la.kind == 46) {
			Attribute(ref attrs);
		}
		if (la.kind == 1) {
			NoUSIdent(out id);
			hasName = true; 
		}
		if (!hasName) {
		 id = keywordToken;
		 if (!isConstructor) {
		   SemErr(la, "a method must be given a name (expecting identifier)");
		 }
		}
		EncodeExternAsAttribute(dmod, ref attrs, id, /* needAxiom */ true);
		
		if (la.kind == 50 || la.kind == 52) {
			if (la.kind == 52) {
				GenericParameters(typeArgs);
			}
			Formals(true, !dmod.IsGhost, ins);
			if (la.kind == 88) {
				Get();
				if (isConstructor) { SemErr(t, "constructors cannot have out-parameters"); } 
				Formals(false, !dmod.IsGhost, outs);
			}
		} else if (la.kind == 59) {
			Get();
			signatureEllipsis = t; 
		} else SynErr(174);
		while (StartOf(13)) {
			MethodSpec(req, mod, ens, dec, ref decAttrs, ref modAttrs);
		}
		if (la.kind == 46) {
			BlockStmt(out body, out bodyStart, out bodyEnd);
		}
		if (!isWithinAbstractModule && DafnyOptions.O.DisallowSoundnessCheating && body == null && ens.Count > 0 && !Attributes.Contains(attrs, "axiom") && !Attributes.Contains(attrs, "imported") && !Attributes.Contains(attrs, "decl") && theVerifyThisFile) {
		  SemErr(t, "a method with an ensures clause must have a body, unless given the :axiom attribute");
		}
		
		IToken tok = theVerifyThisFile ? id : new IncludeToken(id);
		if (isConstructor) {
		 m = new Constructor(tok, hasName ? id.val : "_ctor", typeArgs, ins,
		                     req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis);
		} else if (isIndLemma) {
		 m = new InductiveLemma(tok, id.val, dmod.IsStatic, typeArgs, ins, outs,
		                        req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis);
		} else if (isCoLemma) {
		 m = new CoLemma(tok, id.val, dmod.IsStatic, typeArgs, ins, outs,
		                 req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis);
		} else if (isLemma) {
		 m = new Lemma(tok, id.val, dmod.IsStatic, typeArgs, ins, outs,
		               req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis);
		} else if(isTactic) {
		 m = new Tactic(tok, id.val, dmod.IsStatic, typeArgs, ins, outs,
		               req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis);
		
		} else {
		 m = new Method(tok, id.val, dmod.IsStatic, dmod.IsGhost, typeArgs, ins, outs,
		                req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis);
		}
		m.BodyStartTok = bodyStart;
		m.BodyEndTok = bodyEnd;
		
	}
コード例 #21
0
        /// <summary>
        /// Gets the example expected summary text for a constructor, based on the type of the constructor.
        /// </summary>
        /// <param name="constructor">The constructor.</param>
        /// <param name="type">The type of the element containing the constructor.</param>
        /// <returns>Returns the example summary text.</returns>
        private static string GetExampleSummaryTextForConstructorType(Constructor constructor, string type)
        {
            Param.AssertNotNull(constructor, "constructor");
            Param.AssertValidString(type, "type");

            if (constructor.ContainsModifier(TokenType.Static))
            {
                return string.Format(
                    CultureInfo.InvariantCulture,
                    CachedCodeStrings.ExampleHeaderSummaryForStaticConstructor,
                    type);
            }
            else if (constructor.AccessModifierType == AccessModifierType.Private &&
                (constructor.ParameterList == null || constructor.ParameterList.Count == 0))
            {
                return string.Format(
                    CultureInfo.InvariantCulture,
                    CachedCodeStrings.ExampleHeaderSummaryForPrivateInstanceConstructor,
                    type);
            }
            else
            {
                return string.Format(
                    CultureInfo.InvariantCulture,
                    CachedCodeStrings.ExampleHeaderSummaryForInstanceConstructor,
                    type);
            }
        }
コード例 #22
0
        /// <summary>
        /// Checks a constructor to ensure that the summary text matches the expected text.
        /// </summary>
        /// <param name="constructor">The constructor to check.</param>
        /// <param name="formattedDocs">The formatted header documentation.</param>
        private void CheckConstructorSummaryText(Constructor constructor, XmlDocument formattedDocs)
        {
            Param.AssertNotNull(constructor, "constructor");
            Param.AssertNotNull(formattedDocs, "formattedDocs");

            XmlNode node = formattedDocs.SelectSingleNode("root/summary");
            if (node != null)
            {
                string summaryText = node.InnerXml.Trim();
                string type = constructor.Parent is Struct ? "struct" : "class";

                ClassBase parent = constructor.Parent as ClassBase;
                if (parent != null)
                {
                    // Get a regex to match the type name.
                    string typeRegex = BuildCrefValidationStringForType(parent);

                    // Get the full expected summary text.
                    string expectedRegex = GetExpectedSummaryTextForConstructorType(constructor, type, typeRegex);

                    if (!Regex.IsMatch(summaryText, expectedRegex, RegexOptions.ExplicitCapture))
                    {
                        this.AddViolation(
                            constructor,
                            Rules.ConstructorSummaryDocumentationMustBeginWithStandardText,
                            GetExampleSummaryTextForConstructorType(constructor, type));
                    }
                }
            }
        }
コード例 #23
0
ファイル: delegate.cs プロジェクト: ermau/mono
        protected override bool DoDefineMembers()
        {
            var builtin_types = Compiler.BuiltinTypes;

            var ctor_parameters = ParametersCompiled.CreateFullyResolved(
                new [] {
                new Parameter(new TypeExpression(builtin_types.Object, Location), "object", Parameter.Modifier.NONE, null, Location),
                new Parameter(new TypeExpression(builtin_types.IntPtr, Location), "method", Parameter.Modifier.NONE, null, Location)
            },
                new [] {
                builtin_types.Object,
                builtin_types.IntPtr
            }
                );

            Constructor = new Constructor(this, Constructor.ConstructorName,
                                          Modifiers.PUBLIC, null, ctor_parameters, Location);
            Constructor.Define();

            //
            // Here the various methods like Invoke, BeginInvoke etc are defined
            //
            // First, call the `out of band' special method for
            // defining recursively any types we need:
            //
            var p = parameters;

            if (!p.Resolve(this))
            {
                return(false);
            }

            //
            // Invoke method
            //

            // Check accessibility
            foreach (var partype in p.Types)
            {
                if (!IsAccessibleAs(partype))
                {
                    Report.SymbolRelatedToPreviousError(partype);
                    Report.Error(59, Location,
                                 "Inconsistent accessibility: parameter type `{0}' is less accessible than delegate `{1}'",
                                 partype.GetSignatureForError(), GetSignatureForError());
                }
            }

            var ret_type = ReturnType.ResolveAsType(this);

            if (ret_type == null)
            {
                return(false);
            }

            //
            // We don't have to check any others because they are all
            // guaranteed to be accessible - they are standard types.
            //
            if (!IsAccessibleAs(ret_type))
            {
                Report.SymbolRelatedToPreviousError(ret_type);
                Report.Error(58, Location,
                             "Inconsistent accessibility: return type `" +
                             ret_type.GetSignatureForError() + "' is less " +
                             "accessible than delegate `" + GetSignatureForError() + "'");
                return(false);
            }

            CheckProtectedModifier();

            if (Compiler.Settings.StdLib && ret_type.IsSpecialRuntimeType)
            {
                Method.Error1599(Location, ret_type, Report);
                return(false);
            }

            VarianceDecl.CheckTypeVariance(ret_type, Variance.Covariant, this);

            var resolved_rt = new TypeExpression(ret_type, Location);

            InvokeBuilder = new Method(this, resolved_rt, MethodModifiers, new MemberName(InvokeMethodName), p, null);
            InvokeBuilder.Define();

            //
            // Don't emit async method for compiler generated delegates (e.g. dynamic site containers)
            //
            if (!IsCompilerGenerated)
            {
                DefineAsyncMethods(resolved_rt);
            }

            return(true);
        }
コード例 #24
0
            public static void Test <U, V> (Context <U> .D2 <V> d)
            {
                var c = new Constructor();

                c.Before(d);
            }
コード例 #25
0
        public override void EmitCpp(CppEmitContext cec)
        {
            if (cec.Pass == CppPasses.PREDEF)
            {
                if (!cec.CheckCanEmit(Location))
                {
                    return;
                }

                if (!has_static_constructor && HasStaticFieldInitializer)
                {
                    var c = DefineDefaultConstructor(true);
                    c.Define();
                }

                if (!(this.Parent is NamespaceContainer))
                {
                    cec.Report.Error(7175, Location, "C++ code generation for nested types not supported.");
                    return;
                }

                Constructor constructor = null;

                foreach (var member in Members)
                {
                    var c = member as Constructor;
                    if (c != null)
                    {
                        if ((c.ModFlags & Modifiers.STATIC) != 0)
                        {
                            continue;
                        }
                        if (constructor != null)
                        {
                            cec.Report.Error(7177, c.Location, "C++ generation not supported for overloaded constructors");
                            return;
                        }
                        constructor = c;
                    }
                }
            }

            if (cec.Pass == CppPasses.PREDEF)
            {
                cec.Buf.Write("\tclass ", MemberName.Name, ";\n");
            }
            else if (cec.Pass == CppPasses.CLASSDEF)
            {
                cec.Buf.Write("\tclass ", MemberName.Name, " {\n", Location);
                cec.Buf.Indent();
                cec.Buf.Write("\tpublic:\n");
            }

            base.EmitCpp(cec);

            if (cec.Pass == CppPasses.CLASSDEF)
            {
                cec.Buf.Unindent();
                cec.Buf.Write("\t};\n");
            }
        }
コード例 #26
0
		  public virtual int compare<T1, T2>(Constructor<T1> arg0, Constructor<T2> arg1)
		  {
			return arg0.toGenericString().compareTo(arg1.toGenericString());
		  }
コード例 #27
0
 public override int GetHashCode()
 {
     return(Constructor.GetHashCode() ^ TargetMethod.GetHashCode());
 }
コード例 #28
0
ファイル: BasicForm.cs プロジェクト: maxwelld90/pleasetakes2
 public BasicForm()
 {
     this._rightPane = new Constructor();
     this._rows      = new List <Row>();
 }
コード例 #29
0
			internal Constructor GetConstructorInvoker()
			{
				if (_constructor == null)
				{
					ConstructorInfo info = _type.GetConstructor(Type.EmptyTypes);
					DynamicMethod dynamicMethod = new DynamicMethod(string.Empty, _type, new Type[0], info.DeclaringType.Module);
					ILGenerator il = dynamicMethod.GetILGenerator();
					il.Emit(OpCodes.Newobj, info);
					il.Emit(OpCodes.Ret);
					_constructor = (Constructor) dynamicMethod.CreateDelegate(typeof (Constructor));
				}
				return _constructor;
			}
コード例 #30
0
ファイル: BasicForm.cs プロジェクト: maxwelld90/pleasetakes2
 public BasicForm(string rightPaneTemplatePath)
 {
     this._rightPane = new Constructor(rightPaneTemplatePath);
     this._rows      = new List <Row>();
 }
コード例 #31
0
		public override void OnConstructor(AST.Constructor node)
		{
			if (node.IsSynthetic && node.Parameters.Count == 0) return;
			Constructor ctor = new Constructor(GetModifier(node), GetRegion(node), GetClientRegion(node), OuterClass);
			ConvertAttributes(node, ctor);
			ConvertParameters(node.Parameters, ctor);
			_currentClass.Peek().Methods.Add(ctor);
			ctor.UserData = node;
		}
コード例 #32
0
        public View OnCreateView(string name, Context context, IAttributeSet attrs)
        {
            if (name.Equals("com.android.internal.view.menu.ActionMenuItemView", StringComparison.InvariantCultureIgnoreCase))
            {
                View view = null;

                try
                {
                    if (ActionMenuItemViewClass == null)
                    {
                        ActionMenuItemViewClass = ClassLoader.SystemClassLoader.LoadClass(name);
                    }
                }
                catch (ClassNotFoundException)
                {
                    return(null);
                }

                if (ActionMenuItemViewClass == null)
                {
                    return(null);
                }

                if (ActionMenuItemViewConstructor == null)
                {
                    try
                    {
                        ActionMenuItemViewConstructor = ActionMenuItemViewClass.GetConstructor(new Class[] {
                            Class.FromType(typeof(Context)),
                            Class.FromType(typeof(IAttributeSet))
                        });
                    }
                    catch (SecurityException)
                    {
                        return(null);
                    }
                    catch (NoSuchMethodException)
                    {
                        return(null);
                    }
                }
                if (ActionMenuItemViewConstructor == null)
                {
                    return(null);
                }

                try
                {
                    Java.Lang.Object[] args = new Java.Lang.Object[] { context, (Java.Lang.Object)attrs };
                    view = (View)(ActionMenuItemViewConstructor.NewInstance(args));
                }
                catch (IllegalArgumentException)
                {
                    return(null);
                }
                catch (InstantiationException)
                {
                    return(null);
                }
                catch (IllegalAccessException)
                {
                    return(null);
                }
                catch (InvocationTargetException)
                {
                    return(null);
                }
                if (null == view)
                {
                    return(null);
                }

                View v = view;

                new Handler().Post(() => {
                    try
                    {
                        if (v is LinearLayout)
                        {
                            var ll = (LinearLayout)v;
                            for (int i = 0; i < ll.ChildCount; i++)
                            {
                                var button = ll.GetChildAt(i) as Button;

                                if (button != null)
                                {
                                    var title = button.Text;

                                    if (!string.IsNullOrEmpty(title) && title.Length == 1)
                                    {
                                        button.SetTypeface(Typeface, TypefaceStyle.Normal);
                                    }
                                }
                            }
                        }
                        else if (v is TextView)
                        {
                            var tv       = (TextView)v;
                            string title = tv.Text;

                            if (!string.IsNullOrEmpty(title) && title.Length == 1)
                            {
                                tv.SetTypeface(Typeface, TypefaceStyle.Normal);
                            }
                        }
                    }
                    catch (ClassCastException)
                    {
                    }
                });

                return(view);
            }

            return(null);
        }
コード例 #33
0
ファイル: TestRig.cs プロジェクト: sunfirefox/antlr4cs
        /// <exception cref="System.Exception"></exception>
        public virtual void Process()
        {
            //		System.out.println("exec "+grammarName+"."+startRuleName);
            string      lexerName  = grammarName + "Lexer";
            ClassLoader cl         = Sharpen.Thread.CurrentThread().GetContextClassLoader();
            Type        lexerClass = null;

            try
            {
                lexerClass = cl.LoadClass(lexerName).AsSubclass <Lexer>();
            }
            catch (TypeLoadException)
            {
                // might be pure lexer grammar; no Lexer suffix then
                lexerName = grammarName;
                try
                {
                    lexerClass = cl.LoadClass(lexerName).AsSubclass <Lexer>();
                }
                catch (TypeLoadException)
                {
                    System.Console.Error.WriteLine("Can't load " + lexerName + " as lexer or parser");
                    return;
                }
            }
            Constructor <Lexer> lexerCtor = lexerClass.GetConstructor(typeof(ICharStream));
            Lexer  lexer       = lexerCtor.NewInstance((ICharStream)null);
            Type   parserClass = null;
            Parser parser      = null;

            if (!startRuleName.Equals(LexerStartRuleName))
            {
                string parserName = grammarName + "Parser";
                parserClass = cl.LoadClass(parserName).AsSubclass <Parser>();
                if (parserClass == null)
                {
                    System.Console.Error.WriteLine("Can't load " + parserName);
                    return;
                }
                Constructor <Parser> parserCtor = parserClass.GetConstructor(typeof(ITokenStream));
                parser = parserCtor.NewInstance((ITokenStream)null);
            }
            if (inputFiles.IsEmpty())
            {
                Stream       @is = Sharpen.Runtime.@in;
                StreamReader r;
                if (encoding != null)
                {
                    r = new StreamReader(@is, encoding);
                }
                else
                {
                    r = new StreamReader(@is);
                }
                Process(lexer, parserClass, parser, @is, r);
                return;
            }
            foreach (string inputFile in inputFiles)
            {
                Stream @is = Sharpen.Runtime.@in;
                if (inputFile != null)
                {
                    @is = new FileInputStream(inputFile);
                }
                StreamReader r;
                if (encoding != null)
                {
                    r = new StreamReader(@is, encoding);
                }
                else
                {
                    r = new StreamReader(@is);
                }
                if (inputFiles.Count > 1)
                {
                    System.Console.Error.WriteLine(inputFile);
                }
                Process(lexer, parserClass, parser, @is, r);
            }
        }
コード例 #34
0
        static void Main(string[] args)
        {
            var resultado = Menu();

            if (resultado == -1)
            {
                Console.WriteLine("Opcion no valida ");
                return;
            }
            Constructor Comida = null;

            switch (resultado)
            {
            case 1:
                Console.Clear();
                Console.WriteLine("Escoge hamburguesa");
                Console.WriteLine("1. Hamburguesa Carne ");
                Console.WriteLine("2. Hamburguesa Queso");
                Console.WriteLine("3. Hamburguesa Vegetariana");
                var l   = Console.ReadLine();
                var num = int.Parse(l);
                switch (num)
                {
                case 1:
                    Comida = new ConstructorHamCarne();
                    break;

                case 2:
                    Comida = new ConstrutorHamQueso();
                    break;

                case 3:
                    Comida = new ConstrutorHamVege();
                    break;
                }
                break;

            case 2:
                Console.Clear();
                Console.WriteLine("Escoge Baggette");
                Console.WriteLine("1. Baggette Atun ");
                Console.WriteLine("2. Baggette Jamon");
                Console.WriteLine("3. Baggette Pepperoni");
                var b    = Console.ReadLine();
                var num2 = int.Parse(b);
                switch (num2)
                {
                case 1:
                    Comida = new ConstructorBaggAtun();
                    break;

                case 2:
                    Comida = new ConstructorBaggJamon();
                    break;

                case 3:
                    Comida = new ConstructorBaggPeppe();
                    break;
                }
                break;

            default:
                Console.WriteLine("Intentelo de nuevo");
                break;
            }
            var ComidaHecha = Comida.ComerComida();

            Console.WriteLine($"Ingredientes: {ComidaHecha.PonerIngredientes()}");
            Console.WriteLine($"Catsup: {ComidaHecha.PonerCatsup()}");
            Console.WriteLine($"Salsa: {ComidaHecha.PonerSalsa()}");
        }
コード例 #35
0
 /// <summary>
 /// This is used to scan the specified constructor for annotations
 /// that it contains. Each parameter annotation is evaluated and
 /// if it is an XML annotation it is considered to be a valid
 /// parameter and is added to the parameter map.
 /// </summary>
 /// <param name="factory">
 /// this is the constructor that is to be scanned
 /// </param>
 /// <param name="map">
 /// this is the parameter map that contains parameters
 /// </param>
 public void Scan(Constructor factory, Index map) {
    Annotation[][] labels = factory.getParameterAnnotations();
    Class[] types = factory.getParameterTypes();
    for(int i = 0; i < types.length; i++) {
       for(int j = 0; j < labels[i].length; j++) {
          Parameter value = Process(factory, labels[i][j], i);
          if(value != null) {
             String name = value.getName();
             if(map.containsKey(name)) {
                throw new PersistenceException("Parameter '%s' is a duplicate in %s", name, factory);
             }
             index.put(name, value);
             map.put(name, value);
          }
       }
    }
    if(types.length == map.size()) {
       Build(factory, map);
    }
 }
コード例 #36
0
 public object Create() => Constructor.Invoke(Arguments.Select(x => x.Next()).ToArray());
コード例 #37
0
 /// <summary>
 /// This is used to create a <c>Parameter</c> object which is
 /// used to represent a parameter to a constructor. Each parameter
 /// contains an annotation an the index it appears in.
 /// </summary>
 /// <param name="factory">
 /// this is the constructor the parameter is in
 /// </param>
 /// <param name="label">
 /// this is the annotation used for the parameter
 /// </param>
 /// <param name="ordinal">
 /// this is the position the parameter appears at
 /// </param>
 /// <returns>
 /// this returns the parameter for the constructor
 /// </returns>
 public Parameter Process(Constructor factory, Annotation label, int ordinal) {
    if(label instanceof Attribute) {
       return Create(factory, label, ordinal);
    }
    if(label instanceof ElementList) {
       return Create(factory, label, ordinal);
    }
    if(label instanceof ElementArray) {
       return Create(factory, label, ordinal);
    }
    if(label instanceof ElementMap) {
       return Create(factory, label, ordinal);
    }
    if(label instanceof Element) {
       return Create(factory, label, ordinal);
    }
    return null;
 }
コード例 #38
0
ファイル: MainActivity.cs プロジェクト: xamamit/mobileEfr
        // TODO: Refactor this method into multiple helper methods and possibly into a control for Toolbar
        private View CreateCustomToolbarItem(string name, Context context, IAttributeSet attrs)
        {
            View view = null;

            try
            {
                if (null == ActionMenuItemViewClass)
                {
                    ActionMenuItemViewClass = ClassLoader.LoadClass(name);
                }
            }
            catch (ClassNotFoundException cnf)
            {
                LogDebugMessage(cnf, "CreateCustomToolbarItem()");
                return(null);
            }

            if (ActionMenuItemViewClass == null)
            {
                return(null);
            }

            if (ActionMenuItemViewConstructor == null)
            {
                try
                {
                    ActionMenuItemViewConstructor = ActionMenuItemViewClass.GetConstructor(new Class[] {
                        Class.FromType(typeof(Context)),
                        Class.FromType(typeof(IAttributeSet))
                    });
                }
                catch (SecurityException se)
                {
                    LogDebugMessage(se, "CreateCustomToolbarItem()");
                    return(null);
                }
                catch (NoSuchMethodException nsme)
                {
                    LogDebugMessage(nsme, "CreateCustomToolbarItem()");
                    return(null);
                }
            }
            if (ActionMenuItemViewConstructor == null)
            {
                return(null);
            }

            try
            {
                Java.Lang.Object[] args = new Java.Lang.Object[] { context, (Java.Lang.Object)attrs };
                view = (View)(ActionMenuItemViewConstructor.NewInstance(args));
            }
            catch (IllegalArgumentException)
            {
                //LogDebugMessage(se, "CreateCustomToolbarItem()");
                return(null);
            }
            catch (InstantiationException)
            {
                //LogDebugMessage(se, "CreateCustomToolbarItem()");
                return(null);
            }
            catch (IllegalAccessException)
            {
                //LogDebugMessage(se, "CreateCustomToolbarItem()");
                return(null);
            }
            catch (InvocationTargetException)
            {
                //LogDebugMessage(se, "CreateCustomToolbarItem()");
                return(null);
            }

            if (null == view)
            {
                return(null);
            }
            View v = view;

            new Handler().Post(() =>
            {
                try
                {
                    if (v is LinearLayout)
                    {
                        var linearLayout = (LinearLayout)v;
                        for (int i = 0; i < linearLayout.ChildCount; i++)
                        {
                            var button = linearLayout.GetChildAt(i) as Button;

                            var title = button?.Text;

                            if (!string.IsNullOrEmpty(title) && title.Length == 1)
                            {
                                button.SetTypeface(Typeface, TypefaceStyle.Normal);
                            }
                        }
                    }
                    else if (v is TextView)
                    {
                        var tv       = (TextView)v;
                        string title = tv.Text;

                        if (!string.IsNullOrEmpty(title) && title.Length == 1)
                        {
                            tv.SetTypeface(Typeface, TypefaceStyle.Normal);
                        }
                    }
                }
                catch (ClassCastException cce)
                {
                    LogDebugMessage(cce, "CreateCustomToolbarItem()");
                }
            });

            return(view);
        }
コード例 #39
0
 public override void OnConstructor(Constructor node)
 {
     OnMethod(node);
 }
コード例 #40
0
ファイル: SouthwindClient.cs プロジェクト: lulzzz/southwind
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <EmployeeEntity>()
                    {
                        View = e => new Employee()
                    },
                    new EntitySettings <TerritoryEntity>()
                    {
                        View = e => new Territory()
                    },
                    new EntitySettings <RegionEntity>()
                    {
                        View = e => new Region()
                    },

                    new EntitySettings <ProductEntity>()
                    {
                        View = e => new Product()
                    },
                    new EntitySettings <CategoryEntity>()
                    {
                        View = e => new Category(), IsViewable = true
                    },
                    new EntitySettings <SupplierEntity>()
                    {
                        View = e => new Supplier()
                    },

                    new EntitySettings <CompanyEntity>()
                    {
                        View = e => new Company()
                    },
                    new EntitySettings <PersonEntity>()
                    {
                        View = e => new Person()
                    },

                    new EntitySettings <OrderEntity>()
                    {
                        View = e => new Order()
                    },
                });


                QuerySettings.RegisterPropertyFormat((EmployeeEntity e) => e.Photo, b =>
                {
                    b.Converter = SouthwindConverters.ImageConverter;
                    return(Fluent.GetDataTemplate(() => new Image {
                        MaxHeight = 32.0, Stretch = Stretch.Uniform
                    }
                                                  .Bind(Image.SourceProperty, b)
                                                  .Set(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.Linear)));
                }); //Photo

                QuerySettings.RegisterPropertyFormat((CategoryEntity e) => e.Picture, b =>
                {
                    b.Converter = SouthwindConverters.EmbeddedImageConverter;
                    return(Fluent.GetDataTemplate(() => new Image {
                        MaxHeight = 32.0, Stretch = Stretch.Uniform
                    }
                                                  .Bind(Image.SourceProperty, b)
                                                  .Set(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.Linear)));
                }); //Picture

                Constructor.Register(ctx => new EmployeeEntity {
                    Address = new AddressEmbedded()
                });
                Constructor.Register(ctx => new PersonEntity {
                    Address = new AddressEmbedded()
                });
                Constructor.Register(ctx => new CompanyEntity {
                    Address = new AddressEmbedded()
                });
                Constructor.Register(ctx => new SupplierEntity {
                    Address = new AddressEmbedded()
                });

                OperationClient.AddSettings(new List <OperationSettings>()
                {
                    new ConstructorOperationSettings <OrderEntity>(OrderOperation.Create)
                    {
                        Constructor = ctx =>
                        {
                            var cust = Finder.Find <CustomerEntity>(); // could return null, but we let it continue

                            return(OperationServer.Construct(OrderOperation.Create, cust));
                        },
                    },


                    new ContextualOperationSettings <ProductEntity>(OrderOperation.CreateOrderFromProducts)
                    {
                        Click = ctx =>
                        {
                            var cust = Finder.Find <CustomerEntity>(); // could return null, but we let it continue

                            var result = OperationServer.ConstructFromMany(ctx.Entities, OrderOperation.CreateOrderFromProducts, cust);

                            Navigator.Navigate(result);
                        },
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.SaveNew)
                    {
                        IsVisible = ctx => ctx.Entity.IsNew
                    },
                    new EntityOperationSettings <OrderEntity>(OrderOperation.Save)
                    {
                        IsVisible = ctx => !ctx.Entity.IsNew
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.Cancel)
                    {
                        ConfirmMessage = ctx => ((OrderEntity)ctx.Entity).State == OrderState.Shipped ? OrderMessage.CancelShippedOrder0.NiceToString(ctx.Entity) : null
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.Ship)
                    {
                        Click = ctx =>
                        {
                            DateTime shipDate = DateTime.Now;
                            if (!ValueLineBox.Show(ref shipDate,
                                                   labelText: DescriptionManager.NiceName((OrderEntity o) => o.ShippedDate),
                                                   owner: Window.GetWindow(ctx.EntityControl)))
                            {
                                return(null);
                            }

                            try
                            {
                                return(ctx.Entity.Execute(OrderOperation.Ship, shipDate));
                            }
                            catch (IntegrityCheckException e)
                            {
                                ctx.Entity.SetGraphErrors(e);
                                throw e;
                            }
                        },

                        Contextual =
                        {
                            Click                 = ctx =>
                            {
                                DateTime shipDate = DateTime.Now;
                                if (!ValueLineBox.Show(ref shipDate,
                                                       labelText: DescriptionManager.NiceName((OrderEntity o) => o.ShippedDate),
                                                       owner: Window.GetWindow(ctx.SearchControl)))
                                {
                                    return;
                                }

                                ctx.Entities.SingleEx().ExecuteLite(OrderOperation.Ship, shipDate);
                            }
                        }
                    },
                });

                //NotDefined
            }
        }
コード例 #41
0
 public RotationsGroup(byte dimensions, Constructor <T, P, int> ctor) : base(dimensions, ctor)
 {
 }
コード例 #42
0
        static void Main(string[] args)
        {
            var boolType = SolidityType.Bool;
            var intType  = SolidityType.Int;

            var propertyName  = "PropertyName1";
            var propertyName2 = "PropertyName2";
            var propertyName3 = "PropertyName3";

            var pr1 = new ContractProperty()
            {
                Variable   = PrepareVariable(propertyName, boolType),
                Visibility = Visibility.Public
            };

            var pr2 = new ContractProperty()
            {
                Variable   = PrepareVariable(propertyName2, intType),
                Visibility = Visibility.Private
            };

            var pr3 = new ContractProperty()
            {
                Variable   = PrepareVariable(propertyName3, boolType),
                Visibility = Visibility.Public
            };

            var properties = new List <ContractProperty>()
            {
                pr1, pr2, pr3
            };

            var eventName  = "EventName1";
            var eventName2 = "EventName2";
            var eventName3 = "EventName3";

            var epl = new ParametersList()
            {
                Parameters = new List <Variable>()
                {
                    PrepareVariable("ep1", boolType), PrepareVariable("ep2", intType)
                }
            };

            var epl2 = new ParametersList()
            {
                Parameters = new List <Variable>()
                {
                    PrepareVariable("ep1", boolType)
                }
            };

            var epl3 = new ParametersList()
            {
                Parameters = new List <Variable>()
                {
                    PrepareVariable("ep1", intType)
                }
            };

            var e1 = new ContractEvent()
            {
                Name       = eventName,
                Parameters = epl
            };

            var e2 = new ContractEvent()
            {
                Name       = eventName2,
                Parameters = epl2
            };

            var e3 = new ContractEvent()
            {
                Name       = eventName3,
                Parameters = epl3
            };

            var events = new List <ContractEvent>()
            {
                e1, e2, e3
            };

            var name1 = "_p";
            var name2 = "_q";
            var name3 = "_r";
            var name4 = "v";
            var p1    = PrepareVariable(name1, boolType);
            var p2    = PrepareVariable(name2, boolType);
            var p3    = PrepareVariable(name3, boolType);
            var v     = PrepareVariable(name4, boolType);

            var pl = new ParametersList()
            {
                Parameters = new List <Variable>()
                {
                    p1, p2
                }
            };

            var pl2 = new ParametersList()
            {
                Parameters = new List <Variable>()
                {
                    p1, p2, p3
                }
            };

            var cpl = new CallingParametersList()
            {
                Parameters = new List <IAssignable>()
                {
                    p1, p2
                }
            };

            var cpl2 = new CallingParametersList()
            {
                Parameters = new List <IAssignable>()
                {
                    p1, p2, p3
                }
            };

            var d = new Declaration()
            {
                Variable = v
            };

            var op = new Operation()
            {
                LeftSide  = p1,
                Operator  = OperationOperator.OR,
                RightSide = p2
            };

            var instruction = new Assignment()
            {
                Destination = d,
                Source      = op
            };

            var ao = new Operation()
            {
                LeftSide = v,
                Operator = OperationOperator.Negation
            };

            var instruction2 = new Assignment()
            {
                Destination = v,
                Source      = ao
            };

            var instructions = new InstructionsList();

            instructions.AppendInstruction(instruction);
            instructions.AppendInstruction(instruction2);

            var c = new Constructor()
            {
                Visibility   = Visibility.Public,
                Parameters   = pl,
                Instructions = instructions
            };

            var functionInstructions = new InstructionsList();

            functionInstructions.AppendInstruction(instruction);

            var aof = new Operation()
            {
                LeftSide  = v,
                Operator  = OperationOperator.AND,
                RightSide = p3
            };

            var instruction3 = new Assignment()
            {
                Destination = v,
                Source      = aof
            };

            functionInstructions.AppendInstruction(instruction3);

            var function = new ContractFunction()
            {
                Name         = "TestFunction",
                Visibility   = Visibility.Public,
                Parameters   = pl2,
                Instructions = functionInstructions
            };

            var fp1 = PrepareVariable(name1, intType);
            var fp2 = PrepareVariable(name2, intType);
            var fp3 = PrepareVariable(name3, intType);
            var fv  = PrepareVariable(name4, intType);

            var fpl = new ParametersList()
            {
                Parameters = new List <Variable>()
                {
                    fp1, fp2, fp3
                }
            };

            var fd = new Declaration()
            {
                Variable = fv
            };

            var fop = new Operation()
            {
                LeftSide  = p1,
                Operator  = OperationOperator.Plus,
                RightSide = p2
            };

            var finstruction = new Assignment()
            {
                Destination = fd,
                Source      = fop
            };

            var fao = new Operation()
            {
                LeftSide  = v,
                Operator  = OperationOperator.Multiply,
                RightSide = fp3
            };

            var finstruction2 = new Assignment()
            {
                Destination = pr2,
                Source      = fao
            };

            var finstructions = new InstructionsList();

            finstructions.AppendInstruction(finstruction);
            finstructions.AppendInstruction(finstruction2);

            var function2 = new ContractFunction()
            {
                Name         = "TestFunction2",
                Visibility   = Visibility.External,
                Parameters   = fpl,
                Instructions = finstructions
            };

            var trueInstructions  = new InstructionsList();
            var falseInstructions = new InstructionsList();

            trueInstructions.AppendInstruction(
                new FunctionCall()
            {
                FunctionToCall = function, Parameters = cpl2
            }
                );

            var ecpl = new CallingParametersList()
            {
                Parameters = new List <IAssignable>()
                {
                    p1
                }
            };

            falseInstructions.AppendInstruction(
                new EventCall()
            {
                EventToCall = e2, Parameters = ecpl
            }
                );

            var newFInstructions = new InstructionsList();
            var condOp           = new Operation()
            {
                LeftSide = p1,
                Operator = OperationOperator.Negation
            };
            var cond = new Condition()
            {
                ConditionOperation = condOp
            };
            var ifStatement = new IfStatement()
            {
                Condition         = cond,
                TrueInstructions  = trueInstructions,
                FalseInstructions = falseInstructions
            };

            newFInstructions.AppendInstruction(ifStatement);

            var loopVariable = PrepareVariable("loopVariable", intType);
            var declaration  = new Declaration()
            {
                Variable = loopVariable
            };
            var assignment = new Assignment()
            {
                Destination = declaration,
                Source      = new ConstantValue()
                {
                    Value = "0"
                }
            };

            var condOperation = new Operation()
            {
                LeftSide  = loopVariable,
                Operator  = OperationOperator.NotEquals,
                RightSide = new ConstantValue()
                {
                    Value = "1"
                }
            };

            var breakCondition = new Condition()
            {
                ConditionOperation = condOperation
            };

            var stepOp = new Operation()
            {
                LeftSide  = loopVariable,
                Operator  = OperationOperator.Plus,
                RightSide = new ConstantValue()
                {
                    Value = "1"
                }
            };

            var stepInstruction = new Assignment()
            {
                Destination = loopVariable,
                Source      = stepOp
            };

            var loopInstructions = new InstructionsList();
            var cple             = new CallingParametersList()
            {
                Parameters = new List <IAssignable>()
                {
                    loopVariable
                }
            };

            loopInstructions.AppendInstruction(
                new EventCall()
            {
                EventToCall = e3,
                Parameters  = cple
            }
                );

            var loop = new ContractLoop()
            {
                InitialAssignment = assignment,
                BreakCondition    = breakCondition,
                StepInstruction   = stepInstruction,
                Instructions      = loopInstructions
            };

            newFInstructions.AppendInstruction(loop);

            var function3 = new ContractFunction()
            {
                Name         = "NewFunction",
                Visibility   = Visibility.Public,
                Parameters   = pl2,
                Instructions = newFInstructions
            };

            var functions = new List <ContractFunction>()
            {
                function, function2, function3
            };

            string   contractName = "TestContract";
            Contract contract     = new Contract()
            {
                Name        = contractName,
                Constructor = c,
                Functions   = functions,
                Events      = events,
                Properties  = properties
            };

            Console.WriteLine(contract.GenerateCode(new Indentation()));
        }
コード例 #43
0
ファイル: MainViewModel.cs プロジェクト: Geeksltd/Matrix
 public MainViewModel()
 {
     SampleGeneration       = Command.RegisterCommand(GenerateSample);
     MyMethod               = new MethodPresenter().PresentMethod();
     Params                 = new ObservableCollection <Parameter>(MyMethod.MethodInformation.GetParameters().ToParamaters());
     Ctors                  = new ObservableCollection <KeyValuePair <object, string> >(Constructor.GetCTors(MyMethod.ClassInstance.GetType()).GetSelectList(EMPTYCTOR));
     SelectedCtorParameters = new ObservableCollection <Parameter>();
     Results                = new ObservableCollection <TestResult>();
     SelectedCtor           = Ctors.FirstOrDefault();
     SetProperties          = MyMethod.ClassInstance.GetType().GetProps().ToCaption();
     System.Diagnostics.Debug.WriteLine(SetProperties);
     GenerateSample();
 }
コード例 #44
0
 public static IManualTypeDefinitionManager WithAcceptedDefinition <T>(this IManualTypeDefinitionManager manualTypeDefinitionManager, T defaultValue, string editorName = null, string displayName = null)
 => manualTypeDefinitionManager.WithAcceptedDefinition(Constructor.TypeDefinition(defaultValue, editorName, displayName));
コード例 #45
0
ファイル: Tuples.cs プロジェクト: zhangf911/ql
 internal static void constructors(this TextWriter trapFile, Constructor key, string name, Type definingType, Constructor originalDefinition)
 {
     trapFile.WriteTuple("constructors", key, name, definingType, originalDefinition);
 }
		public View OnCreateView(string name, Context context, IAttributeSet attrs)
		{
			if (name.Equals("com.android.internal.view.menu.ActionMenuItemView", StringComparison.InvariantCultureIgnoreCase))
			{
				View view = null;

				try
				{
					if (ActionMenuItemViewClass == null)
						ActionMenuItemViewClass = ClassLoader.SystemClassLoader.LoadClass(name);
				}
				catch (ClassNotFoundException)
				{
					return null;
				}

				if (ActionMenuItemViewClass == null)
					return null;

				if (ActionMenuItemViewConstructor == null)
				{
					try
					{
						ActionMenuItemViewConstructor = ActionMenuItemViewClass.GetConstructor(new Class[] {
							Class.FromType(typeof(Context)),
							Class.FromType(typeof(IAttributeSet))
						});
					}
					catch (SecurityException)
					{
						return null;
					}
					catch (NoSuchMethodException)
					{
						return null;
					}
				}
				if (ActionMenuItemViewConstructor == null)
					return null;

				try
				{
					Java.Lang.Object[] args = new Java.Lang.Object[] { context, (Java.Lang.Object)attrs };
					view = (View)(ActionMenuItemViewConstructor.NewInstance(args));
				}
				catch (IllegalArgumentException)
				{
					return null;
				}
				catch (InstantiationException)
				{
					return null;
				}
				catch (IllegalAccessException)
				{
					return null;
				}
				catch (InvocationTargetException)
				{
					return null;
				}
				if (null == view)
					return null;

				View v = view;

				new Handler().Post(() => {

					try
					{
						var tv = (TextView)v;

						string title = tv.Text;

						if (!string.IsNullOrEmpty(title) && title.Length == 1)
						{
							tv.SetTypeface(Typeface, TypefaceStyle.Normal);
						}
					}
					catch (ClassCastException)
					{
					}
				});

				return view;
			}

			return null;
		}
コード例 #47
0
    void HandleConstructor()
    {
        for (int i = 0; i < myUnits.Count; i++)
        {
            if (myUnits[i].GetComponent <Constructor>() && myUnits[i].GetComponent <Constructor>().doingNothing())
            {
                Constructor constructor = myUnits[i].GetComponent <Constructor>();

                CreationBuilding buildingToBuild;
                if (UnityEngine.Random.value < 0.5f)
                {
                    buildingToBuild = constructor.Buildings[0];
                }
                else
                {
                    buildingToBuild = constructor.Buildings[1];
                }

                float money = myFaction.Equals(Faction.Blue) ? gameMaster.BlueWool : gameMaster.RedWool;
                if (buildingToBuild.Cost <= money)
                {
                    GameObject    tmp = Instantiate(buildingToBuild.BuildingGhost, initialBuildingPosition.position + Vector3.up * 0.5f, buildingToBuild.BuildingGhost.transform.rotation);
                    BuildingGhost bdGhostInstantied = tmp.GetComponent <BuildingGhost>();

                    int cap = 0;

                    RaycastHit ra;
                    bool       hittedSomeGO = true;
                    Physics.SphereCast(bdGhostInstantied.transform.position + Vector3.up * 40, 5, -Vector3.up, out ra, 50);
                    if (ra.collider.gameObject.GetComponent <RTSGameObject>())
                    {
                        hittedSomeGO = true;
                    }
                    else
                    {
                        hittedSomeGO = false;
                    }

                    while (hittedSomeGO && cap < 7)
                    {
                        bdGhostInstantied.transform.position += Vector3.forward * -20;

                        Physics.SphereCast(bdGhostInstantied.transform.position + Vector3.up * 40, 5, -Vector3.up, out ra, 50);
                        if (ra.collider.gameObject.GetComponent <RTSGameObject>())
                        {
                            hittedSomeGO = true;
                        }
                        else
                        {
                            hittedSomeGO = false;
                        }

                        cap++;
                    }

                    if (cap >= 7)
                    {
                        tooMuchBuilding = true;
                    }
                    else
                    {
                        constructor.SendBuildOrder(buildingToBuild.gameObject, bdGhostInstantied.gameObject,
                                                   bdGhostInstantied.transform.position, buildingToBuild.gameObject.transform.rotation, true, false);
                    }
                }
                else
                {
                    constructor.SendDirectMoveOrder(constructorBasePosition.position);
                }
            }
        }
    }
コード例 #48
0
ファイル: Testable.cs プロジェクト: jcono/Prova
 public Testable(Type type)
 {
     _type = type;
     _constructor = new Constructor(_type);
     _dependencies = new Dependencies(_type);
 }
コード例 #49
0
ファイル: Parser.cs プロジェクト: zippy1981/GTools
 public OperationDescription(string name, Constructor create)
 {
     Name = name;
     Create = create;
 }
コード例 #50
0
 public GenericInstanceConstructorInfo(Constructor ctor, Type declaringType, GenericTypeInfo genericType) : base(ctor)
 {
     _declaringType = declaringType;
     _genericType = genericType;
 }
コード例 #51
0
    /*!
       \brief Create a forest of trees.

       forest ::= nil | cons(tree, forest)
       tree   ::= nil | cons(forest, forest)
    */
    public void forest_example()
    {
        mk_context();
        Sort tree, forest;
        FuncDecl nil1_decl, is_nil1_decl, cons1_decl, is_cons1_decl, car1_decl, cdr1_decl;
        FuncDecl nil2_decl, is_nil2_decl, cons2_decl, is_cons2_decl, car2_decl, cdr2_decl;
        Expr nil1, nil2, t1, t2, t3, t4, f1, f2, f3, l1, l2, x, y, u, v;

        //
        // Declare the names of the accessors for cons.
        // Then declare the sorts of the accessors.
        // For this example, all sorts refer to the new types 'forest' and 'tree'
        // being declared, so we pass in null for both sorts1 and sorts2.
        // On the other hand, the sort_refs arrays contain the indices of the
        // two new sorts being declared. The first element in sort1_refs
        // points to 'tree', which has index 1, the second element in sort1_refs array
        // points to 'forest', which has index 0.
        //
        Symbol[] head_tail1 = new Symbol[] { z3.MkSymbol("head"), z3.MkSymbol("tail") };
        Sort[] sorts1 = new Sort[] { null, null };
        uint[] sort1_refs = new uint[] { 1, 0 }; // the first item points to a tree, the second to a forest

        Symbol[] head_tail2 = new Symbol[] { z3.MkSymbol("car"), z3.MkSymbol("cdr") };
        Sort[] sorts2 = new Sort[] { null, null };
        uint[] sort2_refs = new uint[] { 0, 0 }; // both items point to the forest datatype.
        Constructor nil1_con, cons1_con, nil2_con, cons2_con;
        Constructor[] constructors1 = new Constructor[2], constructors2 = new Constructor[2];
        Symbol[] sort_names = { z3.MkSymbol("forest"), z3.MkSymbol("tree") };

        Console.WriteLine("\nforest_example");

        /* build a forest */
        nil1_con = z3.MkConstructor(z3.MkSymbol("nil"), z3.MkSymbol("is_nil"), null, null, null);
        cons1_con = z3.MkConstructor(z3.MkSymbol("cons1"), z3.MkSymbol("is_cons1"), head_tail1, sorts1, sort1_refs);
        constructors1[0] = nil1_con;
        constructors1[1] = cons1_con;

        /* build a tree */
        nil2_con = z3.MkConstructor(z3.MkSymbol("nil2"), z3.MkSymbol("is_nil2"), null, null, null);
        cons2_con = z3.MkConstructor(z3.MkSymbol("cons2"), z3.MkSymbol("is_cons2"), head_tail2, sorts2, sort2_refs);
        constructors2[0] = nil2_con;
        constructors2[1] = cons2_con;

        Constructor[][] clists = new Constructor[][] { constructors1, constructors2 };

        Sort[] sorts = z3.MkDatatypeSorts(sort_names, clists);
        forest = sorts[0];
        tree = sorts[1];

        //
        // Now that the datatype has been created.
        // Query the constructors for the constructor
        // functions, testers, and field accessors.
        //
        nil1_decl = nil1_con.ConstructorDecl;
        is_nil1_decl = nil1_con.TesterDecl;
        cons1_decl = cons1_con.ConstructorDecl;
        is_cons1_decl = cons1_con.TesterDecl;
        FuncDecl[] cons1_accessors = cons1_con.AccessorDecls;
        car1_decl = cons1_accessors[0];
        cdr1_decl = cons1_accessors[1];

        nil2_decl = nil2_con.ConstructorDecl;
        is_nil2_decl = nil2_con.TesterDecl;
        cons2_decl = cons2_con.ConstructorDecl;
        is_cons2_decl = cons2_con.TesterDecl;
        FuncDecl[] cons2_accessors = cons2_con.AccessorDecls;
        car2_decl = cons2_accessors[0];
        cdr2_decl = cons2_accessors[1];

        nil1 = z3.MkConst(nil1_decl);
        nil2 = z3.MkConst(nil2_decl);
        f1 = mk_binary_app(cons1_decl, nil2, nil1);
        t1 = mk_binary_app(cons2_decl, nil1, nil1);
        t2 = mk_binary_app(cons2_decl, f1, nil1);
        t3 = mk_binary_app(cons2_decl, f1, f1);
        t4 = mk_binary_app(cons2_decl, nil1, f1);
        f2 = mk_binary_app(cons1_decl, t1, nil1);
        f3 = mk_binary_app(cons1_decl, t1, f1);

        /* nil != cons(nil,nil) */
        prove2(z3.MkNot(z3.MkEq(nil1, f1)), true);
        prove2(z3.MkNot(z3.MkEq(nil2, t1)), true);

        /* cons(x,u) = cons(x, v) => u = v */
        u = mk_var("u", forest);
        v = mk_var("v", forest);
        x = mk_var("x", tree);
        y = mk_var("y", tree);
        l1 = mk_binary_app(cons1_decl, x, u);
        l2 = mk_binary_app(cons1_decl, y, v);
        prove2(z3.MkImplies(z3.MkEq(l1, l2), z3.MkEq(u, v)), true);
        prove2(z3.MkImplies(z3.MkEq(l1, l2), z3.MkEq(x, y)), true);

        /* is_nil(u) or is_cons(u) */
        prove2(z3.MkOr((BoolExpr)z3.MkApp(is_nil1_decl, u),
                       (BoolExpr)z3.MkApp(is_cons1_decl, u)), true);

        /* occurs check u != cons(x,u) */
        prove2(z3.MkNot(z3.MkEq(u, l1)), true);
    }
コード例 #52
0
 private T InvokeConstructor(Constructor constructorWithParameters, object[] parameters)
 {
     return(constructorWithParameters.ConstructorInfo.Invoke(parameters) as T);
 }
        public View OnCreateView(View parent, string name, Context context, IAttributeSet attrs)
        {
            System.Diagnostics.Debug.WriteLine (name);

            if (name.Equals("android.support.v7.internal.view.menu.ActionMenuItemView", StringComparison.InvariantCultureIgnoreCase))
            {
                View view = null;

                try
                {
                    if (ActionMenuItemViewClass == null)
                        ActionMenuItemViewClass = ClassLoader.SystemClassLoader.LoadClass(name);
                }
                catch (ClassNotFoundException)
                {
                    return null;
                }

                if (ActionMenuItemViewClass == null)
                    return null;

                if (ActionMenuItemViewConstructor == null)
                {
                    try
                    {
                        ActionMenuItemViewConstructor = ActionMenuItemViewClass.GetConstructor(new Class[] {
                            Class.FromType(typeof(Context)),
                                 Class.FromType(typeof(IAttributeSet))
                        });
                    }
                    catch (SecurityException)
                    {
                        return null;
                    }
                    catch (NoSuchMethodException)
                    {
                        return null;
                    }
                }
                if (ActionMenuItemViewConstructor == null)
                    return null;

                try
                {
                    Java.Lang.Object[] args = new Java.Lang.Object[] { context, (Java.Lang.Object)attrs };
                    view = (View)(ActionMenuItemViewConstructor.NewInstance(args));
                }
                catch (IllegalArgumentException)
                {
                    return null;
                }
                catch (InstantiationException)
                {
                    return null;
                }
                catch (IllegalAccessException)
                {
                    return null;
                }
                catch (InvocationTargetException)
                {
                    return null;
                }
                if (null == view)
                    return null;

                View v = view;

                new Handler().Post(() => {

                    try
                    {
                        if(v is LinearLayout) {
                            var ll = (LinearLayout)v;
                            for(int i = 0; i < ll.ChildCount; i++) {
                                var button = ll.GetChildAt(i) as Button;

                                if(button != null) {
                                    var title = button.Text;

                                    if (!string.IsNullOrEmpty(title) && title.Length == 1)
                                    {
                                        button.SetTypeface(Typeface, TypefaceStyle.Normal);
                                    }
                                }
                            }
                        }
                        else if(v is TextView) {
                            var tv = (TextView)v;
                            string title = tv.Text;

                            if (!string.IsNullOrEmpty(title) && title.Length == 1)
                            {
                                tv.SetTypeface(Typeface, TypefaceStyle.Normal);
                            }
                        }
                    }
                    catch (ClassCastException)
                    {
                    }
                });

                return view;
            }

            return null;
        }
コード例 #54
0
 public override int getLength()
 {
     return(_value.Length + Constructor.getLength() + _width);
 }
コード例 #55
0
        private static INodeField ValueDisplay(ITypeDefinition typeDef, object x)
        {
            INodeField output = Constructor.NodeField(x.ToString()).WithValue("Displayed", Constructor.RigidTypeDefinitionManager(typeDef.DefaultValue, null, "DefaultDisplay"), false);

            output.DisplayedValue.Value = x;
            output.SetFlowOutput();
            return(output);
        }
コード例 #56
0
ファイル: Builder.cs プロジェクト: ngallagher/simplexml
 /// <summary>
 /// Constructor for the <c>Builder</c> object. This is used
 /// to create a factory like object used for instantiating objects.
 /// Each builder will score its suitability using the parameters
 /// it is provided.
 /// </summary>
 /// <param name="factory">
 /// this is the factory used for instantiation
 /// </param>
 /// <param name="index">
 /// this is the map of parameters that are declared
 /// </param>
 public Builder(Constructor factory, Index index) {
    this.list = index.Parameters;
    this.factory = factory;
    this.index = index;
 }
コード例 #57
0
ファイル: Sum.cs プロジェクト: zippy1981/GTools
 public ApplyOperation(Constructor c)
 {
     C = c;
 }
コード例 #58
0
 private object[] GetParameterValues(Constructor constructor)
 {
     return(constructor.Parameters.Select(x => x.Value).ToArray());
 }
コード例 #59
0
		public override object VisitConstructorDeclaration(AST.ConstructorDeclaration constructorDeclaration, object data)
		{
			DomRegion region     = GetRegion(constructorDeclaration.StartLocation, constructorDeclaration.EndLocation);
			DomRegion bodyRegion = GetRegion(constructorDeclaration.EndLocation, constructorDeclaration.Body != null ? constructorDeclaration.Body.EndLocation : RefParser.Location.Empty);
			DefaultClass c = GetCurrentClass();
			
			Constructor constructor = new Constructor(ConvertModifier(constructorDeclaration.Modifier), region, bodyRegion, GetCurrentClass());
			constructor.Documentation = GetDocumentation(region.BeginLine, constructorDeclaration.Attributes);
			ConvertAttributes(constructorDeclaration, constructor);
			if (constructorDeclaration.Parameters != null) {
				foreach (AST.ParameterDeclarationExpression par in constructorDeclaration.Parameters) {
					constructor.Parameters.Add(CreateParameter(par));
				}
			}
			
			if (constructor.Modifiers.HasFlag(ModifierEnum.Static))
				constructor.Modifiers = ConvertModifier(constructorDeclaration.Modifier, ModifierEnum.None);

			c.Methods.Add(constructor);
			return null;
		}
コード例 #60
0
 private bool IsCtorWithInterfacesOnly(Constructor constructor)
 {
     return(constructor.Parameters.All(x => x.Type.IsInterface));
 }