public override async Task GenerateForClass(StructuredStringBuilder sb) { sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); sb.AppendLine($"private readonly {DictInterface(getter: false)} _{Name} = new {GetActualItemClass(getter: false)};"); Comments?.Apply(sb, LoquiInterfaceType.Direct); sb.AppendLine($"public {DictInterface(getter: false)} {Name} => _{Name};"); var member = $"_{Name}"; using (sb.Region("Interface Members")) { if (!ReadOnly) { sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); sb.AppendLine($"{DictInterface(getter: false)} {ObjectGen.Interface(internalInterface: false)}.{Name} => {member};"); } sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); sb.AppendLine($"{DictInterface(getter: true)} {ObjectGen.Interface(getter: true, internalInterface: false)}.{Name} => {member};"); } }
public override async Task GenerateForClass(StructuredStringBuilder sb) { sb.AppendLine($"private readonly Dictionary<{TypeTuple(getter: false)}> _{Name} = new Dictionary<{TypeTuple(getter: false)}>();"); Comments?.Apply(sb, LoquiInterfaceType.Direct); sb.AppendLine($"public IDictionary<{TypeTuple(getter: false)}> {Name} => _{Name};"); var member = "_" + Name; using (new Region(sb, "Interface Members")) { if (!ReadOnly) { sb.AppendLine($"IDictionary{(ReadOnly ? "Getter" : string.Empty)}<{TypeTuple(getter: false)}> {ObjectGen.Interface()}.{Name} => {member};"); } if (ValueIsLoqui) { sb.AppendLine($"IReadOnlyDictionary<{TypeTuple(getter: true)}> {ObjectGen.Interface(getter: true)}.{Name} => {member}.Covariant<{TypeTuple(getter: false)}, {ValueTypeGen.TypeName(getter: true)}>();"); } else { sb.AppendLine($"IReadOnlyDictionary<{TypeTuple(getter: true)}> {ObjectGen.Interface(getter: true)}.{Name} => {member};"); } } }
public override async Task GenerateForClass(StructuredStringBuilder sb) { if (!IntegrateField) { return; } if (Nullable) { if (CanBeNullable(false)) { if (!TrueReadOnly) { sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); sb.AppendLine($"protected {TypeName(getter: false)}? _{Name};"); Comments?.Apply(sb, LoquiInterfaceType.Direct); sb.AppendLine($"public {OverrideStr}{TypeName(getter: false)}? {Name}"); using (sb.CurlyBrace()) { sb.AppendLine($"get => this._{ Name};"); sb.AppendLine($"{SetPermissionStr}set => this._{Name} = value;"); } sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); if (CanBeNullable(getter: true)) { sb.AppendLine($"{TypeName(getter: true)}? {ObjectGen.Interface(getter: true, InternalGetInterface)}.{Name} => this.{Name};"); } else { sb.AppendLine($"{TypeName(getter: true)} {ObjectGen.Interface(getter: true, InternalGetInterface)}.{Name} => this.{Name};"); sb.AppendLine($"bool {ObjectGen.Interface(getter: true, InternalGetInterface)}.{Name}_IsSet => this.{Name} != null;"); } } else { Comments?.Apply(sb, LoquiInterfaceType.Direct); sb.AppendLine($"public readonly {TypeName(getter: false)}? {Name};"); sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); } } else { throw new NotImplementedException(); } } else { sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); sb.AppendLine($"private {TypeName(getter: false)} _{Name}{(IsNullable ? string.Empty : $" = {GetNewForNonNullable()}")};"); Comments?.Apply(sb, LoquiInterfaceType.Direct); if (Singleton) { sb.AppendLine($"public {OverrideStr}{TypeName(getter: false)} {Name} => {ProtectedName};"); } else { sb.AppendLine($"public {OverrideStr}{TypeName(getter: false)} {Name}"); using (sb.CurlyBrace()) { sb.AppendLine($"get => {ProtectedName};"); sb.AppendLine($"{SetPermissionStr}set => this._{Name} = value;"); } } if (TypeName(getter: true) != TypeName(getter: false)) { sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); sb.AppendLine($"{TypeName(getter: true)} {ObjectGen.Interface(getter: true, InternalGetInterface)}.{Name} => this.{Name};"); } } }
public override async Task GenerateForClass(StructuredStringBuilder sb) { void GenerateTypicalNullableMembers(bool notifying) { Comments?.Apply(sb, LoquiInterfaceType.Direct); sb.AppendLine($"public {OverrideStr}{TypeName(getter: false)}{NullChar} {Name} {{ get; {(ReadOnly ? "protected " : string.Empty)}set; }}{(HasDefault ? $" = {DefaultValueMemberName};" : null)}"); sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); sb.AppendLine($"{TypeName(getter: true)}{NullChar} {ObjectGen.Interface(getter: true, internalInterface: InternalGetInterface)}.{Name} => this.{Name};"); } if (HasDefault) { Comments?.Apply(sb, LoquiInterfaceType.Direct); sb.AppendLine($"public readonly static {TypeName(getter: false)} {DefaultValueMemberName} = {DefaultValue};"); } if (Nullable) { if (!TrueReadOnly) { GenerateTypicalNullableMembers(false); } else { Comments?.Apply(sb, LoquiInterfaceType.Direct); sb.AppendLine($"public readonly {TypeName(getter: false)} {Name};"); sb.AppendLine($"{TypeName(getter: false)} {ObjectGen.Interface(getter: true, internalInterface: InternalGetInterface)}.{Name} => this.{Name};"); } } else { var subFg = new StructuredStringBuilder(); WrapSetAccessor(subFg, linePrefix: $"{SetPermissionStr}set", toDo: subGen => { if (subGen.Count == 0) { return; } subGen.AppendLine($"this._{Name} = value;"); }); if (subFg.Count > 1) { sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); sb.AppendLine($"private {TypeName(getter: false)} _{Name};"); Comments?.Apply(sb, LoquiInterfaceType.Direct); sb.AppendLine($"public {OverrideStr}{TypeName(getter: false)} {Name}"); using (sb.CurlyBrace()) { sb.AppendLine($"get => this._{Name};"); sb.AppendLines(subFg); } } else if (subFg.Count == 1) { Comments?.Apply(sb, LoquiInterfaceType.Direct); sb.AppendLine($"public {OverrideStr}{TypeName(getter: false)} {Name} {{ get; {subFg[0]}; }} = {(HasDefault ? DefaultValueMemberName : GetDefault(getter: false))};"); } else { throw new ArgumentException(); } if (!InternalGetInterface && TypeName(getter: true) != TypeName(getter: false)) { sb.AppendLine($"{TypeName(getter: true)} {ObjectGen.Interface(getter: true, internalInterface: InternalGetInterface)}.{Name} => this.{Name};"); } } if (InternalSetInterface) { sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); sb.AppendLine($"{TypeName(getter: false)}{NullChar} {ObjectGen.Interface(getter: false, internalInterface: true)}.{Name}"); using (sb.CurlyBrace()) { sb.AppendLine($"get => this.{Name};"); sb.AppendLine($"set => this.{Name} = {GetValueSetString("value")};"); } } if (InternalGetInterface) { if (Nullable) { if (CanBeNullable(getter: true)) { sb.AppendLine($"{TypeName(getter: false)}? {ObjectGen.Interface(getter: true, internalInterface: true)}.{Name} => this.{Name}"); } else { sb.AppendLine($"{TypeName(getter: false)} {ObjectGen.Interface(getter: true, internalInterface: true)}.{Name} => this.{Name}"); sb.AppendLine($"bool {ObjectGen.Interface(getter: true, internalInterface: true)}.{Name}_IsSet => this.{Name} != null"); } } else { sb.AppendLine($"{TypeName(getter: false)} {ObjectGen.Interface(getter: true, internalInterface: true)}.{Name} => this.{Name}"); } } }
public void GenerateInterfaceMembers(StructuredStringBuilder sb, string member) { using (sb.Region("Interface Members")) { sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); sb.AppendLine($"{ListTypeName(getter: true, internalInterface: true)}{NullChar} {ObjectGen.Interface(getter: true, internalInterface: InternalGetInterface)}.{Name} => {member};"); } }