Beispiel #1
0
        static void Main(string[] args)
        {
            CodeGenerateHelper helper = new CodeGenerateHelper();

            foreach (var item in helper.GetFindChildByPropertyMethods())
            {
                helper.TargetClass.Members.Add(item);
            }
            DisplayCode(helper.Unit);



            // CodeMethodReturnStatement returnStatement = new CodeMethodReturnStatement();
            // CodeMemberMethod method = new CodeMemberMethod();
            // CodeTypeParameter tpPara = new CodeTypeParameter("TReturn");
            // tpPara.Constraints.Add(new CodeTypeReference(" class",CodeTypeReferenceOptions.GenericTypeParameter));
            // method.TypeParameters.Add(tpPara);

            // tpPara = new CodeTypeParameter("TInput");
            // tpPara.Constraints.Add(new CodeTypeReference(" class", CodeTypeReferenceOptions.GenericTypeParameter));
            // method.TypeParameters.Add(tpPara);



            // method.Name = "findByNameTemplate";
            // method.Attributes = MemberAttributes.Static | MemberAttributes.Private;
            // method.ReturnType = new CodeTypeReference("TReturn");
            // method.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference("TInput"), "Container"));
            // method.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(string)), "Name"));

            // CodeConditionStatement conditionalStatement = new CodeConditionStatement(
            //     // The condition to test.

            //    new CodeSnippetExpression("Container is GuiVContainer"),

            //     // The statements to execute if the condition evaluates to true.
            //new CodeStatement[] {
            //    new CodeSnippetStatement("var container = Container as GuiVContainer;")
            //   ,new CodeSnippetStatement("TReturn item = container.FindByName(Name, typeof(TReturn).Name) as TReturn;")
            //   ,new CodeSnippetStatement("return item;")},
            //     // The statements to execute if the condition evalues to false.
            //new CodeStatement[] { new CodeSnippetStatement("throw new Exception(\"Not Found FindByName method in type:\" + typeof(TInput).Name);") });


            // method.Statements.Add(conditionalStatement);
            // //DisplayCode(method);

            // Console.ReadLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            CodeGenerateHelper helper = new CodeGenerateHelper();
            foreach (var item in helper.GetFindChildrenByPropertyMethods())
            {
                helper.TargetClass.Members.Add(item);
            }
            DisplayCode(helper.Unit);

               // CodeMethodReturnStatement returnStatement = new CodeMethodReturnStatement();
               // CodeMemberMethod method = new CodeMemberMethod();
               // CodeTypeParameter tpPara = new CodeTypeParameter("TReturn");
               // tpPara.Constraints.Add(new CodeTypeReference(" class",CodeTypeReferenceOptions.GenericTypeParameter));
               // method.TypeParameters.Add(tpPara);

               // tpPara = new CodeTypeParameter("TInput");
               // tpPara.Constraints.Add(new CodeTypeReference(" class", CodeTypeReferenceOptions.GenericTypeParameter));
               // method.TypeParameters.Add(tpPara);

               // method.Name = "findByNameTemplate";
               // method.Attributes = MemberAttributes.Static | MemberAttributes.Private;
               // method.ReturnType = new CodeTypeReference("TReturn");
               // method.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference("TInput"), "Container"));
               // method.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(string)), "Name"));

               // CodeConditionStatement conditionalStatement = new CodeConditionStatement(
               //     // The condition to test.

               //    new CodeSnippetExpression("Container is GuiVContainer"),

               //     // The statements to execute if the condition evaluates to true.
               //new CodeStatement[] {
               //    new CodeSnippetStatement("var container = Container as GuiVContainer;")
               //   ,new CodeSnippetStatement("TReturn item = container.FindByName(Name, typeof(TReturn).Name) as TReturn;")
               //   ,new CodeSnippetStatement("return item;")},
               //     // The statements to execute if the condition evalues to false.
               //new CodeStatement[] { new CodeSnippetStatement("throw new Exception(\"Not Found FindByName method in type:\" + typeof(TInput).Name);") });

               // method.Statements.Add(conditionalStatement);
               // //DisplayCode(method);

               // Console.ReadLine();
        }