public DownloadViewModelFactory(IFileSystemManager fileSystemManager)
        {
            if (fileSystemManager == null)
                throw new ArgumentNullException("fileSystemManager");

            this.fileSystemManager = fileSystemManager;
        }
		public FileSystemNetworkServer(IFileSystemManager fileSystemManager, int port)
			: this(new ConnectionFactory(typeof(FileSystemCommandConnection), fileSystemManager),
					new CommandBuilderFactory(typeof(TextCommandBuilder)),
					new CommandProcessorProviderFactory(typeof(TextCommandProcessorProvider), typeof(FileSystemNetworkServer).Assembly),
					port)
		{
		}
Esempio n. 3
0
 /// <summary>
 /// Тест-конструктор
 /// </summary>
 public SyncFile(string fullPath, IFileSystemManager manager)
 {
     // инициализируем класс менеджера файловой системы:
     _manager = manager;
     // проставляем путь к файлу
     FullPath = fullPath;
 }
        internal ContainerDirectory(IFileSystemManager fileSystem, string containerPath)
        {
            this.fileSystem = fileSystem;
            this.containerPath = containerPath;

            this.containerBinPath = CanonicalizePath(Path.Combine(containerPath, BinRelativePath), ensureTrailingSlash: true);
            this.containerUserPath = CanonicalizePath(Path.Combine(containerPath, UserRelativePath), ensureTrailingSlash: true);
        }
Esempio n. 5
0
 private IFileSystemManager GetFileSystemManager()
 {
     if (_fileSystemManager == null)
         lock (s_fileSystemManagerSync)
             if (_fileSystemManager == null)
                 _fileSystemManager = CoreApplication.Instance.GetSubsystem<IFileSystemManager>();
     return _fileSystemManager;
 }
        internal ContainerDirectory(IFileSystemManager fileSystem, string containerPath)
        {
            this.fileSystem    = fileSystem;
            this.containerPath = containerPath;

            this.containerBinPath  = CanonicalizePath(Path.Combine(containerPath, BinRelativePath), ensureTrailingSlash: true);
            this.containerUserPath = CanonicalizePath(Path.Combine(containerPath, UserRelativePath), ensureTrailingSlash: true);
        }
Esempio n. 7
0
        private bool ExecuteCommandLine(string commandLine)
        {
            string Command;
            string Arguments;

            if (ExtractCommand(commandLine, out Command, out Arguments))
            {
                // Special processing for CD command
                if (Command.Equals("cd", StringComparison.OrdinalIgnoreCase))
                {
                    int    DummyIndex;
                    string FolderPath = DequoteString(Arguments, out DummyIndex);
                    if (!string.IsNullOrEmpty(FolderPath))
                    {
                        ITwoPanelTab TwoPanelTab = GetService(typeof(ITab)) as ITwoPanelTab;
                        if (TwoPanelTab != null)
                        {
                            try
                            {
                                // Convert FolderPath string to virtual folder object
                                IFileSystemManager FileSystemManager = (IFileSystemManager)GetService(typeof(IFileSystemManager));
                                TwoPanelTab.CurrentPanel.CurrentFolder =
                                    (IVirtualFolder)FileSystemManager.FromFullName(FolderPath, VirtualItemType.Folder, CurrentFolder);
                            }
                            catch (ArgumentException)
                            {
                                // Skip invalid FolderPath value
                                MessageDialog.Show(FindForm(), Resources.sInvalidPath, Resources.sCaptionWarning, MessageDialog.ButtonsOk, MessageBoxIcon.Warning);
                                return(false);
                            }
                        }
                    }
                    return(true);
                }

                // Try to start new process
                try
                {
                    ProcessStartInfo StartInfo = new ProcessStartInfo(Command, Arguments);

                    string CurrentDir = CurrentDirectory;
                    if (!string.IsNullOrEmpty(CurrentDir))
                    {
                        StartInfo.WorkingDirectory = CurrentDir;
                    }

                    Process.Start(StartInfo);
                    return(true);
                }
                catch (Win32Exception e)
                {
                    // Skip any start process error
                    MessageDialog.Show(FindForm(), e.Message, Resources.sCaptionWarning, MessageDialog.ButtonsOk, MessageBoxIcon.Warning);
                    return(false);
                }
            }
            return(false);
        }
