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

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

            return(snapshotFile);
        }
示例#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);
            }
示例#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");
        }
示例#6
0
文件: PathTest.cs 项目: xubinvc/Catel
        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");
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#12
0
        public static string GetRootDirectory()
        {
            var directory = Path.GetApplicationDataDirectory();

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

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

            return(directory);
        }
示例#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");
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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);
                }
            }
        }
示例#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);
        }
示例#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);
        }
示例#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();
        }
示例#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>();
        }
示例#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))
            {
            }
        }
示例#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));
        }
        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);
        }
示例#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);
        }