async Task <IEnumerable <Product> > load() { var request = new Rest(Globals.Global.apiProduct, Method.GET); var response = await SingletonClient.GetClient().Execute <IEnumerable <Product> >(request.request); return(response.Data); }
/// <summary> /// connect the GUI to a Server /// </summary> /// <returns>true if Succeeded to connect, false o.w</returns> private bool ConnectToServer() { SingletonClient client = SingletonClient.getInstance; bool result = client.ConnectToServer(); return(result); }
public void TestMethod1() { SingletonClient test = new SingletonClient(); test.Grabar("Lucia", "Marte", DateTime.Today); test.ToString(); }
async Task <ICollection <Category> > load() { var request = new Rest(Globals.Global.apiCategories, Method.GET); var response = await SingletonClient.GetClient().Execute <ICollection <Category> >(request.request); return(response.Data); }
/// <summary> /// send a request to remove a directory handler from Service. /// </summary> /// <param name="handler">a handler to remove</param> public void RemoveHandler(string handler) { SingletonClient client = SingletonClient.getInstance; List <string> l = new List <string>(); l.Add(handler); client.CloseHandler(l); }
public bool Execute(object dbModel) { SingletonClient client = SingletonClient.GetInstance(); Risk risk = dbModel as Risk; bool result = client.Client.InsertRisk(risk); return(result); }
public bool Execute(object dbModel) { SingletonClient client = SingletonClient.GetInstance(); Strategy strategy = dbModel as Strategy; bool result = client.Client.UpdateStrategy(strategy); return(result); }
async void DeleteButtonOnClicked(object sender, EventArgs eventArgs) { var request = new Rest(Globals.Global.baseUrl + _product.ProductId, Method.DELETE); var response = await SingletonClient.GetClient().Execute(request.request); if (response.IsSuccess) { await Navigation.PopAsync(); } }
async void CreateButtonOnClicked(object sender, EventArgs eventArgs) { var request = new Rest(Globals.Global.apiProduct, Method.PUT); var response = SingletonClient.GetClient().Execute(request); if (response.Result.IsSuccess) { await Navigation.PopAsync(); } }
public MainViewModel() { ViewLoaded += OnViewLoaded; UserSaving += OnUserSaving; RiskSaving += OnRiskSaving; StrategySaving += OnStrategySaving; Client = SingletonClient.GetInstance(this).Client; RiskContext = new RiskContext(); StrategyContext = new StrategyContext(); }
async void SaveButtonOnClicked(object sender, EventArgs eventArgs) { var request = new Rest(Globals.Global.apiProduct, Method.PUT); var response = await SingletonClient.GetClient().Execute(request.request.AddBody(_product)); if (response.IsSuccess) { await Navigation.PopAsync(); } }
async void OnButtonClicked(object sender, EventArgs e) { var email = user.Email; var password = user.Password; var connect = new Rest(Globals.Global.apiApiKey + email + Globals.Global.passwordQuery + password, Method.GET); var response = await SingletonClient.GetClient().Execute <User>(connect.request); user = response.Data; await Navigation.PushAsync(new ProductsPage(user)); }
/// <summary> /// constructor /// </summary> public LogsModel() { SingletonClient client = SingletonClient.getInstance; client.MsgRecievedFromServer += delegate(object sender, ServiceInfoEventArgs e) { if (e.LogsList != null) { AddLogs(e.LogsList); } }; dt = new DataTable(); SetDT(); }
/// <summary> /// constructor /// </summary> public MainWindowViewModel() { serverIsOffColor = "gray"; SingletonClient client = SingletonClient.getInstance; client.ConnectionIsBroken += delegate(object sender, ConnectionArgs args) { App.Current.Dispatcher.Invoke((Action) delegate { this.BackgroundColor = serverIsOffColor; }); }; // SettingsModel and LogsModel register at the client's event this.SettingsViewModel = new SettingsViewModel(new SettingsModel()); this.LogsViewModel = new LogsViewModel(new LogsModel()); if (!ConnectToServer()) { this.BackgroundColor = serverIsOffColor; } CloseWindowCommand = new DelegateCommand <object>(OnClose, CanClose); }
/// <summary> /// constructor /// </summary> public SettingsModel() { SingletonClient client = SingletonClient.getInstance; client.MsgRecievedFromServer += delegate(object sender, ServiceInfoEventArgs e) { if (e.ConfigMap != null) { SetConfigInfo(e.ConfigMap); } if (e.RemovedHandlers != null) { App.Current.Dispatcher.Invoke((Action) delegate { foreach (string handler in e.RemovedHandlers) { this.HandlersList.Remove(handler); } }); } }; this.HandlersList = new ObservableCollection <string>(); }
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(); }
/// <summary> /// what to do when the user wants to close the window /// </summary> /// <param name="obj"></param> private void OnClose(object obj) { SingletonClient client = SingletonClient.getInstance; client.StartClosingWindow(); }
private void btnGuardar_Click(object sender, EventArgs e) { SingletonClient client = new SingletonClient(); client.Grabar(txtNombre.Text, txtPlaneta.Text, DateTime.Now); }
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(); }
private void Grid_Unloaded(object sender, RoutedEventArgs e) { ServiceClient client = SingletonClient.GetInstance().Client; client?.Disconnect(); }