Esempio n. 8
0
 public CommonScriptModule(IIoTService ioTService, IScriptEngineService scriptEngineService, IFileSystemManager fileSystemManager, NeonConfig neonConfig, ILogger <ScriptEngineService> logger, IHttpClientFactory httpClientFactory)
 {
     _httpClientFactory   = httpClientFactory;
     _logger              = logger;
     _ioTService          = ioTService;
     _fileSystemManager   = fileSystemManager;
     _scriptEngineService = scriptEngineService;
     _scriptEngineConfig  = neonConfig.ServicesConfig.ScriptEngineConfig;
 }
Esempio n. 9
0
 public NotificationService(ILogger <NotificationService> logger, IMediator mediator, IFileSystemManager fileSystemManager, INeonManager neonManager, List <NotifierData> notifierData, NeonConfig neonConfig)
 {
     _logger                  = logger;
     _fileSystemManager       = fileSystemManager;
     _mediator                = mediator;
     _neonManager             = neonManager;
     _notifierData            = notifierData;
     _notifierConfigDirectory = neonConfig.NotifierConfig.DirectoryConfig.DirectoryName;
 }
Esempio n. 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PathResolver"/> class.
        /// </summary>
        /// <param name="manager">The <see cref="IFileSystemManager"/> to use to interface with the file system.</param>
        public PathResolver(IFileSystemManager manager)
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }

            this.manager = manager;
        }
Esempio n. 11
0
        public DownloadViewModelFactory(IFileSystemManager fileSystemManager)
        {
            if (fileSystemManager == null)
            {
                throw new ArgumentNullException("fileSystemManager");
            }

            this.fileSystemManager = fileSystemManager;
        }
Esempio n. 12
0
 public MsmqServer(IServerOptions options, IFileSystemManager fileManager, IQueueCreateManager queueManager, IMessageToFilePartMapper messageToFilePartMapper, IFileMessageBuffer messageBuffer, IFileCopyManager copyManager)
 {
     _options                 = options;
     _fileManager             = fileManager;
     _queueCreateManager      = queueManager;
     _messageToFilePartMapper = messageToFilePartMapper;
     _filesBuffer             = messageBuffer;
     _copyManager             = copyManager;
 }
Esempio n. 13
0
 public LayoutFileDefinitionBuilderViewModel(ISkinDefinitionSerializer serializer,
                                             IFileSystemManager fileSystemManager,
                                             IDialogServices dialogServices)
 {
     this.Serializer        = serializer;
     this.FileSystemManager = fileSystemManager;
     this.DialogServices    = dialogServices;
     this.SelectFileCommand = new Command(SelectFile);
 }
Esempio n. 14
0
 public Multithread(IHtmlParser htmlParser, IHtmlReader htmlReader, IFileSystemManager fileSystemManager, IDataBaseManager dataBaseManager)
 {
     this.htmlParser        = htmlParser;
     this.htmlReader        = htmlReader;
     this.fileSystemManager = fileSystemManager;
     this.dataBaseManager   = dataBaseManager;
     locker = new object();
     tasks  = new List <Task>();
 }
Esempio n. 15
0
 public FileSystemBiz(IFileSystemManager fileSystemManager,
                      IZipManager zipManager,
                      IImageManager imageManager,
                      IContentManagementContext contentManagementContext)
 {
     _fileSystemManager        = fileSystemManager;
     _zipManager               = zipManager;
     _imageManager             = imageManager;
     _contentManagementContext = contentManagementContext;
 }
