Skip to content

Commit

Permalink
#1 TextAnalyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinacupac committed Jun 13, 2020
1 parent 511d53a commit ad67c1a
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 108 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
using TextAnalyzer.Web.ConsoleClient.Interface;
using TextAnalyzer.Web.ConsoleClient.Readers;

namespace TextAnalyzer.Web.ConsoleClient.Factories
{
public class ConsoleDatabaseReaderFactory : IReaderFactory
{
public IReader Create()
{
Console.WriteLine("Database Connection String: ");

var connectionString = Console.ReadLine();

Console.WriteLine("Document Name: ");

var documentName = Console.ReadLine();

return new DatabaseReader(connectionString, documentName);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using TextAnalyzer.Web.ConsoleClient.Interface;
using TextAnalyzer.Web.ConsoleClient.Readers;

namespace TextAnalyzer.Web.ConsoleClient.Factories
{
public class ConsoleFileReaderFactory : IReaderFactory
{
public IReader Create()
{
Console.WriteLine("Document File Path: ");

var filePath = Console.ReadLine();

return new FileReader(filePath);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
using TextAnalyzer.Web.ConsoleClient.Interface;
using TextAnalyzer.Web.ConsoleClient.Readers;

namespace TextAnalyzer.Web.ConsoleClient.Factories
{
public class ConsoleInputReaderFactory : IReaderFactory
{
public IReader Create()
{
Console.WriteLine("Document Name: ");

var name = Console.ReadLine();

Console.WriteLine("Document Text: ");

var text = Console.ReadLine();

return new InputReader(name, text);
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace TextAnalyzer.Web.ConsoleClient
{
public interface IReader : IDisposable
public interface IReader
{
Document Read();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace TextAnalyzer.Web.ConsoleClient.Interface
{
public interface IReaderFactory
{
IReader Create(ReaderType readerType);
IReader Create();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace TextAnalyzer.Web.ConsoleClient.Readers
{
public class DatabaseReader : IReader
{
private const string DefaultDocumentTableName = "Documents";
private const string DefaultDocumentNameField = "Name";
private const string DefaultDocumentTextField = "Text";

public DatabaseReader(string connectionString,
string documentName,
string documentTableName = DefaultDocumentTableName,
string documentNameField = DefaultDocumentNameField,
string documentTextField = DefaultDocumentTextField)
{
ConnectionString = connectionString;
DocumentName = documentName;
DocumentTableName = documentTableName;
DocumentNameField = documentNameField;
DocumentTextField = documentTextField;
}

public string ConnectionString { get; }

public string DocumentName { get; }

public string DocumentTableName { get; }

public string DocumentNameField { get; }

public string DocumentTextField { get; }

public Document Read()
{
// TODO: Create DB connection read, close DB connection

throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ namespace TextAnalyzer.Web.ConsoleClient.Readers
{
public class FileReader : IReader
{
private bool _disposedValue = false;

public FileReader(string filePath)
{
FilePath = filePath;
Expand All @@ -23,23 +21,5 @@ public Document Read()

return new Document(name, text);
}

public void Dispose()
{
Dispose(true);
}

protected virtual void Dispose(bool disposing)
{
if (!_disposedValue)
{
if (disposing)
{
// TODO: dispose managed state (managed objects).
}

_disposedValue = true;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace TextAnalyzer.Web.ConsoleClient.Readers
{
public class InputReader : IReader
{
public InputReader(string name, string text)
{
Name = name;
Text = text;
}

public string Name { get; }

public string Text { get; }

public Document Read()
{
return new Document(Name, Text);
}
}
}

0 comments on commit ad67c1a

Please sign in to comment.