public void SetModel(PropertyModel model) { this.model = model; if (model != null) { textModifier.Text = model.Modifier; textName.Text = model.Name; textType.Text = model.TypeName; checkHasGet.Checked = model.HasGetAccess; checkHasSet.Checked = model.HasSetAccess; } else { textModifier.Text = ""; textName.Text = ""; textType.Text = ""; checkHasGet.Checked = false; checkHasSet.Checked = false; } }
private IEnumerable<PropertyModel> GetProperty(ClassDeclarationSyntax cs, CompilationUnitSyntax root) { List<PropertyModel> result = new List<PropertyModel>(); foreach (PropertyDeclarationSyntax ps in cs.DescendantNodes().OfType<PropertyDeclarationSyntax>()) { PropertyModel prop = new PropertyModel(); prop.Name = ps.Identifier.ToFullString().Trim(); prop.Modifier = ps.Modifiers.ToFullString().Trim(); prop.TypeName = ps.Type.ToFullString().Trim(); foreach (var accessor in ps.AccessorList.Accessors) { if (accessor.Keyword.ValueText == "set") { prop.HasSetAccess = true; if (accessor.Body != null) { prop.SetAccessor = accessor.Body.ToFullString(); } } if (accessor.Keyword.ValueText == "get") { prop.HasGetAccess = true; if (accessor.Body != null) { prop.GetAccessor = accessor.Body.ToFullString(); } } } result.Add(prop); } return result; }