Esempio n. 1
0
        public IDictionary <string, string> ExecutePluginsToFiles <TPlugin>(IPluginsContainer <TPlugin> plugins, string tagOpen, string tagClose, IConceptCodeGenerator initialCodeGenerator)
            where TPlugin : IConceptCodeGenerator
        {
            var codeBuilder = BuildCode(plugins, tagOpen, tagClose, initialCodeGenerator);

            return(codeBuilder.GeneratedCodeByFile);
        }
Esempio n. 2
0
 public ProcessingEngine(
     IPluginsContainer<ICommandImplementation> commandRepository,
     IPluginsContainer<ICommandObserver> commandObservers,
     ILogProvider logProvider,
     IPersistenceTransaction persistenceTransaction,
     IAuthorizationManager authorizationManager,
     XmlUtility xmlUtility,
     IUserInfo userInfo,
     ISqlUtility sqlUtility,
     ILocalizer localizer)
 {
     _commandRepository = commandRepository;
     _commandObservers = commandObservers;
     _logger = logProvider.GetLogger("ProcessingEngine");
     _performanceLogger = logProvider.GetLogger("Performance");
     _requestLogger = logProvider.GetLogger("ProcessingEngine Request");
     _commandsLogger = logProvider.GetLogger("ProcessingEngine Commands");
     _commandsResultLogger = logProvider.GetLogger("ProcessingEngine CommandsResult");
     _persistenceTransaction = persistenceTransaction;
     _authorizationManager = authorizationManager;
     _xmlUtility = xmlUtility;
     _userInfo = userInfo;
     _sqlUtility = sqlUtility;
     _localizer = localizer;
 }
        private List <CodeGeneratorDependency> ExtractDependenciesFromMefPluginMetadata(
            IPluginsContainer <IConceptDatabaseDefinition> plugins,
            IEnumerable <CodeGenerator> codeGenerators)
        {
            var stopwatch    = Stopwatch.StartNew();
            var dependencies = new List <CodeGeneratorDependency>();

            var codeGeneratorsByImplementationType = codeGenerators
                                                     .GroupBy(ca => ca.ConceptImplementation.GetType())
                                                     .ToDictionary(g => g.Key, g => g.ToList());

            var distinctConceptImplementations = codeGenerators.Select(ca => ca.ConceptImplementation.GetType()).Distinct().ToList();

            var implementationDependencies = GetImplementationDependencies(plugins, distinctConceptImplementations);

            foreach (var implementationDependency in implementationDependencies)
            {
                if (codeGeneratorsByImplementationType.ContainsKey(implementationDependency.Item1) &&
                    codeGeneratorsByImplementationType.ContainsKey(implementationDependency.Item2))
                {
                    AddDependenciesOnSameConceptInfo(
                        codeGeneratorsByImplementationType[implementationDependency.Item1],
                        codeGeneratorsByImplementationType[implementationDependency.Item2],
                        dependencies);
                }
            }

            dependencies = dependencies.Distinct().ToList();

            _performanceLogger.Write(stopwatch, nameof(ExtractDependenciesFromMefPluginMetadata));
            _logger.Trace(() => ReportDependencies("MefPlugin DependsOn", dependencies));

            return(dependencies);
        }
Esempio n. 4
0
 public ApplicationInitialization(
     ILogProvider logProvider,
     IPluginsContainer<IServerInitializer> initializersContainer)
 {
     _deployPackagesLogger = logProvider.GetLogger("DeployPackages");
     _initializersContainer = initializersContainer;
 }
Esempio n. 5
0
        public string ExecutePlugins <TPlugin>(IPluginsContainer <TPlugin> plugins, string tagOpen, string tagClose, IConceptCodeGenerator initialCodeGenerator)
            where TPlugin : IConceptCodeGenerator
        {
            var codeBuilder = BuildCode(plugins, tagOpen, tagClose, initialCodeGenerator);

            return(codeBuilder.GenerateCode());
        }
 public ApplicationInitialization(
     ILogProvider logProvider,
     IPluginsContainer <IServerInitializer> initializersContainer)
 {
     _deployPackagesLogger  = logProvider.GetLogger("DeployPackages");
     _initializersContainer = initializersContainer;
 }
