public DefaultDependencyExporter(IDependencySupport dependencies)
 {
     dependencies.EnsureNotNull(nameof(dependencies));
     //
     _dependencies       = dependencies;
     _handlerChain       = null;
     _exportDependencies = P_ExportDependencies_FromDependencySupport;
 }
 public DefaultDependencyExporter(IDependencyHandler2 handler, bool ownsHandler = default)
 {
     handler.EnsureNotNull(nameof(handler));
     //
     _dependencies       = null;
     _handlerChain       = new IVh <IDependencyHandler2>[] { handler.ToValueHolder(ownsValue: ownsHandler) };
     _exportDependencies = P_ExportDependencies_FromHandlerChain;
 }
 protected override void Dispose(bool explicitDispose)
 {
     if (explicitDispose)
     {
         _handlerChain?.DisposeAndClearArray();
     }
     _dependencies       = null;
     _handlerChain       = null;
     _exportDependencies = null;
     //
     base.Dispose(explicitDispose);
 }
Exemplo n.º 4
0
 public static bool TrySelectNonexistentFileName(
     IDependencySupport dependencies,
     DirectoryInfo directory,
     string fileName,
     int maxIterations,
     out FileInfo selectedFileName)
 =>
 P_RequireFileSystemServiceProvider(dependencies: dependencies)
 .TrySelectNonexistentFileName(
     directory: directory,
     fileName: fileName,
     maxIterations: maxIterations,
     selectedFileName: out selectedFileName);
Exemplo n.º 5
0
 protected override void Dispose(bool explicitDispose)
 {
     if (explicitDispose)
     {
         _dependencyScopeLazy?.Dispose();
         _outerServiceProviderHandler?.Dispose();
     }
     _dependencyScopeLazy         = null;
     _outerServiceProviderHandler = null;
     _outerDependencies           = null;
     //
     base.Dispose(explicitDispose);
 }
Exemplo n.º 6
0
        // TODO: Put exception messages into the resources.
        //
        static IFileSystemServiceProvider P_RequireFileSystemServiceProvider(IDependencySupport dependencies)
        {
            dependencies.EnsureNotNull(nameof(dependencies));
            //
            var fileSystemAccessProvider = dependencies.GetService <IFileSystemServiceProvider>();

            if (fileSystemAccessProvider == null)
            {
                throw new EonException(message: $"Невозможно выполнить операцию, так как поставщик функциональных зависимостей не предоставил компонент доступа к файловой системе.{Environment.NewLine}\tПоставщик функциональных зависимостей:{Environment.NewLine}{dependencies.FmtStr().G().IndentLines2()}");
            }
            else
            {
                return(fileSystemAccessProvider);
            }
        }
 // TODO: Put strings into the resources.
 //
 public TComponent Create(IServiceProvider serviceProvider = default, IDependencySupport dependencies = default, IContext ctx = default)
 {
     try {
         var result = _factory(serviceProvider: serviceProvider, dependencies: dependencies);
         if (result is null)
         {
             throw new EonException($"Factory method '{_factory.GetMethodInfo().FmtStr().GForMemberInfo()}' has returned invalid value '{result.FmtStr().GNLI2()}'.");
         }
         else
         {
             return(result);
         }
     }
     catch (Exception exception) {
         throw new EonException($"An exception occurred while factory the component '{typeof(TComponent)}'.{Environment.NewLine}\tComponent:{this.FmtStr().GNLI2()}", exception);
     }
 }
Exemplo n.º 8
0
 public static JsonSerializer SelectSerializer(JsonSerializer serializer = default, IDependencySupport dependencies = default)
 {
     if (serializer is null)
     {
         return(dependencies?.GetService <JsonSerializer>() ?? DefaultSerializer);
     }
     else
     {
         return(serializer);
     }
 }
Exemplo n.º 9
0
 public static string CombinePath(IDependencySupport dependencies, params string[] paths)
 => P_RequireFileSystemServiceProvider(dependencies).CombinePath(paths);
Exemplo n.º 10
0
 public static string CombinePath(IDependencySupport dependencies, string path1, string path2)
 => P_RequireFileSystemServiceProvider(dependencies).CombinePath(path1, path2);
