public static async Task <bool> Create( this IHaveADirectory packageBase, IPackageInitializer initializer) { using (var operation = Logger <PackageBase> .Log.OnEnterAndConfirmOnExit()) { if (!packageBase.Directory.Exists) { operation.Info("Creating directory {directory}", packageBase.Directory); packageBase.Directory.Create(); packageBase.Directory.Refresh(); } using (await FileLock.TryCreateAsync(packageBase.Directory)) { if (!packageBase.Directory.GetFiles("*", SearchOption.AllDirectories).Where(f => !FileLock.IsLockFile(f)).Any()) { operation.Info("Initializing package using {_initializer} in {directory}", initializer, packageBase.Directory); await initializer.Initialize(packageBase.Directory); } } operation.Succeed(); return(true); } }
public void Initialize() { try { logger.Log($"Initializing"); coverageProjectFactory.Initialize(); fccEngine.Initialize(this); packageInitializer.Initialize(); logger.Log($"Initialized"); } catch (Exception exception) { InitializeStatus = InitializeStatus.Error; InitializeExceptionMessage = exception.Message; logger.Log($"Failed Initialization", exception); } if (InitializeStatus != InitializeStatus.Error) { InitializeStatus = InitializeStatus.Initialized; } }