private CloudDriveFactory InitializeCloudDriveFactory(string libPath) { CompositionInitializer.Preload(typeof(CloudFS.Interface.Composition.ICloudGateway)); CompositionInitializer.Initialize(new[] { typeof(Program).Assembly }, libPath, "IgorSoft.CloudFS.Gateways.*.dll"); var factory = new CloudDriveFactory(); CompositionInitializer.SatisfyImports(factory); return(factory); }
internal static void Main(string[] args) { var mountSection = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).Sections[MountSection.Name] as MountSection; if (mountSection == null) { throw new ConfigurationErrorsException("Mount configuration missing"); } CompositionInitializer.Preload(typeof(IgorSoft.CloudFS.Interface.Composition.ICloudGateway)); CompositionInitializer.Initialize(mountSection.LibPath, "IgorSoft.CloudFS.Gateways.*.dll"); var factory = new CloudDriveFactory(); CompositionInitializer.SatisfyImports(factory); try { var logger = new LogFactory().GetCurrentClassLogger(); using (var tokenSource = new CancellationTokenSource()) { var tasks = new List <Task>(); foreach (var drive in mountSection.Drives.Cast <DriveElement>()) { var operations = new CloudOperations(factory.CreateCloudDrive(drive.Schema, drive.UserName, drive.Root, new CloudDriveParameters() { EncryptionKey = drive.EncryptionKey, Parameters = drive.GetParameters() }), logger); // HACK: handle non-unique parameter set of DokanOperations.Mount() by explicitely specifying AllocationUnitSize and SectorSize tasks.Add(Task.Run(() => operations.Mount(drive.Root, DokanOptions.RemovableDrive | DokanOptions.MountManager | DokanOptions.CurrentSession, mountSection.Threads, 1100, TimeSpan.FromSeconds(drive.Timeout != 0 ? drive.Timeout : 20), null, 512, 512), tokenSource.Token)); var driveInfo = new DriveInfo(drive.Root); while (!driveInfo.IsReady) { Thread.Sleep(10); } } Console.ReadKey(true); tokenSource.Cancel(); } } finally { foreach (var drive in mountSection.Drives.Cast <DriveElement>()) { Dokan.Unmount(drive.Root[0]); } } }
public static void Initialize() { CompositionInitializer.Preload(typeof(ICloudGateway)); CompositionInitializer.Initialize(COMPOSITION_DIRECTORY); }
public void CompositionInitializer_Preload_Succeeds() { CompositionInitializer.Preload(typeof(CompositionInitializerTests)); }
public void CompositionInitializer_Preload_WhereTypeIsNull_Throws() { CompositionInitializer.Preload(null); }