Пример #1
0
 public StatementBuilder AddCreator(FieldGenerator to, ParamBuilder parameters)
 {
     Expressions.Add(
         new CodeAssignStatement(
             new FieldTarget(to).Expression,
             new CodeObjectCreateExpression(to.Member.Type, parameters)));
     return this;
 }
Пример #2
0
        public MethodReturnField(FieldGenerator field)
        {
            Member = new CodeMemberMethod()
            {
                Name       = "Get" + field.Name,
                Attributes = MemberAttributes.Public
            };

            var returnStatement = new CodeMethodReturnStatement();

            Member.ReturnType = new CodeTypeReference(field.FieldType);
            Member.Statements.Add(returnStatement);

            var fieldReference = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), field.Name);

            returnStatement.Expression = fieldReference;
        }
Пример #3
0
 public StructGenerator AddField(FieldGenerator field)
 {
     structType.Members.Add(field.Member);
     Fields.Add(field);
     return(this);
 }
Пример #4
0
 public ClassGenerator AddField(FieldGenerator field)
 {
     classType.Members.Add(field.Member);
     Fields.Add(field);
     return(this);
 }
Пример #5
0
 public FieldTarget(FieldGenerator field)
 {
     Expression = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), field.Name);
 }