This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void ConcurrentDicTest() | |
| { | |
| ConcurrentDictionary<string, string> concurrDic = new ConcurrentDictionary<string, string>(); | |
| Task tsk1 = Task.Factory.StartNew(() => | |
| { | |
| for (int i = 0; i < 100; i++) | |
| { | |
| concurrDic.TryAdd(i.ToString(), (i + i).ToString()); | |
| Thread.Sleep(100); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class BookContext : DbContext // DbContext - ADOModel Generated by EF. | |
| { | |
| public BookContext() : base("DefaultConnection") | |
| { } | |
| public DbSet<Book> Books { get; set; } | |
| } | |
| interface IRepository<T> //: IDisposable where T : class | |
| { | |
| IEnumerable<T> GetBookList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static string GenerateNewWord(int minLength, int maxLength) | |
| { | |
| string wordNew = ""; | |
| int wordLength = r.Next(minLength, maxLength); | |
| for (int k = 0; k < wordLength; k++) | |
| { | |
| int charNew; | |
| charNew = (k == 0) ? r.Next(65, 90) : r.Next(97, 122); | |
| // (char)48..57 = 0-9 | |
| // (char)65..90 = A-Z |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class OuterHelperClass | |
| { | |
| public void HlprClaWork() | |
| { | |
| Console.WriteLine("Outer HelperClass Doing something..."); | |
| } | |
| } | |
| public class MyService | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MyService | |
| { | |
| public int _intVal; | |
| public MyService(int x) | |
| { | |
| _intVal = x; | |
| } | |
| [Dependency] | |
| public Random MyRnd { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.Practices.Unity; | |
| using Microsoft.Practices.Unity.Configuration; | |
| using System; | |
| using System.Configuration; | |
| // Classes Pursuit_Game & Maze_Game are : IGame | |
| public class Game_Box | |
| { | |
| private IGame _game; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void WorkWithRMQ(bool isReceiver) | |
| { | |
| string Exchange = "my.special"; | |
| string Queue = "my.special.outq2"; | |
| string RoutingKey = "my.special.outq2"; | |
| var factory = new ConnectionFactory() | |
| { | |
| HostName = "RabbitMQ.server", | |
| Port = 15672, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal void Run() | |
| { | |
| var rez = Task<string>.Run(() => | |
| { | |
| return LongTermProcedure(); | |
| }); | |
| // OR use "TaskCompletionSource" : | |
| // var rez = GetDataAsync(); | |
| Console.WriteLine(rez.Result); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| int port = 31519; | |
| string url = "http://localhost:" + port + "/api/hello"; | |
| WebRequest REQ = WebRequest.Create(url); | |
| REQ.Method = "POST"; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ATTENTION !!! | |
| using System.Configuration; | |
| // ATTENTION !!! | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| IMessageWriter writer = new ConsoleMessageWriter(); | |
| var app = new AppForMsgWriter(writer); | |
| app.Exec(); |