Esempio n. 16
0
 public MsmqServiceFactory(IServerOptionsProvider optionsProvider, IFileSystemManager fileManager, IQueueCreateManager queueManager, IMessageToFilePartMapper messageToFilePartMapper,
                           IFileMessageBuffer buffer, IFileCopyManager copyManager)
 {
     _optionsProvider         = optionsProvider;
     _fileManager             = fileManager;
     _queueManager            = queueManager;
     _messageToFilePartMapper = messageToFilePartMapper;
     _buffer      = buffer;
     _copyManager = copyManager;
 }
        public ViewNodeProvider(IFileSystemManager fileSystemManager, IFileSystem fileSystem)
            : base(fileSystemManager)
        {
            this.schemes = new string[]
            {
                fileSystem.RootDirectory.Address.Scheme
            };

            this.viewFileSystem = fileSystem;
        }
 public CreateNewAudioResourceVersionWork(ResourceRepository resourceRepository, IFileSystemManager fileSystemManager, long audioId,
                                          CreateAudioContract data, Stream fileStream, int userId) : base(resourceRepository)
 {
     m_resourceRepository = resourceRepository;
     m_fileSystemManager  = fileSystemManager;
     m_audioId            = audioId;
     m_data       = data;
     m_fileStream = fileStream;
     m_userId     = userId;
 }
Esempio n. 19
0
 public BrowserCodeBiz(ISourceControl sourceControl,
                       IContentManagementContext contentManagementContext, IFileSystemManager fileSystemManager
                       , IWebConfigManager webConfigManager, ICompressManager compressManager, IBundleManager bundleManager
                       , ISecurityContext securityContext)
     : base(sourceControl, contentManagementContext, fileSystemManager
            , webConfigManager, securityContext)
 {
     _compressManager = compressManager;
     _bundleManager   = bundleManager;
 }
        public LanguageAndCultureBiz(IContentManagementContext contentManagementContext,
                                     IFileSystemManager fileSystemManager
                                     , IWebConfigManager webConfigManager, ICompressManager compressManager)

        {
            _contentManagementContext = contentManagementContext;
            _fileSystemManager        = fileSystemManager;
            _webConfigManager         = webConfigManager;
            _compressManager          = compressManager;
        }
Esempio n. 21
0
        private static void SyncTransactionWithBackup(IFileSystemManager manager, SyncFile nonActualFile, SyncFile actualFile, string backupDirPath)
        {
            // в самом начале делаем бекап неактуального файла в директории с исполняемым файлом
            manager.CopyFile(nonActualFile.FullPath,
                             String.Format("{3}\\{0}[{1:yyyy-MM-dd HH-mm-ss}]{2}", //AppDomain.CurrentDomain.BaseDirectory +
                                           Path.GetFileNameWithoutExtension(nonActualFile.FullPath),
                                           SystemTime.Now(), Path.GetExtension(nonActualFile.FullPath), backupDirPath));

            SyncTransaction(manager, nonActualFile, actualFile);
        }
Esempio n. 22
0
 public ProjectItemManager(AuthenticationManager authenticationManager, ResourceRepository resourceRepository,
                           FulltextStorageProvider fulltextStorageProvider, IFileSystemManager fileSystemManager,
                           IMapper mapper)
 {
     m_authenticationManager   = authenticationManager;
     m_resourceRepository      = resourceRepository;
     m_fulltextStorageProvider = fulltextStorageProvider;
     m_fileSystemManager       = fileSystemManager;
     m_mapper = mapper;
 }
Esempio n. 23
0
        public SettingsViewModel(ISettings settings, IFileSystemManager folderSelector)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");
            if (folderSelector == null)
                throw new ArgumentNullException("folderSelector");

            this.settings = settings;
            this.folderSelector = folderSelector;
            this.settings.Load();
        }
Esempio n. 24
0
 public SqlServerBiz(ISourceControl sourceControl,
                     IContentManagementContext contentManagementContext
                     , IFileSystemManager fileSystemManager
                     , IWebConfigManager webConfigManager
                     , IDataBaseManager dataBaseManager
                     , ISecurityContext securityContext)
     : base(sourceControl, contentManagementContext, fileSystemManager
            , webConfigManager, securityContext)
 {
     _dataBaseManager = dataBaseManager;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="OutputTemplateManager"/> class.
        /// </summary>
        /// <param name="xmlPath">The XML path.</param>
        /// <param name="runResultParser">The run result parser.</param>
        /// <param name="directoryWrapper">The directory wrapper.</param>
        /// <exception cref="ArgumentException">Value cannot be null or whitespace. - xmlPath</exception>
        /// <exception cref="ArgumentNullException">
        /// runResultParser
        /// or
        /// directoryWrapper
        /// </exception>
        public OutputTemplateManager(string xmlPath, ITestRunResultParser runResultParser, IFileSystemManager directoryWrapper)
        {
            if (string.IsNullOrWhiteSpace(xmlPath))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(xmlPath));
            }

            _xmlPath             = xmlPath;
            _testRunResultParser = runResultParser ?? throw new ArgumentNullException(nameof(runResultParser));
            _directoryWrapper    = directoryWrapper ?? throw new ArgumentNullException(nameof(directoryWrapper));
        }
