protected virtual string GetSnapshotFileName(string directory, ISnapshot snapshot)
        {
            Argument.IsNotNull(() => snapshot);

            var snapshotFile = Path.Combine(directory, $"{snapshot.Title.GetSlug()}{SnapshotExtension}");

            return(snapshotFile);
        }
Esempio n. 2
0
        public void CombinePath_NoValues()
        {
            // Call method
            string result = Path.Combine();

            // Validate
            Assert.AreEqual(@"", result);
        }
            private string GetExampleFileName(string relativeFileName)
            {
                var rootDirectory = AssemblyDirectoryHelper.GetCurrentDirectory();

                var path = Path.Combine(rootDirectory, "Models", relativeFileName);

                return(path);
            }
Esempio n. 4
0
        public void GetApplicationDataDirectory_CompanyAndApp()
        {
            string expected = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                           Assembly.GetExecutingAssembly().Company(), Assembly.GetExecutingAssembly().Product());

            string result = Path.GetApplicationDataDirectory(Assembly.GetExecutingAssembly().Company(), Assembly.GetExecutingAssembly().Product());

            Assert.AreEqual(expected, result);
        }
        public KeyboardMappingsService(ICommandManager commandManager, IXmlSerializer xmlSerializer)
        {
            Argument.IsNotNull(() => commandManager);
            Argument.IsNotNull(() => xmlSerializer);

            _commandManager = commandManager;
            _xmlSerializer  = xmlSerializer;
            _fileName       = Path.Combine(Path.GetApplicationDataDirectory(), "keyboardmappings.xml");
        }
Esempio n. 6
0
        public void GetApplicationDataDirectoryForAllUsers_AppOnly()
        {
            string expected = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
                                           Assembly.GetExecutingAssembly().Product());

            string result = Path.GetApplicationDataDirectoryForAllUsers(Assembly.GetExecutingAssembly().Product());

            Assert.AreEqual(expected, result);
        }
        public FileSystemSnapshotStorageService(IDirectoryService directoryService, IFileService fileService)
        {
            Argument.IsNotNull(() => directoryService);
            Argument.IsNotNull(() => fileService);

            _directoryService = directoryService;
            _fileService      = fileService;

            Directory = Path.Combine(Path.GetApplicationDataDirectory(), "snapshots");
        }
Esempio n. 8
0
        private static string GetLogDirectory()
        {
            var appDataService = ServiceLocator.Default.ResolveType <IAppDataService>();

            var directory = Path.Combine(appDataService.GetApplicationDataDirectory(Catel.IO.ApplicationDataTarget.UserRoaming), "log");

            Directory.CreateDirectory(directory);

            return(directory);
        }
Esempio n. 9
0
        public void CombinePath_1Value()
        {
            // Declare variables
            string path1 = @"C:\Windows";

            // Call method
            string result = Path.Combine(path1);

            // Validate
            Assert.AreEqual(@"C:\Windows", result);
        }
Esempio n. 10
0
        public void CombinePath_OneNullValue()
        {
            // Declare variables
            string path1 = @"C:\";
            string path2 = null;
            string path3 = @"Program Files";

            // Call method
            string result = Path.Combine(path1, path2, path3);

            // Validate
            Assert.AreEqual(@"C:\Program Files", result);
        }
Esempio n. 11
0
        public void Initialize()
        {
            // Determine test directory
            _testDirectory = Path.Combine(System.IO.Path.GetTempPath(), "PathTest");

            // Delete directory, than create it
            if (Directory.Exists(_testDirectory))
            {
                Directory.Delete(_testDirectory, true);
            }

            Directory.CreateDirectory(_testDirectory);
        }
Esempio n. 12
0
        public static string GetRootDirectory()
        {
            var directory = Path.GetApplicationDataDirectory();

            directory = Path.Combine(directory, "search");

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            return(directory);
        }
Esempio n. 13
0
        public RecentlyUsedItemsService(IXmlSerializer xmlSerializer)
        {
            Argument.IsNotNull(() => xmlSerializer);

            _xmlSerializer = xmlSerializer;

            _fileName = Path.Combine(Path.GetApplicationDataDirectory(), "recentlyused.xml");
            _items    = new RecentlyUsedItems();

            MaximumItemCount = 10;

            Load();
        }
        public FileSystemSnapshotStorageService(IDirectoryService directoryService, IFileService fileService,
                                                IAppDataService appDataService)
        {
            Argument.IsNotNull(() => directoryService);
            Argument.IsNotNull(() => fileService);
            Argument.IsNotNull(() => appDataService);

            _directoryService = directoryService;
            _fileService      = fileService;
            _appDataService   = appDataService;

            Directory = Path.Combine(_appDataService.GetApplicationDataDirectory(Catel.IO.ApplicationDataTarget.UserRoaming), "snapshots");
        }
Esempio n. 15
0
        public void CombinePath_3Values()
        {
            // Declare variables
            string path1 = @"C:\";
            string path2 = @"Windows";
            string path3 = @"System";

            // Call method
            string result = Path.Combine(path1, path2, path3);

            // Validate
            Assert.AreEqual(@"C:\Windows\System", result);
        }
Esempio n. 16
0
        public void CombinePath_EmptyValues()
        {
            // Declare variables
            string path1 = @"";
            string path2 = @"";
            string path3 = @"";

            // Call method
            string result = Path.Combine(path1, path2, path3);

            // Validate
            Assert.AreEqual(@"", result);
        }
