private static void RunExample3() { var temp = new Example3(); temp.srvcprt = 8080; temp.employeeemail = "*****@*****.**"; }
static void Main(string[] args) { Example.Main(); Example2.Main(); Example3.Main(); Example4.Main(); ExampleDiscard.Main(); ExampleClassDeconstruction.Main(); ExampleExtension.Main(); }
static void Main(string[] args) { Example.Main(); Example2.Main(); Example3.Main(); Example4.Main(); ExampleDiscard.Main(); ExampleClassDeconstruction.Main(); ExampleExtension.Main(); ExampleNullableEx.Main(); ExampleSystem.KeyValuePair(); }
public void Example3Test() { Example3 example; example = new Example3(); example.Property1 = "aAa"; example.Property2 = "bBb"; example.Transform(); Assert.AreEqual("aaa", example.Property1); Assert.AreEqual("BBB", example.Property2); }
public static void MenuExamples() { CreateExamplesList(); Console.WriteLine("> Menu Examples: "); foreach (var example in Examples) { Console.WriteLine(example); } Console.WriteLine("Write the number of the example you want to see:"); var input = Console.ReadLine(); var select = 0; if (input == null) { Console.WriteLine("You must choose."); MenuExamples(); return; } select = Int32.Parse(input); switch (select) { case 0: Menu(); break; case 1: Console.Clear(); Example1.Run(); break; case 2: Console.Clear(); Example2.Run(); break; case 3: Console.Clear(); Example3.Run(); break; default: Console.Clear(); Console.WriteLine("That example doesn't exist."); MenuExamples(); break; } }
static void Main() { Example1 example1 = new Example1(); Console.WriteLine("Class type instance is {0} and derives from {1}", example1.GetType().Name, example1.GetType().BaseType); Example2 example2 = new Example2(); Console.WriteLine("Class type instance is {0} and derives from {1}", example2.GetType().Name, example2.GetType().BaseType); Example3 example3 = new Example3(); Console.WriteLine("Class type instance is {0} and derives from {1}", example3.GetType().Name, example3.GetType().BaseType); }
static void Main(string[] args) { bool print = args.Contains("--print"); Check("Example 1", Example1.Run(print)); Check("Example 2", Example2.Run(print)); Check("Example 3", Example3.Run(print)); Check("Example 4", Example4.Run(print)); Check("Example 5", Example5.Run(print)); Check("Example 6", Example6.Run(print)); Check("Example 7", Example7.Run(print)); Check("Example 8", Example8.Run(print)); Check("Example 9", Example9.Run()); Check("Example 10", Example10.Run(print)); Check("Example 11", Example11.Run(print)); }
static void Main(string[] args) { // Example3 test2 = delegate (int x, int y) { return x + y; }; // Sai, Shailza, Shivani // Func<int,int>square = x => x*x; // Example 3: // Step 2: Initialize Anonymous function() Example3 test = (x, y) => x + y; //Invoke the delegates Console.WriteLine(test(5, 5)); // Output: // 10 }
static void Main(string[] args) { // // TODO: Add code to start application here // Example1 example1 = new Example1(); Console.WriteLine("Class type instance is {0} and derives from {1}", example1.GetType().Name, example1.GetType().BaseType); Example2 example2 = new Example2(); Console.WriteLine("Class type instance is {0} and derives from {1}", example2.GetType().Name, example2.GetType().BaseType); Example3 example3 = new Example3(); Console.WriteLine("Class type instance is {0} and derives from {1}", example3.GetType().Name, example3.GetType().BaseType); Console.WriteLine(example1); Console.WriteLine(example2); Teacher st = new SupplyTeacher(54); Console.WriteLine(st.GetCountryCode()); StaffTeacher staff = new StaffTeacher(54); Console.WriteLine(staff.GetCountryCode("UK")); string teacherString = String.Empty; InvocationClass.InvokeMemberOnTeacher(st, out teacherString); INonAdminPublicSectorWorker hw = new HospitalWorker(); hw.Load("C:\\agenda.txt"); InvocationClass.InvokeMemberOnINonAdminPublicSectorWorkerInterface(hw, "C:\\agenda.txt"); HospitalWorker h = new HospitalWorker(); Console.WriteLine(h.WastedTime()); ILazyWorker ilw = (ILazyWorker)h; INonAdminPublicSectorWorker inaps2 = (INonAdminPublicSectorWorker)ilw; Console.WriteLine(inaps2.GetItem(DateTime.Now)); Console.WriteLine(ilw.WastedTime()); }
static void Main() { Example1 example1 = new Example1(); example1.ShowExample(); Example2 example2 = new Example2(); example2.ShowExample(); Example3 example3 = new Example3(); example3.ShowExample(); Example4 example4 = new Example4(); example4.ShowExample(); Example5 example5 = new Example5(); example5.ShowExample(); Console.ReadKey(); }
static void Main(string[] args) { /* * Start by creating a factory and putting an instance Example1 and Example2 in it. * * In practice, these would be the classes that are injected into further classes created * but we can see how the factory works with these. */ Factory iocFactory = new Factory(); iocFactory.RegisterType(new Example1()); iocFactory.RegisterType(new Example2()); /* * Get an instance of the Example1 class. Because there may be several (for interfaces specifically) * we get a list and ensure we have it. * * In this case there will be exactly 1 */ List <object> obj = iocFactory.GetInstance(typeof(Example1)); Console.WriteLine($"Recieved {obj.Count} instances of Example1"); Console.WriteLine($"Of type {obj[0].GetType()} \n"); /* * Get instances of the deriving classes. * * In this case there will be exactly 2 because Example1 and Example2 both derive from the * interface IExampleInterface. */ List <object> interfaces = iocFactory.GetInstance(typeof(IExampleInterface)); Console.WriteLine($"Recieved {interfaces.Count} instances of IExampleInterface, they are:"); foreach (object iface in interfaces) { Console.WriteLine($"\t {((IExampleInterface)iface).Name}"); } /* * Now create a more complext type. Example3 requires an instance of IExampleInterface as * a construction parameter. * * Simply asking the factory to create one will get one from the internal list (first one) * and inject it into our class. * * WARNING: Because you just get the first version, if you have multiple objects deriving from the * same interface but you need specific ones you may run into issues. Can certainly be worked around * but just be aware. * * We can further identify the other construction parameters in a dictionary if they are not * a class/interface already created with RegisterType. */ Console.WriteLine("\nExample of true IOC"); Example3 e3 = (Example3)iocFactory.CreateInstance( typeof(Example3), new Dictionary <string, object>() { { "name", "IOC Example" } }); e3.DoSomething(); /* * If we ask for Example3 again, we will get the same instance as above because it was added to * the internal list of objects it's tracking. * * In this case we don't even need to include the additional construcotr parameters. */ e3 = (Example3)iocFactory.CreateInstance(typeof(Example3)); e3.DoSomething(); /* * For the last example, Example4, this is a template class expecting 2 generic parameters * in the constructor. * * NOTE: For template classes this library will only work if the class takes an instance in the construcotr * parameters (I think). * * Since we have both expected types (Example1 and Example2) as the definied types we won't hit a conflict * mentioned above as if we had used IExampleInterface. It will inject the two created classes into the * generic class for you and return an instance of Exaple4 all set up. * * To keep the code simple, Example4 is just going to write to the console during construction to say it's * being created and with which parameters. */ Console.WriteLine("\nExample of IOC with generic template class"); IGenericClassWrapper e4 = (IGenericClassWrapper)iocFactory.CreateInstance(typeof(Example4 <,>)); Console.WriteLine($"Object is {e4.GetType()}"); }
public override void Uninstall(IDictionary savedState) { Example3.Run(Example3.calc_x86, Example3.calc_x64); }
static void Main(string[] args) { int sel = -1; if (args != null && args.Count() > 0) { if (!Int32.TryParse(args[0], out sel)) { sel = -1; } } switch (sel) { case 0: Console.WriteLine("Example 0: GET ACCOUNTS AND TINTERFACES"); Example0.Main0(args); break; case 1: Console.WriteLine("Example 1: PRICE STREAMING"); Example1.Main1(args); break; case 2: Console.WriteLine("Example 2: PRICE POLLING"); Example2.Main2(args); break; case 3: Console.WriteLine("Example 3: POSITION STREAMING"); Example3.Main3(args); break; case 4: Console.WriteLine("Example 4: POSITION POLLING"); Example4.Main4(args); break; case 5: Console.WriteLine("Example 5: ORDER STREAMING"); Example5.Main5(args); break; case 6: Console.WriteLine("Example 6: ORDER POLLING"); Example6.Main6(args); break; case 7: Console.WriteLine("Example 7: ORDER CREATION"); Example7.Main7(args); break; case 8: Console.WriteLine("Example 8: CANCEL PENDING ORDER WITH ORDER POLLING"); Example8.Main8(args); break; case 9: Console.WriteLine("Example 9: MODIFY PENDING ORDER WITH ORDER POLLING"); Example9.Main9(args); break; case 10: Console.WriteLine("Example 10: CANCEL PENDING ORDER WITH ORDER STREAMING"); Example10.Main10(args); break; case 11: Console.WriteLine("Example 11: MODIFY PENDING ORDER WITH ORDER STREAMING"); Example11.Main11(args); break; case 12: Console.WriteLine("Example 12: STRATEGY"); Example12.Main12(args); break; case 13: Console.WriteLine("Example 13: MULTIPLE ORDER CREATION"); Example13.Main13(args); break; case 14: Console.WriteLine("Example 14: GET HISTORICAL PRICE"); Example14.Main14(args); break; default: Console.WriteLine("Choose option: "); Console.WriteLine("-1: EXIT"); Console.WriteLine(" 0: GET ACCOUNTS AND TINTERFACES"); Console.WriteLine(" 1: PRICE STREAMING"); Console.WriteLine(" 2: PRICE POLLING"); Console.WriteLine(" 3: POSITION STREAMING"); Console.WriteLine(" 4: POSITION POLLING"); Console.WriteLine(" 5: ORDER STREAMING"); Console.WriteLine(" 6: ORDER POLLING"); Console.WriteLine(" 7: ORDER CREATION"); Console.WriteLine(" 8: CANCEL PENDING ORDER WITH ORDER POLLING"); Console.WriteLine(" 9: MODIFY PENDING ORDER WITH ORDER POLLING"); Console.WriteLine("10: CANCEL PENDING ORDER WITH ORDER STREAMING"); Console.WriteLine("11: MODIFY PENDING ORDER WITH ORDER STREAMING"); Console.WriteLine("12: STRATEGY"); Console.WriteLine("13: MULTIPLE ORDER CREATION"); Console.WriteLine("14: GET HISTORICAL PRICE"); string input = Console.ReadLine(); if (input.Equals("-1")) { Console.WriteLine("Exit"); return; } string[] newargs = new string[1]; newargs[0] = input; Main(newargs); break; } }
public static void Main(String[] args) { Example2.echo(); Example3.echo(); }