Esempio n. 26
0
 public ProjectContentManager(ResourceRepository resourceRepository, IFileSystemManager fileSystemManager,
                              AuthenticationManager authenticationManager, FulltextStorageProvider fulltextStorageProvider,
                              UserDetailManager userDetailManager, IMapper mapper)
 {
     m_resourceRepository      = resourceRepository;
     m_fileSystemManager       = fileSystemManager;
     m_authenticationManager   = authenticationManager;
     m_fulltextStorageProvider = fulltextStorageProvider;
     m_userDetailManager       = userDetailManager;
     m_mapper = mapper;
 }
		public ViewNodeProvider(IFileSystemManager fileSystemManager, Configuration config)
			: this
			(
				fileSystemManager,
				config.Scheme,
				ResolveRootDirectory(fileSystemManager, config.Uri, config.Create),
				FileSystemOptions.Default,
				config
			)
		{
		}
        public GenericUpdater(AddonInfoFromYaml addon, IConfigurationManager configurationManager)
        {
            _fileSystemManager    = new FileSystemManager();
            _addonName            = addon.folder_name;
            _addonInfo            = addon;
            _configurationManager = configurationManager;
            _viewModel            = UpdatingViewModel.GetInstance;

            _addonExpandedPath = Path.Combine(Path.GetTempPath(), _addonName);
            _addonInstallPath  = Path.Combine(configurationManager.UserConfig.GamePath, "addons");
        }
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_FileSystemManager = GameFrameworkEntry.GetModule <IFileSystemManager>();
            if (m_FileSystemManager == null)
            {
                Log.Fatal("File system manager is invalid.");
                return;
            }
        }
		public ImaginaryNodeProvider(IFileSystemManager manager, string scheme)
			: base(manager)
		{
			this.schemas = new string[]
			{
				scheme
			};

			this.imaginaryFileSystem = new ImaginaryFileSystem(scheme);
			this.root = this.imaginaryFileSystem.RootDirectory;
		}
Esempio n. 31
0
        public PluginsManager(ILogger logger, IFileSystemManager fileSystemManager, IServicesManager servicesManager,
                              NeonConfig neonConfig)
        {
            _neonConfig        = neonConfig;
            _logger            = logger;
            _servicesManager   = servicesManager;
            _fileSystemManager = fileSystemManager;


            InitNuGet();
        }
Esempio n. 32
0
        public ImaginaryNodeProvider(IFileSystemManager manager, string scheme)
            : base(manager)
        {
            this.schemas = new string[]
            {
                scheme
            };

            this.imaginaryFileSystem = new ImaginaryFileSystem(scheme);
            this.root = this.imaginaryFileSystem.RootDirectory;
        }
 public ViewNodeProvider(IFileSystemManager fileSystemManager, Configuration config)
     : this
     (
         fileSystemManager,
         config.Scheme,
         ResolveRootDirectory(fileSystemManager, config.Uri, config.Create),
         FileSystemOptions.Default,
         config
     )
 {
 }
 static FileSystemManager()
 {
     try
     {
         manager = (IFileSystemManager)Activator.CreateInstance(Type.GetType(ConfigurationSection.Default.DefaultManager));
     }
     catch (TargetInvocationException e)
     {
         Console.Error.WriteLine("There was an error initializing the {0}", typeof(FileSystemManager).Name);
         Console.Error.WriteLine(e.InnerException);
     }
 }
