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); }
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);
protected override void Dispose(bool explicitDispose) { if (explicitDispose) { _dependencyScopeLazy?.Dispose(); _outerServiceProviderHandler?.Dispose(); } _dependencyScopeLazy = null; _outerServiceProviderHandler = null; _outerDependencies = null; // base.Dispose(explicitDispose); }
// 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); } }
public static JsonSerializer SelectSerializer(JsonSerializer serializer = default, IDependencySupport dependencies = default) { if (serializer is null) { return(dependencies?.GetService <JsonSerializer>() ?? DefaultSerializer); } else { return(serializer); } }
public static string CombinePath(IDependencySupport dependencies, params string[] paths) => P_RequireFileSystemServiceProvider(dependencies).CombinePath(paths);
public static string CombinePath(IDependencySupport dependencies, string path1, string path2) => P_RequireFileSystemServiceProvider(dependencies).CombinePath(path1, path2);
public static IFileInfo GetFileInfo(IDependencySupport dependencies, string filePath) => P_RequireFileSystemServiceProvider(dependencies).GetFileInfo(filePath);
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));
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);
public static bool ChooseSingleFileForOpenUI(IDependencySupport dependencies, string prompt, string fileFilter, out IFileInfo chosenFile) => P_RequireFileSystemServiceProvider(dependencies).ChooseSingleFileForOpenUI(prompt, fileFilter, out chosenFile);
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); }
public static ITransactionScopeProxy SuppressTx(IDependencySupport dependencies) => dependencies.RequireService <ITxScopeProvider>().SuppressTx();
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; }
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);
public static string EscapeInvalidFileNameChars(IDependencySupport dependencies, string value) => P_RequireFileSystemServiceProvider(dependencies).EscapeInvalidFileNameChars(value);
public bool CanCreate(IServiceProvider serviceProvider = default, IDependencySupport dependencies = default) => true;
public static ITransactionScopeProxy RequireTxSerializable(IDependencySupport dependencies) => dependencies.RequireService <ITxScopeProvider>().RequireTxSerializable();