Beispiel #1
0
 internal void Register(CodeConstructor constructor, CodeMemberMethod reader, CodeMemberMethod writer)
 {
     constructor.PopulateParameters += (object sender, EventArgs _) =>
                                       ((CodeConstructor)sender).Parameters.Add(new CodeParameterDeclarationExpression(Type.OutputTypeName, VariableName));
     constructor.PopulateStatements += (object sender, EventArgs _) =>
                                       (sender as CodeConstructor).Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), Name),
                                                                                                          new CodeArgumentReferenceExpression(VariableName)));
     reader.PopulateStatements += (object sender, EventArgs _) =>
     {
         var r        = sender as CodeMemberMethod;
         var readExpr = Type.GetReadValueExpression(new CodeArgumentReferenceExpression("reader"));
         r.Statements.Add(new CodeVariableDeclarationStatement(Type.OutputTypeName, VariableName, readExpr));
     };
     writer.PopulateStatements += (object sender, EventArgs _) =>
     {
         var w          = sender as CodeMemberMethod;
         var fieldExpr  = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), Name);
         var writerExpr = new CodeArgumentReferenceExpression("writer");
         w.Statements.Add(Type.GetWriteStatement(writerExpr, fieldExpr));
     };
 }