Esempio n. 35
0
 public ServiceBiz(IContentManagementContext contentManagementContext
                   , IFileSystemManager fileSystemManager, ISourceControl sourceControl
                   , IWebConfigManager webConfigManager, ICodeTemplate codeTemplate
                   , ISecurityContext securityContext)
 {
     _contentManagementContext = contentManagementContext;
     _fileSystemManager        = fileSystemManager;
     _sourceControl            = sourceControl;
     _webConfigManager         = webConfigManager;
     _codeTemplate             = codeTemplate;
     _securityContext          = securityContext;
 }
        public void Constructor_ShouldThrowArgumentException_WhenXmlPathIsNullOrWhitespace(string xmlPath)
        {
            // Arrange
            ITestRunResultParser testRunResultParser = Substitute.For <ITestRunResultParser>();
            IFileSystemManager   fileSystemManager   = Substitute.For <IFileSystemManager>();

            // Act
            ArgumentException argumentException = Assert.Throws <ArgumentException>(() => new OutputTemplateManager(xmlPath, testRunResultParser, fileSystemManager));

            // Assert
            Assert.AreEqual($"Value cannot be null or whitespace.{Environment.NewLine}Parameter name: xmlPath", argumentException.Message);
        }
		static FileSystemManager()
		{
			try
			{
				manager = (IFileSystemManager)Activator.CreateInstance(Type.GetType(ConfigurationSection.Default.DefaultManager));
			}
			catch (TargetInvocationException e)
			{
				Console.Error.WriteLine("There was an error initializing the {0}", typeof(FileSystemManager).Name);
				Console.Error.WriteLine(e.InnerException);
			}
		}
Esempio n. 38
0
 public override void Init(SubsystemConfig config)
 {
     _config = (ConfigurationManagerConfig)config;
     var keyAttributeNames = new Dictionary<string, string> { { "subsystem", "name" } };
     _mergeUtil = new XmlMerge(_config.PrivateConfigElementXPaths.ToList(), keyAttributeNames);
     _currentConfig = CoreApplication.Instance.Config;
     _currentConfigXml = _currentConfig.ToXml();
     _fileSystemManager = Application.GetSubsystemOrThrow<IFileSystemManager>();
     _electionManager = Application.GetSubsystemOrThrow<IElectionManager>();
     WorkingConfigLoaded = false;
     Application.ConfigUpdated += ApplicationConfigUpdated;
 }
Esempio n. 39
0
 /// <summary>
 ///     Ctor
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="fileSystemManager"></param>
 /// <param name="config"></param>
 public IoTService(ILogger <IIoTService> logger, IFileSystemManager fileSystemManager,
                   NeonConfig config,
                   IEventDatabaseService eventDatabaseService,
                   IMqttService mqttService
                   )
 {
     _logger               = logger;
     _mqttService          = mqttService;
     _eventDatabaseService = eventDatabaseService;
     _fileSystemManager    = fileSystemManager;
     _config               = config;
 }
Esempio n. 40
0
 private IFileSystemManager GetFileSystemManager()
 {
     if (_fileSystemManager == null)
     {
         lock (s_fileSystemManagerSync)
             if (_fileSystemManager == null)
             {
                 _fileSystemManager = CoreApplication.Instance.GetSubsystem <IFileSystemManager>();
             }
     }
     return(_fileSystemManager);
 }
 internal ContainerService(ContainerHandleHelper handleHelper, IUserManager userManager, IFileSystemManager fileSystem, IContainerPropertyService containerPropertiesService, ILocalTcpPortManager tcpPortManager, IProcessRunner processRunner, IContainerHostService containerHostService, IDiskQuotaManager diskQuotaManager, IContainerDirectoryFactory directoryFactory, string containerBasePath)
 {
     this.handleHelper = handleHelper;
     this.userManager = userManager;
     this.fileSystem = fileSystem;
     this.containerPropertiesService = containerPropertiesService;
     this.tcpPortManager = tcpPortManager;
     this.processRunner = processRunner;
     this.containerHostService = containerHostService;
     this.containerBasePath = containerBasePath;
     this.diskQuotaManager = diskQuotaManager;
     this.directoryFactory = directoryFactory;
 }
