public static void Wire() { var bus = new MiniVan(); var storage = new RestStore(); var rep = new Repository<InventoryItem>(storage); var commands = new InventoryCommandHandlers(rep); bus.RegisterHandler<CheckInItemsToInventory>(commands.Handle); bus.RegisterHandler<CreateInventoryItem>(commands.Handle); bus.RegisterHandler<DeactivateInventoryItem>(commands.Handle); bus.RegisterHandler<RemoveItemsFromInventory>(commands.Handle); bus.RegisterHandler<RenameInventoryItem>(commands.Handle); ServiceLocator.Bus = bus; }
static void Main(string[] args) { Car myCar = new Car(); myCar.Speed = 50; Console.WriteLine("My car is going: {0} MPH", myCar.Speed); MiniVan myVan = new MiniVan(); myVan.Speed = 10; Console.WriteLine("My van is going: {0}", myVan.Speed); Console.ReadLine(); }
private void btnCarInheritance_Click(object sender, RoutedEventArgs e) { var myCar = new CarInheritance(80); myCar.Speed = 50; Console.WriteLine(@"My Car is goin : {0} MPH", myCar.Speed); myCar.Speed = 150; Console.WriteLine(@"My Car is goin : {0} MPH", myCar.Speed); var myCar1 = new CarInheritance(); myCar1.Speed = 150; Console.WriteLine(@"My Car 1 is goin : {0} MPH", myCar1.Speed); var myVan = new MiniVan(); myVan.Speed = 180; Console.WriteLine(@"My Van 1 is goin : {0} MPH", myVan.Speed); }
static int Main(string[] args) { // build and consume Custom Class Library, P573 { SportsCar sc1 = new SportsCar { PetName = "ZL", MaxSpeed = 200, CurrentSpeed = 10 }; MiniVan mv1 = new MiniVan { PetName = "XY", MaxSpeed = 100, CurrentSpeed = 20 }; sc1.TurboBoost(); mv1.TurboBoost(); System.Console.WriteLine(sc1.ToString()); System.Console.WriteLine(mv1.ToString()); Console.ReadLine(); // see Project folder "custom_namespace01" // see project folder "custom_namespace02" } // configure private assemblies, P586 { /* * + note in "*.config" file + - <probing> element simply instructs the CLR to investigate all specified subdirectories for the requested assembly until the first match is encountered; + - <probing privatePath="subdir_libraries_folder_name"> attribute can NOT be used to specify an absolute or relative path! + - using <codeBase> element to do it instead; + + note about the name of "*.config" files + - file names MUST be prefixed with the same name as the related client application; + + ```c# + + <probing privatePath="MyLibraries;MyLibraries\Tests"/> + + ``` + */ // see Project folder "MyCSharpCarApp" // see Project folder "MyVBCarApp" // see Project folder "MyApp" } // configure shared assemblies, P589 { /* * + when to use + - building libraries to be widely used over lots of projects + + how to configure + - assign SNK to your assembly(*.dll); + >> command-line named "developer command prompt" + >> using VS + - add your libraries(*.dll) to GAC(folder name: assembly); + >> using command-line tool named "gacutil.exe" to install */ } { } return(0); }