Esempio n. 7
0
        public IAssemblySource ExecutePlugins <TPlugin>(IPluginsContainer <TPlugin> plugins, string tagOpen, string tagClose, IConceptCodeGenerator initialCodeGenerator)
            where TPlugin : IConceptCodeGenerator
        {
            var stopwatch = Stopwatch.StartNew();

            var codeBuilder = new CodeBuilder(tagOpen, tagClose);

            if (initialCodeGenerator != null)
            {
                initialCodeGenerator.GenerateCode(null, codeBuilder);
            }

            foreach (var conceptInfo in _dslModel.Concepts)
            {
                foreach (var plugin in plugins.GetImplementations(conceptInfo.GetType()))
                {
                    try
                    {
                        plugin.GenerateCode(conceptInfo, codeBuilder);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(ex.ToString());
                        _logger.Error("Part of the source code that was generated before the exception was thrown is written in the trace log.");
                        _logger.Trace(codeBuilder.GeneratedCode);
                        throw;
                    }
                }
            }

            _performanceLogger.Write(stopwatch, "CodeGenerator: Code generated.");

            return(codeBuilder);
        }
Esempio n. 8
0
 public ProcessingEngine(
     IPluginsContainer <ICommandImplementation> commandRepository,
     IPluginsContainer <ICommandObserver> commandObservers,
     ILogProvider logProvider,
     IPersistenceTransaction persistenceTransaction,
     IAuthorizationManager authorizationManager,
     XmlUtility xmlUtility,
     IUserInfo userInfo,
     ISqlUtility sqlUtility,
     ILocalizer localizer)
 {
     _commandRepository         = commandRepository;
     _commandObservers          = commandObservers;
     _logger                    = logProvider.GetLogger("ProcessingEngine");
     _performanceLogger         = logProvider.GetLogger("Performance");
     _requestLogger             = logProvider.GetLogger("ProcessingEngine Request");
     _commandsLogger            = logProvider.GetLogger("ProcessingEngine Commands");
     _commandsResultLogger      = logProvider.GetLogger("ProcessingEngine CommandsResult");
     _commandsClientErrorLogger = logProvider.GetLogger("ProcessingEngine CommandsWithClientError");
     _commandsServerErrorLogger = logProvider.GetLogger("ProcessingEngine CommandsWithServerError");
     _persistenceTransaction    = persistenceTransaction;
     _authorizationManager      = authorizationManager;
     _xmlUtility                = xmlUtility;
     _userInfo                  = userInfo;
     _sqlUtility                = sqlUtility;
     _localizer                 = localizer;
 }
Esempio n. 9
0
 public DslContainer(ILogProvider logProvider, IPluginsContainer <IDslModelIndex> dslModelIndexPlugins)
 {
     _performanceLogger     = logProvider.GetLogger("Performance." + GetType().Name);
     _logger                = logProvider.GetLogger("DslContainer");
     _dslModelIndexes       = dslModelIndexPlugins.GetPlugins().ToList();
     _dslModelIndexesByType = _dslModelIndexes.ToDictionary(index => index.GetType());
 }
Esempio n. 10
0
 public DslContainer(ILogProvider logProvider, IPluginsContainer <IDslModelIndex> dslModelIndexPlugins, IConfiguration configuration)
 {
     _performanceLogger     = logProvider.GetLogger("Performance");
     _logger                = logProvider.GetLogger("DslContainer");
     _dslModelIndexes       = dslModelIndexPlugins.GetPlugins().ToList();
     _dslModelIndexesByType = _dslModelIndexes.ToDictionary(index => index.GetType());
     _sortConceptsMethod    = configuration.GetEnum("CommonConcepts.Debug.SortConcepts", SortConceptsMethod.None);
 }
 public EntityFrameworkMappingGenerator(
     ICodeGenerator codeGenerator,
     IPluginsContainer<IConceptMapping> plugins,
     ILogProvider logProvider)
 {
     _plugins = plugins;
     _codeGenerator = codeGenerator;
     _performanceLogger = logProvider.GetLogger("Performance");
 }
 public EntityFrameworkMappingGenerator(
     ICodeGenerator codeGenerator,
     IPluginsContainer <IConceptMapping> plugins,
     ILogProvider logProvider)
 {
     _plugins           = plugins;
     _codeGenerator     = codeGenerator;
     _performanceLogger = logProvider.GetLogger("Performance");
 }