Esempio n. 42
0
 internal ContainerService(ContainerHandleHelper handleHelper, IUserManager userManager, IFileSystemManager fileSystem, IContainerPropertyService containerPropertiesService, ILocalTcpPortManager tcpPortManager, IProcessRunner processRunner, IContainerHostService containerHostService, IDiskQuotaManager diskQuotaManager, IContainerDirectoryFactory directoryFactory, string containerBasePath)
 {
     this.handleHelper = handleHelper;
     this.userManager  = userManager;
     this.fileSystem   = fileSystem;
     this.containerPropertiesService = containerPropertiesService;
     this.tcpPortManager             = tcpPortManager;
     this.processRunner        = processRunner;
     this.containerHostService = containerHostService;
     this.containerBasePath    = containerBasePath;
     this.diskQuotaManager     = diskQuotaManager;
     this.directoryFactory     = directoryFactory;
 }
Esempio n. 43
0
        public void InitializeTest()
        {
            // создаём тестовый набор данных:

            // иньекция системного времени:
            SystemTime.Now = () => _testDateTimeNow;

            // файл номер 1
            var file1Path = @"C:\some_folder\some_file1.csv"; // путь
            var file1Meta = new FileMetadata {ByteSize = 10, LastModified = new DateTime(2013, 1, 5)}; // свойства

            // файл номер 2, три файла(три пути) с одинаковыми свойствами
            var file2Path = @"D:\some_folder2\stuff\some_file1.csv";
            var file2WithDifferNamePath = @"D:\some_folder2\stuff\some_file1_with_differ_name.csv";
            var file2WithDifferExtensionPath = @"D:\some_folder2\stuff\some_file1.with_differ_extension";
            var file2Meta = new FileMetadata { ByteSize = 15, LastModified = new DateTime(2013, 1, 7) };

            // создаем тестовый менеджер файловой системы
            _injectedManager = A.Fake<IFileSystemManager>();
            // прописываем какие свойства (матаданные) он должен возвращать по каждому файлу
            A.CallTo(() => _injectedManager.GetFileMetadata(file1Path)).Returns(file1Meta);
            A.CallTo(() => _injectedManager.GetFileMetadata(file2Path)).Returns(file2Meta);
            A.CallTo(() => _injectedManager.GetFileMetadata(file2WithDifferNamePath)).Returns(file2Meta);
            A.CallTo(() => _injectedManager.GetFileMetadata(file2WithDifferExtensionPath)).Returns(file2Meta);

            #region делаем иньекцию тестового менеджера файловой системы:

            // создаем объекты SyncFile для файлов:
            // объект SyncFile для файла номер 1, неактуальный (более старый)
            _nonActualFile = new SyncFile(file1Path, _injectedManager);
            // объект SyncFile для файла номер 2, актуальный (более новый)
            _actualFile = new SyncFile(file2Path, _injectedManager);

            //  объект SyncFile для файла номер 2, актуальный (более новый) с другим именем
            _actualFileWithDifferName = new SyncFile(file2WithDifferNamePath, _injectedManager);
            //  объект SyncFile для файла номер 2, актуальный (более новый) с другим расширением
            _actualFileWithDifferExtension = new SyncFile(file2WithDifferExtensionPath, _injectedManager);

            _sfp = new SyncFilesPair(_injectedManager);
            #endregion
        }
		public FileSystemCommandConnection(NetworkServer networkServer, Socket socket, IFileSystemManager fileSystemManager)
			: base(networkServer, socket)
		{
			this.connectionId = Interlocked.Increment(ref connectionIdCount);

			this.ProtocolReadLogger = new ProtocolReadLog(this.connectionId.ToString());
			this.ProtocolWriteLogger = new ProtocolWriteLog(this.connectionId.ToString());
			this.ProtocolTrafficLogger = new ProtocolTrafficLog(this.connectionId.ToString());
			
			this.FileSystemManager = fileSystemManager;

            this.ReadStream = RawReadStream;
			this.WriteStream = RawWriteStream;

			System.Reflection.AssemblyName name;

			name = GetType().Assembly.GetName();

			WriteTextBlock("NETVFS {0}.{1}", name.Version.Major, name.Version.Minor);
			
			this.binaryReadContext = new DeterministicBinaryReadContext(this);
		}
Esempio n. 45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PgpNodeProvider"/> class.
 /// </summary>
 /// <param name="manager">The manager.</param>
 public PgpNodeProvider(IFileSystemManager manager)
     : base(manager)
 {
 }
