Ejemplo n.º 1
0
        /// <summary>
        /// Adds a pre-defined set of code generator services to provide Chrome Remote Interface generation.
        /// </summary>
        /// <param name="serviceCollection"></param>
        /// <param name="settings"></param>
        /// <returns></returns>
        public static IServiceCollection AddCodeGenerationServices(this IServiceCollection serviceCollection, CodeGenerationSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            return(serviceCollection
                   .AddSingleton(settings)
                   .AddSingleton <TemplatesManager>()
                   .AddSingleton <ICodeGenerator <ProtocolDefinition> >((sp) => new ProtocolGenerator(sp))
                   .AddSingleton <ICodeGenerator <DomainDefinition> >((sp) => new DomainGenerator(sp))
                   .AddSingleton <ICodeGenerator <TypeDefinition> >((sp) => new TypeGenerator(sp))
                   .AddSingleton <ICodeGenerator <CommandDefinition> >((sp) => new CommandGenerator(sp))
                   .AddSingleton <ICodeGenerator <EventDefinition> >((sp) => new EventGenerator(sp)));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Replaces tokens in the target path.
 /// </summary>
 /// <param name="path"></param>
 /// <param name="className"></param>
 /// <param name="context"></param>
 /// <param name="settings"></param>
 /// <returns></returns>
 public static string ReplaceTokensInPath(string path, string className, CodeGeneratorContext context, CodeGenerationSettings settings)
 {
     path = path.Replace("{{className}}", className);
     path = path.Replace("{{rootNamespace}}", settings.RootNamespace);
     path = path.Replace("{{templatePath}}", settings.TemplatesPath);
     path = path.Replace("{{domainName}}", context.Domain.Name);
     return(path);
 }
Ejemplo n.º 3
0
 public TemplatesManager(CodeGenerationSettings settings)
 {
     m_settings = settings ?? throw new ArgumentNullException(nameof(settings));
 }