private static void GenerateProperty(PropertyReferenceInfo propertyInfo, string prefix, bool generateOnPropertyChanged, StringBuilder builder) { //create field builder.AppendLine($"{prefix}private {propertyInfo.ReturnTypeName} _{propertyInfo.Name};"); builder.AppendLine($"{prefix}public {propertyInfo.ReturnTypeName} {propertyInfo.Name}"); builder.AppendLine($"{prefix}{{"); builder.AppendLine($"{prefix + prefix}get"); builder.AppendLine($"{prefix + prefix}{{"); builder.AppendLine($"{prefix + prefix + prefix}return _{propertyInfo.Name};"); builder.AppendLine($"{prefix + prefix}}}"); builder.AppendLine($"{prefix + prefix}set"); builder.AppendLine($"{prefix + prefix}{{"); builder.AppendLine($"{prefix + prefix + prefix}_{propertyInfo.Name} = value;"); if (generateOnPropertyChanged) { builder.AppendLine($"{prefix + prefix + prefix}OnPropertyChanged(nameof({propertyInfo.Name}));"); } builder.AppendLine($"{prefix + prefix}}}"); builder.AppendLine($"{prefix}}}"); builder.AppendLine(); }
private void SetPropertyValue(PropertyReferenceInfo propertyInfo, string prefix, bool generateOnPropertyChanged, StringBuilder builder, string baseServiceName, Dictionary <string, Dictionary <string, string> > nameSpaces) { bool isNullable = propertyInfo.ReturnTypeName.Contains("?"); //create field builder.AppendLine($"{prefix}{prefix}this.{propertyInfo.Name.ToCamelCase()} = {GetTypeValueSetter(isNullable, GetReturnTypeName(propertyInfo.ReturnTypeName, baseServiceName, nameSpaces))};"); builder.AppendLine(); }
private void GenerateProperty(PropertyReferenceInfo propertyInfo, string prefix, bool generateOnPropertyChanged, StringBuilder builder, string baseServiceName, Dictionary <string, Dictionary <string, string> > nameSpaces) { bool isNullable = propertyInfo.ReturnTypeName.Contains("?"); propertyInfo.ReturnTypeName = GetReturnTypeName(propertyInfo.ReturnTypeName, baseServiceName, nameSpaces); //create field {(isNullable ? "?" : "")} builder.AppendLine($"{prefix}var {propertyInfo.Name.ToCamelCase()}:{propertyInfo.ReturnTypeName}!"); builder.AppendLine(); }
private void GenerateProperty(PropertyInfo propertyInfo, ClassReferenceInfo classReferenceInfo) { if (!propertyInfo.CanWrite || !propertyInfo.CanRead) { return; } AddToGenerate(propertyInfo.PropertyType); PropertyReferenceInfo propertyReferenceInfo = new PropertyReferenceInfo { Name = propertyInfo.Name, ReturnTypeName = GetFullNameOfType(propertyInfo.PropertyType, true) }; classReferenceInfo.Properties.Add(propertyReferenceInfo); }
private void GeneratePropertyGetterSetter(PropertyReferenceInfo propertyInfo, string prefix, bool generateOnPropertyChanged, StringBuilder builder, string baseServiceName, Dictionary <string, Dictionary <string, string> > nameSpaces) { bool isNullable = propertyInfo.ReturnTypeName.Contains("?"); propertyInfo.ReturnTypeName = GetReturnTypeName(propertyInfo.ReturnTypeName, baseServiceName, nameSpaces); //AddToDictionary(nameSpaces, propertyInfo.ReturnTypeName); //create field builder.AppendLine($"{prefix} @JsonProperty(\"{propertyInfo.Name}\")"); builder.AppendLine($"{prefix} public {propertyInfo.ReturnTypeName} get{propertyInfo.Name}(){{"); builder.AppendLine($"{prefix + prefix} return {propertyInfo.Name.ToCamelCase()};"); builder.AppendLine($"{prefix} }}"); builder.AppendLine($"{prefix} @JsonProperty(\"{propertyInfo.Name}\")"); builder.AppendLine($"{prefix} public void set{propertyInfo.Name}({propertyInfo.ReturnTypeName} {propertyInfo.Name.ToCamelCase()}){{"); builder.AppendLine($"{prefix + prefix} this.{propertyInfo.Name.ToCamelCase()} = {propertyInfo.Name.ToCamelCase()};"); builder.AppendLine($"{prefix} }}"); }
private void GenerateProperty(PropertyReferenceInfo propertyInfo, string prefix, bool generateOnPropertyChanged, StringBuilder builder, string baseServiceName) { bool isNullable = propertyInfo.ReturnTypeName.Contains("?"); propertyInfo.ReturnTypeName = GetReturnTypeName(propertyInfo.ReturnTypeName, baseServiceName); //create field builder.AppendLine($"{prefix}{propertyInfo.Name}{(isNullable ? "?" : "")}: {propertyInfo.ReturnTypeName};"); //builder.AppendLine($"{prefix}public get {propertyInfo.Name}(): {propertyInfo.ReturnTypeName} {{"); //builder.AppendLine($"{prefix + prefix }return this._{propertyInfo.Name};"); //builder.AppendLine($"{prefix}}}"); //builder.AppendLine($"{prefix}public set {propertyInfo.Name}(v: {propertyInfo.ReturnTypeName}) {{"); //builder.AppendLine($"{prefix + prefix}this._{propertyInfo.Name} = v;"); //if (generateOnPropertyChanged) // builder.AppendLine($"{prefix + prefix + prefix}OnPropertyChanged(nameof({propertyInfo.Name}));"); //builder.AppendLine($"{prefix}}}"); builder.AppendLine(); }
private void GenerateProperty(PropertyReferenceInfo propertyInfo, string prefix, bool generateOnPropertyChanged, StringBuilder builder, string baseServiceName, Dictionary <string, Dictionary <string, string> > nameSpaces) { bool isNullable = propertyInfo.ReturnTypeName.Contains("?"); //Tuple<string, string> space = GetNameSpaceAndName(propertyInfo.ReturnTypeName); AddToDictionary(nameSpaces, propertyInfo.ReturnTypeName); propertyInfo.ReturnTypeName = GetReturnTypeName(propertyInfo.ReturnTypeName, baseServiceName, nameSpaces); //AddToDictionary(nameSpaces, propertyInfo.ReturnTypeName); //create field builder.AppendLine($"{prefix} private {propertyInfo.ReturnTypeName} {propertyInfo.Name.ToCamelCase()};"); //builder.AppendLine($"{prefix}public get {propertyInfo.Name}(): {propertyInfo.ReturnTypeName} {{"); //builder.AppendLine($"{prefix + prefix }return this._{propertyInfo.Name};"); //builder.AppendLine($"{prefix}}}"); //builder.AppendLine($"{prefix}public set {propertyInfo.Name}(v: {propertyInfo.ReturnTypeName}) {{"); //builder.AppendLine($"{prefix + prefix}this._{propertyInfo.Name} = v;"); //if (generateOnPropertyChanged) // builder.AppendLine($"{prefix + prefix + prefix}OnPropertyChanged(nameof({propertyInfo.Name}));"); //builder.AppendLine($"{prefix}}}"); }