public PostCodeManager(string filePath, string fileName) { ITextFileSource source = new TextFileSource { FilePath = filePath, FileName = fileName }; PostCodeEntitys = _parseResult.Parse((TextFileSource)source); }
public void PostCode() { PostCodeTextFileParser <TextFileSource, PostCodeEntity> test = new PostCodeTextFileParser <TextFileSource, PostCodeEntity>(); ITextFileSource source = new TextFileSource { FilePath = @"Z:\", FileName = "kody.csv" }; test.Parse((TextFileSource)source); }
static void Main(string[] args) { ShowGreeting(); Console.Clear(); List <ISource> Sources = new List <ISource>(); HardcodedSource L1 = new HardcodedSource(); { L1.AddBook("Time Machine ", "H. G. Wells"); L1.AddBook("Brave New World ", "A. Huxley"); L1.AddBook("The Air Seller ", "A. Beliaev"); L1.AddBook("Ariel ", "A. Beliaev"); L1.AddBook("Montezuma's Dauter", "H. R. Haggard"); L1.AddBook("Around the Moon", "J. G. Verne"); L1.AddVisitor("Maxim Nesterov"); L1.AddVisitor("Mihail Yahlakov"); L1.AddVisitor("Boris Stepanov"); L1.AddIssue(0, 0, DateTime.Today.AddMonths(-10)); L1.AddIssue(0, 4, DateTime.Today); L1.AddIssue(1, 3, DateTime.Today.AddMonths(-2)); L1.Ready = true; } Sources.Add(L1); HardcodedSource L2 = new HardcodedSource(); { L2.AddBook("War and Peace ", "L. Tolstoy"); L2.AddBook("Children's Book ", "B. Akunin"); L2.AddBook("We ", "E. Zamyatin"); L2.AddBook("A Scandal in Bohemia", "A. C. Doyle"); L2.AddBook("Harry Potter Series", "J. K. Rowling"); L2.AddBook("Amphibian Man ", "A. Beliaev"); L2.AddVisitor("Maxim Nesterov"); L2.AddVisitor("Mihail Yahlakov"); L2.AddVisitor("Boris Stepanov"); L2.AddIssue(0, 2, System.DateTime.Today); L2.AddIssue(1, 3, System.DateTime.Today); L2.AddIssue(2, 1, System.DateTime.Today.AddMonths(-5)); L2.Ready = true; } Sources.Add(L2); Console.WriteLine("Type path for textfile source(or leave empty for 1.txt):"); string path = Console.ReadLine(); TextFileSource F1 = new TextFileSource(path.Length == 0 ? "1.txt" : path); Sources.Add(F1); LibraryModel Lib1 = new LibraryModel(); Controller Cntr1 = new Controller(ref Lib1); Viewer LibViewer = new Viewer(ref Cntr1, Sources); Cntr1.RegisterView(ref LibViewer); LibViewer.StartModel(); }
public void CodeRender() { PostCodeTextFileParser <TextFileSource, PostCodeEntity> test = new PostCodeTextFileParser <TextFileSource, PostCodeEntity>(); ITextFileSource source = new TextFileSource { FilePath = @"Z:\", FileName = "kody.csv" }; var postcodeEntities = test.Parse((TextFileSource)source); CodeRenderer <ConstCodeSnippet, PostCodeEntity> renderer = new PostCodeRenderer <ConstCodeSnippet, PostCodeEntity>(); ConstCodeSnippet snippet = new ConstCodeSnippet(); foreach (var item in postcodeEntities) { ICodeFragment fragment = renderer.CreateCodeFragment(item, snippet); } }
private static void Main(string[] args) { if (args == null || args.Length == 0 || (args.Length != 4 && args.Length != 5) || args.Any(string.IsNullOrEmpty)) { PrintUsage(); return; } var operation = args[0]?.Replace("-", string.Empty).ToUpperInvariant(); if (string.IsNullOrEmpty(operation)) { PrintUsage(); return; } var outToConsole = args.Length == 4; ISource source = null, target1 = null, target2 = null; switch (Array.IndexOf(m_operations, operation)) { case 0: source = new StringSource(args[1]); target1 = new StringSource(args[2]); target2 = new StringSource(args[3]); break; case 1: try { source = new TextFileSource(args[1]); target1 = new TextFileSource(args[2]); target2 = new TextFileSource(args[3]); } catch (Exception ex) { Console.WriteLine("Во время загрузки файлов произошла ошибка:"); Console.WriteLine(ex.Message); PrintUsage(); return; } break; default: PrintUsage(); break; } var diffEngine = new MyersDiffEngine(); var operations1 = diffEngine.GetDiff(source, target1); var operations2 = diffEngine.GetDiff(source, target2); var mergeEngine = new MergeEngine(ResolveStrategyAction.AcceptFirst, false); mergeEngine.ConflictOperationsResolveStrategies.Add(OperationKind.Insert, new ResolveStrategy(ResolveStrategyAction.AcceptAll, true)); var final = mergeEngine.GetMergeOperations(operations1.ToList(), operations2.ToList()); Console.WriteLine("Эталон: {0}", source); Console.WriteLine("Первый элемент: {0}", target1); Console.WriteLine("Второй элемент: {0}", target2); var sb = new StringBuilder(); foreach (var op in final) { switch (op.Kind) { case OperationKind.Equal: case OperationKind.Insert: default: sb.AppendFormat("{0}{1}", op.IsConflict ? " Конфликт! >" : string.Empty, op.Source[op.Index]); break; case OperationKind.Unknown: case OperationKind.Delete: break; } } Console.WriteLine(); Console.WriteLine("---РЕЗУЛЬТАТ---"); if (outToConsole) { Console.WriteLine(sb.ToString()); } else { try { using (var wrtr = new StreamWriter(args[4])) { wrtr.Write(sb.ToString()); wrtr.Close(); } Console.WriteLine("Изменения записаны в файл {0}", args[4]); } catch (Exception ex) { Console.WriteLine("Во время записи результата в файл произошла ошибка:"); Console.WriteLine(ex.Message); PrintUsage(); return; } } Console.WriteLine(); Console.WriteLine("Нажмите <Enter> для завершения работы..."); Console.ReadLine(); }