예제 #1
0
    protected override async Task GenerateCtor(StructuredStringBuilder sb)
    {
        if (BasicCtorPermission == CtorPermissionLevel.noGeneration)
        {
            return;
        }
        using (sb.Region("Ctor"))
        {
            sb.AppendLine($"{BasicCtorPermission.ToStringFast_Enum_Only()} {Name}()");
            using (sb.CurlyBrace())
            {
                List <Task> toDo = new List <Task>();
                toDo.AddRange(gen.GenerationModules.Select(mod => mod.GenerateInCtor(this, sb)));
                var fieldsTask = Task.WhenAll(IterateFields().Select(field => field.GenerateForCtor(sb)));
                toDo.Add(fieldsTask);
                await fieldsTask;
                fieldCtorsGenerated.SetResult();
                await Task.WhenAll(toDo);
                await GenerateInitializer(sb);

                sb.AppendLine("CustomCtor();");
            }
            sb.AppendLine("partial void CustomCtor();");
        }
    }
예제 #2
0
파일: ListType.cs 프로젝트: Noggog/Loqui
 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};");
     }
 }
예제 #3
0
    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};");
        }
    }