protected override object NewProperty(NewCodeElementItemParams newItemParams, string path) { return(_codeClass.AddProperty(newItemParams.Get ? path : null, newItemParams.Set ? path : null, newItemParams.MemberType, newItemParams.Position, newItemParams.AccessKind, Type.Missing)); }
public static void GeneratePropertyFromVariable(CodeVariable2 variable, bool generateGetter, bool generateSetter, bool generateComments) { CodeClass2 codeClass = variable.Collection.Parent as CodeClass2; CodeGenerator codeGenerator = CreateCodeGenerator(codeClass.Language); string propertyName = ConvertVariableNameToPropertyName(variable.Name); if (!ContainsMember(codeClass, propertyName)) { string getterName = String.Empty; string setterName = String.Empty; if (generateGetter) { getterName = propertyName; } if (generateSetter) { setterName = propertyName; } CodeProperty property = (CodeProperty)codeClass.AddProperty(getterName, setterName, variable.Type, -1, vsCMAccess.vsCMAccessPublic, null); if (generateComments) { StringBuilder sb = new StringBuilder(); sb.AppendLine("<doc>"); sb.AppendLine("<summary>"); sb.AppendLine(); sb.AppendLine("</summary>"); sb.Append("</doc>"); property.DocComment = sb.ToString(); } if (generateGetter) { EditPoint2 editPoint = (EditPoint2)property.Getter.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); editPoint.EndOfLine(); int position = editPoint.LineCharOffset; editPoint.StartOfLine(); editPoint.Delete(position); editPoint.Insert(codeGenerator.GenerateReturnStatement(variable.Name)); editPoint.SmartFormat(editPoint); } if (generateSetter) { EditPoint2 editPoint = (EditPoint2)property.Setter.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint(); editPoint.Insert(codeGenerator.GenerateAssignStatement(variable.Name, "value")); editPoint.SmartFormat(editPoint); } } }
public ShellCodeProperty AddProperty(string GetterName, string PutterName, object Type, object Position, vsCMAccess Access, object Location) { return (new ShellCodeProperty(_codeClass.AddProperty(GetterName, PutterName, Type, Position, Access, Location))); }