Exemplo n.º 1
0
        public static CodeDefaultProperty Property <T, T2, T3>(CodeTypeReference propertyType, MemberAttributes ma,
                                                               Expression <Func <T, T2, T3, string> > paramsAndName, bool indexer,
                                                               CodeStatement[] getStatements, params CodeStatement[] setStatements)
        {
            var c = new CodeMemberProperty
            {
                Attributes = ma,
                Type       = propertyType,
                HasGet     = true,
                HasSet     = true
            };

            if (getStatements != null)
            {
                c.GetStatements.AddRange(getStatements);
            }

            if (setStatements != null)
            {
                c.SetStatements.AddRange(setStatements);
            }

            CodeParameterDeclarationExpressionCollection parameters = new CodeParameterDeclarationExpressionCollection();

            c.Name = CodeDom.GetMethodName <string>(paramsAndName, parameters);

            return(new CodeDefaultProperty(c, parameters, indexer));
        }
Exemplo n.º 2
0
        public static CodeConstructor Ctor <T, T2>(Expression <Func <T, T2, MemberAttributes> > paramsAndAccessLevel,
                                                   params CodeStatement[] statements)
        {
            var c = new CodeConstructor();

            c.Attributes = CodeDom.GetMethodName <MemberAttributes>(paramsAndAccessLevel, c.Parameters);
            c.Statements.AddRange(statements);

            return(c);
        }
Exemplo n.º 3
0
        public static CodeTypeDelegate Delegate <T>(MemberAttributes ma,
                                                    Expression <Func <T, string> > paramsAndName)
        {
            var c = new CodeTypeDelegate()
            {
                Attributes = ma
            };

            c.Name = CodeDom.GetMethodName <string>(paramsAndName, c.Parameters);

            return(c);
        }
Exemplo n.º 4
0
        public static CodeMemberMethod Method <T, T2>(MemberAttributes ma,
                                                      Expression <Func <T, T2, string> > paramsAndName, params CodeStatement[] statements)
        {
            CodeMemberMethod method = new CodeMemberMethod()
            {
                Attributes = ma
            };

            method.Name = CodeDom.GetMethodName <string>(paramsAndName, method.Parameters);
            method.Statements.AddRange(statements);

            return(method);
        }
Exemplo n.º 5
0
        public static CodeTypeDelegate Delegate(Type returnType, MemberAttributes ma,
                                                Expression <Func <string> > paramsAndName)
        {
            var c = new CodeTypeDelegate()
            {
                Attributes = ma,
                ReturnType = new CodeTypeReference(returnType),
            };

            c.Name = CodeDom.GetMethodName <string>(paramsAndName, c.Parameters);

            return(c);
        }
Exemplo n.º 6
0
        public static CodeMemberOperatorOverride Operator <T>(
            CodeTypeReference returnType,
            Expression <Func <T, OperatorType> > paramsAndType,
            params CodeStatement[] statements)
        {
            CodeParameterDeclarationExpressionCollection pars = new CodeParameterDeclarationExpressionCollection();

            var c = new CodeMemberOperatorOverride(
                CodeDom.GetMethodName <OperatorType>(paramsAndType, pars),
                pars.ToArray(), returnType, statements);

            return(c);
        }
Exemplo n.º 7
0
        public static CodeMemberMethod Method <T>(MemberAttributes ma, string returnType,
                                                  Expression <Func <T, string> > paramsAndName, params CodeStatement[] statements)
        {
            CodeMemberMethod method = new CodeMemberMethod()
            {
                ReturnType = returnType == null ? null : new CodeTypeReference(returnType),
                Attributes = ma
            };

            method.Name = CodeDom.GetMethodName <string>(paramsAndName, method.Parameters);
            method.Statements.AddRange(statements);

            return(method);
        }