Пример #1
0
        public string GetContent()
        {
            var scope = "public";

            if (!string.IsNullOrEmpty(this.scope))
            {
                scope = this.scope;
            }

            var header = $"// {Program.BuildAutogenDisclaimer(this.collection.SourcePath)}";

            if (this.collection.ListConstants?.Any() == true)
            {
                header += $"{Environment.NewLine}{Environment.NewLine}using System.Collections.Generic;";
            }

            var model = new ConstantCollectionTemplateModel
            {
                Header          = header,
                Namespace       = this.namespaceProperty,
                Name            = this.className,
                Scope           = scope,
                StringConstants = this.collection.StringConstants?.ToDictionary(pair => pair.Key.Camelize(), pair => pair.Value),
                ListConstants   = this.collection.ListConstants?.ToDictionary(pair => pair.Key.Camelize(), pair => $"{{ \"{string.Join("\", \"", pair.Value)}\" }}"),
            };

            return(outputTemplate.Render(model, member => member.Name));
        }
Пример #2
0
        public string GetContent()
        {
            var model = new ConstantCollectionTemplateModel
            {
                AutogenDisclaimer = Program.BuildAutogenDisclaimer(_collection.SourcePath),
                Namespace         = _namespace,
                Name      = _className,
                Constants = _collection.Constants.ToDictionary(pair => pair.Key.Camelize(), pair => pair.Value),
            };

            return(OutputTemplate.Render(model, member => member.Name));
        }