Fluent configuration builder
Exemplo n.º 1
0
        private void ExtractReferences()
        {
            if (_isAnalyzed) return;
            _settings.Documentation =
                new DocumentationManager(_settings.GenerateDocumentation ? _settings.DocumentationFilePath : null);
            var fluentConfigurationPresents = _settings.ConfigurationMethod != null;
            if (fluentConfigurationPresents)
            {
                var configurationBuilder = new ConfigurationBuilder();
                _settings.ConfigurationMethod(configurationBuilder);
                _configurationRepository = configurationBuilder.Build();
                ConfigurationRepository.Instance = _configurationRepository;

                foreach (var additionalDocumentationPath in _configurationRepository.AdditionalDocumentationPathes)
                {
                    _settings.Documentation.CacheDocumentation(additionalDocumentationPath);
                }
            }

            _allTypes = _settings.SourceAssemblies
                .SelectMany(c => c.GetTypes().Where(d => d.GetCustomAttribute<TsAttributeBase>(false) != null))
                .Union(ConfigurationRepository.Instance.AttributesForType.Keys).Distinct()
                .ToList();

            _allTypesHash = new HashSet<Type>(_allTypes);

            if (_settings.Hierarchical)
            {
                foreach (var type in _allTypesHash)
                {
                    ConfigurationRepository.Instance.AddFileSeparationSettings(type);
                }
            }

            var grp = _allTypes.GroupBy(c => c.GetNamespace(true));
            _namespace = grp.Where(g => !string.IsNullOrEmpty(g.Key)) // avoid anonymous types
                .ToDictionary(k => k.Key, v => v.ToList());

            _settings.SourceAssemblies.Where(c => c.GetCustomAttributes<TsReferenceAttribute>().Any())
                .SelectMany(c => c.GetCustomAttributes<TsReferenceAttribute>())
                .Select(c => string.Format("/// <reference path=\"{0}\"/>", c.Path))
                .Union(
                    ConfigurationRepository.Instance.References.Select(
                        c => string.Format("/// <reference path=\"{0}\"/>", c)))
                .ToList()
                .ForEach(a => _referenceBuilder.AppendLine(a));

            _settings.References = _referenceBuilder.ToString();


            _isAnalyzed = true;
        }
Exemplo n.º 2
0
 public static void Configure(ConfigurationBuilder configuration)
 {
     configuration.Substitute(typeof(DateTimeOffset), new RtSimpleTypeName("Date"));
     configuration.Substitute(typeof(DateTime), new RtSimpleTypeName("Date"));
     configuration.Context.TargetDirectory = "Components/Model";
     configuration.Global(config =>
     {
         config.UseModules();
         config.RootNamespace("explorer.Model");
         config.CamelCaseForMethods();
         config.CamelCaseForProperties();
     });
 }
        public static void Configure(ConfigurationBuilder builder)
        {
            // Configuration for exporting JQuery infrastructure

            // Configuration exporting test model class as interface
            builder.ExportAsInterface<SampleResponseModel>().WithPublicProperties();

            // Configuration for JQueryController
            // Setting code generator for each method performed in JQueryMethodAttribute
            builder.ExportAsClass<JQueryController>();

            // Configuration for Angular.js-firndly controller
            // Setting code generator for methods also performed in attribute - see AngularMethodAttribute
            builder.ExportAsClass<AngularController>().WithCodeGenerator<AngularControllerGenerator>();
        }
Exemplo n.º 4
0
        private void ExtractReferences()
        {
            if (_isAnalyzed) return;
            _context.Documentation =
                new DocumentationManager(_context.GenerateDocumentation ? _context.DocumentationFilePath : null, _context.Warnings);
            var fluentConfigurationPresents = _context.ConfigurationMethod != null;
            if (fluentConfigurationPresents)
            {
                var configurationBuilder = new ConfigurationBuilder();
                _context.ConfigurationMethod(configurationBuilder);
                _configurationRepository = configurationBuilder.Build();
                ConfigurationRepository.Instance = _configurationRepository;

                foreach (var additionalDocumentationPath in _configurationRepository.AdditionalDocumentationPathes)
                {
                    _context.Documentation.CacheDocumentation(additionalDocumentationPath, _context.Warnings);
                }
            }

            _allTypes = _context.SourceAssemblies
                .SelectMany(c => c.GetTypes().Where(d => d.GetCustomAttribute<TsAttributeBase>(false) != null))
                .Union(ConfigurationRepository.Instance.AttributesForType.Keys).Distinct()
                .ToList();

            _allTypesHash = new HashSet<Type>(_allTypes);

            if (_context.Hierarchical)
            {
                foreach (var type in _allTypesHash)
                {
                    ConfigurationRepository.Instance.AddFileSeparationSettings(type);
                }
            }

            _context.SourceAssemblies.Where(c => c.GetCustomAttributes<TsReferenceAttribute>().Any())
                .SelectMany(c => c.GetCustomAttributes<TsReferenceAttribute>())
                .Select(c => string.Format("/// <reference path=\"{0}\"/>", c.Path))
                .Union(
                    ConfigurationRepository.Instance.References.Select(
                        c => string.Format("/// <reference path=\"{0}\"/>", c)))
                .ToList()
                .ForEach(a => _referenceBuilder.AppendLine(a));

            _context.References = _referenceBuilder.ToString();


            _isAnalyzed = true;
        }