Exemplo n.º 11
0
 public static IFileInfo GetFileInfo(IDependencySupport dependencies, string filePath)
 => P_RequireFileSystemServiceProvider(dependencies).GetFileInfo(filePath);
Exemplo n.º 12
0
 public static ITransactionScopeProxy RequireTxReadCommitted(IDependencySupport dependencies)
 => dependencies.RequireService <ITxScopeProvider>().RequireTxReadCommitted();
 public TaskWrap <TComponent> CreateAsync(IServiceProvider serviceProvider, IDependencySupport dependencies, IContext ctx = default)
 => TaskWrap <TComponent> .Wrap(func : () => Create(serviceProvider: serviceProvider, dependencies: dependencies, ctx: ctx));
Exemplo n.º 14
0
 public static bool TrySelectNonexistentFileName(IDependencySupport dependencies, DirectoryInfo directory, string fileNameTemplate, int maxIterations, Func <ITextTemplateVarSubstitution, int, ITextTemplateVarSubstitution> fileNameTemplateSubstitutionSelector, out FileInfo selectedFileName)
 =>
 P_RequireFileSystemServiceProvider(dependencies: dependencies)
 .TrySelectNonexistentFileName(directory: directory, fileNameTemplate: fileNameTemplate, maxIterations: maxIterations, fileNameTemplateSubstitutionSelector: fileNameTemplateSubstitutionSelector, selectedFileName: out selectedFileName);
Exemplo n.º 15
0
 public static bool ChooseSingleFileForOpenUI(IDependencySupport dependencies, string prompt, string fileFilter, out IFileInfo chosenFile)
 => P_RequireFileSystemServiceProvider(dependencies).ChooseSingleFileForOpenUI(prompt, fileFilter, out chosenFile);
Exemplo n.º 16
0
 protected DependencySupport(IServiceProvider outerServiceProvider = default, IDependencySupport outerDependencies = default)
 {
     _outerDependencies           = outerDependencies;
     _dependencyScopeLazy         = new DisposableLazy <IDependencyScope>(factory: P_DependencyScopeLazyInitializer);
     _outerServiceProviderHandler = outerServiceProvider is null ? null : new ServiceProviderHandler(serviceProvider: outerServiceProvider);
 }
Exemplo n.º 17
0
 public static ITransactionScopeProxy SuppressTx(IDependencySupport dependencies)
 => dependencies.RequireService <ITxScopeProvider>().SuppressTx();
Exemplo n.º 18
0
 internal P_Disposable(EfCoreDbContext efContext, IDataContext2 dataContext, ILogger logger, IDependencySupport outerDependencies)
     : base(outerDependencies: outerDependencies)
 {
     //
     efContext.EnsureNotNull(nameof(efContext));
     //
     _efContext       = efContext;
     _efContextString = efContext.ToString();
     _dataContext     = dataContext;
     _logger          = logger;
 }
Exemplo n.º 19
0
 public static bool ChooseSingleFileForSaveUI(IDependencySupport dependencies, string prompt, string fileFilter, string defaultFileName, out Stream chosenFileStream)
 => P_RequireFileSystemServiceProvider(dependencies).ChooseSingleFileForSaveUI(prompt, fileFilter, defaultFileName, out chosenFileStream);
 ITaskWrap <TComponent> IOptionalFactory <IServiceProvider, IDependencySupport, TComponent> .CreateAsync(IServiceProvider arg1, IDependencySupport arg2, IContext ctx)
 => CreateAsync(serviceProvider: arg1, dependencies: arg2, ctx: ctx);
Exemplo n.º 21
0
 public static string EscapeInvalidFileNameChars(IDependencySupport dependencies, string value)
 => P_RequireFileSystemServiceProvider(dependencies).EscapeInvalidFileNameChars(value);
 public bool CanCreate(IServiceProvider serviceProvider = default, IDependencySupport dependencies = default)
 => true;
Exemplo n.º 23
0
 public static ITransactionScopeProxy RequireTxSerializable(IDependencySupport dependencies)
 => dependencies.RequireService <ITxScopeProvider>().RequireTxSerializable();