Esempio n. 13
0
 public CaptionsValueProvider(
     IDslModel dslModel,
     IPluginsContainer <ICaptionsValuePlugin> plugins,
     ILogProvider logProvider)
 {
     _dslModel          = dslModel;
     _plugins           = plugins;
     _performanceLogger = logProvider.GetLogger("Performance");
 }
 public CaptionsValueProvider(
     IDslModel dslModel,
     IPluginsContainer<ICaptionsValuePlugin> plugins,
     ILogProvider logProvider)
 {
     _dslModel = dslModel;
     _plugins = plugins;
     _logger = logProvider.GetLogger("CaptionsValueGenerator");
     _performanceLogger = logProvider.GetLogger("Performance");
 }
        public List <CodeGeneratorDependency> ExtractCodeGeneratorDependencies(
            IEnumerable <CodeGenerator> codeGenerators,
            IPluginsContainer <IConceptDatabaseDefinition> plugins)
        {
            var dependenciesFromConceptInfo = ExtractDependenciesFromConceptInfos(codeGenerators);

            var dependenciesFromMefPluginMetadata = ExtractDependenciesFromMefPluginMetadata(plugins, codeGenerators);

            return(dependenciesFromConceptInfo.Union(dependenciesFromMefPluginMetadata).ToList());
        }
Esempio n. 16
0
 public ODataGenerator(
     IPluginsContainer <IODataGeneratorPlugin> plugins,
     ICodeGenerator codeGenerator,
     IAssemblyGenerator assemblyGenerator
     )
 {
     _plugins           = plugins;
     _codeGenerator     = codeGenerator;
     _assemblyGenerator = assemblyGenerator;
 }
Esempio n. 17
0
 public DomGenerator(
     IPluginsContainer <IConceptCodeGenerator> plugins,
     ICodeGenerator codeGenerator,
     ISourceWriter sourceWriter,
     InitialDomCodeGenerator initialDomCodeGenerator)
 {
     _pluginRepository        = plugins;
     _codeGenerator           = codeGenerator;
     _sourceWriter            = sourceWriter;
     _initialDomCodeGenerator = initialDomCodeGenerator;
 }
 public JavaScriptModelGenerator(
     IPluginsContainer <IJavascriptModelGeneratorPlugin> plugins,
     ICodeGenerator codeGenerator,
     IAssemblyGenerator assemblyGenerator,
     ILogProvider logProvider)
 {
     _plugins           = plugins;
     _codeGenerator     = codeGenerator;
     _assemblyGenerator = assemblyGenerator;
     _performanceLogger = logProvider.GetLogger("Performance");
 }
Esempio n. 19
0
 /// <summary>
 /// If assemblyName is not null, the assembly will be saved on disk.
 /// If assemblyName is null, the assembly will be generated in memory.
 /// </summary>
 public DomGenerator(
     IPluginsContainer <IConceptCodeGenerator> plugins,
     ICodeGenerator codeGenerator,
     ILogProvider logProvider,
     IAssemblyGenerator assemblyGenerator)
 {
     _pluginRepository = plugins;
     _codeGenerator    = codeGenerator;
     _log = logProvider;
     _assemblyGenerator = assemblyGenerator;
 }
Esempio n. 20
0
        public IAssemblySource ExecutePlugins <TPlugin>(IPluginsContainer <TPlugin> plugins, string tagOpen, string tagClose, IConceptCodeGenerator initialCodeGenerator)
            where TPlugin : IConceptCodeGenerator
        {
            var codeBuilder = BuildCode(plugins, tagOpen, tagClose, initialCodeGenerator);

            return(new AssemblySource
            {
                GeneratedCode = codeBuilder.GenerateCode(),
                RegisteredReferences = codeBuilder.RegisteredReferences
            });
        }
