-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
423 lines (308 loc) · 16 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
//Logger logger = new Logger();
//logger.FileLogger("this Logger Is File Txt.");
//NewFatucherLoggerDecorator newLogger = new NewFatucherLoggerDecorator(logger);
//newLogger.DatabseLogger("this Logger Is Databse.");
//using DeginPaterrn.Decorator.DecoratorVsInheritance;
//ConcreteWindow window = new ConcreteWindow("red");
//Console.WriteLine(window.GetColor());
//ConcreteDecoratorScrollWindow windowDecorator = new ConcreteDecoratorScrollWindow(window , "blue");
//Console.WriteLine(windowDecorator.GetColor());
//ConcreteDecoratorShdowWindow windowDecorator2 = new ConcreteDecoratorShdowWindow(window, "silver");
//windowDecorator2.SetColor("oreng");
//Console.WriteLine(windowDecorator2.GetColor());
//Console.WriteLine(windowDecorator.GetColor());
//Console.WriteLine(window.GetColor());
//using DeginPaterrn.Decorator;
//using System.Net;
//WebClient webClient = new WebClient();
//var source = webClient.DownloadString("https://www.google.com/");
//Console.WriteLine(source);
//WebClinetDecorator webClinetDecorator = new WebClinetDecorator(webClient);
//var source2 = webClinetDecorator.DownloadString("https://www.google.com/");
//Console.WriteLine(source2);
//using DeginPaterrn.Facade;
//Facade.RigesterUser();
//using DeginPaterrn.Bridge;
//RefinedAbstraction refinedAbstraction = new RefinedAbstraction();
//refinedAbstraction.Function();
//using DeginPaterrn.Proxy;
////ILogger logger = new Logger();
//ILogger logger = new VirtualProxyLogger();
//logger.InfoLogger("this is info logger ....");
//using DeginPaterrn.Composite;
//CompositeTreeStructure treeStructure = new CompositeTreeStructure(new CompositeTreeStructureDto()
//{
// Id = 1,
// Name = "Root Tree Structure",
// Description = "This Is Root Tree Structure",
// Children = new List<TreeStructure>()
// {
// new LifeTreeStructure(new LifeTreeStructureDto { Id = 2 , Name = "Life 1" , Description = "This Is Life 1 In Tree Structure" }),
// new LifeTreeStructure(new LifeTreeStructureDto { Id = 3 , Name = "Life 2" , Description = "This Is Life 2 In Tree Structure" }),
// new LifeTreeStructure(new LifeTreeStructureDto { Id = 4 , Name = "Life 3" , Description = "This Is Life 3 In Tree Structure" }),
// new LifeTreeStructure(new LifeTreeStructureDto { Id = 5 , Name = "Life 4" , Description = "This Is Life 4 In Tree Structure" }),
// new CompositeTreeStructure(new CompositeTreeStructureDto()
// {
// Id = 6 ,
// Name = "Composite 1" ,
// Description = "This Is Composite 1 In Tree Structure",
// Children = new List<TreeStructure>()
// {
// new LifeTreeStructure(new LifeTreeStructureDto { Id = 7 , Name = "Life 1-1" , Description = "This Is Life 1-1 In Tree Structure" }),
// new LifeTreeStructure(new LifeTreeStructureDto { Id = 8 , Name = "Life 1-2" , Description = "This Is Life 1-2 In Tree Structure" }),
// new CompositeTreeStructure(new CompositeTreeStructureDto()
// {
// Id = 9 ,
// Name = "Composite 1-3" ,
// Description = "This Is Composite 1-3 In Tree Structure",
// Children = new List<TreeStructure>()
// {
// new LifeTreeStructure(new LifeTreeStructureDto { Id = 10 , Name = "Life 1-3-1" , Description = "This Is Life 1-3-1 In Tree Structure" }),
// new CompositeTreeStructure(new CompositeTreeStructureDto()
// {
// Id = 10 ,
// Name = "Composite 1-3-2" ,
// Description = "This Is Composite 1-3-2 In Tree Structure",
// Children = new List<TreeStructure>() {}
// })
// }
// })
// }
// }),
// }
//});
//treeStructure.AddTree(new LifeTreeStructure(new LifeTreeStructureDto { Id = 11, Name = "Life 5", Description = "This Is Life 5 In Tree Structure" }));
//treeStructure.DisplayTree(5);
//using DeginPaterrn.Flyweight;
//FlyweightFactory flyweightFactory = new FlyweightFactory();
//SoliderConcreteFlyweight soliderConcreteFlyweight = (SoliderConcreteFlyweight)flyweightFactory.GetObject(nameof(SoliderConcreteFlyweight) , "test1");
//soliderConcreteFlyweight.Operation();
//SoliderConcreteFlyweight soliderConcreteFlyweight2 = (SoliderConcreteFlyweight) flyweightFactory.GetObject(nameof(SoliderConcreteFlyweight) , "test2");
//soliderConcreteFlyweight.Operation();
//ArrowConcreteFlyweight arrowConcreteFlyweight = (ArrowConcreteFlyweight)flyweightFactory.GetObject(nameof(ArrowConcreteFlyweight), "test3");
//arrowConcreteFlyweight.Operation();
//UnsheardFlyweight unsheardFlyweight = new UnsheardFlyweight(new List<IFlyweight>()
//{
// flyweightFactory.GetObject(nameof(SoliderConcreteFlyweight) , "test1"),
// flyweightFactory.GetObject(nameof(SoliderConcreteFlyweight) , "test2"),
// flyweightFactory.GetObject(nameof(ArrowConcreteFlyweight) , "test3"),
//});
//unsheardFlyweight.Operation();
//using DeginPaterrn.Adapter;
//IAdaptee circle = new CircleObject();
//circle.Operation();
//IAdaptee square = new SquareObject();
//square.Operation();
//IAdaptee diamond = new DiamondObject();
//diamond.Operation();
//IAdaptee adapteeObject3D = new AdapteeObject3D();
//adapteeObject3D.Operation();
//using DeginPaterrn.Prototype;
//IPrototype sampleObjectClone = new SampleObjectClone();
//SampleObjectClone sampleObjectClone2 = (SampleObjectClone)sampleObjectClone.ShallowClone();
//SampleObjectClone sampleObjectClone3 = (SampleObjectClone)sampleObjectClone.ShallowClone();
//SampleObjectClone sampleObjectClone4 = (SampleObjectClone)sampleObjectClone.DeepClone();
//SampleObjectClone sampleObjectClone5 = (SampleObjectClone)sampleObjectClone.DeepClone();
//Console.WriteLine(sampleObjectClone2 == sampleObjectClone3);
//Console.WriteLine(sampleObjectClone3 == sampleObjectClone4);
//Console.WriteLine(sampleObjectClone2 == sampleObjectClone2);
//Console.WriteLine(sampleObjectClone5 == sampleObjectClone4);
//Console.WriteLine(sampleObjectClone5 == sampleObjectClone2);
//Console.WriteLine(sampleObjectClone5 == sampleObjectClone5);
//using DeginPaterrn.Singletone;
//SampleObjectSingletone sampleObjectSingletone1 = SampleObjectSingletone.GetInstance();
//SampleObjectSingletone sampleObjectSingletone2 = SampleObjectSingletone.GetInstance();
//Console.WriteLine(sampleObjectSingletone1 == sampleObjectSingletone2);
//using DeginPaterrn.Factory_Method;
//ISmsSernder smsSernderOne = SmsSernderCreateor.SmsSernderFactoryMethod();
//ISmsSernder smsSernderTwo = SmsSernderCreateor.SmsSernderFactoryMethod(SmsSernderType.ShahParkSms);
//smsSernderOne.Send(new SmsSernderDto()
//{
// Line = "+988965894",
// Message = "This is Message Test",
// Receiver = "Hossein Ghojavand",
// Sender = "System",
//});
//smsSernderTwo.Send(new SmsSernderDto()
//{
// Line = "+983216458",
// Message = "This is Message Test",
// Receiver = "Hossein Ghojavand",
// Sender = "System",
//});
//Console.WriteLine("============================= --Reports-- ====================================");
//for (int i = 0; i < smsSernderOne.GetList().Count; i++)
//{
// SmsSernderDto sms = smsSernderOne.GetList()[i];
// Console.WriteLine($"{i}- Line:{sms.Line} Sender:{sms.Sender} - Receiver:{sms.Receiver} - Message:{sms.Message} ({nameof(SmsSernderType.IranSms)})");
//}
//for (int i = 0; i < smsSernderTwo.GetList().Count; i++)
//{
// SmsSernderDto sms = smsSernderTwo.GetList()[i];
// Console.WriteLine($"{i}- Line:{sms.Line} Sender:{sms.Sender} - Receiver:{sms.Receiver} - Message:{sms.Message} ({nameof(SmsSernderType.ShahParkSms)})");
//}
//using DeginPaterrn.AbstractFactory;
//using DeginPaterrn.AbstractFactory.Services.CatecoryService;
//using DeginPaterrn.AbstractFactory.Services.UserService;
//ICatecoryService catecoryService = AbstractFactory.CreateCatecoryService(CatecoryServiceType.LeftCatecoryService);
//IUserService userService = AbstractFactory.CreateUserService(UserServiceType.LegalUserService);
//catecoryService.Excute();
//userService.Excute();
//using DeginPaterrn.Builder;
//using DeginPaterrn.Builder.Services.UserService;
//IDirctorUserService dirctorUserService = new DirctorUserService();
//dirctorUserService.SetFullRealUserInformation("Hossein" , "ghojavand" , 23 , "Tehran" , 02112345678);
//IUserService realUserService = dirctorUserService.GetRealUser();
//dirctorUserService.SetFullLegalUserInformation("Hossein", "ghojavand", 23, "Tehran", 02112345678);
//IUserService legalUserService = dirctorUserService.GetRealUser();
//Console.WriteLine($"RealUser --- {nameof(realUserService.Firstname)}: {realUserService.Firstname} - {nameof(realUserService.Lastname)}: {realUserService.Lastname} - {nameof(realUserService.Age)}: {realUserService.Age} - {nameof(realUserService.City)}: {realUserService.City} - {nameof(realUserService.Phone)}: {realUserService.Phone}");
//Console.WriteLine($"LegalUser --- {nameof(legalUserService.Firstname)}: {legalUserService.Firstname} - {nameof(legalUserService.Lastname)}: {legalUserService.Lastname} - {nameof(legalUserService.Age)}: {legalUserService.Age} - {nameof(legalUserService.City)}: {legalUserService.City} - {nameof(legalUserService.Phone)}: {legalUserService.Phone}");
//using DeginPaterrn.Strategy;
//IStrategy sortId = new SortAlgorithmById();
//IStrategy sortPrice = new SortAlgorithmByPrice();
//IContect contect = new Contect(sortId);
//contect.SortData();
//contect = new Contect(sortPrice);
//contect.SortData();
//StrategyArrayUsers strategyArrayUsers = new StrategyArrayUsers();
//strategyArrayUsers.Excte(nameof(User.Firstname));
//using DeginPaterrn.ChainResponsibility;
//ChainResponsibility stepOne = new ChainResponsibilityConcreate();
//ChainResponsibility stepTwo = new ChainResponsibilityConcreate2();
//ChainResponsibility stepThree = new ChainResponsibilityConcreate3();
//stepOne.SetSuccessor(stepTwo);
//stepTwo.SetSuccessor(stepThree);
//Console.WriteLine("--------------------------------------------------");
//stepOne.RequestHandeler(50);
//Console.WriteLine("--------------------------------------------------");
//stepOne.RequestHandeler(80);
//Console.WriteLine("--------------------------------------------------");
//stepOne.RequestHandeler(100);
//Console.WriteLine("--------------------------------------------------");
//CheckUserActiveUser checkUserActiveUser = new CheckUserActiveUser();
//CreateOrder createOrder = new CreateOrder();
//SendOrderToDriver sendOrderToDriver = new SendOrderToDriver();
//CheckTest checkTest = new CheckTest();
//checkUserActiveUser
// .SetSuccessor(checkTest)
// .SetSuccessor(createOrder)
// .SetSuccessor(sendOrderToDriver);
//checkUserActiveUser.Execute(new RequestContextSanpp
//{
// UserId = 1,
// Origin = new PointSanpp { Lat = 53.3636, Lng = 54.22 },
// Destination = new PointSanpp { Lat = 53.3636, Lng = 54.22 },
//});
//using DeginPaterrn.Command;
//using DeginPaterrn.Command.Services;
//var concreteCommandOne = new ConcreteCommandOne<IServiceOne>(new ServiceOne());
//var invokerCommandOne = new InvokerCommand<IServiceOne>(concreteCommandOne);
//invokerCommandOne.ExcuteCommand();
//using DeginPaterrn.Observer;
//ConcreteSubject subject = new ConcreteSubject();
//subject.SubjectState = "MySubjectState";
//IObserverbel observableOne = new ConcreteObserver("observableOne", subject);
//IObserverbel observableTwo = new ConcreteObserver("observableTwo", subject);
//IObserverbel observableThree = new ConcreteObserver("observableThree", subject);
//IObserverbel observableFour = new ConcreteObserver("observableFour", subject);
//subject.AttechObserver(observableOne);
//subject.AttechObserver(observableTwo);
//subject.AttechObserver(observableThree);
//subject.AttechObserver(observableFour);
//subject.Notify();
//using DeginPaterrn.Memento;
//Originator originator = new Originator();
//originator.ExsampleState = "Red";
//Caretaker caretaker = new Caretaker();
//caretaker.Memento = originator.CreateMemento();
//originator.ExsampleState = "Green";
//originator.ExsampleState = "Blue";
//originator.ExsampleState = "Pink";
//Console.WriteLine("===================================================================================================");
//originator.SetMemento(caretaker.Memento);
//using DeginPaterrn.Visitor;
//ISnapp ChikenOne = new SnappFoodElement("ChikenOne", "1000");
//ISnapp ChikenTwo = new SnappFoodElement("ChikenTwo", "2000");
//ISnapp ChikenThree = new SnappFoodElement("ChikenThree", "3000");
//ISnapp ChikenFour = new SnappFoodElement("ChikenFour", "4000");
//ISnapp ChikenFive = new SnappFoodElement("ChikenFive", "5000");
//ISnapp PencelOne = new SnappBoxElement("PencelOne", "1000");
//ISnapp PencelTwo = new SnappBoxElement("PencelTwo", "2000");
//ISnapp PencelThree = new SnappBoxElement("PencelThree", "3000");
//ISnapp PencelFour = new SnappBoxElement("PencelFour", "4000");
//ISnapp PencelFive = new SnappBoxElement("PencelFive", "5000");
//ISnapp MilkeOne = new SnappMarketElement("MilkeOne", "1000");
//ISnapp MilkeTwo = new SnappMarketElement("MilkeTwo", "2000");
//ISnapp MilkeThree = new SnappMarketElement("MilkeThree", "3000");
//ISnapp MilkeFour = new SnappMarketElement("MilkeFour", "4000");
//ISnapp MilkeFive = new SnappMarketElement("MilkeFive", "5000");
//ElementSnappStructure objectStructure = new ElementSnappStructure();
//objectStructure.Add(ChikenOne);
//objectStructure.Add(ChikenTwo);
//objectStructure.Add(ChikenThree);
//objectStructure.Add(ChikenFour);
//objectStructure.Add(ChikenFive);
//objectStructure.Add(PencelOne);
//objectStructure.Add(PencelTwo);
//objectStructure.Add(PencelThree);
//objectStructure.Add(PencelFour);
//objectStructure.Add(PencelFive);
//objectStructure.Add(MilkeOne);
//objectStructure.Add(MilkeTwo);
//objectStructure.Add(MilkeThree);
//objectStructure.Add(MilkeFour);
//objectStructure.Add(MilkeFive);
//IVisitor visitorReport = new VisitorReport();
//IVisitor visitorInformation = new VisitorInformation();
//Console.WriteLine("===============================================================================");
//objectStructure.Accept(visitorReport);
//Console.WriteLine("===============================================================================");
//objectStructure.Accept(visitorInformation);
//Console.WriteLine("===============================================================================");
//using DeginPaterrn.Mediator;
//using DeginPaterrn.Mediator.Services;
//Products products = new Products();
//Users users = new Users();
//Mediator mediator = new ConcreateMediator(products , users);
//products.SetMediator(mediator);
//users.SetMediator(mediator);
//products.Send("Exsample Sand Message From Product");
//Console.WriteLine("=================================================");
//users.Send("Exsample Sand Message From User");
//using DeginPaterrn.State;
//Context context = new Context();
//for (int i = 0; i < 3 ; i++)
// context.Request();
//using DeginPaterrn.Interpreter;
//IList<IExpressionDateTime> expressionDateTimes = new List<IExpressionDateTime>();
//Context context = new Context(DateTime.Now);
//while (true)
//{
// Console.WriteLine("Please select the expression dateTime:");
// string? input = Console.ReadLine();
// if (input != null)
// context.Expression = input.ToUpper();
// else
// Console.WriteLine("Please enter the desired date format.");
// string[] formats = context.Expression.Split(' ');
// foreach (string format in formats)
// {
// switch (format)
// {
// case "YYYY":
// expressionDateTimes.Add(new CocreateExpressionYers());
// break;
// case "MM":
// expressionDateTimes.Add(new CocreateExpressionMonth());
// break;
// case "DD":
// expressionDateTimes.Add(new CocreateExpressionDay());
// break;
// }
// }
// foreach (IExpressionDateTime expressionDateTime in expressionDateTimes)
// expressionDateTime.Interpret(context);
// Console.WriteLine(context.Expression);
// Console.ReadKey();
//}