Esempio n. 17
0
        private static string GetWindowStorageFile(this Window window)
        {
            Argument.IsNotNull(() => window);

            var appData   = Path.GetApplicationDataDirectory();
            var directory = Path.Combine(appData, "windows");

            Directory.CreateDirectory(directory);

            var file = Path.Combine(directory, $"{window.GetType().FullName}.dat");

            return(file);
        }
Esempio n. 18
0
        public static void CleanUpAllLogTypeFiles(bool keepCleanInRealTime = false)
        {
            var directory = Path.Combine(Path.GetApplicationDataDirectory(), "log");

            foreach (var prefix in LogFilePrefixes.All)
            {
                var filter = prefix + "*.log";
                CleanUpLogFiles(directory, filter);
                if (keepCleanInRealTime)
                {
                    ConfigureFileSystemWatcher(directory, filter);
                }
            }
        }
Esempio n. 19
0
        public static ILogListener CreateFileLogListener(string prefix)
        {
            Argument.IsNotNull(() => prefix);

            var directory = GetLogDirectory();

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            var fileName        = Path.Combine(directory, prefix + "_{Date}_{Time}_{ProcessId}");
            var fileLogListener = new Orchestra.Logging.FileLogListener(fileName, 10 * 1024);

            return(fileLogListener);
        }
Esempio n. 20
0
        public static ILogListener CreateFileLogListener(string prefix)
        {
            Argument.IsNotNull(() => prefix);

            var directory = Path.Combine(Path.GetApplicationDataDirectory(), "log");

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            var fileName        = Path.Combine(directory, prefix + "_{Date}_{Time}_{ProcessId}");
            var fileLogListener = new FileLogListener(fileName, 10 * 1024);

            return(fileLogListener);
        }
Esempio n. 21
0
        public RecentlyUsedItemsService(IXmlSerializer xmlSerializer, IFileService fileService, IAppDataService appDataService)
        {
            Argument.IsNotNull(() => xmlSerializer);
            Argument.IsNotNull(() => fileService);
            Argument.IsNotNull(() => appDataService);

            _xmlSerializer  = xmlSerializer;
            _fileService    = fileService;
            _appDataService = appDataService;

            _fileName = Path.Combine(appDataService.GetApplicationDataDirectory(Catel.IO.ApplicationDataTarget.UserRoaming), "recentlyused.xml");
            _items    = new RecentlyUsedItems();

            MaximumItemCount = 10;

            Load();
        }
Esempio n. 22
0
        public KeyboardMappingsService(ICommandManager commandManager, IXmlSerializer xmlSerializer,
                                       IFileService fileService, IAppDataService appDataService)
        {
            Argument.IsNotNull(() => commandManager);
            Argument.IsNotNull(() => xmlSerializer);
            Argument.IsNotNull(() => fileService);
            Argument.IsNotNull(() => appDataService);

            _commandManager = commandManager;
            _xmlSerializer  = xmlSerializer;
            _fileService    = fileService;
            _appDataService = appDataService;

            _fileName = Path.Combine(appDataService.GetApplicationDataDirectory(Catel.IO.ApplicationDataTarget.UserRoaming), "keyboardmappings.xml");

            AdditionalKeyboardMappings = new List <KeyboardMapping>();
        }
Esempio n. 23
0
        protected override void OnOperationFinished(object sender, PackageOperationEventArgs e)
        {
            if (e.PackageOperationType != PackageOperationType.Uninstall)
            {
                return;
            }

            if (!Directory.Exists(e.InstallPath))
            {
                return;
            }

            var fileName = $"{e.PackageDetails.Id}.deleteme";
            var fullName = Path.Combine(e.InstallPath, fileName);

            using (File.Create(fullName))
            {
            }
        }
Esempio n. 24
0
        public void GetApplicationDataDirectory_CompanyAndAppAndTestDirectoryCreation()
        {
            // Set up directory
            string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                            Assembly.GetExecutingAssembly().Company(), Assembly.GetExecutingAssembly().Product());

            // Make sure that the directory does not exist
            if (Directory.Exists(directory))
            {
                Directory.Delete(directory);
            }

            // Now create the directory
            string result = Path.GetApplicationDataDirectory(Assembly.GetExecutingAssembly().Company(), Assembly.GetExecutingAssembly().Product());

            // Check if the directory exists
            Assert.AreEqual(directory, result);
            Assert.IsTrue(Directory.Exists(result));
        }
Esempio n. 25
0
        private static string GetWindowStorageFile(this Window window, string tag)
        {
            Argument.IsNotNull(() => window);

            var appData   = Catel.IO.Path.GetApplicationDataDirectory();
            var directory = Path.Combine(appData, "windows");

            Directory.CreateDirectory(directory);

            var tagToUse = string.Empty;

            if (!string.IsNullOrWhiteSpace(tag))
            {
                tagToUse = $"_{tag.GetSlug()}";
            }

            var file = Path.Combine(directory, $"{window.GetType().FullName}{tagToUse}.dat");

            return(file);
        }
Esempio n. 26
0
        private static string GetWindowStorageFile(this Window window, string tag)
        {
            Argument.IsNotNull(() => window);

            var appDataService = ServiceLocator.Default.ResolveType <IAppDataService>();

            var appData   = appDataService.GetApplicationDataDirectory(Catel.IO.ApplicationDataTarget.UserRoaming);
            var directory = Path.Combine(appData, "windows");

            Directory.CreateDirectory(directory);

            var tagToUse = string.Empty;

            if (!string.IsNullOrWhiteSpace(tag))
            {
                tagToUse = $"_{tag.GetSlug()}";
            }

            var file = Path.Combine(directory, $"{window.GetType().FullName}{tagToUse}.dat");

            return(file);
        }