Esempio n. 21
0
 public EntityFrameworkMappingGenerator(
     ICodeGenerator codeGenerator,
     IPluginsContainer <IConceptMapping> plugins,
     RhetosBuildEnvironment rhetosBuildEnvironment,
     ILogProvider logProvider)
 {
     _plugins                = plugins;
     _codeGenerator          = codeGenerator;
     _performanceLogger      = logProvider.GetLogger("Performance." + GetType().Name);
     _rhetosBuildEnvironment = rhetosBuildEnvironment;
 }
Esempio n. 22
0
 public NHibernateMappingGenerator(
     ICodeGenerator codeGenerator,
     IPluginsContainer<IConceptMappingCodeGenerator> plugins,
     IDomainObjectModel domainObjectModel,
     ILogProvider logProvider)
 {
     _plugins = plugins;
     _codeGenerator = codeGenerator;
     _domainObjectModel = domainObjectModel;
     _performanceLogger = logProvider.GetLogger("Performance");
 }
Esempio n. 23
0
 public ClaimGenerator(
     IPluginsContainer <IClaimProvider> claimProviders,
     IDslModel dslModel,
     ILogProvider logProvider,
     GenericRepository <ICommonClaim> claimRepository)
 {
     _claimProviders    = claimProviders;
     _dslModel          = dslModel;
     _performanceLogger = logProvider.GetLogger("Performance");
     _claimsLogger      = logProvider.GetLogger("ClaimGenerator Claims");
     _claimRepository   = claimRepository;
 }
 public MvcModelGenerator(
     IPluginsContainer <IMvcModelGeneratorPlugin> plugins,
     ICodeGenerator codeGenerator,
     ILogProvider logProvider,
     RhetosBuildEnvironment rhetosBuildEnvironment
     )
 {
     _plugins                = plugins;
     _codeGenerator          = codeGenerator;
     _rhetosBuildEnvironment = rhetosBuildEnvironment;
     _performanceLogger      = logProvider.GetLogger("Performance");
 }
Esempio n. 25
0
 public ConceptDataMigrationGenerator(
     ILogProvider logProvider,
     IDslModel dslModel,
     RhetosBuildEnvironment rhetosBuildEnvironment,
     IPluginsContainer <IConceptDataMigration> plugins)
 {
     _performanceLogger      = logProvider.GetLogger("Performance." + GetType().Name);
     _logger                 = logProvider.GetLogger(GetType().Name);
     _dslModel               = dslModel;
     _plugins                = plugins;
     _rhetosBuildEnvironment = rhetosBuildEnvironment;
 }
 public DatabaseModelBuilder(
     IPluginsContainer <IConceptDatabaseDefinition> plugins,
     IDslModel dslModel,
     ILogProvider logProvider,
     DatabaseModelDependencies databaseModelDependencies)
 {
     _plugins                   = plugins;
     _dslModel                  = dslModel;
     _logger                    = logProvider.GetLogger(GetType().Name);
     _performanceLogger         = logProvider.GetLogger("Performance." + GetType().Name);
     _databaseModelDependencies = databaseModelDependencies;
 }
Esempio n. 27
0
        public CaptionsGenerator(
            IPluginsContainer <ICaptionsGeneratorPlugin> plugins,
            ICodeGenerator codeGenerator,
            ILogProvider logProvider
            )
        {
            _plugins       = plugins;
            _codeGenerator = codeGenerator;

            _logger       = logProvider.GetLogger("CaptionsGenerator");
            _sourceLogger = logProvider.GetLogger("Mvc Captions source");
        }
        public CaptionsGenerator(
            IPluginsContainer<ICaptionsGeneratorPlugin> plugins,
            ICodeGenerator codeGenerator,
            ILogProvider logProvider
            )
        {
            _plugins = plugins;
            _codeGenerator = codeGenerator;

            _logger = logProvider.GetLogger("CaptionsGenerator");
            _sourceLogger = logProvider.GetLogger("Mvc Captions source");
        }
 public MvcModelGenerator(
     IPluginsContainer<IMvcModelGeneratorPlugin> plugins,
     ICodeGenerator codeGenerator,
     IAssemblyGenerator assemblyGenerator,
     ILogProvider logProvider
     )
 {
     _plugins = plugins;
     _codeGenerator = codeGenerator;
     _assemblyGenerator = assemblyGenerator;
     _performanceLogger = logProvider.GetLogger("Performance");
 }
