public Object GetUnknownTypeObject(string prefix, string resource, string view) { Object retval = null; DebugMgr.start(9, "Reference.GetUnknownTypeObject"); foreach (Assembly assembly in _assemblies) { Object @object; IImplementations implementations = (IImplementations)assembly.CreateInstance("Reference.Implementation"); if (implementations != null) { @object = implementations.GetResource(prefix, resource, view); if (@object != null) { DebugMgr.output(9, "Found Object"); retval = @object; break; } } else { DebugMgr.outputVar(9, "Did not implement", assembly.FullName); } } DebugMgr.end(9); return(retval); }
public static void SecondMethod(RunningTotal param) { DebugMgr.start(10, "ExMethodCall.SecondMethod"); param.IncrementValue(); DebugMgr.output(10, "During RunningTotal.value = " + param.GetValue()); DebugMgr.end(10); }
// Constructor is made private so that only // the class can instantiate itself private Reference() { DebugMgr.start(9, "Reference.Reference"); NameValueCollection pluginConfig = (NameValueCollection)ConfigurationSettings.GetConfig("settings/plugin"); if (pluginConfig["dir"] == null) { throw(new ConfigurationException("Incorrect Plugin Directory")); } else { _path = pluginConfig["dir"]; DebugMgr.outputVar(9, "Plugin directory", _path); _pluginEntries = Directory.GetFileSystemEntries(_path, "*.dll"); OperatingSystem os = System.Environment.OSVersion; DebugMgr.outputVar(9, "Operating System", os.Platform); foreach (string path in _pluginEntries) { DebugMgr.outputVar(9, "assembly", path); Assembly assembly; if ((int)os.Platform == 128) { // This is Linux assembly = Assembly.LoadFrom(path); } else { // This is everything else assembly = Assembly.Load(AssemblyName.GetAssemblyName(path)); } _assemblies.Add(assembly); } } DebugMgr.end(9); }
private static Animal CreateCurrentDogInstance() { DebugMgr.start(10, "TestInheritance.CreateCurrentDogInstance"); DebugMgr.end(10); return(new EnglishBulldog()); // return new Dog(); Original version }
public static void DoIt() { DebugMgr.start(10, "RunExamples.DoIt"); SimpleOldContainer(); SimpleNewContainer(); DebugMgr.end(10); }
private static void TimeProofPolymorphicInheritance() { DebugMgr.start(10, "TestInheritance.TimeProofPolymorphicInheritance"); Animal animal = CreateCurrentDogInstance(); animal.WhatAmI(); DebugMgr.end(10); }
public static void DoIt() { DebugMgr.start(10, "RunExamples.DoIt"); ReceiveMessage receiver = new ReceiveMessage(); DoItNow myDelegate = new DoItNow(receiver.MethodToDoItNow); myDelegate("do something"); DebugMgr.end(10); }
public static void SecondMethod(ExStruct param1, ExClass param2) { DebugMgr.start(10, "ExMethodCall.SecondMethod"); param1.value++; param2.value++; DebugMgr.output(10, "During ExStruct.value = " + param1.value); DebugMgr.output(10, "During ExClass.value = " + param2.value); DebugMgr.end(10); }
public static void SimpleOldContainer() { DebugMgr.start(10, "RunExamples.SimpleOldContainer"); OldContainer container = new OldContainer(); container.MyProperty = 2; int value = (int)container.MyProperty; DebugMgr.output(10, "Value is " + value); DebugMgr.end(10); }
public static void Main(string[] args) { DebugMgr.assignDebugFlags(10); DebugMgr.start(8, "Main"); try { RunDynamic(); } catch (Exception ex) { DebugMgr.output(1, "!!! " + ex.Message + " !!!"); } DebugMgr.end(8); }
private static void SimpleInheritance() { DebugMgr.start(10, "TestInheritance.SimpleInheritance"); Subclassed subcls = new Subclassed(); subcls.SimpleMethod(); DebugMgr.output(10, "Now assigning to type BaseClass"); BaseClass basecls = subcls; basecls.SimpleMethod(); DebugMgr.end(10); }
public void greetings() { DebugMgr.start(10, "InAssembly2Class.greetings"); InAssembly1Class cls = new InAssembly1Class(); cls.greetings(); // cls.greetingsProtected(); // This method cannot be access due to protected measures // cls.greetingsInternal(); // This method cannot be accessed outside the assembly // InAssembly1Class2 cls2 = new InAssembly1Class2(); // Cannot be accessed DebugMgr.end(10); }
public static void FirstMethod() { DebugMgr.start(10, "ExMethodCall.FirstMethod"); ExStruct cls1 = new ExStruct(); ExClass cls2 = new ExClass(); DebugMgr.output(10, "Before ExStruct.value = " + cls1.value); DebugMgr.output(10, "Before ExClass.value = " + cls2.value); SecondMethod(cls1, cls2); DebugMgr.output(10, "After ExStruct.value = " + cls1.value); DebugMgr.output(10, "After ExClass.value = " + cls2.value); DebugMgr.end(10); }
private static void MultipleInheritance() { DebugMgr.start(10, "TestInheritance.MultipleInheritance"); DebugMgr.output(10, "Created NewVersionSubclassed, and assigned to type BaseClass"); BaseClass baseCls = new NewVersionSubclassed(); baseCls.VirtualMethod(); DebugMgr.output(10, "Now assigning to type NewVersion"); NewVersion newVer = (NewVersion)baseCls; newVer.VirtualMethod(); DebugMgr.end(10); }
private static void PolymorphicInheritance() { DebugMgr.start(10, "TestInheritance.PolymorphicInheritance"); DebugMgr.output(10, "Created Human and assigned to Animal"); Animal animal1 = new Human(); animal1.WhatAmI(); DebugMgr.output(10, "Created Dog and assigned to Animal"); Animal animal2 = new Dog(); animal2.WhatAmI(); DebugMgr.end(10); }
public static void SimpleNewContainer() { DebugMgr.start(10, "RunExamples.SimpleNewContainer"); #if GenericsSupported NewContainer <int> container = new NewContainer <int>(); container.MyProperty = 2; int value = container.MyProperty; DebugMgr.output(10, "Value is " + value); #else DebugMgr.output(10, "Not Implemented"); #endif DebugMgr.end(10); }
public static void FirstMethod() { DebugMgr.start(10, "ExMethodCall.FirstMethod"); ExStruct2 cls1 = new ExStruct2(); ExClass2 cls2 = new ExClass2(); DebugMgr.output(10, "Before ExStruct2.value = " + cls1.GetValue()); DebugMgr.output(10, "Before ExClass2.value = " + cls2.GetValue()); SecondMethod(cls1); SecondMethod(cls2); DebugMgr.output(10, "After ExStruct2.value = " + cls1.GetValue()); DebugMgr.output(10, "After ExClass2.value = " + cls2.GetValue()); DebugMgr.end(10); }
public UserReference.IUser LoadUser(string reference) { DebugMgr.start(9, "XMLUserImpl.Operations.LoadUser"); DebugMgr.outputVar(9, "Reference", reference); GetLocalDirectory(); UserReference.IUser user = null; if (reference == "some.identifier") { user = new User(); XmlSerializer reader = new XmlSerializer(user.GetType()); StreamReader file = new StreamReader(Directory.GetCurrentDirectory() + "/some.identifier.xml"); user = (User)reader.Deserialize(file); } DebugMgr.end(9); return(user); }
// Notice how the Operations object is responsible for loading the // User object. Classical OO dictates elsewise, but component // engineering prefers separation. public UserReference.IUser LoadUser(string reference) { DebugMgr.start(9, "DbUserImpl.Operations.LoadUser"); DebugMgr.outputVar(9, "reference", reference); GetLocalDirectory(); UserReference.IUser user = null; if (reference == "some.identifier") { user = new User(); StreamReader sr = new StreamReader(Directory.GetCurrentDirectory() + "/some.identifier.txt"); user.name = sr.ReadLine(); user.street = sr.ReadLine(); user.city = sr.ReadLine(); user.country = sr.ReadLine(); } DebugMgr.end(9); return(user); }
public static void RunIt() { DebugMgr.start(10, "TestExternalreference.RunIt"); InAssembly2Class2 cls = new InAssembly2Class2(); cls.greetings(); //cls.greetingsProtected(); cls.greetingsInternal(); cls.greetingsInternalVirtual(); DebugMgr.output(10, "-----------"); InAssembly1Class cls2 = cls; cls2.greetings(); //cls2.greetingsInternal(); cls2.CallTheInternalMethod(); DebugMgr.end(10); }
public Object GetObject(string @class) { Object retval = null; DebugMgr.start(9, "Reference.GetObject"); DebugMgr.outputVar(9, "Class to instantiate", @class); foreach (Assembly assembly in _assemblies) { Object @object; @object = assembly.CreateInstance(@class); if (@object != null) { DebugMgr.outputVar(9, "loaded object", @class); retval = @object; break; } } DebugMgr.end(9); return(retval); }
// Function that will help you figure out what the local directory is. private void GetLocalDirectory() { DebugMgr.start(9, "XMLUserImpl.Operations.GetLocalDirectory"); DebugMgr.outputVar(9, "Local Directory", Directory.GetCurrentDirectory()); DebugMgr.end(9); }
public virtual void VirtualMethod() { DebugMgr.start(10, "BaseClass.VirtualMethod"); DebugMgr.end(10); }
public override void VirtualMethod() { DebugMgr.start(10, "NewVersionSubclassed.VirtualMethod"); DebugMgr.end(10); }
public virtual new void VirtualMethod() { DebugMgr.start(10, "NewVersion.VirtualMethod"); DebugMgr.end(10); }
public virtual void greetingsInternalVirtual() { DebugMgr.start(10, "InAssembly2Class2.greetingsInternalVirtual"); DebugMgr.end(10); }
new void greetingsProtected() { DebugMgr.start(10, "InAssembly2Clas2.greetingsProtected"); DebugMgr.end(10); }
public new void greetings() { DebugMgr.start(10, "InAssembly2Class2.greetings"); DebugMgr.end(10); }
public void MethodToDoItNow(string param) { DebugMgr.start(10, "ReceiveMessage.MethodToDoItNow"); DebugMgr.output(10, "Received message " + param); DebugMgr.end(10); }
public new void SimpleMethod() { DebugMgr.start(10, "Subclassed.SimpleMethod"); DebugMgr.end(10); }