├── .gitattributes
├── .gitignore
├── AppInfraDemo
├── .Exercises
│ ├── PointsOfAttention.html
│ ├── PointsOfAttention.md
│ ├── readme.html
│ └── readme.md
├── .editorconfig
├── ClassDiagram.png
├── DemoApplication.sln
├── Infrastructure
│ ├── CodeMap.dgml
│ ├── Common
│ │ ├── App.config
│ │ ├── Common.csproj
│ │ ├── DataModel
│ │ │ ├── Abstractions
│ │ │ │ └── Demo_IAuditable.cs
│ │ │ └── Demo_AuditableInterceptor.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── packages.config
│ ├── DataAccess
│ │ ├── App.config
│ │ ├── CollectionExtensions.cs
│ │ ├── DataAccess.csproj
│ │ ├── DbContexts
│ │ │ ├── SalesEntities.Context.cs
│ │ │ └── SalesEntities.Context.tt
│ │ ├── EfRepository.cs
│ │ ├── EntityEntry.cs
│ │ ├── EntityInterceptor.cs
│ │ ├── Exceptions
│ │ │ ├── ConcurrencyRepositoryException.cs
│ │ │ ├── DataValidationException.cs
│ │ │ ├── DataValidationResult.cs
│ │ │ ├── DateTimeRangeRepositoryException.cs
│ │ │ ├── DeadlockVictimRepositoryException.cs
│ │ │ ├── DeleteConstraintRepositoryException.cs
│ │ │ ├── Handlers
│ │ │ │ ├── ConcurrencyExceptionHandler.cs
│ │ │ │ ├── DbEntityValidationExceptionHandler.cs
│ │ │ │ ├── DefaultExceptionHandler.cs
│ │ │ │ ├── ExceptionHandler.cs
│ │ │ │ ├── IExceptionHandler.cs
│ │ │ │ ├── SqlExceptionHandler.cs
│ │ │ │ └── UpdateExceptionHandler.cs
│ │ │ ├── RepositoryException.cd
│ │ │ ├── RepositoryException.cs
│ │ │ ├── RepositoryUpdateException.cs
│ │ │ ├── UniqueConstraintRepositoryException.cs
│ │ │ └── ValidationError.cs
│ │ ├── GlobalEntityInterceptor.cs
│ │ ├── IDbContextFactory.cs
│ │ ├── IEntityEntryFacade.cs
│ │ ├── IEntityInterceptor.cs
│ │ ├── IRepository.cs
│ │ ├── IUnitOfWork.cs
│ │ ├── InterceptorsResolver.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── RepositoryDiagram.cd
│ │ ├── SimplifiedIsolationLevel.cs
│ │ └── packages.config
│ └── DependencyValidation
│ │ ├── DependencyValidation.layerdiagram
│ │ ├── DependencyValidation.layerdiagram.layout
│ │ ├── DependencyValidation.layerdiagram.suppressions
│ │ └── DependencyValidation.modelproj
├── Modules
│ ├── Contracts
│ │ ├── Contracts.csproj
│ │ ├── Crm
│ │ │ └── ICrmService.cs
│ │ ├── Location
│ │ │ └── ILocationService.cs
│ │ ├── Notifications
│ │ │ ├── IAmAliveSubscriber.cs
│ │ │ ├── INotificationService.cs
│ │ │ ├── IStateChangeSubscriber.cs
│ │ │ └── Status.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── Sales
│ │ │ ├── IOrderingService.cs
│ │ │ ├── OrderRequest.cs
│ │ │ ├── SalesOrderInfo.cs
│ │ │ └── SalesOrderResult.cs
│ │ └── packages.config
│ ├── DataModel
│ │ ├── Customer.cs
│ │ ├── DataModel.csproj
│ │ ├── Order.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── packages.config
│ ├── Export
│ │ ├── Export.DataModel
│ │ │ ├── App.Config
│ │ │ ├── Category.cs
│ │ │ ├── Customer.cs
│ │ │ ├── CustomerDemographic.cs
│ │ │ ├── Employee.cs
│ │ │ ├── Export.DataModel.csproj
│ │ │ ├── ExportEntities.Designer.cs
│ │ │ ├── ExportEntities.cs
│ │ │ ├── ExportEntities.edmx
│ │ │ ├── ExportEntities.edmx.diagram
│ │ │ ├── ExportEntities.tt
│ │ │ ├── Order.cs
│ │ │ ├── Order_Detail.cs
│ │ │ ├── Product.cs
│ │ │ ├── Properties
│ │ │ │ └── AssemblyInfo.cs
│ │ │ ├── Region.cs
│ │ │ ├── Shipper.cs
│ │ │ ├── Supplier.cs
│ │ │ ├── Territory.cs
│ │ │ └── packages.config
│ │ └── Export.Services
│ │ │ ├── Export.Services.csproj
│ │ │ ├── PageXmlDemo
│ │ │ ├── CustomerData.cs
│ │ │ ├── PageContentEnricher.cs
│ │ │ ├── PageData.cs
│ │ │ ├── PageXml.cs
│ │ │ └── PageXmlExport.cs
│ │ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ │ ├── app.config
│ │ │ └── packages.config
│ ├── Notifications
│ │ └── Notification.Services
│ │ │ ├── NotificationService.cs
│ │ │ ├── Notifications.Services.csproj
│ │ │ ├── OrderStateChangeSubscriber.cs
│ │ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ │ ├── StateChangeSubscriber.cs
│ │ │ ├── app.config
│ │ │ └── packages.config
│ └── Sales
│ │ ├── Sales.DataAccess
│ │ ├── App.config
│ │ ├── DbContextFactory.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── Sales.DataAccess.csproj
│ │ ├── SalesEntities.Context.Context.cs
│ │ ├── SalesEntities.Context.Context.tt
│ │ └── packages.config
│ │ ├── Sales.DataModel
│ │ ├── App.Config
│ │ ├── CountryRegionCurrency.cs
│ │ ├── CreditCard.cs
│ │ ├── Currency.cs
│ │ ├── CurrencyRate.cs
│ │ ├── Customer.cs
│ │ ├── Person.cs
│ │ ├── PersonCreditCard.cs
│ │ ├── Product.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── Sales.DataModel.csproj
│ │ ├── SalesEntities.Designer.cs
│ │ ├── SalesEntities.cs
│ │ ├── SalesEntities.edmx
│ │ ├── SalesEntities.edmx.diagram
│ │ ├── SalesEntities.tt
│ │ ├── SalesOrderDetail.cs
│ │ ├── SalesOrderHeader.cs
│ │ ├── SalesOrderHeaderSalesReason.cs
│ │ ├── SalesPerson.cs
│ │ ├── SalesPersonQuotaHistory.cs
│ │ ├── SalesReason.cs
│ │ ├── SalesTaxRate.cs
│ │ ├── SalesTerritory.cs
│ │ ├── SalesTerritoryHistory.cs
│ │ ├── ShoppingCartItem.cs
│ │ ├── SpecialOffer.cs
│ │ ├── SpecialOfferProduct.cs
│ │ ├── Store.cs
│ │ ├── Values
│ │ │ └── SalesOrderHeaderStatusValues.cs
│ │ └── packages.config
│ │ └── Sales.Services
│ │ ├── ApprovalService.cs
│ │ ├── IApprovalService.cs
│ │ ├── ModelInterceptors
│ │ ├── InvalidOrderException.cs
│ │ ├── SalesOrderCalculationsInterceptors.cs
│ │ └── SalesOrderValidationInterceptor.cs
│ │ ├── OrderingService.cs
│ │ ├── PriceCalculator.cs
│ │ ├── Properties
│ │ └── AssemblyInfo.cs
│ │ ├── Sales.Services.csproj
│ │ ├── SalesServicesModule.cs
│ │ ├── app.config
│ │ └── packages.config
├── UI
│ ├── ConsoleApplication
│ │ ├── AdventureWorksTestQueries
│ │ │ ├── SalesOrdersHeader.sql
│ │ │ └── SalesPersons.sql
│ │ ├── App.config
│ │ ├── AppConsole.cs
│ │ ├── ConsoleApplication.csproj
│ │ ├── IConsole.cs
│ │ ├── OnModuleIsAliveConsole.cs
│ │ ├── OrdersConsoleApplication.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── packages.config
│ └── WpfApplication
│ │ ├── App.config
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── MainWindow.xaml
│ │ ├── MainWindow.xaml.cs
│ │ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ │ ├── WpfApplication.csproj
│ │ └── packages.config
└── _App_Data
│ ├── readme.html
│ └── readme.md
├── DesignPatterns
├── CodeDesign-DesignPatterns.sln
└── ConsoleDemo
│ ├── AbstractFactory
│ ├── AbstractFactory.cs
│ ├── AnimalWorld.cs
│ ├── ScrollBar.cs
│ ├── WidgetFactory.cs
│ ├── WidgetsClientApp.cs
│ └── Window.cs
│ ├── App.config
│ ├── ChainOfResponsibility
│ ├── 011_PurchaseOrderApprover.cs
│ ├── 01_PurchaseOrder.cs
│ ├── 021_RequestHandler.cs
│ ├── 022_Handlers.cs
│ ├── 023_FileManager2.cs
│ ├── 02_FileManager.cs
│ └── PurchaseOrder.cs
│ ├── Composite
│ ├── 00_Client.cs
│ ├── 01_IGraphicElement.cs
│ ├── 02_Leafs.cs
│ ├── 03_Composites.cs
│ ├── 10_Client.cs
│ ├── 11_GraphicElement.cs
│ ├── 12_Leafs.cs
│ ├── 13_Composites.cs
│ ├── Extension.cs
│ └── Extension1.cs
│ ├── ConsoleDemo.csproj
│ ├── Decorator
│ ├── 01_ScrollWindow.cs
│ ├── 02_ScrollBarWindow.cs
│ └── _Client.cs
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Strategy
│ ├── 01_Robots.cs
│ ├── 02_Robot_.cs
│ ├── 031_Composition.cs
│ ├── 03_Composition_.cs
│ ├── 04_GenericRobot.cs
│ ├── Coordonates.cs
│ ├── ITextWrappingStrategy.cs
│ └── _RobotsClient.cs
│ └── Visitor
│ ├── .readme.html
│ ├── .readme.md
│ ├── ICrmService.cs
│ ├── IUnitOfWork.cs
│ ├── OrderLine.cs
│ ├── Product.cs
│ ├── UofFactory.cs
│ ├── v0
│ ├── Commands.cs
│ └── CommandsManager.cs
│ ├── v1
│ ├── Client.cs
│ └── Command.cs
│ ├── v2
│ ├── Client.cs
│ └── Command.cs
│ ├── v3
│ ├── Client.cs
│ ├── Commands.cs
│ ├── CommandsRepository.cs
│ ├── DemoData.cs
│ ├── IVisitable.cs
│ ├── IVisitor.cs
│ ├── NewCustomerCommandApprover.cs
│ ├── PurchaseOrderCommandApprover.cs
│ ├── ReportVisitor.cs
│ ├── SalesOrderCommandApprover.cs
│ └── VisitorDemo.cs
│ ├── v4
│ ├── Client.cs
│ ├── Commands.cs
│ ├── CommandsRepository.cs
│ ├── DemoData.cs
│ ├── IVisitable.cs
│ ├── IVisitor.cs
│ ├── NewCustomerCommandApprover.cs
│ ├── PurchaseOrderCommandApprover.cs
│ ├── ReportVisitor.cs
│ ├── SalesOrderCommandApprover.cs
│ ├── Visitor.cs
│ └── VisitorDemo.cs
│ ├── v5
│ ├── Client.cs
│ ├── Commands.cs
│ ├── CommandsRepository.cs
│ ├── DemoData.cs
│ ├── IVisitable.cs
│ ├── IVisitor.cs
│ ├── NewCustomerCommandApporver.cs
│ ├── PurchaseOrderCommandApprover.cs
│ ├── Report.cs
│ ├── ReportVisitor.cs
│ ├── SalesOrderCommandApprover.cs
│ ├── Visitor.cs
│ └── VisitorDemo.cs
│ └── v6
│ ├── Client.cs
│ ├── Commands.cs
│ ├── CommandsRepository.cs
│ ├── DemoData.cs
│ ├── IVisitable.cs
│ ├── IVisitor.cs
│ ├── NewCustomerCommandApporver.cs
│ ├── PurchaseOrderCommandApprover.cs
│ ├── ReportVisitor.cs
│ ├── SalesOrderCommandApprover.cs
│ ├── Visitor.cs
│ └── VisitorDemo.cs
├── InterProcessCommunication
└── TradingApp
│ ├── .Notes
│ ├── PresentationScript.html
│ ├── PresentationScript.md
│ ├── md-styles.css
│ └── md-template.html
│ ├── AppBootEx
│ ├── AppBootEx.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── ServiceProxyAttribute.cs
│ └── ServiceProxyRegistrationBehavior.cs
│ ├── ConsoleHost
│ ├── .Deployment
│ │ ├── ConsoleHost.portfolio.config
│ │ ├── ConsoleHost.quotation.config
│ │ ├── ConsoleHost.sales.config
│ │ ├── Deploy-HostAll.bat
│ │ ├── Deploy-HostEach.bat
│ │ ├── Deploy-HostPortfolio.bat
│ │ ├── Deploy-HostQuotation.bat
│ │ ├── Deploy-HostSales.bat
│ │ └── startAll.bat
│ ├── App.config
│ ├── AppBootBootstrapper.cs
│ ├── ConsoleHost.csproj
│ ├── Controllers
│ │ ├── OrdersController.cs
│ │ ├── PortfolioController.cs
│ │ └── QuotationController.cs
│ ├── Filters
│ │ └── ConsoleLogFilter.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── Startup.cs
│ ├── ConsoleUi
│ ├── .Deployment
│ │ └── Deploy-ConsoleUi-ProxyOnly.bat
│ ├── App.config
│ ├── ConsoleEx.cs
│ ├── ConsoleUi.csproj
│ ├── Program.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
│ ├── Infrastructure
│ ├── Common
│ │ └── Infra.Hosts
│ │ │ ├── Infra.Hosts.csproj
│ │ │ ├── ModulesHostContainer.cs
│ │ │ └── Properties
│ │ │ └── AssemblyInfo.cs
│ └── Proxies
│ │ ├── HttpHelpers.cs
│ │ ├── OrdersServiceProxy.cs
│ │ ├── PortfolioServiceProxy.cs
│ │ ├── Properties
│ │ └── AssemblyInfo.cs
│ │ ├── Proxies.csproj
│ │ ├── ProxiesModule.cs
│ │ ├── QuotationServiceProxy.cs
│ │ └── app.config
│ ├── MigrationBackup
│ ├── 00c682d4
│ │ └── Infrastructure
│ │ │ └── Infra.Hosts
│ │ │ ├── Infra.Hosts.csproj
│ │ │ ├── NuGetUpgradeLog.html
│ │ │ └── packages.config
│ ├── 13c6add7
│ │ └── ConsoleUi
│ │ │ ├── ConsoleUi.csproj
│ │ │ ├── NuGetUpgradeLog.html
│ │ │ └── packages.config
│ ├── 1abf21ee
│ │ └── Infrastructure
│ │ │ └── AppBootEx
│ │ │ ├── AppBootEx.csproj
│ │ │ ├── NuGetUpgradeLog.html
│ │ │ └── packages.config
│ ├── 637404f9
│ │ └── ConsoleHost
│ │ │ ├── ConsoleHost.csproj
│ │ │ ├── NuGetUpgradeLog.html
│ │ │ └── packages.config
│ ├── 6a755282
│ │ └── Modules
│ │ │ └── Quotations
│ │ │ └── Quotations.Services
│ │ │ ├── NuGetUpgradeLog.html
│ │ │ ├── Quotations.Services.csproj
│ │ │ └── packages.config
│ ├── 99eadac7
│ │ └── Modules
│ │ │ └── Sales
│ │ │ └── Sales.Services
│ │ │ ├── NuGetUpgradeLog.html
│ │ │ ├── Sales.Services.csproj
│ │ │ └── packages.config
│ ├── 9d36020b
│ │ └── Modules
│ │ │ └── Portfolio
│ │ │ └── Portfolio.Services
│ │ │ ├── NuGetUpgradeLog.html
│ │ │ ├── Portfolio.Services.csproj
│ │ │ └── packages.config
│ └── ab5e6800
│ │ └── Infrastructure
│ │ └── Proxies
│ │ ├── NuGetUpgradeLog.html
│ │ ├── Proxies.csproj
│ │ └── packages.config
│ ├── Modules
│ ├── Portfolio
│ │ └── Portofolio.Services
│ │ │ ├── Portfolio.Services.csproj
│ │ │ ├── PortfolioModule.cs
│ │ │ ├── PortfolioService.cs
│ │ │ └── Properties
│ │ │ └── AssemblyInfo.cs
│ ├── Quotation
│ │ └── Quotation.Services
│ │ │ └── QuotationService.cs
│ ├── Quotations
│ │ └── Quotation.Services
│ │ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ │ ├── QuotationService.cs
│ │ │ ├── Quotations.Services.csproj
│ │ │ └── QuotationsModule.cs
│ ├── Sales
│ │ └── Sales.Services
│ │ │ ├── IRepository.cs
│ │ │ ├── InMemoryRepository.cs
│ │ │ ├── OrdersService.cs
│ │ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ │ ├── Sales.Services.csproj
│ │ │ └── SalesModule.cs
│ └── _Contracts
│ │ ├── Contracts.csproj
│ │ ├── Infrastructure
│ │ └── IModulesHostContainer.cs
│ │ ├── Portfolio.Services
│ │ └── IPortfolioService.cs
│ │ ├── Properties
│ │ └── AssemblyInfo.cs
│ │ ├── Quotations.Services
│ │ ├── IQuotationService.cs
│ │ └── Quotation.cs
│ │ └── Sales.Services
│ │ ├── IOrdersService.cs
│ │ └── LimitOrder.cs
│ └── TradingApp.sln
├── LICENSE
├── LessonsSamples
├── LessonsSamples.sln
└── LessonsSamples
│ ├── App.config
│ ├── Customer.cs
│ ├── Lesson2
│ ├── querymanager.cpp
│ └── querymanager.cs
│ ├── Lesson5
│ ├── Class2.cs
│ ├── ImageScale.cs
│ ├── Line.cs
│ ├── Modem.cs
│ ├── Rectangle.cs
│ ├── Shapes.cs
│ └── TimedDoorAdapter.cs
│ ├── Lesson6
│ ├── CoreContainerConstructorSelection
│ │ ├── App.cs
│ │ ├── IRootService.cs
│ │ ├── IService1.cs
│ │ ├── IService2.cs
│ │ └── NetCoreConstructorSelectionDemo.cs
│ ├── CoreContainerLifetime
│ │ ├── App.cs
│ │ ├── IOperation.cs
│ │ ├── MyController.cs
│ │ ├── NetCoreLifetimeDemo.cs
│ │ ├── Operation.cs
│ │ └── Service.cs
│ ├── DI-Demo
│ │ ├── AppConsole.cs
│ │ ├── FileStorage.cs
│ │ ├── IConsole.cs
│ │ ├── IMovieConsoleCreator.cs
│ │ ├── IMovieTranslator.cs
│ │ ├── ITextStorage.cs
│ │ ├── MovieConsoleApplication.cs
│ │ ├── MovieTranslator.cs
│ │ ├── NetCoreContainerDemo.cs
│ │ ├── UnityDemo.cs
│ │ ├── _Exercises.html
│ │ └── _Exercises.md
│ ├── DI_AndDisposable
│ │ ├── Model.cs
│ │ ├── Repository.cs
│ │ ├── RepositoryFactory.cs
│ │ ├── Service11.cs
│ │ └── Service12.cs
│ ├── Expenses
│ │ ├── 1.ExpenseData.cs
│ │ ├── 1.ExpensesService.cs
│ │ ├── 1.IExpensesService.cs
│ │ └── 2.Expense.cs
│ ├── IMovieProvider.cs
│ ├── Logger
│ │ ├── LogEntry.cs
│ │ └── Logger.cs
│ ├── Movie.cs
│ ├── MovieListerFactory.cs
│ ├── MovieLister_DI.cs
│ ├── MovieLister_InterafaceInj.cs
│ ├── MovieLister_SL.cs
│ └── ServiceLocatorTestability
│ │ ├── INumberGeneratorService.cs
│ │ ├── ServiceLocatorDoubleStorage.cs
│ │ ├── TestRunner.cs
│ │ ├── UnderTest.cs
│ │ └── UnitTest.cs
│ ├── Lesson7
│ ├── Class1.cs
│ ├── CohesionCoupling
│ │ ├── 00_PageXmlExport.cs
│ │ ├── 01_PageXmlExport.cs
│ │ ├── 02_PageXmlExport.cs
│ │ ├── 03_PageXmlExport.cs
│ │ ├── 04_PageXmlExport.cs
│ │ ├── 05_PageXmlExport.cs
│ │ ├── 10_PageXmlExportClient.cs
│ │ ├── 11_PageXmlExportClient.cs
│ │ ├── 12_PageXmlExportClientcs.cs
│ │ ├── 13_PageXmlExportClient.cs
│ │ ├── EfRepository.cs
│ │ ├── ICrmService.cs
│ │ ├── IExportDataProvider_4.cs
│ │ ├── IExportDataProvider_5.cs
│ │ ├── ILocationService.cs
│ │ ├── IPageFileWriter.cs
│ │ ├── IRepository.cs
│ │ ├── PageData.cs
│ │ └── PageXml.cs
│ ├── ErrorHandling
│ │ ├── CodeSnippet.cs
│ │ └── DeviceController.cs
│ ├── GoodClasses
│ │ ├── DataModel
│ │ │ ├── Repository.cs
│ │ │ └── SalesOrder.cs
│ │ └── Geometry
│ │ │ ├── CircleGeometry.cs
│ │ │ ├── GeometryCalculatorFactory.cs
│ │ │ ├── IGeometryCalculator.cs
│ │ │ ├── PolymorphicShapes.cs
│ │ │ └── ProceduralShapes.cs
│ └── InheritanceComposition
│ │ ├── Account.cs
│ │ ├── AccountClientCode.cs
│ │ ├── AccountClientCodeTests.cs
│ │ ├── AccountTests.cs
│ │ ├── ILogMessageParser.cs
│ │ ├── LogEntry.cs
│ │ ├── LogSource.cd
│ │ ├── LogSource.cs
│ │ ├── LogSource_2.cd
│ │ ├── LogSource_2.cs
│ │ └── Month.cs
│ ├── Lesson8
│ ├── AuditLog
│ │ ├── EntityInterceptor.cs
│ │ ├── IAuditLog.cs
│ │ └── PatientAuditLogInterceptor.cs
│ ├── RowLevelAuth
│ │ ├── IRowAuthPoliciesContainer.cs
│ │ ├── Repository.cs
│ │ ├── RowAuthPoliciesContainer.cs
│ │ ├── RowAuthPolicy.cs
│ │ └── SomeService.cs
│ └── Validation
│ │ ├── AddressValidationRules.cs
│ │ ├── Country.cs
│ │ ├── EntityValidationRulesRegistrator.cs
│ │ ├── IValidationRulesSet.cs
│ │ └── ValidationMessages.cs
│ ├── LessonsSamples.csproj
│ ├── Point.cs
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ └── packages.config
├── MultitenancySamples
├── SeparatedDbsConsoleDemo
│ ├── SeparatedDbs.ConsoleDemo
│ │ ├── App.config
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── SeparatedDbs.ConsoleDemo.csproj
│ ├── SeparatedDbs.DataAccess
│ │ ├── App.config
│ │ ├── MultitenancyDbContextFactory.cs
│ │ ├── PhysioEntities.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── SeparatedDbs.DataAccess.csproj
│ │ └── packages.config
│ └── SeparatedDbsConsoleDemo.sln
└── SharedDbConsoleDemo
│ ├── SharedDb.ConsoleDemo
│ ├── App.config
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SharedDb.ConsoleDemo.csproj
│ └── packages.config
│ ├── SharedDb.DataAccess
│ ├── App.config
│ ├── DbContextFactory.cs
│ ├── Diagnostic.cs
│ ├── EmptyInterceptorsResolver.cs
│ ├── ITenantEntity.cs
│ ├── Patient.cs
│ ├── PatientFile.cs
│ ├── PatientHistory.cs
│ ├── Physio.Context.cs
│ ├── Physio.Context.tt
│ ├── Physio.Designer.cs
│ ├── Physio.cs
│ ├── Physio.edmx
│ ├── Physio.edmx.diagram
│ ├── Physio.tt
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Repository.cs
│ ├── SharedDb.DataAccess.csproj
│ ├── Tenant.cs
│ ├── TenantEntities.cs
│ └── packages.config
│ ├── SharedDb.Database
│ ├── RefactorToMultitenancy.publish.sql
│ ├── SharedDb.Database.sqlproj
│ └── dbo
│ │ └── Tables
│ │ ├── Diagnostics.sql
│ │ ├── PatientFile.sql
│ │ ├── PatientHistory.sql
│ │ ├── Patients.sql
│ │ └── Tenants.sql
│ └── SharedDbConsoleDemo.sln
└── README.md
/AppInfraDemo/.Exercises/PointsOfAttention.md:
--------------------------------------------------------------------------------
1 | # Enforce Data Access Layer and Business Logic Layer separation
2 |
3 | - No assembly except the `*.DataAccess` ones are allowed to reference the `Entity Framework`
4 |
5 | - By default the EF generates the DTOs in the same project w/ the `DbContext`. This does not enforce the separation.
6 |
7 | - We should change the generator to put in the `DataAccess` the `DbContext` needed for implementing the `Repository` and `UnitOfWork` and in the Sales Module the DTOs as they are its Data Model
8 |
9 | - The tag `Infra_DataAccessDependsOnSales` shows a first step on doing this.
10 | - however, here there is "wrong" reference from the `DataAccess` to the Sales Modules assembly
11 |
12 | - The tag `Infra_DataAccessDependencyOnSalesRemoved` shows how this reference is inverted by using the `IDbContextFactory` abstraction
13 |
--------------------------------------------------------------------------------
/AppInfraDemo/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 |
3 | # DV2002: Unmapped types
4 | dotnet_diagnostic.DV2002.severity = silent
5 |
--------------------------------------------------------------------------------
/AppInfraDemo/ClassDiagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onCodeDesign/Code-Design-Training/738d05aae78965ec7825606b5da2915aa28194e4/AppInfraDemo/ClassDiagram.png
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/Common/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/Common/DataModel/Abstractions/Demo_IAuditable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Common.DataModel.Abstractions
4 | {
5 | public interface IAuditable
6 | {
7 | DateTime? LastEditDate { get; set; }
8 | DateTime CreationDate { get; set; }
9 | string LastEditBy { get; set; }
10 | string CreatedBy { get; set; }
11 | }
12 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/Common/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/CollectionExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace DataAccess
4 | {
5 | static class CollectionExtensions
6 | {
7 | public static void AddIfNotExists(this ICollection list, T item)
8 | {
9 | if (list.Contains(item) == false)
10 | {
11 | list.Add(item);
12 | }
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/EntityInterceptor.cs:
--------------------------------------------------------------------------------
1 | namespace DataAccess
2 | {
3 | public abstract class EntityInterceptor : IEntityInterceptor
4 | where TEntity : class
5 | {
6 | public virtual void OnLoad(IEntityEntryFacade entry, IRepository repository)
7 | {
8 | }
9 |
10 | public virtual void OnSave(IEntityEntryFacade entry, IRepository repository)
11 | {
12 | }
13 |
14 | public virtual void OnEntityRemoved(IEntityEntryFacade entry, IRepository repository)
15 | {
16 | }
17 |
18 | public void OnLoad(IEntityEntryFacade entry, IRepository repository)
19 | {
20 | this.OnLoad(entry.Convert(), repository);
21 | }
22 |
23 | public void OnSave(IEntityEntryFacade entity, IRepository repository)
24 | {
25 | this.OnSave(entity.Convert(), repository);
26 | }
27 |
28 | public void OnEntityRemoved(IEntityEntryFacade entity, IRepository repository)
29 | {
30 | this.OnEntityRemoved(entity.Convert(), repository);
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/Exceptions/DataValidationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace DataAccess.Exceptions
6 | {
7 | [Serializable]
8 | public class DataValidationResult
9 | {
10 | private readonly List errors;
11 |
12 | public DataValidationResult(IEntityEntryFacade entry, IEnumerable errors)
13 | {
14 | Entry = entry;
15 | this.errors = errors.ToList();
16 | }
17 |
18 | public IEntityEntryFacade Entry { get; private set; }
19 |
20 | public IEnumerable Errors
21 | {
22 | get { return errors; }
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/Exceptions/DateTimeRangeRepositoryException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data.SqlClient;
3 | using System.Runtime.Serialization;
4 |
5 | namespace DataAccess.Exceptions
6 | {
7 | [Serializable]
8 | public class DateTimeRangeRepositoryException : RepositoryException
9 | {
10 | public DateTimeRangeRepositoryException()
11 | {
12 | }
13 |
14 | public DateTimeRangeRepositoryException(string errorMessage)
15 | : base(errorMessage)
16 | {
17 | }
18 |
19 | public DateTimeRangeRepositoryException(SqlException exception)
20 | : base(exception)
21 | {
22 | }
23 |
24 | public DateTimeRangeRepositoryException(string message, Exception exception)
25 | : base(message, exception)
26 | {
27 | }
28 |
29 | protected DateTimeRangeRepositoryException(SerializationInfo info, StreamingContext context)
30 | : base(info, context)
31 | {
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/Exceptions/DeadlockVictimRepositoryException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data.SqlClient;
3 | using System.Runtime.Serialization;
4 |
5 | namespace DataAccess.Exceptions
6 | {
7 | [Serializable]
8 | public class DeadlockVictimRepositoryException : RepositoryException
9 | {
10 | public DeadlockVictimRepositoryException()
11 | {
12 | }
13 |
14 | public DeadlockVictimRepositoryException(string errorMessage)
15 | : base(errorMessage)
16 | {
17 | }
18 |
19 | public DeadlockVictimRepositoryException(SqlException exception)
20 | : base(exception)
21 | {
22 | }
23 |
24 | public DeadlockVictimRepositoryException(string message, Exception exception)
25 | : base(message, exception)
26 | {
27 | }
28 |
29 | protected DeadlockVictimRepositoryException(SerializationInfo info, StreamingContext context)
30 | : base(info, context)
31 | {
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/Exceptions/DeleteConstraintRepositoryException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data.SqlClient;
3 | using System.Runtime.Serialization;
4 |
5 | namespace DataAccess.Exceptions
6 | {
7 | [Serializable]
8 | public class DeleteConstraintRepositoryException : RepositoryException
9 | {
10 | public DeleteConstraintRepositoryException()
11 | {
12 | }
13 |
14 | public DeleteConstraintRepositoryException(string errorMessage)
15 | : base(errorMessage)
16 | {
17 | }
18 |
19 | public DeleteConstraintRepositoryException(SqlException exception)
20 | : base(exception)
21 | {
22 | }
23 |
24 | public DeleteConstraintRepositoryException(string message, Exception exception)
25 | : base(message, exception)
26 | {
27 | }
28 |
29 | protected DeleteConstraintRepositoryException(SerializationInfo info, StreamingContext context)
30 | : base(info, context)
31 | {
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/Exceptions/Handlers/ConcurrencyExceptionHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data.Entity.Core;
3 | using iQuarc.SystemEx;
4 |
5 | namespace DataAccess.Exceptions.Handlers
6 | {
7 | class ConcurrencyExceptionHandler : IExceptionHandler
8 | {
9 | private readonly IExceptionHandler successor;
10 |
11 | public ConcurrencyExceptionHandler(IExceptionHandler successor)
12 | {
13 | this.successor = successor;
14 | }
15 |
16 | public void Handle(Exception exception)
17 | {
18 | var concurrencyException = exception.FirstInner();
19 | if (concurrencyException != null)
20 | {
21 | throw new ConcurrencyRepositoryException(concurrencyException);
22 | }
23 |
24 | successor.Handle(exception);
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/Exceptions/Handlers/DefaultExceptionHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DataAccess.Exceptions.Handlers
4 | {
5 | class DefaultExceptionHandler : IExceptionHandler
6 | {
7 | public void Handle(Exception exception)
8 | {
9 | throw new RepositoryException(exception);
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/Exceptions/Handlers/ExceptionHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DataAccess.Exceptions.Handlers
4 | {
5 | class ExceptionHandler : IExceptionHandler
6 | {
7 | private readonly IExceptionHandler chainHead =
8 | new SqlExceptionHandler(
9 | new ConcurrencyExceptionHandler(
10 | new UpdateExceptionHandler(
11 | new DbEntityValidationExceptionHandler(
12 | new DefaultExceptionHandler())))
13 | );
14 |
15 | public void Handle(Exception exception)
16 | {
17 | chainHead.Handle(exception);
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/Exceptions/Handlers/IExceptionHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DataAccess.Exceptions.Handlers
4 | {
5 | interface IExceptionHandler
6 | {
7 | void Handle(Exception exception);
8 | }
9 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/Exceptions/Handlers/UpdateExceptionHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data.Entity.Core;
3 | using iQuarc.SystemEx;
4 |
5 | namespace DataAccess.Exceptions.Handlers
6 | {
7 | class UpdateExceptionHandler : IExceptionHandler
8 | {
9 | private readonly IExceptionHandler successor;
10 |
11 | public UpdateExceptionHandler(IExceptionHandler successor)
12 | {
13 | this.successor = successor;
14 | }
15 |
16 | public void Handle(Exception exception)
17 | {
18 | var updateException = exception.FirstInner();
19 | if (updateException != null)
20 | {
21 | throw new RepositoryUpdateException(updateException);
22 | }
23 |
24 | successor.Handle(exception);
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/Exceptions/RepositoryUpdateException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 |
4 | namespace DataAccess.Exceptions
5 | {
6 | [Serializable]
7 | public class RepositoryUpdateException : RepositoryException
8 | {
9 | public RepositoryUpdateException()
10 | {
11 | }
12 |
13 | public RepositoryUpdateException(string errorMessage)
14 | : base(errorMessage)
15 | {
16 | }
17 |
18 | public RepositoryUpdateException(Exception exception)
19 | : base(exception)
20 | {
21 | }
22 |
23 | public RepositoryUpdateException(string message, Exception exception)
24 | : base(message, exception)
25 | {
26 | }
27 |
28 | protected RepositoryUpdateException(SerializationInfo info, StreamingContext context)
29 | : base(info, context)
30 | {
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/Exceptions/UniqueConstraintRepositoryException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data.SqlClient;
3 | using System.Runtime.Serialization;
4 |
5 | namespace DataAccess.Exceptions
6 | {
7 | [Serializable]
8 | public class UniqueConstraintRepositoryException : RepositoryException
9 | {
10 | public UniqueConstraintRepositoryException()
11 | {
12 | }
13 |
14 | public UniqueConstraintRepositoryException(string errorMessage)
15 | : base(errorMessage)
16 | {
17 | }
18 |
19 | public UniqueConstraintRepositoryException(SqlException exception)
20 | : base(exception)
21 | {
22 | }
23 |
24 | public UniqueConstraintRepositoryException(string message, Exception exception)
25 | : base(message, exception)
26 | {
27 | }
28 |
29 | protected UniqueConstraintRepositoryException(SerializationInfo info, StreamingContext context)
30 | : base(info, context)
31 | {
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/Exceptions/ValidationError.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DataAccess.Exceptions
4 | {
5 | [Serializable]
6 | public class ValidationError
7 | {
8 | public ValidationError(string propertyName, string errorMessage)
9 | {
10 | PropertyName = propertyName;
11 | ErrorMessage = errorMessage;
12 | }
13 |
14 | public string PropertyName { get; private set; }
15 | public string ErrorMessage { get; private set; }
16 | }
17 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/IDbContextFactory.cs:
--------------------------------------------------------------------------------
1 | using System.Data.Entity;
2 |
3 | namespace DataAccess
4 | {
5 | public interface IDbContextFactory
6 | {
7 | DbContext CreateContext();
8 | }
9 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/IEntityEntryFacade.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DataAccess
4 | {
5 | public interface IEntityEntryFacade
6 | {
7 | object Entity { get; }
8 | EntityEntryStates State { get; }
9 | object GetOriginalValue(string propertyName);
10 | IEntityEntryFacade Convert() where T : class;
11 | void SetOriginalValue(string propertyName, object value);
12 | }
13 |
14 | public interface IEntityEntryFacade
15 | where T : class
16 | {
17 | T Entity { get; }
18 | EntityEntryStates State { get; }
19 | object GetOriginalValue(string propertyName);
20 | void SetOriginalValue(string propertyName, object value);
21 | }
22 |
23 | [Flags]
24 | public enum EntityEntryStates
25 | {
26 | Detached = 1,
27 | Unchanged = 2,
28 | Added = 4,
29 | Deleted = 8,
30 | Modified = 16,
31 | }
32 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/IEntityInterceptor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DataAccess
4 | {
5 | public interface IEntityInterceptor
6 | {
7 | void OnLoad(IEntityEntryFacade entry, IRepository repository);
8 | void OnSave(IEntityEntryFacade entity, IRepository repository);
9 | void OnEntityRemoved(IEntityEntryFacade entity, IRepository repository);
10 | }
11 |
12 | public interface IEntityInterceptor : IEntityInterceptor
13 | where T : class
14 | {
15 | void OnLoad(IEntityEntryFacade entry, IRepository repository);
16 | void OnSave(IEntityEntryFacade entry, IRepository repository);
17 | void OnEntityRemoved(IEntityEntryFacade entity, IRepository repository);
18 | }
19 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/IRepository.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 |
3 | namespace DataAccess
4 | {
5 | public interface IRepository
6 | {
7 | IQueryable GetEntities() where TDbEntity : class;
8 | IUnitOfWork CreateUnitOfWork();
9 | }
10 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DataAccess/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AppInfraDemo/Infrastructure/DependencyValidation/DependencyValidation.layerdiagram.suppressions:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Contracts/Crm/ICrmService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Contracts.Crm
8 | {
9 | public interface ICrmService
10 | {
11 | CustomerInfo GetCustomerInfo(string customerName);
12 | }
13 |
14 | public class CustomerInfo
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Contracts/Location/ILocationService.cs:
--------------------------------------------------------------------------------
1 | namespace Contracts.Location
2 | {
3 | public interface ILocationService
4 | {
5 | Coordinates GetCoordinates(string city, string street, string number);
6 | }
7 |
8 | public class Coordinates
9 | {
10 | public double Latitude { get; set; }
11 | public double Longitude { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Contracts/Notifications/IAmAliveSubscriber.cs:
--------------------------------------------------------------------------------
1 | namespace Contracts.Notifications
2 | {
3 | public interface IAmAliveSubscriber
4 | {
5 | void AmAlive(T item);
6 | }
7 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Contracts/Notifications/INotificationService.cs:
--------------------------------------------------------------------------------
1 | namespace Contracts.Notifications
2 | {
3 | public interface INotificationService
4 | {
5 | void NotifyNew(T item);
6 | void NotifyDeleted(T item);
7 | void NotifyChanged(T item);
8 | void NotifyStatusChange(T item, Status newStatus, Status oldStatus);
9 | void NotifyAlive(T item);
10 | }
11 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Contracts/Notifications/IStateChangeSubscriber.cs:
--------------------------------------------------------------------------------
1 | namespace Contracts.Notifications
2 | {
3 | public interface IStateChangeSubscriber
4 | {
5 | void NewItem(T item);
6 | void NotifyDeleted(T item);
7 | void NotifyChanged(T item);
8 | }
9 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Contracts/Notifications/Status.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Contracts.Notifications
4 | {
5 | [Flags]
6 | public enum Status
7 | {
8 | New = 0,
9 | PreProcess = 2,
10 | InProgress = 4,
11 | PreApprove = 8,
12 | Approved = 16,
13 | Rejected = 32,
14 | OnHold = 64,
15 | Deleted = 128
16 | }
17 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Contracts/Sales/IOrderingService.cs:
--------------------------------------------------------------------------------
1 | namespace Contracts.Sales
2 | {
3 | public interface IOrderingService
4 | {
5 | SalesOrderResult PlaceOrder(string customerName, OrderRequest request);
6 |
7 | SalesOrderInfo[] GetOrdersInfo(string customerName);
8 | }
9 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Contracts/Sales/OrderRequest.cs:
--------------------------------------------------------------------------------
1 | namespace Contracts.Sales
2 | {
3 | public class OrderRequest
4 | {
5 | public ProductQuantity[] Products { get; set; }
6 | }
7 |
8 | public class ProductQuantity
9 | {
10 | public ProductDescription Product { get; set; }
11 | public float Quantity { get; set; }
12 | public UnitOfMeasure Unit { get; set; }
13 | }
14 |
15 | public class ProductDescription
16 | {
17 | public int? ProductId { get; set; }
18 | public string Code { get; set; }
19 | public string Description { get; set; }
20 | }
21 |
22 | public enum UnitOfMeasure
23 | {
24 | Item,
25 | Kilograms,
26 | Liters
27 | }
28 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Contracts/Sales/SalesOrderInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Contracts.Sales
4 | {
5 | public class SalesOrderInfo
6 | {
7 | public string CustomerName { get; set; }
8 | public string Number { get; set; }
9 |
10 | public string SalesPersonName { get; set; }
11 |
12 | public DateTime DueDate { get; set; }
13 |
14 | public decimal TotalDue { get; set; }
15 |
16 | }
17 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Contracts/Sales/SalesOrderResult.cs:
--------------------------------------------------------------------------------
1 | namespace Contracts.Sales
2 | {
3 | public class SalesOrderResult
4 | {
5 | public int OrderId { get; set; }
6 | public OrderResultState State { get; set; }
7 | public string Message { get; set; }
8 | }
9 |
10 | public enum OrderResultState
11 | {
12 | ///
13 | /// Technical unknown error
14 | ///
15 | Error,
16 |
17 | ///
18 | /// Order placement was successful
19 | ///
20 | Placed,
21 |
22 | ///
23 | /// Order wasn't placed because of business rules
24 | ///
25 | Failure,
26 |
27 | ///
28 | /// The order request was invalid.
29 | /// The order was not placed
30 | ///
31 | Invalid
32 | }
33 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Contracts/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/DataModel/Customer.cs:
--------------------------------------------------------------------------------
1 | namespace DataModel
2 | {
3 | public class Customer
4 | {
5 | public string Name { get; set; }
6 | }
7 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/DataModel/Order.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DataModel
4 | {
5 | public class Order
6 | {
7 | public Customer Customer { get; set; }
8 | public DateTime Date { get; set; }
9 | }
10 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/DataModel/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Export/Export.DataModel/Category.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Export.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class Category
16 | {
17 | public Category()
18 | {
19 | this.Products = new HashSet();
20 | }
21 |
22 | public int CategoryID { get; set; }
23 | public string CategoryName { get; set; }
24 | public string Description { get; set; }
25 | public byte[] Picture { get; set; }
26 |
27 | public virtual ICollection Products { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Export/Export.DataModel/CustomerDemographic.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Export.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class CustomerDemographic
16 | {
17 | public CustomerDemographic()
18 | {
19 | this.Customers = new HashSet();
20 | }
21 |
22 | public string CustomerTypeID { get; set; }
23 | public string CustomerDesc { get; set; }
24 |
25 | public virtual ICollection Customers { get; set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Export/Export.DataModel/ExportEntities.Designer.cs:
--------------------------------------------------------------------------------
1 | // T4 code generation is enabled for model 'C:\D\Work\Training\OOD\git\AppInfraDemo\Modules\Export\Export.DataModel\ExportEntities.edmx'.
2 | // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer
3 | // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model
4 | // is open in the designer.
5 |
6 | // If no context and entity classes have been generated, it may be because you created an empty model but
7 | // have not yet chosen which version of Entity Framework to use. To generate a context class and entity
8 | // classes for your model, open the model in the designer, right-click on the designer surface, and
9 | // select 'Update Model from Database...', 'Generate Database from Model...', or 'Add Code Generation
10 | // Item...'.
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Export/Export.DataModel/ExportEntities.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Export/Export.DataModel/Order_Detail.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Export.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class Order_Detail
16 | {
17 | public int OrderID { get; set; }
18 | public int ProductID { get; set; }
19 | public decimal UnitPrice { get; set; }
20 | public short Quantity { get; set; }
21 | public float Discount { get; set; }
22 |
23 | public virtual Order Order { get; set; }
24 | public virtual Product Product { get; set; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Export/Export.DataModel/Region.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Export.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class Region
16 | {
17 | public Region()
18 | {
19 | this.Territories = new HashSet();
20 | }
21 |
22 | public int RegionID { get; set; }
23 | public string RegionDescription { get; set; }
24 |
25 | public virtual ICollection Territories { get; set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Export/Export.DataModel/Shipper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Export.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class Shipper
16 | {
17 | public Shipper()
18 | {
19 | this.Orders = new HashSet();
20 | }
21 |
22 | public int ShipperID { get; set; }
23 | public string CompanyName { get; set; }
24 | public string Phone { get; set; }
25 |
26 | public virtual ICollection Orders { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Export/Export.DataModel/Territory.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Export.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class Territory
16 | {
17 | public Territory()
18 | {
19 | this.Employees = new HashSet();
20 | }
21 |
22 | public string TerritoryID { get; set; }
23 | public string TerritoryDescription { get; set; }
24 | public int RegionID { get; set; }
25 |
26 | public virtual Region Region { get; set; }
27 | public virtual ICollection Employees { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Export/Export.DataModel/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Export/Export.Services/PageXmlDemo/CustomerData.cs:
--------------------------------------------------------------------------------
1 | namespace Export.Services.PageXmlDemo
2 | {
3 | public class CustomerData
4 | {
5 | }
6 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Export/Export.Services/PageXmlDemo/PageData.cs:
--------------------------------------------------------------------------------
1 | namespace Export.Services.PageXmlDemo
2 | {
3 | public class PageData
4 | {
5 | public CustomerData CustomerData { get; set; }
6 | }
7 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Export/Export.Services/PageXmlDemo/PageXml.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Export.Services.PageXmlDemo
4 | {
5 | public class PageXml
6 | {
7 | public CustomerXml Customer { get; set; }
8 | }
9 |
10 | public class CustomerXml
11 | {
12 | public string Name { get; set; }
13 | public List Addresses { get; set; }
14 | }
15 |
16 | public class AddressXml
17 | {
18 | public string Street { get; set; }
19 | public string City { get; set; }
20 | public string Number { get; set; }
21 | public string Coordinates { get; set; }
22 | }
23 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Export/Export.Services/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Notifications/Notification.Services/OrderStateChangeSubscriber.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Contracts.Notifications;
3 | using Contracts.Sales;
4 | using iQuarc.AppBoot;
5 |
6 | namespace Notifications
7 | {
8 | [Service("Order Default Subscriber", typeof (IStateChangeSubscriber))]
9 | class OrderStateChangeSubscriber : IStateChangeSubscriber
10 | {
11 | public void NewItem(SalesOrderResult item)
12 | {
13 | //TODO: We've got new order!!!
14 | }
15 |
16 | public void NotifyDeleted(SalesOrderResult item)
17 | {
18 | throw new NotImplementedException();
19 | }
20 |
21 | public void NotifyChanged(SalesOrderResult item)
22 | {
23 | throw new NotImplementedException();
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Notifications/Notification.Services/StateChangeSubscriber.cs:
--------------------------------------------------------------------------------
1 | using Contracts.Notifications;
2 | using iQuarc.AppBoot;
3 |
4 | namespace Notifications
5 | {
6 | [Service("Default Change Subscriber", typeof (IStateChangeSubscriber<>))]
7 | class StateChangeSubscriber : IStateChangeSubscriber
8 | {
9 | public void NewItem(T item)
10 | {
11 | //TODO: write to monitoring dashboard
12 | }
13 |
14 | public void NotifyDeleted(T item)
15 | {
16 | //TODO: write to monitoring dashboard
17 | }
18 |
19 | public void NotifyChanged(T item)
20 | {
21 | //TODO: write to monitoring dashboard
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Notifications/Notification.Services/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Notifications/Notification.Services/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataAccess/DbContextFactory.cs:
--------------------------------------------------------------------------------
1 | using iQuarc.AppBoot;
2 | using iQuarc.DataAccess;
3 |
4 | namespace Sales.DataAccess
5 | {
6 | [Service(typeof(IDbContextFactory))]
7 | public class DbContextFactory : DbContextFactory
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataAccess/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/App.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/CountryRegionCurrency.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Sales.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class CountryRegionCurrency
16 | {
17 | public string CountryRegionCode { get; set; }
18 | public string CurrencyCode { get; set; }
19 | public System.DateTime ModifiedDate { get; set; }
20 |
21 | public virtual Currency Currency { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/PersonCreditCard.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Sales.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class PersonCreditCard
16 | {
17 | public int BusinessEntityID { get; set; }
18 | public int CreditCardID { get; set; }
19 | public System.DateTime ModifiedDate { get; set; }
20 |
21 | public virtual CreditCard CreditCard { get; set; }
22 | public virtual Person Person { get; set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/SalesEntities.Designer.cs:
--------------------------------------------------------------------------------
1 | // T4 code generation is enabled for model 'C:\D\Work\Training\OOD\git\AppInfraDemo\Modules\Sales\Sales.DataModel\SalesEntities.edmx'.
2 | // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer
3 | // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model
4 | // is open in the designer.
5 |
6 | // If no context and entity classes have been generated, it may be because you created an empty model but
7 | // have not yet chosen which version of Entity Framework to use. To generate a context class and entity
8 | // classes for your model, open the model in the designer, right-click on the designer surface, and
9 | // select 'Update Model from Database...', 'Generate Database from Model...', or 'Add Code Generation
10 | // Item...'.
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/SalesEntities.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/SalesOrderHeaderSalesReason.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Sales.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class SalesOrderHeaderSalesReason
16 | {
17 | public int SalesOrderID { get; set; }
18 | public int SalesReasonID { get; set; }
19 | public System.DateTime ModifiedDate { get; set; }
20 |
21 | public virtual SalesOrderHeader SalesOrderHeader { get; set; }
22 | public virtual SalesReason SalesReason { get; set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/SalesPersonQuotaHistory.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Sales.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class SalesPersonQuotaHistory
16 | {
17 | public int BusinessEntityID { get; set; }
18 | public System.DateTime QuotaDate { get; set; }
19 | public decimal SalesQuota { get; set; }
20 | public System.Guid rowguid { get; set; }
21 | public System.DateTime ModifiedDate { get; set; }
22 |
23 | public virtual SalesPerson SalesPerson { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/SalesReason.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Sales.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class SalesReason
16 | {
17 | public SalesReason()
18 | {
19 | this.SalesOrderHeaderSalesReasons = new HashSet();
20 | }
21 |
22 | public int SalesReasonID { get; set; }
23 | public string Name { get; set; }
24 | public string ReasonType { get; set; }
25 | public System.DateTime ModifiedDate { get; set; }
26 |
27 | public virtual ICollection SalesOrderHeaderSalesReasons { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/SalesTaxRate.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Sales.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class SalesTaxRate
16 | {
17 | public int SalesTaxRateID { get; set; }
18 | public int StateProvinceID { get; set; }
19 | public byte TaxType { get; set; }
20 | public decimal TaxRate { get; set; }
21 | public string Name { get; set; }
22 | public System.Guid rowguid { get; set; }
23 | public System.DateTime ModifiedDate { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/SalesTerritoryHistory.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Sales.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class SalesTerritoryHistory
16 | {
17 | public int BusinessEntityID { get; set; }
18 | public int TerritoryID { get; set; }
19 | public System.DateTime StartDate { get; set; }
20 | public Nullable EndDate { get; set; }
21 | public System.Guid rowguid { get; set; }
22 | public System.DateTime ModifiedDate { get; set; }
23 |
24 | public virtual SalesPerson SalesPerson { get; set; }
25 | public virtual SalesTerritory SalesTerritory { get; set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/ShoppingCartItem.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Sales.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class ShoppingCartItem
16 | {
17 | public int ShoppingCartItemID { get; set; }
18 | public string ShoppingCartID { get; set; }
19 | public int Quantity { get; set; }
20 | public int ProductID { get; set; }
21 | public System.DateTime DateCreated { get; set; }
22 | public System.DateTime ModifiedDate { get; set; }
23 |
24 | public virtual Product Product { get; set; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/SpecialOfferProduct.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Sales.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class SpecialOfferProduct
16 | {
17 | public SpecialOfferProduct()
18 | {
19 | this.SalesOrderDetails = new HashSet();
20 | }
21 |
22 | public int SpecialOfferID { get; set; }
23 | public int ProductID { get; set; }
24 | public System.Guid rowguid { get; set; }
25 | public System.DateTime ModifiedDate { get; set; }
26 |
27 | public virtual ICollection SalesOrderDetails { get; set; }
28 | public virtual SpecialOffer SpecialOffer { get; set; }
29 | public virtual Product Product { get; set; }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/Store.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Sales.DataModel
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class Store
16 | {
17 | public Store()
18 | {
19 | this.Customers = new HashSet();
20 | }
21 |
22 | public int BusinessEntityID { get; set; }
23 | public string Name { get; set; }
24 | public Nullable SalesPersonID { get; set; }
25 | public string Demographics { get; set; }
26 | public System.Guid rowguid { get; set; }
27 | public System.DateTime ModifiedDate { get; set; }
28 |
29 | public virtual ICollection Customers { get; set; }
30 | public virtual SalesPerson SalesPerson { get; set; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/Values/SalesOrderHeaderStatusValues.cs:
--------------------------------------------------------------------------------
1 | namespace Sales.DataModel.Values
2 | {
3 | public static class SalesOrderHeaderStatusValues
4 | {
5 | public const byte InProcess = 1;
6 | public const byte Approved = 2;
7 | public const byte Backordered = 3;
8 | public const byte Rejected = 4;
9 | public const byte Shipped = 5;
10 | public const byte Cancelled = 6;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.DataModel/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.Services/IApprovalService.cs:
--------------------------------------------------------------------------------
1 | namespace Sales
2 | {
3 | internal interface IApprovalService
4 | {
5 | bool Approve(ApproveRequest approveRequest);
6 | }
7 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.Services/ModelInterceptors/InvalidOrderException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Sales.ModelInterceptors
4 | {
5 | class InvalidOrderException : Exception
6 | {
7 | }
8 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.Services/PriceCalculator.cs:
--------------------------------------------------------------------------------
1 | using Contracts.Sales;
2 | using iQuarc.AppBoot;
3 | using Sales.DataModel;
4 |
5 | namespace Sales
6 | {
7 | interface IPriceCalculator
8 | {
9 | decimal CalculateTaxes(OrderRequest o, Customer c);
10 |
11 | decimal CalculateDiscount(OrderRequest o, Customer c);
12 | }
13 |
14 | [Service(typeof (IPriceCalculator), Lifetime.Instance)]
15 | class PriceCalculator : IPriceCalculator
16 | {
17 | public decimal CalculateTaxes(OrderRequest o, Customer c)
18 | {
19 | // do actual calculation
20 | return 10;
21 | }
22 |
23 | public decimal CalculateDiscount(OrderRequest o, Customer c)
24 | {
25 | // do actual calculation
26 | return 20;
27 | }
28 | }
29 |
30 |
31 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.Services/SalesServicesModule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Contracts.Notifications;
3 | using iQuarc.AppBoot;
4 |
5 | namespace Sales
6 | {
7 | [Service("Sales Services Module", typeof(IModule))]
8 | class SalesServicesModule : IModule
9 | {
10 | private readonly INotificationService notificationService;
11 |
12 | public SalesServicesModule(INotificationService notificationService)
13 | {
14 | this.notificationService = notificationService;
15 | }
16 |
17 | public string Name
18 | {
19 | get { return "Sales Module"; }
20 | }
21 |
22 | public void Initialize()
23 | {
24 | IModule m = this;
25 | notificationService.NotifyAlive(m);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/AppInfraDemo/Modules/Sales/Sales.Services/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AppInfraDemo/UI/ConsoleApplication/AdventureWorksTestQueries/SalesOrdersHeader.sql:
--------------------------------------------------------------------------------
1 | SELECT * FROM [Sales].[Customer] C
2 | INNER JOIN [Person].[Person] P ON C.PersonId = P.[BusinessEntityID]
3 | --WHERE C.CustomerID=11019
4 |
5 | SELECT CustomerID, count(*) as Orders
6 | FROM [Sales].[SalesOrderHeader]
7 | GROUP BY CustomerID
8 |
9 | SELECT *
10 | FROM [Sales].[SalesOrderHeader] SO
11 | INNER JOIN [Sales].[Customer] C ON SO.CustomerID=C.CustomerId
12 | INNER JOIN [Person].[Person] P ON P.BusinessEntityID=C.PersonId
13 | WHERE P.LastName='Abel'
--------------------------------------------------------------------------------
/AppInfraDemo/UI/ConsoleApplication/AdventureWorksTestQueries/SalesPersons.sql:
--------------------------------------------------------------------------------
1 | SELECT *
2 | FROM [Sales].[SalesOrderHeader] SO
3 | INNER JOIN [Person].[Person] P ON P.BusinessEntityID=SO.SalesPersonId
4 |
--------------------------------------------------------------------------------
/AppInfraDemo/UI/ConsoleApplication/IConsole.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ConsoleApplication
4 | {
5 | internal interface IConsole
6 | {
7 | string AskInput(string message);
8 | string ReadLine();
9 | ConsoleKeyInfo ReadKey();
10 | void WriteEntity(T entity);
11 | void WriteLine(string line);
12 | void Clear();
13 | }
14 | }
--------------------------------------------------------------------------------
/AppInfraDemo/UI/ConsoleApplication/OnModuleIsAliveConsole.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Contracts.Notifications;
3 | using iQuarc.AppBoot;
4 |
5 | namespace ConsoleApplication
6 | {
7 | [Service("Module Is Alive on Console", typeof(IAmAliveSubscriber))]
8 | public class OnModuleIsAliveConsole : IAmAliveSubscriber
9 | {
10 | public void AmAlive(IModule item)
11 | {
12 | Console.WriteLine(item.GetType().Name);
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/AppInfraDemo/UI/ConsoleApplication/OrdersConsoleApplication.cs:
--------------------------------------------------------------------------------
1 | using Contracts.Sales;
2 |
3 | namespace ConsoleApplication
4 | {
5 | class OrdersConsoleApplication
6 | {
7 | private readonly IConsole console;
8 | private readonly IOrderingService orderingService;
9 |
10 | public OrdersConsoleApplication(IConsole console, IOrderingService orderingService)
11 | {
12 | this.console = console;
13 | this.orderingService = orderingService;
14 | }
15 |
16 |
17 | public void ShowAllOrders()
18 | {
19 | console.WriteLine("OrdersConsole: Show all orders function");
20 | string customerName = console.AskInput("Enter customer last name: ");
21 |
22 | SalesOrderInfo[] orders = orderingService.GetOrdersInfo(customerName);
23 |
24 | console.WriteLine($"Orders for customer {customerName}: "); //Test data: Abel | Smith | Adams
25 | foreach (SalesOrderInfo salesOrderInfo in orders)
26 | {
27 | console.WriteEntity(salesOrderInfo);
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/AppInfraDemo/UI/ConsoleApplication/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/AppInfraDemo/UI/WpfApplication/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/AppInfraDemo/UI/WpfApplication/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace WpfApplication
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/AppInfraDemo/UI/WpfApplication/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/AppInfraDemo/UI/WpfApplication/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace WpfApplication
4 | {
5 | ///
6 | /// Interaction logic for MainWindow.xaml
7 | ///
8 | public partial class MainWindow : Window
9 | {
10 | public MainWindow()
11 | {
12 | InitializeComponent();
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/AppInfraDemo/UI/WpfApplication/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WpfApplication.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.2.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AppInfraDemo/UI/WpfApplication/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/AppInfraDemo/UI/WpfApplication/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/AppInfraDemo/_App_Data/readme.md:
--------------------------------------------------------------------------------
1 | Use this folder when you want to use the AdventureWorks2012 database from the local SQL Express.
2 | -----------------
3 |
4 | The `AppInfraDemo\_App_Data` folder should contain the `AdventureWorks2012.mdf` in order to be attached to the local database on the application start.
5 |
6 | To configure this follow these steps:
7 | 1. Download the `AdventureWorks2012.mdf` from [https://1drv.ms/u/s!AttpJoJRCtSQiiG8WJT8t3C4y450](https://1drv.ms/u/s!AttpJoJRCtSQiiG8WJT8t3C4y450)
8 | 2. Copy it to `AppInfraDemo\_App_Data` folder
9 | 3. Make sure that your host app sets the |DataDirectory| on the AppDomain
10 | - see `AppInfraDemo\UI\ConsoleApplication\Program.SetupDataDirectory()`
11 | 4. Set the connection string that uses `AttachDbFilename` setting
12 | - see `AppInfraDemo\UI\ConsoleApplication\App.config`
13 | - ex: `data source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\AdventureWorks2012.mdf;initial catalog=AdventureWorks2012;Integrated Security=True;MultipleActiveResultSets=True;App=EntityFramework`
14 | - make sure that the `AdventureWorks2012.mdf` file name matches the one in the connection string
15 |
16 | More about AdventureWorks sample databases [here](https://learn.microsoft.com/en-us/sql/samples/adventureworks-install-configure?view=sql-server-ver16&tabs=ssms).
--------------------------------------------------------------------------------
/DesignPatterns/CodeDesign-DesignPatterns.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleDemo", "ConsoleDemo\ConsoleDemo.csproj", "{D2F71473-27B8-4A87-A248-4919A8E62F61}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {D2F71473-27B8-4A87-A248-4919A8E62F61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {D2F71473-27B8-4A87-A248-4919A8E62F61}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {D2F71473-27B8-4A87-A248-4919A8E62F61}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {D2F71473-27B8-4A87-A248-4919A8E62F61}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/AbstractFactory/AnimalWorld.cs:
--------------------------------------------------------------------------------
1 | namespace ConsoleDemo.AbstractFactory
2 | {
3 | ///
4 | /// The 'Client' class
5 | ///
6 | class AnimalWorld
7 | {
8 | private readonly Herbivore _herbivore;
9 | private readonly Carnivore _carnivore;
10 |
11 | // Constructor
12 | public AnimalWorld(ContinentFactory factory)
13 | {
14 | _carnivore = factory.CreateCarnivore();
15 | _herbivore = factory.CreateHerbivore();
16 | }
17 |
18 | public void RunFoodChain()
19 | {
20 | _carnivore.Eat(_herbivore);
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/AbstractFactory/ScrollBar.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ConsoleDemo.AbstractFactory
4 | {
5 | class MacScrollBar : IScrollBar
6 | {
7 | public void ScrollUp(int points)
8 | {
9 | Console.WriteLine("Mac scrolling up");
10 | }
11 |
12 | public void ScrollDown(int points)
13 | {
14 | Console.WriteLine("Mac scrolling down");
15 | }
16 | }
17 |
18 | class WinScrollBar : IScrollBar
19 | {
20 | public void ScrollUp(int points)
21 | {
22 | Console.WriteLine("Win scrolling up");
23 | }
24 |
25 | public void ScrollDown(int points)
26 | {
27 | Console.WriteLine("Win scrolling down");
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/AbstractFactory/WidgetsClientApp.cs:
--------------------------------------------------------------------------------
1 | namespace ConsoleDemo.AbstractFactory
2 | {
3 | public class WidgetsClientApp
4 | {
5 | private readonly IWidgetFactory factory;
6 |
7 | public WidgetsClientApp(IWidgetFactory factory)
8 | {
9 | this.factory = factory;
10 | }
11 |
12 | public void Run()
13 | {
14 | IWindow window = factory.CreateWidget();
15 | IScrollBar scrollBar = factory.CreateWidget();
16 |
17 | window.SetScrollbars(scrollBar, scrollBar);
18 | window.Open();
19 | window.VerticalScrollBar.ScrollDown(10);
20 |
21 | window.Close();
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/ChainOfResponsibility/021_RequestHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ConsoleDemo.ChainOfResponsibility
4 | {
5 | interface IRequestHandler
6 | {
7 | int Handle(Request request);
8 |
9 | IRequestHandler Successor { get; set; }
10 | }
11 |
12 | abstract class RequestHandler : IRequestHandler
13 | {
14 | public int Handle(Request request)
15 | {
16 | if (CanHandle(request))
17 | return HandleInternal(request);
18 |
19 | if (Successor !=null)
20 | {
21 | return Successor.Handle(request);
22 | }
23 |
24 | throw new InvalidOperationException("This handler cannot handle this request");
25 | }
26 |
27 | protected abstract bool CanHandle(Request request);
28 | protected abstract int HandleInternal(Request request);
29 |
30 | public IRequestHandler Successor { get; set; }
31 |
32 |
33 | protected bool FileExists(string fileName)
34 | {
35 | // ... real implementation here ...
36 | return false;
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/ChainOfResponsibility/023_FileManager2.cs:
--------------------------------------------------------------------------------
1 | namespace ConsoleDemo.ChainOfResponsibility
2 | {
3 | class FileManager2
4 | {
5 | private readonly IRequestHandler handler;
6 |
7 | public FileManager2 ()
8 | {
9 | handler = new CreateNew
10 | {
11 | Successor = new FileExistsAndOverwriteNotRequested
12 | {
13 | Successor = new OverwriteWithNewFormat
14 | {
15 | Successor = new OverwriteWithSameFormat
16 | {
17 | Successor = new CannotOverwrite()
18 | }
19 | }
20 | }
21 | };
22 | }
23 |
24 | public int CreateFile(Request createFileRequest)
25 | {
26 | return handler.Handle(createFileRequest);
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/ChainOfResponsibility/PurchaseOrder.cs:
--------------------------------------------------------------------------------
1 | namespace ConsoleDemo.ChainOfResponsibility
2 | {
3 | public class PurchaseOrder
4 | {
5 | public PurchaseOrder(int number, double amount, string assets)
6 | {
7 | Number = number;
8 | Amount = amount;
9 | Assets = assets;
10 | }
11 |
12 | public int Number { get; set; }
13 | public double Amount { get; set; }
14 | public string Assets { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Composite/01_IGraphicElement.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace ConsoleDemo.Composite.Transparency
4 | {
5 | public interface IGraphicElement
6 | {
7 | void Draw(int leftMargin);
8 | string Name { get; set; }
9 |
10 | int Order { get; set; }
11 | IGraphicElement Parent { get; set; }
12 |
13 | void Add(IGraphicElement childElement);
14 | void Remove(IGraphicElement element);
15 | IEnumerable GetChildElements();
16 | }
17 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Composite/11_GraphicElement.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace ConsoleDemo.Composite.Safety
4 | {
5 | public interface IGraphicElement
6 | {
7 | void Draw(int leftMargin);
8 | string Name { get; set; }
9 |
10 | int Order { get; set; }
11 | IGraphicElement Parent { get; set; }
12 | }
13 |
14 | public interface IGraphicElementContainer : IGraphicElement
15 | {
16 | void Add(IGraphicElement childElement);
17 | void Remove(IGraphicElement element);
18 | IEnumerable GetChildElements();
19 | }
20 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Composite/Extension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ConsoleDemo.Composite.Transparency
5 | {
6 | internal static class DisplayExtension
7 | {
8 | public static void Display(this string text, int margin)
9 | {
10 | Console.WriteLine(new string(' ', margin*2) + text);
11 | }
12 | }
13 |
14 | internal static class GraphicElementExtensions
15 | {
16 | public static void Draw(this IGraphicElement graphic)
17 | {
18 | graphic.Draw(0);
19 | }
20 |
21 | public static void Draw(this IGraphicElement[] drawing)
22 | {
23 | foreach (var graphicElement in drawing)
24 | {
25 | graphicElement.Draw();
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Composite/Extension1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ConsoleDemo.Composite.Safety
4 | {
5 | static class DisplayExtension
6 | {
7 | public static void Display(this string text, int margin)
8 | {
9 | Console.WriteLine(new string(' ', margin*2) + text);
10 | }
11 | }
12 |
13 | static class GraphicElementExtensions
14 | {
15 | public static void Draw(this IGraphicElement graphic)
16 | {
17 | graphic.Draw(0);
18 | }
19 |
20 | public static void Draw(this IGraphicElement[] drawing)
21 | {
22 | foreach (var graphicElement in drawing)
23 | {
24 | graphicElement.Draw();
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Decorator/02_ScrollBarWindow.cs:
--------------------------------------------------------------------------------
1 | namespace ConsoleDemo.Decorator
2 | {
3 | class ScrollBarWindow : WindowDecorator
4 | {
5 | private readonly IWindow scrollBarWindow;
6 |
7 | public ScrollBarWindow(IWindow decorated)
8 | : base(decorated)
9 | {
10 | var horizontalScrollBarWindow = new HorizontalScrollBarWindow(decorated);
11 | scrollBarWindow = new VerticalScrollBarWindow(horizontalScrollBarWindow);
12 | }
13 |
14 | public override void Draw()
15 | {
16 | scrollBarWindow.Draw();
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Decorator/_Client.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ConsoleDemo.Decorator
4 | {
5 | public static class DecoratorClient
6 | {
7 | public static void Run()
8 | {
9 | var simpleWindow = new Window();
10 | var verticalScrollWindow = new VerticalScrollBarWindow(simpleWindow);
11 | var scrollWindow = new HorizontalScrollBarWindow(verticalScrollWindow);
12 |
13 | scrollWindow.Draw();
14 | Console.WriteLine();
15 |
16 | Console.WriteLine("--------------------------------------------------------------------");
17 | ScrollBarWindow scrollBarWindow = new ScrollBarWindow(simpleWindow);
18 | scrollBarWindow.Draw();
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ConsoleDemo.AbstractFactory;
3 | using ConsoleDemo.ChainOfResponsibility;
4 | using ConsoleDemo.Decorator;
5 | using ConsoleDemo.Strategy;
6 | using ConsoleDemo.Visitor.v3;
7 | using ConsoleDemo.Visitor.v5;
8 | using ConsoleDemo.Visitor.v6;
9 |
10 | namespace ConsoleDemo
11 | {
12 | public static class Program
13 | {
14 | public static void Main()
15 | {
16 | AnimalWorldDemo.Run();
17 | //WidgetsDemo.Run();
18 |
19 | //DecoratorClient.Run();
20 |
21 | //Composite.Transparency.CompositeClient.Demo();
22 | //Composite.Safety.CompositeClient.Demo();
23 |
24 | //StrategyClient.RobotsDemo();
25 |
26 | //ChainOfResponsibilityClient.PurchaseOrderApproverDemo();
27 |
28 |
29 | //VisitorDemo5.Run();
30 | //VisitorDemo6.Run();
31 |
32 |
33 | // Wait for user input
34 | Console.ReadLine();
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Strategy/04_GenericRobot.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ConsoleDemo.Strategy
4 | {
5 | public class GenericRobot
6 | where TBehavior : IBehaviour, new()
7 | {
8 | private readonly IBehaviour behaviour;
9 | private String name;
10 |
11 | public GenericRobot(String name)
12 | {
13 | this.name = name;
14 | behaviour = new TBehavior();
15 | }
16 |
17 | public IBehaviour Behaviour
18 | {
19 | get { return behaviour; }
20 | }
21 |
22 | public void Move()
23 | {
24 | Console.WriteLine(this.name + ": Based on current position " +
25 | "the behavior decides the next Move:");
26 | int command = behaviour.Move();
27 | }
28 |
29 | public string Name
30 | {
31 | get { return name; }
32 | set { this.name = value; }
33 | }
34 | }
35 |
36 | // the client does not need to know about the behaviors. It can directly use the AgressiveRobot
37 | public class AggressiveRobot : GenericRobot
38 | {
39 | public AggressiveRobot(string name)
40 | : base(name)
41 | {
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Strategy/Coordonates.cs:
--------------------------------------------------------------------------------
1 | namespace ConsoleDemo.Strategy
2 | {
3 | public struct Configuration
4 | {
5 | public Coordonates Natural;
6 | public Coordonates Stretchability;
7 | public Coordonates Shrinkability ;
8 | }
9 |
10 | public class Coordonates
11 | {
12 | }
13 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Strategy/ITextWrappingStrategy.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace ConsoleDemo.Strategy
4 | {
5 | public interface ITextWrappingStrategy
6 | {
7 | PageRow Format(IEnumerable componentsStream);
8 | }
9 |
10 | class InlineStrategy : ITextWrappingStrategy
11 | {
12 | public PageRow Format(IEnumerable componentsStream)
13 | {
14 | throw new System.NotImplementedException();
15 | }
16 | }
17 |
18 | class TightStrategy : ITextWrappingStrategy
19 | {
20 | public PageRow Format(IEnumerable componentsStream)
21 | {
22 | throw new System.NotImplementedException();
23 | }
24 | }
25 |
26 | class CenterStrategy : ITextWrappingStrategy
27 | {
28 | public PageRow Format(IEnumerable componentsStream)
29 | {
30 | throw new System.NotImplementedException();
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Strategy/_RobotsClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ConsoleDemo.Strategy
4 | {
5 | public class StrategyClient
6 | {
7 | public static void RobotsDemo()
8 | {
9 | Robot bigRobot = new Robot("Big Robot");
10 | Robot george = new Robot("George v.2.1");
11 | Robot r2 = new Robot("R2");
12 |
13 | bigRobot.Behaviour = new AgressiveBehaviour();
14 | george.Behaviour = new DefensiveBehaviour();
15 | r2.Behaviour = new NormalBehaviour();
16 |
17 | bigRobot.Move();
18 | george.Move();
19 | r2.Move();
20 |
21 | Console.WriteLine("\r\n Base on current context, new behaviors: " +
22 | "\r\n\t'Big Robot' gets really scared" +
23 | "\r\n\t, 'George v.2.1' becomes really mad because" +
24 | "it's always attacked by other robots" +
25 | "\r\n\t and R2 keeps its calm\r\n");
26 |
27 | bigRobot.Behaviour = new DefensiveBehaviour();
28 | george.Behaviour = new AgressiveBehaviour();
29 |
30 | bigRobot.Move();
31 | george.Move();
32 | r2.Move();
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Visitor/.readme.html:
--------------------------------------------------------------------------------
1 |
Sample Description
2 |
This folder contains an evolution of the same sample from v1 to v5 showing from version to version ow same implementation can gradually be improved with the Visitor pattern (v3) towards better implementations of the same pattern
3 |
Versions:
4 |
5 |
v0 - just sets the stage
6 |
v1 - each operation is done in the client with if/else if
7 |
v2 - each operation is implemented in every element.
8 |
9 |
downsides:
10 |
11 |
mixture of concerns in same class (element)
12 |
had to add new operations
13 |
14 |
15 |
16 |
17 |
v3 - by the book implementation of the Visitor pattern
18 |
v4 - a better implementation of the Visitor pattern, where the client code links the general visitor and the specific one
19 |
20 |
Report report = new Report();
21 | IVisitor reportVisitor = new Visitor(report);
22 |
23 |
24 |
v5 - an improvement by making the link between IVisitor and IVisitor<TElement> visible in the interfaces, but making the specific visitor implementations a bit more complex.
25 |
26 |
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Visitor/.readme.md:
--------------------------------------------------------------------------------
1 | Sample Description
2 | ==========
3 |
4 | This folder contains an evolution of the same sample from v1 to v5 showing from version to version how the same implementation can gradually be improved with the Visitor pattern (v3) towards better implementations of the same pattern
5 |
6 | Versions:
7 | - v0 - just sets the stage
8 | - v1 - each operation is done in the client with `if/else if`
9 | - v2 - each operation is implemented in every element.
10 | - downsides:
11 | - mixture of concerns in same class (element)
12 | - had to add new operations
13 | - v3 - by the book implementation of the Visitor pattern
14 | - v4 - a better implementation of the Visitor pattern, where the client code links the general visitor and the specific one
15 | ```
16 | Report report = new Report();
17 | IVisitor reportVisitor = new Visitor(report);
18 | ```
19 |
20 | - v5 - an improvement by making the link between `IVisitor` and `IVisitor` visible in the interfaces, but making the specific visitor implementations a bit more complex.
21 |
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Visitor/ICrmService.cs:
--------------------------------------------------------------------------------
1 | namespace ConsoleDemo.Visitor
2 | {
3 | internal interface ICrmService
4 | {
5 | }
6 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Visitor/IUnitOfWork.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ConsoleDemo.Visitor
4 | {
5 | internal interface IUnitOfWork : IDisposable
6 | {
7 | void Add(object entity);
8 | void SaveChanges();
9 | }
10 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Visitor/OrderLine.cs:
--------------------------------------------------------------------------------
1 | namespace ConsoleDemo.Visitor
2 | {
3 | public class OrderLine
4 | {
5 | public Product Product { get; set; }
6 | public int Quantity { get; set; }
7 | }
8 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Visitor/Product.cs:
--------------------------------------------------------------------------------
1 | namespace ConsoleDemo.Visitor
2 | {
3 | public class Product
4 | {
5 | public string Name { get; set; }
6 | }
7 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Visitor/UofFactory.cs:
--------------------------------------------------------------------------------
1 | namespace ConsoleDemo.Visitor
2 | {
3 | internal class UofFactory
4 | {
5 | public static IUnitOfWork CreateUnitOfWork()
6 | {
7 | throw new System.NotImplementedException();
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Visitor/v0/Commands.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ConsoleDemo.Visitor.v0
5 | {
6 | class NewCustomerCommand
7 | {
8 | public string Name { get; set; }
9 |
10 | public string BusinessDomain { get; set; }
11 | }
12 |
13 | class NewPurchaseOrderCommand
14 | {
15 | public NewPurchaseOrderCommand(Product product, int i)
16 | {
17 | Product = product;
18 | }
19 |
20 | public Product Product { get; }
21 |
22 | public int Quantity { get; }
23 | }
24 |
25 | class NewSalesOrderCommand
26 | {
27 | public IEnumerable OrderLines { get; }
28 |
29 | public string CustomerCode { get; set; }
30 |
31 | public DateTime Date { get; set; }
32 | }
33 | }
--------------------------------------------------------------------------------
/DesignPatterns/ConsoleDemo/Visitor/v0/CommandsManager.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace ConsoleDemo.Visitor.v0
4 | {
5 | public class CommandsManager
6 | {
7 | readonly List