Esempio n. 30
0
 public ClaimGenerator(
     IPluginsContainer<IClaimProvider> claimProviders,
     IDslModel dslModel,
     IDomainObjectModel domainObjectModel,
     ILogProvider logProvider,
     IClaimRepository claimRepository)
 {
     _claimProviders = claimProviders;
     _dslModel = dslModel;
     _performanceLogger = logProvider.GetLogger("Performance");
     _logger = logProvider.GetLogger("ClaimGenerator");
     _claimRepository = claimRepository;
 }
Esempio n. 31
0
        public IEnumerable <string> Dependencies => new[] { "Rhetos.Deployment.ResourcesGenerator" }; // Required since Rhetos v4.1, because at build-time it uses files from the generated Resources folder.

        public Angular2ModelGenerator(
            IPluginsContainer <IAngular2ModelGeneratorPlugin> plugins,
            ICodeGenerator codeGenerator,
            IAssemblyGenerator assemblyGenerator,
            ILogProvider logProvider
            )
        {
            _plugins           = plugins;
            _codeGenerator     = codeGenerator;
            _assemblyGenerator = assemblyGenerator;
            _performanceLogger = logProvider.GetLogger("Performance");
            _logger            = logProvider.GetLogger(GetType().Name);
        }
Esempio n. 32
0
 /// <summary>
 /// If assemblyName is not null, the assembly will be saved on disk.
 /// If assemblyName is null, the assembly will be generated in memory.
 /// </summary>
 public DomGenerator(
     IPluginsContainer<IConceptCodeGenerator> plugins,
     ICodeGenerator codeGenerator,
     ILogProvider logProvider,
     IAssemblyGenerator assemblyGenerator,
     string assemblyName)
 {
     _assemblyName = assemblyName;
     _pluginRepository = plugins;
     _codeGenerator = codeGenerator;
     _log = logProvider;
     _assemblyGenerator = assemblyGenerator;
 }
Esempio n. 33
0
 /// <summary>
 /// If assemblyName is not null, the assembly will be saved on disk.
 /// If assemblyName is null, the assembly will be generated in memory.
 /// </summary>
 public DomGenerator(
     IPluginsContainer <IConceptCodeGenerator> plugins,
     ICodeGenerator codeGenerator,
     IAssemblyGenerator assemblyGenerator,
     RhetosBuildEnvironment buildEnvironment,
     ISourceWriter sourceWriter)
 {
     _pluginRepository  = plugins;
     _codeGenerator     = codeGenerator;
     _assemblyGenerator = assemblyGenerator;
     _buildEnvironment  = buildEnvironment;
     _sourceWriter      = sourceWriter;
 }
Esempio n. 34
0
 /// <summary>
 /// If assemblyName is not null, the assembly will be saved on disk.
 /// If assemblyName is null, the assembly will be generated in memory.
 /// </summary>
 public DomGenerator(
     IPluginsContainer<IConceptCodeGenerator> plugins,
     ICodeGenerator codeGenerator,
     ILogProvider logProvider,
     IAssemblyGenerator assemblyGenerator,
     DomGeneratorOptions domGeneratorOptions)
 {
     _domGeneratorOptions = domGeneratorOptions;
     _pluginRepository = plugins;
     _codeGenerator = codeGenerator;
     _log = logProvider;
     _assemblyGenerator = assemblyGenerator;
 }
Esempio n. 35
0
        public RestGenerator(
            IPluginsContainer<IRestGeneratorPlugin> plugins,
            ICodeGenerator codeGenerator,
            ILogProvider logProvider,
            IAssemblyGenerator assemblyGenerator
            )
        {
            _plugins = plugins;
            _codeGenerator = codeGenerator;
            _assemblyGenerator = assemblyGenerator;

            _logger = logProvider.GetLogger("RestGenerator");
            _sourceLogger = logProvider.GetLogger("Rest service");
        }
 public CaptionsResourceGenerator(
     IPluginsContainer<ICaptionsResourceGeneratorPlugin> plugins,
     CaptionsInitialCodePlugin initialCodePlugin,
     ICodeGenerator codeGenerator,
     IAssemblyGenerator assemblyGenerator,
     ILogProvider logProvider)
 {
     _plugins = plugins;
     _initialCodePlugin = initialCodePlugin;
     _codeGenerator = codeGenerator;
     _assemblyGenerator = assemblyGenerator;
     _logger = logProvider.GetLogger("CaptionsResourceGenerator");
     _performanceLogger = logProvider.GetLogger("Performance");
 }
