diff --git a/core/encoding/cyrillic-to-latin/cs/Common/Common.cs b/core/encoding/cyrillic-to-latin/cs/Common/Common.cs new file mode 100644 index 00000000000..511ca3c3107 --- /dev/null +++ b/core/encoding/cyrillic-to-latin/cs/Common/Common.cs @@ -0,0 +1,15 @@ +using System; +namespace CyrillicToLatin.Common +{ + public static class Common + { + public const string NoSourceOrDestinationFile = "There must be a source and a destination file."; + + public const string FileDoesntExist = "The source file does not exist."; + + public const string WrongDirectory = "Invalid directory: {0}"; + + public const string WrongIO = "I/O exception: {0}"; + } +} + diff --git a/core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs b/core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs index 66864c65c49..a1b2cd71bf4 100644 --- a/core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs +++ b/core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs @@ -1,6 +1,9 @@ using System; using System.IO; +using System.Security.AccessControl; using System.Text; +using CyrillicToLatin.Common; + class ConsoleModule { @@ -9,9 +12,9 @@ static void Main() string[] args = Environment.GetCommandLineArgs(); // Get command line arguments. - if (args.Length != 3 || String.IsNullOrWhiteSpace(args[1]) || String.IsNullOrWhiteSpace(args[2])) + if (args.Length != 3 || string.IsNullOrWhiteSpace(args[1]) || string.IsNullOrWhiteSpace(args[2])) { - Console.WriteLine("There must be a source and a destination file."); + Console.WriteLine(Common.NoSourceOrDestinationFile); ShowSyntax(); return; } @@ -21,7 +24,7 @@ static void Main() if (!File.Exists(source)) { - Console.WriteLine("The source file does not exist."); + Console.WriteLine(Common.NoSourceOrDestinationFile); return; } @@ -74,12 +77,12 @@ static void Main() } catch (DirectoryNotFoundException e) { - Console.WriteLine($"Invalid directory: {e.Message}"); + Console.WriteLine(Common.WrongDirectory); return; } catch (IOException e) { - Console.WriteLine($"I/O exception: {e.Message}"); + Console.WriteLine(Common.WrongIO); return; } } diff --git a/core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.csproj b/core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.csproj index a4fb324cffe..92301346999 100644 --- a/core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.csproj +++ b/core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.csproj @@ -9,4 +9,10 @@ + + + + + + diff --git a/core/encoding/cyrillic-to-latin/cs/CyrillicToLatinFallback.cs b/core/encoding/cyrillic-to-latin/cs/CyrillicToLatinFallback.cs index 8fdee54dea8..c0d09e321c6 100644 --- a/core/encoding/cyrillic-to-latin/cs/CyrillicToLatinFallback.cs +++ b/core/encoding/cyrillic-to-latin/cs/CyrillicToLatinFallback.cs @@ -5,11 +5,11 @@ class CyrillicToLatinFallback : EncoderFallback { - private Dictionary table; + private Dictionary table; public CyrillicToLatinFallback() { - table = new Dictionary(); + table = new Dictionary(); // Define mappings. // Uppercase modern Cyrillic characters. table.Add('\u0410', "A"); @@ -92,12 +92,12 @@ public override int MaxCharCount public class CyrillicToLatinFallbackBuffer : EncoderFallbackBuffer { - private Dictionary table; + private Dictionary table; private int bufferIndex; private string buffer; private int leftToReturn; - internal CyrillicToLatinFallbackBuffer(Dictionary table) + internal CyrillicToLatinFallbackBuffer(Dictionary table) { this.table = table; this.bufferIndex = -1; @@ -153,4 +153,4 @@ public override int Remaining { get { return leftToReturn; } } -} +} \ No newline at end of file diff --git a/csharp/classes-quickstart/BankAccount.cs b/csharp/classes-quickstart/BankAccount.cs index 6385c069d07..01ae6e84e36 100644 --- a/csharp/classes-quickstart/BankAccount.cs +++ b/csharp/classes-quickstart/BankAccount.cs @@ -1,11 +1,12 @@ using System; using System.Collections.Generic; +using classes.Contracts; namespace classes { - public class BankAccount + public class BankAccount : IBank { - public string Number { get; } + public string Number { get; set; } public string Owner { get; set; } #region BalanceComputation public decimal Balance @@ -21,6 +22,7 @@ public decimal Balance return balance; } } + #endregion private static int accountNumberSeed = 1234567890; @@ -36,7 +38,8 @@ public BankAccount(string name, decimal initialBalance) #endregion #region TransactionDeclaration - private List allTransactions = new List(); + + private List allTransactions = new List(); #endregion #region DepositAndWithdrawal @@ -82,4 +85,4 @@ public string GetAccountHistory() } #endregion } -} +} \ No newline at end of file diff --git a/csharp/classes-quickstart/Contracts/IBank.cs b/csharp/classes-quickstart/Contracts/IBank.cs new file mode 100644 index 00000000000..ac1bcd4995a --- /dev/null +++ b/csharp/classes-quickstart/Contracts/IBank.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; + +namespace classes.Contracts +{ + public interface IBank + { + public string Number { get; } + + public string Owner { get; } + + public decimal Balance { get; } + } +} \ No newline at end of file diff --git a/csharp/classes-quickstart/Contracts/ITransaction.cs b/csharp/classes-quickstart/Contracts/ITransaction.cs new file mode 100644 index 00000000000..02c4d382a44 --- /dev/null +++ b/csharp/classes-quickstart/Contracts/ITransaction.cs @@ -0,0 +1,12 @@ +using System; +namespace classes.Contracts +{ + public interface ITransaction + { + public decimal Amount { get; } + + public DateTime Date { get; } + + public string Notes { get; } + } +} \ No newline at end of file diff --git a/csharp/classes-quickstart/classes.csproj b/csharp/classes-quickstart/classes.csproj index 120e38c3150..5c938e63a4c 100644 --- a/csharp/classes-quickstart/classes.csproj +++ b/csharp/classes-quickstart/classes.csproj @@ -5,4 +5,10 @@ net7.0 + + + + + + diff --git a/csharp/classes-quickstart/transaction.cs b/csharp/classes-quickstart/transaction.cs index 198418c62dd..ca256132329 100644 --- a/csharp/classes-quickstart/transaction.cs +++ b/csharp/classes-quickstart/transaction.cs @@ -1,12 +1,13 @@ using System; +using classes.Contracts; namespace classes { - public class Transaction + public class Transaction : ITransaction { - public decimal Amount { get; } + public decimal Amount { get; set; } public DateTime Date { get; } - public string Notes { get; } + public string Notes { get; set; } public Transaction(decimal amount, DateTime date, string note) { @@ -15,4 +16,4 @@ public Transaction(decimal amount, DateTime date, string note) this.Notes = note; } } -} +} \ No newline at end of file