Esempio n. 46
0
 /// <summary>
 /// Тест-конструктор с иньекцией тестового mock объекта IFileSystemManager
 /// </summary>
 /// <param name="manager">IFileSystemManager объект</param>
 public SyncFilesPair(IFileSystemManager manager)
 {
     // инициализируем класс менеджера файловой системы:
     _manager = manager;
 }
Esempio n. 47
0
        private static void SyncTransactionWithBackup(IFileSystemManager manager, SyncFile nonActualFile, SyncFile actualFile, string backupDirPath)
        {
            // в самом начале делаем бекап неактуального файла в директории с исполняемым файлом
            manager.CopyFile(nonActualFile.FullPath,
                String.Format("{3}\\{0}[{1:yyyy-MM-dd HH-mm-ss}]{2}",  //AppDomain.CurrentDomain.BaseDirectory +
                Path.GetFileNameWithoutExtension(nonActualFile.FullPath),
                SystemTime.Now(), Path.GetExtension(nonActualFile.FullPath), backupDirPath));

            SyncTransaction(manager, nonActualFile, actualFile);
        }
		public SystemInfoNodeProvider(IFileSystemManager manager, ConstructionOptions options)
			: this(manager, options.Scheme.IsNullOrEmpty() ? "systeminfo" : options.Scheme)
		{
			var root = (ImaginaryDirectory)this.ImaginaryFileSystem.RootDirectory;
						
			var systemClockDirectory = (ImaginaryDirectory)root.ResolveDirectory("SystemClock").Create();
			ImaginaryDirectory environmentVariablesDirectory = new EnvironmentVariablesDirectory(this.ImaginaryFileSystem, root.Address.ResolveAddress("EnvironmentVariables"));

			root.Add(systemClockDirectory);
			root.Add(environmentVariablesDirectory);
			
			var dateTimeFile = new ImaginaryMemoryFile
			(
				this.ImaginaryFileSystem,
				systemClockDirectory.Address.ResolveAddress("./CurrentDateTime"),
				delegate
				{
					return Encoding.ASCII.GetBytes(DateTime.Now.ToUniversalTime().ToString(DateTimeFormats.SortableUtcDateTimeFormatWithFractionSecondsString) + Environment.NewLine);
				},
				PredicateUtils<ImaginaryMemoryFile>.AlwaysTrue
			);

			dateTimeFile.Changed += delegate
			{
				string s;
				TimeSpan timeSpan;
				DateTime dateTime;

				s = Encoding.ASCII.GetString(dateTimeFile.RawNonDynamicValue);

				s = s.Trim(c => Char.IsWhiteSpace(c) || c == '\r' || c == '\n' || c == '\t');

				if (TimeSpan.TryParse(s, out timeSpan))
				{
					dateTime = DateTime.Now;

					dateTime += timeSpan;
				}
				else
				{
					try
					{
						dateTime = DateTime.ParseExact(s, DateTimeFormats.SortableUtcDateTimeFormatWithFractionSecondsString, CultureInfo.InvariantCulture);

						dateTime = DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
						dateTime = dateTime.ToLocalTime();
					}
					catch (FormatException e)
					{
						Console.Error.WriteLine(e);

						return;
					}
				}

				EnvironmentUtils.SetSystemTime(dateTime);
			};

			systemClockDirectory.Add(dateTimeFile);

			var utcDateTimeFile = new ImaginaryMemoryFile
			(
				this.ImaginaryFileSystem,
				systemClockDirectory.Address.ResolveAddress("./CurrentUtcDateTime"),
				delegate
				{
					return Encoding.ASCII.GetBytes(DateTime.Now.ToUniversalTime().ToString(DateTimeFormats.SortableUtcDateTimeFormatWithFractionSecondsString) + "\n");
				},
				PredicateUtils<ImaginaryMemoryFile>.AlwaysTrue
			);

			utcDateTimeFile.Changed += delegate
			{
				TimeSpan timeSpan;
				DateTime dateTime;

				var s = Encoding.ASCII.GetString(utcDateTimeFile.RawNonDynamicValue);

				s = s.Trim(c => Char.IsWhiteSpace(c) || c == '\r' || c == '\n' || c == '\t');

				if (TimeSpan.TryParse(s, out timeSpan))
				{
					dateTime = DateTime.Now;

					dateTime += timeSpan;
				}
				else
				{
					try
					{
						dateTime = DateTime.ParseExact(s, DateTimeFormats.SortableUtcDateTimeFormatWithFractionSecondsString, CultureInfo.InvariantCulture);

						dateTime = DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
					}
					catch (FormatException e)
					{
						Console.Error.WriteLine(e);

						return;
					}
				}

				EnvironmentUtils.SetSystemTime(dateTime);
			};

			systemClockDirectory.Add(utcDateTimeFile);
			
			var localDateTimeFile = new ImaginaryMemoryFile
			(
				this.ImaginaryFileSystem,
				systemClockDirectory.Address.ResolveAddress("./CurrentLocalDateTime"),
				delegate
				{
					return Encoding.ASCII.GetBytes(DateTime.Now.ToString(DateTimeFormats.SortableUtcDateTimeFormatWithFractionSecondsString) + Environment.NewLine);
				},
				PredicateUtils<ImaginaryMemoryFile>.AlwaysTrue
			);

			localDateTimeFile.Changed += delegate
			{
				TimeSpan timeSpan;
				DateTime dateTime;

				var s = Encoding.ASCII.GetString(localDateTimeFile.RawNonDynamicValue);

				s = s.Trim(c => Char.IsWhiteSpace(c) || c == '\r' || c == '\n' || c == '\t');

				if (TimeSpan.TryParse(s, out timeSpan))
				{
					dateTime = DateTime.Now;

					dateTime += timeSpan;
				}
				else
				{
					try
					{
						dateTime = DateTime.ParseExact(s, DateTimeFormats.SortableUtcDateTimeFormatWithFractionSecondsString, CultureInfo.InvariantCulture);

						dateTime = DateTime.SpecifyKind(dateTime, DateTimeKind.Local);
					}
					catch (FormatException e)
					{
						Console.Error.WriteLine(e);

						return;
					}
				}

				EnvironmentUtils.SetSystemTime(dateTime);
			};

			systemClockDirectory.Add(localDateTimeFile);
		}
		public SystemInfoNodeProvider(IFileSystemManager manager)
			: this(manager, new ConstructionOptions("systeminfo"))
		{
		}
		public TempNodeProvider(IFileSystemManager manager, Configuration options)
			: base(manager, options)
		{
		}
		public TempNodeProvider(IFileSystemManager manager, string scheme, IDirectory root)
			: base(manager, scheme, root)
		{
		}
 public MigrateDatabaseStep(DeployParameters parameters, IFileSystemManager fileSystemManager, IDeployLogger logger)
     : base(parameters, "Migrate database", logger)
 {
     _fileSystemManager = fileSystemManager;
 }