Esempio n. 37
0
        public IDictionary <string, IAssemblySource> ExecutePluginsToFiles <TPlugin>(IPluginsContainer <TPlugin> plugins, string tagOpen, string tagClose, IConceptCodeGenerator initialCodeGenerator)
            where TPlugin : IConceptCodeGenerator
        {
            var codeBuilder = BuildCode(plugins, tagOpen, tagClose, initialCodeGenerator);

            return(codeBuilder.GeneratedCodeByFile
                   .ToDictionary(
                       codeFile => codeFile.Key,
                       codeFile => (IAssemblySource) new AssemblySource
            {
                GeneratedCode = codeFile.Value,
                RegisteredReferences = codeBuilder.RegisteredReferences
            }));
        }
Esempio n. 38
0
        public RestGenerator(
            IPluginsContainer <IRestGeneratorPlugin> plugins,
            ICodeGenerator codeGenerator,
            ILogProvider logProvider,
            IAssemblyGenerator assemblyGenerator
            )
        {
            _plugins           = plugins;
            _codeGenerator     = codeGenerator;
            _assemblyGenerator = assemblyGenerator;

            _logger       = logProvider.GetLogger("RestGenerator");
            _sourceLogger = logProvider.GetLogger("Rest service");
        }
 public ConceptDataMigrationExecuter(
     ILogProvider logProvider,
     SqlTransactionBatches sqlExecuter,
     IDslModel dslModel,
     IPluginsContainer <IConceptDataMigration> plugins)
 {
     _performanceLogger    = logProvider.GetLogger("Performance");
     _logger               = logProvider.GetLogger(GetType().Name);
     _deployPackagesLogger = logProvider.GetLogger("DeployPackages");
     _sqlExecuter          = sqlExecuter;
     _dslModel             = dslModel;
     _plugins              = plugins;
     _scripts              = new Lazy <GeneratedDataMigrationScripts>(ExecutePlugins);
 }
Esempio n. 40
0
 public DatabaseGenerator(
     ISqlExecuter sqlExecuter,
     IDslModel dslModel,
     IPluginsContainer<IConceptDatabaseDefinition> plugins,
     ConceptApplicationRepository conceptApplicationRepository,
     ILogProvider logProvider)
 {
     _sqlExecuter = sqlExecuter;
     _dslModel = dslModel;
     _plugins = plugins;
     _conceptApplicationRepository = conceptApplicationRepository;
     _logger = logProvider.GetLogger("DatabaseGenerator");
     _performanceLogger = logProvider.GetLogger("Performance");
 }
Esempio n. 41
0
 public ProcessingEngine(
     IPluginsContainer<ICommandImplementation> commandRepository,
     IPluginsContainer<ICommandObserver> commandObservers,
     ILogProvider logProvider,
     IPersistenceTransaction persistenceTransaction,
     IAuthorizationManager authorizationManager)
 {
     _commandRepository = commandRepository;
     _commandObservers = commandObservers;
     _logger = logProvider.GetLogger("ProcessingEngine");
     _performanceLogger = logProvider.GetLogger("Performance");
     _persistenceTransaction = persistenceTransaction;
     _authorizationManager = authorizationManager;
 }
