private static FacadeClient CreateApiClient() { var credentials = new BasicAuthenticationCredentials(); var client = new FacadeClient(new Uri(ConfigurationManager.AppSettings["FacadeBaseUrl"]), credentials); return(client); }
private static void Main(string[] args) { #region Adapter ///Adapter pattern example //var adapter = new AdapterClient(); //adapter.Main(); #endregion #region Bridge ///Bridge pattern example //var bridgeClient = new BridgeClient(); //Abstraction abstraction = new Abstraction(new ConcreteImplementationA()); //bridgeClient.ClientCode(abstraction); //Console.WriteLine(); //abstraction = new ExtendedAbstraction(new ConcreteImplementationB()); //bridgeClient.ClientCode(abstraction); #endregion #region Composite ///Composite pattern example //CompositeClient client = new CompositeClient(); //Leaf leaf = new Leaf(); //Console.WriteLine("Client: I get a simple component:"); //client.ClientCode(leaf); //var tree = new Composite.Composite(); //Composite.Composite branch1 = new Composite.Composite(); //branch1.Add(new Leaf()); //branch1.Add(new Leaf()); //Composite.Composite branch2 = new Composite.Composite(); //branch2.Add(new Leaf()); //tree.Add(branch1); //tree.Add(branch2); //Console.WriteLine("Client: Now I've got a composite tree:"); //client.ClientCode(tree); //Console.Write("Client: I don't need to check the components classes even when managing the tree:\n"); //client.ClientCode2(tree, leaf); #endregion #region Decorator /// Decorator pattern example //DecoratorClient client = new DecoratorClient(); //var simple = new ConcreteComponent(); //Console.WriteLine("Client: I get a simple component:"); //client.ClientCode(simple); //Console.WriteLine(); //ConcreteDecoratorA decorator1 = new ConcreteDecoratorA(simple); //ConcreteDecoratorB decorator2 = new ConcreteDecoratorB(decorator1); //Console.WriteLine("Client: Now I've got a decorated component:"); //client.ClientCode(decorator2); #endregion #region Facade /// Facade pattern example SubSystem1 subsystem1 = new SubSystem1(); SubSystem2 subsystem2 = new SubSystem2(); Facade.Facade facade = new Facade.Facade(subsystem1, subsystem2); FacadeClient.ClientCode(facade); #endregion Console.ReadKey(); }
public ActionResult _DetailODSCP(int OrderID) { var dataODS = FacadeOrder.Get(OrderID); var dataClient = FacadeClient.GetByID(dataODS.FK_ClientID); var dataBI = FacadeInstalledBase.GetByID(dataODS.FK_InstalledBaseID); ViewBag.dataODS = dataODS; ViewBag.dataClient = dataClient; return(PartialView()); }
static void Main(string[] args) { //Factory pattern ShapeClient.CallFactory(); //Singleton pattern SingletonClient.TestSingleton(); //Adapter pattern AdapterClient.CallAdapter(); //Composite pattern CardClient cardClient = new CardClient(); cardClient.CallComposite(); //Fascade pattern FacadeClient facadeClient = new FacadeClient(); facadeClient.CallFacade(); Console.ReadKey(); }
static void Main(string[] args) { bool exitLoop = false; while (!exitLoop) { Console.WriteLine(); Console.WriteLine("Please type the number of type of design patterns to veiw"); Console.WriteLine("0 - Exit"); Console.WriteLine("1 - Creational"); Console.WriteLine("2 - Structural"); Console.WriteLine("3 - Behaivoral"); ConsoleKeyInfo keyInfo = Console.ReadKey(); Console.WriteLine(); switch (keyInfo.KeyChar.ToString()) { case "0": exitLoop = true; break; case "1": while (!exitLoop) { Console.WriteLine("Please select Creational Pattern to demo:"); Console.WriteLine("0 - Exit"); Console.WriteLine("1 - Simple Factory"); Console.WriteLine("2 - Factory Method"); Console.WriteLine("3 - Abstract Factory"); Console.WriteLine("4 - Builder"); Console.WriteLine("5 - Fluent Interface"); Console.WriteLine("6 - Prototype"); Console.WriteLine("7 - Singleton"); keyInfo = Console.ReadKey(); Console.WriteLine(); switch (keyInfo.KeyChar.ToString()) { case "0": exitLoop = true; break; case "1": SimpleFactoryClient simpleFactoryClient = new SimpleFactoryClient(); simpleFactoryClient.PrintSimpleFactory(); break; case "2": FactoryMethodClient factoryMethodClient = new FactoryMethodClient(); factoryMethodClient.PrintFactoryMethod(); break; case "3": AbstractFactoryClient abstractFactoryClient = new AbstractFactoryClient(); abstractFactoryClient.PrintAbstractFactory(); break; case "4": BuilderClient builderClient = new BuilderClient(); builderClient.PrintBuilder(); break; case "5": FluentInterfaceClient fluentInterfaceClient = new FluentInterfaceClient(); fluentInterfaceClient.PrintFluentInterface(); break; case "6": PrototypeClient prototypeClient = new PrototypeClient(); prototypeClient.PrintPrototype(); break; case "7": SingletonClient singletonClient = new SingletonClient(); singletonClient.PrintSingleton(); break; default: Console.WriteLine("Selection must be 0-7"); break; } } exitLoop = false; break; case "2": while (!exitLoop) { Console.WriteLine("Please select Structural Pattern to demo:"); Console.WriteLine("0 - Exit"); Console.WriteLine("1 - Adapter"); Console.WriteLine("2 - Facade"); Console.WriteLine("3 - Decorator"); Console.WriteLine("4 - Bridge"); Console.WriteLine("5 - Composite"); Console.WriteLine("6 - Proxy"); Console.WriteLine("7 - Flyweight"); keyInfo = Console.ReadKey(); Console.WriteLine(); switch (keyInfo.KeyChar.ToString()) { case "0": exitLoop = true; break; case "1": AdapterClient adapterClient = new AdapterClient(); adapterClient.PrintAdapter(); break; case "2": FacadeClient facadeClient = new FacadeClient(); facadeClient.PrintFacade(); break; case "3": DecoratorClient decoratorClient = new DecoratorClient(); decoratorClient.PrintDecorator(); break; case "4": BridgeClient bridgeClient = new BridgeClient(); bridgeClient.PrintBridge(); break; case "5": CompositeClient compositeClient = new CompositeClient(); compositeClient.PrintComposite(); break; case "6": ProxyClient proxyClient = new ProxyClient(); proxyClient.PrintProxy(); break; case "7": FlyweightClient flyweightClient = new FlyweightClient(); flyweightClient.PrintFlyweight(); break; default: Console.WriteLine("Selection must be 0-7"); break; } } exitLoop = false; break; case "3": while (!exitLoop) { Console.WriteLine("Please select Behaivoral Pattern to demo:"); Console.WriteLine("0 - Exit"); Console.WriteLine("1 - Iterator"); Console.WriteLine("2 - Observer"); Console.WriteLine("3 - Chain Of Responsibility"); Console.WriteLine("4 - State"); Console.WriteLine("5 - Template"); Console.WriteLine("6 - Command"); Console.WriteLine("7 - Visitor"); Console.WriteLine("8 - Strategy"); Console.WriteLine("9 - Interpreter"); Console.WriteLine("10 - Mediator"); Console.WriteLine("11 - Memento"); string entered = Console.ReadLine(); Console.WriteLine(); switch (entered) { case "0": exitLoop = true; break; case "1": IteratorClient iteratorClient = new IteratorClient(); iteratorClient.PrintIterator(); break; case "2": ObserverClient observerClient = new ObserverClient(); observerClient.PrintObserver(); break; case "3": ChainOfResponsibilityClient chainOfResponsibilityClient = new ChainOfResponsibilityClient(); chainOfResponsibilityClient.PrintChainOfResponsibility(); break; case "4": StateClient stateClient = new StateClient(); stateClient.PrintState(); break; case "5": TemplateClient templateClient = new TemplateClient(); templateClient.PrintTemplate(); break; case "6": CommandClient commandClient = new CommandClient(); commandClient.PrintCommand(); break; case "7": VisitorClient visitorClient = new VisitorClient(); visitorClient.PrintVisitor(); break; case "8": StrategyClient strategyClient = new StrategyClient(); strategyClient.PrintStrategy(); break; case "9": InterpreterClient interpreterClient = new InterpreterClient(); interpreterClient.PrintInterpreter(); break; case "10": MediatorClient mediatorClient = new MediatorClient(); mediatorClient.PrintMediator(); break; case "11": MementoClient mementoClient = new MementoClient(); mementoClient.PrintMemento(); break; default: Console.WriteLine("Selection must be 0-11"); break; } } exitLoop = false; break; default: Console.WriteLine("Must enter number 0 -3"); break; } } Console.WriteLine("End of Design Patterns examples"); Console.WriteLine("Type any key to exit"); Console.ReadKey(); }
public GreenField.IssuerShares.Client.Backend.IssuerShares.FacadeClient CreateClient() { var result = new FacadeClient(); return(result); }
static void Main(string[] args) { var arrODS = FacadeOrder.GetAll().Where(p => p.OrderExecuteDate.Equals(new DateTime(2017, 11, 8))); int j = 1; Console.WriteLine("Total: " + arrODS.Count().ToString()); foreach (var i in arrODS) { try { Console.WriteLine(j.ToString() + " de " + arrODS.Count().ToString()); var dataODS = FacadeOrder.Get(i.PK_OrderID); var dataClient = FacadeClient.GetByID(i.FK_ClientID); var dataBaseInstalled = FacadeInstalledBase.GetByID(dataODS.FK_InstalledBaseID); var dataProduct = FacadeProduct.GetByID(dataBaseInstalled.FK_ProductID.Value); var dataHistory = FacadeMabe.HistoryODSByClient(dataClient.ClientID, dataBaseInstalled.InstalledBaseID); // insertar datos order history foreach (var item in dataHistory) { var dataDBHistory = FacadeHistory.GetByOrderID(dataODS.PK_OrderID); if (dataDBHistory.Where(p => p.OrderID == item.ID_Oper).Count() > 0) { // update var entity = dataDBHistory.Where(p => p.OrderID == item.ID_Oper).FirstOrDefault(); entity.CloseDate = ParseDate(item.Fecha_Cierre_Orden); entity.Failure1 = string.IsNullOrEmpty(item.Desc_ID_Falla1) ? "" : item.Desc_ID_Falla1; entity.Failure2 = string.IsNullOrEmpty(item.Desc_ID_Falla2) ? "" : item.Desc_ID_Falla2; entity.Failure3 = string.IsNullOrEmpty(item.Desc_ID_Falla3) ? "" : item.Desc_ID_Falla3; entity.FailureID1 = string.IsNullOrEmpty(item.ID_Falla1) ? "" : item.ID_Falla1; entity.FailureID2 = string.IsNullOrEmpty(item.ID_Falla2) ? "" : item.ID_Falla2; entity.FailureID3 = string.IsNullOrEmpty(item.ID_Falla3) ? "" : item.ID_Falla3; entity.FK_ClientID = dataODS.FK_ClientID; entity.FK_InstalledBaseID = dataODS.FK_InstalledBaseID; entity.FK_OrderID = dataODS.PK_OrderID; entity.Guaranty = string.IsNullOrEmpty(item.Tipo_Serv) ? "" : item.Tipo_Serv; entity.ItemStatus = string.IsNullOrEmpty(item.Estatus_Visita) ? "" : item.Estatus_Visita; entity.ModifyDate = DateTime.UtcNow; entity.OrderID = string.IsNullOrEmpty(item.ID_Oper) ? "" : item.ID_Oper; entity.OrderStatus = string.IsNullOrEmpty(item.Estatus_Oper) ? "" : item.Estatus_Oper; entity.ShopDate = new DateTime(1980, 1, 1); entity.Status = true; FacadeHistory.Update(entity); } else { // insert var entity = new EntityHistory(); entity.CloseDate = ParseDate(item.Fecha_Cierre_Orden); entity.CreateDate = DateTime.UtcNow; entity.Failure1 = string.IsNullOrEmpty(item.Desc_ID_Falla1) ? "" : item.Desc_ID_Falla1; entity.Failure2 = string.IsNullOrEmpty(item.Desc_ID_Falla2) ? "" : item.Desc_ID_Falla2; entity.Failure3 = string.IsNullOrEmpty(item.Desc_ID_Falla3) ? "" : item.Desc_ID_Falla3; entity.FailureID1 = string.IsNullOrEmpty(item.ID_Falla1) ? "" : item.ID_Falla1; entity.FailureID2 = string.IsNullOrEmpty(item.ID_Falla2) ? "" : item.ID_Falla2; entity.FailureID3 = string.IsNullOrEmpty(item.ID_Falla3) ? "" : item.ID_Falla3; entity.FK_ClientID = dataODS.FK_ClientID; entity.FK_InstalledBaseID = dataODS.FK_InstalledBaseID; entity.FK_OrderID = dataODS.PK_OrderID; entity.Guaranty = string.IsNullOrEmpty(item.Tipo_Serv) ? "" : item.Tipo_Serv; entity.ItemStatus = string.IsNullOrEmpty(item.Estatus_Visita) ? "" : item.Estatus_Visita; entity.ModifyDate = DateTime.UtcNow; entity.OrderID = string.IsNullOrEmpty(item.ID_Oper) ? "" : item.ID_Oper; entity.OrderStatus = string.IsNullOrEmpty(item.Estatus_Oper) ? "" : item.Estatus_Oper; entity.PK_HistoryID = 0; entity.ShopDate = new DateTime(1980, 1, 1); entity.Status = true; FacadeHistory.Insert(entity); } } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } j++; } //Inventory(); //RestImage(); //SendEmial(); //foreach (TimeZoneInfo z in TimeZoneInfo.GetSystemTimeZones()) // Console.WriteLine(z.Id); //Console.WriteLine(FacadeGoogle.GetLocalDateTime(19.3850, -99.1650, DateTime.UtcNow)); //string CLIENT_ID = "6538892993478012"; //string CLIENT_SECRET = "GGGzSZuzfdBDpua7g7wyZo9qiTrnTvcS"; //MP mp = new MP(CLIENT_ID, CLIENT_SECRET); //Hashtable data = mp.getPaymentInfo("9406314591T0170101000525SFODS"); // Sets the filters you want //Dictionary<String, String> filters = new Dictionary<String, String>(); //filters.Add("site_id", "MLM"); // Argentina: MLA; Brasil: MLB // Search payment data according to filters //Hashtable searchResult = mp.searchPayment(filters); // Show payment information //foreach (Hashtable payment in searchResult.SelectToken("response.results")) //{ // Console.WriteLine(String.Format("{0}", payment["collection"]["id"])); //} Console.WriteLine("Finish"); Console.ReadKey(); }
static void Main(string[] args) { Patterns pattern = Patterns.StructuralFacade; ExampleType type = ExampleType.Structural; Console.WriteLine(new string('=', 42 + pattern.ToString().Length)); Console.WriteLine(new string('=', 20) + " " + pattern + " " + new string('=', 20)); Console.WriteLine(new string('=', 42 + pattern.ToString().Length)); Console.WriteLine(); switch (pattern) { case Patterns.CreationalAbstractFactory: // ========================================================================================== // Abstract Factory (Creational) - Creates an instance of several families of classes // ========================================================================================== #region Abstract Factory if (type == ExampleType.Structural) { AbstractFactoryClient.RunStructural(new ConcreteFactory1()); AbstractFactoryClient.RunStructural(new ConcreteFactory2()); } else { // TODO: Abstract Factory Real-world example /* * Lion eats Wildebeest * Wolf eats Bison */ } break; #endregion case Patterns.CreationalFactoryMethod: // ========================================================================================== // Factory Method (Creational) - Creates an instance of several derived classes // ========================================================================================== #region Factory Method if (type == ExampleType.Structural) { FactoryMethodClient.RunStructural(); } else { // TODO: Factory Method Real-world example /* * Resume ------- * SkillsPage * EducationPage * ExperiencePage * * Report ------- * IntroductionPage * ResultsPage * ConclusionPage * SummaryPage * BibliographyPage */ } break; #endregion case Patterns.StructuralFacade: // ========================================================================================== // Facade (Structural) - A single class that represents an entire subsystem // ========================================================================================== #region Facade if (type == ExampleType.Structural) { FacadeClient.RunStructural(); } else { // TODO: Facade Real-world example /* * Ann McKinsey applies for $125,000.00 loan * * Check bank for Ann McKinsey * Check loans for Ann McKinsey * Check credit for Ann McKinsey * * Ann McKinsey has been Approved */ } break; #endregion case Patterns.BehavioralObserver: // ========================================================================================== // Observer (Behavioral) - A way of notifying change to a number of classes // ========================================================================================== #region Observer if (type == ExampleType.Structural) { // TODO: Observer Structural example /* * Observer X's new state is ABC * Observer Y's new state is ABC * Observer Z's new state is ABC */ } else { // TODO: Observer Real-world example /* * Notified Sorros of IBM's change to $120.10 * Notified Berkshire of IBM's change to $120.10 * * Notified Sorros of IBM's change to $121.00 * Notified Berkshire of IBM's change to $121.00 * * Notified Sorros of IBM's change to $120.50 * Notified Berkshire of IBM's change to $120.50 * * Notified Sorros of IBM's change to $120.75 * Notified Berkshire of IBM's change to $120.75 */ } break; #endregion case Patterns.BehavioralIterator: break; case Patterns.BehavioralStrategy: break; case Patterns.StructuralProxy: break; case Patterns.StructuralComposite: break; case Patterns.CreationalSingleton: break; case Patterns.StructuralAdapter: break; case Patterns.BehavioralCommand: break; case Patterns.BehavioralState: break; case Patterns.BehavioralTemplateMethod: break; case Patterns.CreationalPrototype: break; case Patterns.StructuralBridge: break; case Patterns.StructuralDecorator: break; case Patterns.CreationalBuilder: break; case Patterns.BehavioralChainOfResponsibility: break; case Patterns.BehavioralMediator: break; case Patterns.StructuralFlyweight: break; case Patterns.BehavioralInterpreter: break; case Patterns.BehavioralMemento: break; case Patterns.BehavioralVisitor: break; } Console.ReadKey(); }
public TopDown.FacingServer.Backend.Targeting.FacadeClient CreateClient() { var result = new FacadeClient(); return(result); }