Esempio n. 53
0
        private static void SyncTransaction(IFileSystemManager manager, SyncFile nonActualFile, SyncFile actualFile)
        {
            // потом удаляем забекапленный неактуальный файл
            manager.DeleteFile(nonActualFile.FullPath);

            // и создаем новый файл как копию актуального на месте удаленного неактуального
            manager.CopyFile(actualFile.FullPath, nonActualFile.FullPath);
        }
		public SystemInfoNodeProvider(IFileSystemManager manager, string scheme)
			: base(manager, scheme)
		{			
		}
		public TempNodeProvider(IFileSystemManager manager)
			: base(manager, "temp", manager.ResolveDirectory(Path.GetTempPath()).Create(true))
		{
		}
Esempio n. 56
0
 public DeployFilesStep(IFileSystemManager fileSystemManager, DeployParameters parameters, IDeployLogger logger)
     : base(parameters, "Deploy files", logger)
 {
     _fileSystemManager = fileSystemManager;
 }
		public TempNodeProvider(IFileSystemManager manager, string scheme, IDirectory root, FileSystemOptions options)
			: base(manager, scheme, root, options)
		{
		}
		public LocalNodeProvider(IFileSystemManager manager)
			: this(manager, new Configuration())
		{
		}
		public OverlayedNodeProvider(IFileSystemManager manager)
			: base(manager)
		{
		}
		public LocalNodeProvider(IFileSystemManager manager, Configuration config)
			: base(manager)
		{
			this.configuration = config;
		}