Esempio n. 42
0
        private CodeBuilder BuildCode <TPlugin>(IPluginsContainer <TPlugin> plugins, string tagOpen, string tagClose, IConceptCodeGenerator initialCodeGenerator) where TPlugin : IConceptCodeGenerator
        {
            var stopwatch = Stopwatch.StartNew();

            var codeBuilder = new CodeBuilder(tagOpen, tagClose);

            if (initialCodeGenerator != null)
            {
                initialCodeGenerator.GenerateCode(null, codeBuilder);
            }

            var conceptImplementations = _dslModel.GetTypes()
                                         .ToDictionary(conceptType => conceptType, conceptType => plugins.GetImplementations(conceptType).ToList());

            _performanceLogger.Write(stopwatch, $"Get implementations for {typeof(TPlugin).FullName}.");

            var implementationStopwatches = conceptImplementations.SelectMany(ci => ci.Value)
                                            .Select(plugin => plugin.GetType())
                                            .Distinct()
                                            .ToDictionary(pluginType => pluginType, pluginType => new Stopwatch());

            foreach (var conceptInfo in _dslModel.Concepts)
            {
                foreach (var plugin in conceptImplementations[conceptInfo.GetType()])
                {
                    try
                    {
                        var implementationStopwatch = implementationStopwatches[plugin.GetType()];
                        implementationStopwatch.Start();
                        plugin.GenerateCode(conceptInfo, codeBuilder);
                        implementationStopwatch.Stop();
                    }
                    catch (Exception e)
                    {
                        _logger.Info("Part of the source code that was generated before the exception was thrown is written in the trace log.");
                        _logger.Trace(() => codeBuilder.GenerateCode());
                        ExceptionsUtility.Rethrow(e);
                    }
                }
            }

            foreach (var imp in implementationStopwatches.OrderByDescending(i => i.Value.Elapsed.TotalSeconds).Take(3))
            {
                _performanceLogger.Write(imp.Value, () => $"{typeof(TPlugin).Name} total time for {imp.Key}.");
            }

            _performanceLogger.Write(stopwatch, $"Code generated for {typeof(TPlugin).FullName}.");
            return(codeBuilder);
        }
Esempio n. 43
0
        public AuthorizationManager(
            IPluginsContainer<IClaimProvider> claimProviders,
            IUserInfo userInfo,
            ILogProvider logProvider,
            IAuthorizationProvider authorizationProvider)
        {
            _userInfo = userInfo;
            _claimProviders = claimProviders;
            _authorizationProvider = authorizationProvider;

            _logger = logProvider.GetLogger("AuthorizationManager");
            _performanceLogger = logProvider.GetLogger("Performance");

            _allowBuiltinAdminOverride = FromConfigAllowBuiltinAdminOverride();
        }
Esempio n. 44
0
        public AuthorizationManager(
            IPluginsContainer <IClaimProvider> claimProviders,
            IUserInfo userInfo,
            ILogProvider logProvider,
            IAuthorizationProvider authorizationProvider,
            IWindowsSecurity windowsSecurity)
        {
            _userInfo              = userInfo;
            _claimProviders        = claimProviders;
            _authorizationProvider = authorizationProvider;
            _windowsSecurity       = windowsSecurity;
            _logger            = logProvider.GetLogger(GetType().Name);
            _performanceLogger = logProvider.GetLogger("Performance");

            _allowBuiltinAdminOverride = FromConfigAllowBuiltinAdminOverride();
        }
Esempio n. 45
0
 public AuthorizationManager(
     IPluginsContainer <IClaimProvider> claimProviders,
     IUserInfo userInfo,
     ILogProvider logProvider,
     IAuthorizationProvider authorizationProvider,
     AppSecurityOptions appSecurityOptions,
     ILocalizer localizer)
 {
     _appSecurityOptions    = appSecurityOptions;
     _userInfo              = userInfo;
     _claimProviders        = claimProviders;
     _authorizationProvider = authorizationProvider;
     _logger            = logProvider.GetLogger(GetType().Name);
     _performanceLogger = logProvider.GetLogger("Performance." + GetType().Name);
     _allClaimsForUsers = FromConfigAllClaimsForUsers();
     _localizer         = localizer;
 }
