Ho una proprietà creata con CodeDom. Come posso impostarlo per essere una proprietà automatica invece di aggiungere CodeFieldReferenceExpressions a un membro privato?C# CodeDom Automatic Property
9
A
risposta
11
IIRC, CodeDom semplicemente non ha un modo di esprimere questo. Le proprietà implementate automaticamente sono solo lo zucchero del compilatore, ma poiché non mappa (in modo pulito) in tutte le lingue, non si adatta perfettamente a CodeDom (inoltre, CodeDom avrebbe avuto bisogno di un aggiornamento).
7
Sì, è possibile.
È possibile utilizzare la classe CodeSnippetTypeMember per questo scopo.
Ad esempio:
CodeTypeDeclaration newType = new CodeTypeDeclaration("TestType");
CodeSnippetTypeMember snippet = new CodeSnippetTypeMember();
snippet.Comments.Add(new CodeCommentStatement("this is integer property", true));
snippet.Text="public int IntergerProperty { get; set; }";
newType.Members.Add(snippet);
Problemi correlati
- 1. C# UserControl Visible Property
- 2. Metaprograming in C#: metodo Automatic ToString
- 3. Microsoft Roslyn vs. CodeDom
- 4. Hibernate Automatic Versioning
- 5. CodeDom e Silverlight
- 6. Reflection.Emit vs CodeDOM
- 7. programmazione formato generato CodeDom Codice
- 8. obiettivo C underscore property vs self
- 9. Objective-C: dichiarazione @property senza implementazione (@synthesize)
- 10. C# UserControl Visible Property Not Changing
- 11. Cosa fa .property()? in function() {}. property()
- 12. Devo continuare a usare iVar e @property (non anatomico, conservare) più @synthesize in Automatic Reference Counting (ARC)?
- 13. Come inizializzare l'oggetto con CodeDOM?
- 14. creazione dell'enumerazione mediante .NET CodeDom
- 15. Jquery Automatic Image Slider w/CSS & jQuery
- 16. GNUstep supporta @property e @synthesize?
- 17. Python: @staticmethod con @property
- 18. Mongoose __v property - nascondere?
- 19. iniezione Property di attributi
- 20. Python object @property
- 21. Objective-C ha dichiarato attributi @property (nonatomic, copiare, forte, debole)
- 22. D performance: union vs @property
- 23. Riproduci Scala Json Missing Property vs Null
- 24. Access Parent Repeaters DataItem Property
- 25. DialogFragment setCancelable property not working
- 26. Perché usare @property in D?
- 27. spring @Autowire property vs setter
- 28. CodeDom Provider non è stato trovato sulla IIS7
- 29. Come selezionare il framework di destinazione di un compilatore CodeDom utilizzando C#?
- 30. CodeDom può creare argomenti facoltativi durante la generazione di un metodo C#?