Ejemplo n.º 1
0
        public string GenerateCode(IServiceVariableSource services = null)
        {
            foreach (var generatedType in GeneratedTypes)
            {
                services?.StartNewType();
                generatedType.ArrangeFrames(services);
            }

            var namespaces = GeneratedTypes
                             .SelectMany(x => x.AllInjectedFields)
                             .Select(x => x.ArgType.Namespace)
                             .Concat(new string[] { typeof(Task).Namespace })
                             .Distinct().ToList();

            var writer = new SourceWriter();

            foreach (var ns in namespaces.OrderBy(x => x))
            {
                writer.Write($"using {ns};");
            }

            writer.BlankLine();

            writer.Namespace(Generation.ApplicationNamespace);

            foreach (var @class in GeneratedTypes)
            {
                writer.WriteLine($"// START: {@class.TypeName}");
                @class.Write(writer);
                writer.WriteLine($"// END: {@class.TypeName}");

                writer.WriteLine("");
                writer.WriteLine("");
            }

            writer.FinishBlock();


            var code = writer.Code();

            attachSourceCodeToChains(code);


            return(code);
        }
Ejemplo n.º 2
0
 public void Dispose()
 {
     _parent.FinishBlock();
 }