Esempio n. 46
0
 public AuthorizationManager(
     IPluginsContainer<IClaimProvider> claimProviders,
     IUserInfo userInfo,
     ILogProvider logProvider,
     IAuthorizationProvider authorizationProvider,
     IWindowsSecurity windowsSecurity,
     ILocalizer localizer)
 {
     _userInfo = userInfo;
     _claimProviders = claimProviders;
     _authorizationProvider = authorizationProvider;
     _windowsSecurity = windowsSecurity;
     _logger = logProvider.GetLogger(GetType().Name);
     _performanceLogger = logProvider.GetLogger("Performance");
     _allowBuiltinAdminOverride = FromConfigAllowBuiltinAdminOverride();
     _localizer = localizer;
 }
Esempio n. 47
0
 public ApplicationGenerator(
     ILogProvider logProvider,
     ISqlExecuter sqlExecuter,
     IDslModel dslModel,
     IDomGenerator domGenerator,
     IPluginsContainer<IGenerator> generatorsContainer,
     DatabaseCleaner databaseCleaner,
     DataMigration dataMigration,
     IDatabaseGenerator databaseGenerator,
     IDslScriptsProvider dslScriptsLoader)
 {
     _deployPackagesLogger = logProvider.GetLogger("DeployPackages");
     _performanceLogger = logProvider.GetLogger("Performance");
     _sqlExecuter = sqlExecuter;
     _dslModel = dslModel;
     _domGenerator = domGenerator;
     _generatorsContainer = generatorsContainer;
     _databaseCleaner = databaseCleaner;
     _dataMigration = dataMigration;
     _databaseGenerator = databaseGenerator;
     _dslScriptsLoader = dslScriptsLoader;
 }
Esempio n. 48
0
        protected static IEnumerable<Tuple<Type, Type, string>> GetImplementationDependencies(IPluginsContainer<IConceptDatabaseDefinition> plugins, IEnumerable<Type> conceptImplementations)
        {
            var dependencies = new List<Tuple<Type, Type, string>>();

            foreach (Type conceptImplementation in conceptImplementations)
            {
                Type dependency = plugins.GetMetadata(conceptImplementation, "DependsOn");

                if (dependency == null)
                    continue;
                Type implements = plugins.GetMetadata(conceptImplementation, "Implements");
                Type dependencyImplements = plugins.GetMetadata(dependency, "Implements");

                if (!implements.Equals(dependencyImplements)
                    && !implements.IsAssignableFrom(dependencyImplements)
                    && !dependencyImplements.IsAssignableFrom(implements))
                    throw new FrameworkException(string.Format(
                        "DatabaseGenerator plugin {0} cannot depend on {1}."
                        + "\"DependsOn\" value in ExportMetadata attribute must reference implementation of same concept."
                        + " This additional dependencies should be used only to disambiguate between plugins that implement same IConceptInfo."
                        + " {2} implements {3}, while {4} implements {5}.",
                        conceptImplementation.FullName,
                        dependency.FullName,
                        conceptImplementation.Name,
                        implements.FullName,
                        dependency.Name,
                        dependencyImplements.FullName));

                dependencies.Add(Tuple.Create(dependency, conceptImplementation, "DependsOn metadata"));
            }

            return dependencies;
        }
Esempio n. 49
0
        protected static IEnumerable<Dependency> ExtractDependenciesFromMefPluginMetadata(IPluginsContainer<IConceptDatabaseDefinition> plugins, IEnumerable<NewConceptApplication> newConceptApplications)
        {
            var dependencies = new List<Dependency>();

            var conceptApplicationsByImplementation = newConceptApplications
                .GroupBy(ca => ca.ConceptImplementationType)
                .ToDictionary(g => g.Key, g => g.ToList());

            var distinctConceptImplementations = newConceptApplications.Select(ca => ca.ConceptImplementationType).Distinct().ToList();

            var implementationDependencies = GetImplementationDependencies(plugins, distinctConceptImplementations);

            foreach (var implementationDependency in implementationDependencies)
                if (conceptApplicationsByImplementation.ContainsKey(implementationDependency.Item1)
                    && conceptApplicationsByImplementation.ContainsKey(implementationDependency.Item2))
                    AddDependenciesOnSameConceptInfo(
                        conceptApplicationsByImplementation[implementationDependency.Item1],
                        conceptApplicationsByImplementation[implementationDependency.Item2],
                        implementationDependency.Item3,
                        dependencies);

            return dependencies.Distinct().ToList();
        }