Beispiel #1
0
        public void SaveToFile(SystemContext obj, string filePath)
        {
            IFileWriter          fileWriter    = FileWriterFactory.CreateFileWriter();
            IObjectContentReader contentReader = ObjectContentReaderFactory.Instance.CreateSystemContextContentReader();

            ObjectPersistorService.Instance.SaveToFile(obj, fileWriter, contentReader, filePath);
        }
        public void SaveToFile(ISequenceCache obj, string filePath)
        {
            IFileWriter          fileWriter    = FileWriterFactory.CreateBinaryFileWriter();
            IObjectContentReader contentReader = ObjectContentReaderFactory.Instance.CreateSequenceCacheContentReader(filePath);

            ObjectPersistorService.Instance.SaveToFile(obj, fileWriter, contentReader, filePath);
        }
        public void SaveToFile(ElementNodeTemplate obj, string filePath)
        {
            IFileWriter          fileWriter    = FileWriterFactory.CreateFileWriter();
            IObjectContentReader contentReader = ObjectContentReaderFactory.Instance.CreateElementNodeTemplateContentReader();

            ObjectPersistorService.Instance.SaveToFile(obj, fileWriter, contentReader, filePath);
        }
Beispiel #4
0
        public void Save_CreateEmptyBookWithFileWriterInCaseOfCustomBasePath_Success()
        {
            var book = new XMindConfiguration()
                       .WriteTo.Writers(
                new List <IXMindWriter> {
                new FileWriter()
                .SetOutput(new FileWriterOutputConfig(_files[0])
                           .SetBasePath(Path.Combine(_customOutputFolderName, "META-INF"))),
                new FileWriter()
                .SetOutput(new FileWriterOutputConfig(_files[1]).SetBasePath(_customOutputFolderName)),
                new FileWriter()
                .SetOutput(new FileWriterOutputConfig(_files[2]).SetBasePath(_customOutputFolderName))
            })
                       .WriteTo.SetWriterBinding(FileWriterFactory.CreateStandardResolvers())
                       .CreateWorkBook(workbookName: "test");

            //Act
            book.Save();
            //Assert
            DirectoryInfo di = new DirectoryInfo(_customOutputFolderName);

            di.GetFileSystemInfos("*.xml")
            .Select(fi => fi.Should().BeOfType <FileInfo>().Which.Name.Should().BeOneOf(_files))
            .All(x => true);
        }
Beispiel #5
0
        /// <summary>
        /// Writes a DataTable to a CSV file specified by the path
        /// </summary>
        /// <param name="dataTable">The datatable to write</param>
        /// <param name="filePath">The location of the CSV to create</param>
        /// <param name="settings">Optional csv settings</param>
        public static void ToCsv(this DataTable dataTable, string filePath, ToCsvSettings settings = null)
        {
            settings = settings ?? new ToCsvSettings();

            using (IFileWriter fileWriter = FileWriterFactory.GetFileWriter(filePath, settings.Compression))
            {
                fileWriter.Write(dataTable.ToCsv(settings));
            }
        }
Beispiel #6
0
        static int Main(string[] args)
        {
            var result = 0;

            //args = new[] { "compress", @"D:\Data\data.dat", @"d:\Data\data.dat.compressed" };
            //args = new[] { "decompress", @"D:\Data\data.dat.compressed", @"D:\Data\data.dat.decompressed"};
            //args = new[] { "compress", @"D:\Data\data.dat.small", @"D:\Data\data.dat.small.compressed" };
            //args = new[] { "decompress", @"D:\Data\data.dat.small.compressed", @"D:\Data\data.dat.small.decompressed" };

            try
            {
                var startParams = ParseCommandLine(args);

                var readerFactory = new FileReaderFactory(startParams.SrcFilePath);
                var writerFactory = new FileWriterFactory(startParams.DstFilePath);

                IDataDispatcher dispatcher;

                if (startParams.Compress)
                {
                    var readThreadsCount  = Math.Max(1, Environment.ProcessorCount / 4);
                    var writeThreadsCount = Math.Max(1, Environment.ProcessorCount - readThreadsCount);
                    dispatcher = new CompressDataDispatcher(readerFactory, writerFactory, readThreadsCount, writeThreadsCount);
                }
                else
                {
                    var writeThreadsCount = Math.Max(1, Environment.ProcessorCount / 4);
                    var readThreadsCount  = Math.Max(1, Environment.ProcessorCount - writeThreadsCount);
                    dispatcher = new DecompressDataDispatcher(readerFactory, writerFactory, readThreadsCount, writeThreadsCount);
                }

                Stopwatch stopwatch = Stopwatch.StartNew();

                dispatcher.Start();
                var exception = dispatcher.WaitForCompletion();
                stopwatch.Stop();

                Console.WriteLine($"Time elapsed: {stopwatch.ElapsedMilliseconds}");

                if (exception != null)
                {
                    throw exception;
                }
            }
            catch (Exception ex)
            {
                PrintException(ex);
                result = 1;
            }

            //Console.ReadKey();

            return(result);
        }
Beispiel #7
0
        public void SaveToFile(ModuleStore obj, string filePath)
        {
            IFileWriter          fileWriter    = FileWriterFactory.CreateFileWriter();
            IObjectContentReader contentReader = ObjectContentReaderFactory.Instance.CreateModuleStoreContentReader();

            ObjectPersistorService.Instance.SaveToFile(obj, fileWriter, contentReader, filePath);

            if (obj != null)
            {
                obj.LoadedFilePath = filePath;
            }
        }
        public static XMindConfiguration WithFileWriter(
            this XMindConfiguration config,
            string?basePath = default,
            bool zip        = false)
        {
            var result = config
                         .WriteTo.Writers(FileWriterFactory.CreateStandardWriters(basePath))
                         .WriteTo.SetWriterBinding(FileWriterFactory.CreateStandardResolvers());

            if (zip)
            {
                result.WriteTo.SetFinalizeAction(CreateZipXMindFolderCallback(basePath));
            }
            return(result);
        }
        public static XMindConfiguration SetUpXMindWithFileWriter(
            this XMindConfiguration config,
            bool defaultSettings = true,
            bool zip             = false)
        {
            var standardWriters = new List <FileWriterStandardOutput> {
                FileWriterStandardOutput.Manifest,
                FileWriterStandardOutput.Meta,
                FileWriterStandardOutput.Content
            };
            var result = config.WriteTo.Writers(FileWriterFactory.CreateWriters(standardWriters))
                         .WriteTo.SetWriterBinding(FileWriterFactory.CreateResolvers(standardWriters));

            if (zip)
            {
                result.WriteTo.SetFinalizeAction(FileWriterUtils.ZipXMindFolder("build.xmind"));
            }
            return(result);
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            var input = File.ReadAllText(@"ExampleFiles\mock_data.csv");

            Console.WriteLine("What is the name of the output file?");
            var fileName = Console.ReadLine();

            var fileType = DetermineFileType(fileName);

            if (fileType != OutputFileType.Unknown)
            {
                var writer  = new FileWriterFactory().CreateWriter(fileType);
                var parser  = new CsvFileReader();
                var records = parser.RetrieveRecords(input);
                writer.WriteFile(fileName, records);
            }
            else
            {
                DisplayErrorScreen(fileName);
            }
        }