private void button2_Click(object sender, EventArgs e) { SimpleService s = new SimpleService(); NFU_Service.MySoapObject2[] ms = new NFU_Service.MySoapObject2[2]; for (int i = 0; i < ms.Length; i++) { ms[i] = new NFU_Service.MySoapObject2(); ms[i].Author2 = "中文"; ms[i].Description2 = "The One that should be returned"; ms[i].Name2 = i.ToString(); ms[i].Text2 = "something something something " + i.ToString(); ms[i].VoteCount2 = i * 2; ms[i].VoteTotal2 = (int)Math.Pow(ms[i].VoteCount2, 2); } NFU_Service.MySoapObject retn = s.ProcessMySoapObject(ms); // if output ArrayOfString // string[] retn2 = s.ProcessMySoapObject(ms); string output = ""; output += retn.Author + "\t\t\r\n"; output += retn.Description + "\t\t\r\n"; output += retn.Name + "\t\t\r\n"; output += retn.Text + "\t\t\r\n"; output += retn.VoteCount.ToString() + "\t\t\r\n"; output += retn.VoteTotal.ToString() + "\t\t\r\n"; MessageBox.Show(output); }
// 搜尋未使用的訂單 private void button4_Click(object sender, EventArgs e) { bool success = false; string message = ""; SimpleService nfu_service = new SimpleService(); orderData = nfu_service.OrderSearchNotUse(out success, out message); if (success) { /* * Order m = JsonConvert.DeserializeObject<Order>(orderData); // 部分反序列化 * string name = m.id; * MessageBox.Show(name); */ JObject LinqSearch = JObject.Parse(orderData); // {} 物件json LINQ查詢 MessageBox.Show(LinqSearch["id"].ToString()); } else { MessageBox.Show(message); } }
private void button3_Click(object sender, EventArgs e) { SimpleService svc = new SimpleService(); string s = svc.testtest1("steve"); MessageBox.Show(s); }
public void RemovesAllRegisteredServices() { var locator = new ServiceLocator(); var service = new SimpleService(); var defaultNumberOfSerices = locator.Count; locator.Register(Guid.NewGuid(), service); locator.Register(new[] { typeof(ITestService), typeof(SimpleService) }, service); locator.Register(new[] { "Service1", "Service2" }, service); locator.Register(Guid.NewGuid(), ServiceMode.Clone, (sender, e) => { e.Service = new SimpleService(); }); locator.Register(1u, service); locator.Register("Serice3", typeof(SimpleService), ServiceMode.Clone); Assert.AreNotEqual(0, locator.Count); Assert.AreEqual(8 + defaultNumberOfSerices, locator.Count); locator.Clear(); Assert.AreEqual(defaultNumberOfSerices, locator.Count); var newService = locator.GetService(typeof(SimpleService)); Assert.IsNotNull(newService); newService = locator.GetService(1u); Assert.IsNull(newService); newService = locator.GetService("Service1"); Assert.IsNull(newService); }
public void RegisterAndUnregisterService() { var s = new ServiceLocator(); var service = new SimpleService(); s.Register(TestGuid, service); s.Register(TestGuidString, service); s.Register(service); s.Register(TestId, service); // check if was added: Assert.AreEqual(service, s.GetService <ITestService>()); Assert.AreEqual(service, s.GetService(TestGuid)); Assert.AreEqual(service, s.GetService(TestGuidString)); Assert.AreEqual(service, s.GetService(TestId)); // passing the null value instead of real service, will release // service object: s.Register(typeof(ITestService), null); s.Register(TestGuid, null); s.Register(TestGuidString, null); s.Register(TestId, null); // validate if service is no more available: Assert.IsNull(s.GetService <ITestService>()); Assert.IsNull(s.GetService(TestGuid)); Assert.IsNull(s.GetService(TestGuidString)); Assert.IsNull(s.GetService(TestId)); }
// 改變訂單使用狀態 private void ChangeOrderInfoStatus(int id, int NowEnCount, int status, int IsCheck) { bool debug = false; string message = ""; try { SimpleService nfu_service = new SimpleService(); bool isSuccess = nfu_service.OrderChangeOrderInfoStatus(id, NowEnCount, status, IsCheck, out message); if (isSuccess) { if (debug) { MessageBox.Show("已將訂單info之帳號改為失敗(-1)"); } } else { if (debug) { MessageBox.Show(message); } } } catch (Exception ex) { MessageBox.Show("無法取得【更改訂單狀態】服務"); } }
public void SimpleCase() { String contents = "import Castle.Facilities.AspectSharp.Tests.Components in Castle.Facilities.AspectSharp.Tests " + "import Castle.Facilities.AspectSharp.Tests.Interceptors in Castle.Facilities.AspectSharp.Tests " + " " + " aspect MyAspect for SimpleService " + " " + " pointcut method|property(*)" + " advice(LoggerInterceptor)" + " end" + " " + " end "; MutableConfiguration config = new MutableConfiguration("facility", contents); DefaultConfigurationStore store = new DefaultConfigurationStore(); store.AddFacilityConfiguration("aop", config); WindsorContainer container = new WindsorContainer(store); container.AddFacility("aop", new AspectSharpFacility()); container.AddComponent("comp1", typeof(SimpleService)); SimpleService service = container[typeof(SimpleService)] as SimpleService; service.DoSomething(); service.DoSomethingElse(); Assert.AreEqual("Enter DoSomething\r\nEnter DoSomethingElse\r\n", LoggerInterceptor.Messages.ToString()); }
// 搜尋已繳費及未完成之訂單info帳號未使用及以驗證 private bool SearchOrderNotUse() { bool success = false; string message = ""; orderDataJson = ""; try { SimpleService nfu_service = new SimpleService(); orderDataJson = nfu_service.OrderSearchNotUse(out success, out message); if (success) { JObject LinqSearchOrder = JObject.Parse(orderDataJson); // {} 物件json LINQ查詢 //MessageBox.Show(LinqSearchOrder["order_id"].ToString()); return(true); } else { richTextBox1.AppendText(message + "\n"); return(false); } } catch (Exception ex) { richTextBox1.AppendText("無法取得【搜尋未使用訂單之帳號】服務\n"); //MessageBox.Show("無法取得【搜尋未使用訂單之帳號】服務"); return(false); } }
private void button1_Click(object sender, EventArgs e) { //string s = new string[2]; SimpleService svc = new SimpleService(); string s = svc.gethelloworld("steve", "gg"); MessageBox.Show(s); }
public ServiceModel GetServiceModelFromService(SimpleService service) { var serviceType = service.GetType(); var methods = serviceType.GetMethods(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance); var serviceMethods = methods.Select(ConvertToServiceMethod).ToList(); var serviceModel = new ServiceModel(CamelCase(serviceType.Name), GetCleanServicePath(service.Request.Url), serviceMethods); return serviceModel; }
public void simple_ObjectDef_by_value() { var service = new SimpleService(); var container = ContainerFacilitySource.New(x => { x.Register(typeof(IService), ObjectDef.ForValue(service)); }); container.Get <IService>().ShouldBeTheSameAs(service); }
public void simple_ObjectDef_by_value() { var service = new SimpleService(); var container = ContainerFacilitySource.New(x => { x.Register(typeof (IService), ObjectDef.ForValue(service)); }); container.Get<IService>().ShouldBeTheSameAs(service); }
private bool SimpleServiceFilter(object item) { SimpleService service = item as SimpleService; if (service == null) { return(false); } return(service.Name.ToLower().Contains(this.textBoxFilter.Text.ToLower()) || service.DisplayName.ToLower().Contains(this.textBoxFilter.Text.ToLower())); }
public void CanRegisterUsingFactoryMethod() { var tested = new ServiceCollection(); var simpleService = new SimpleService(); tested.Register(c => c .For <ISimpleService>() .UsingFactoryMethod(() => simpleService)); var serviceProvider = tested.BuildServiceProvider(); var service = serviceProvider.GetService <ISimpleService>(); Assert.Same(simpleService, service); }
public void RegisterServiceViaUInt() { var s = new ServiceLocator(); const uint ServiceID = 1u; const uint NonExistingServiceID = 2u; s.Register(ServiceID, ServiceMode.Singleton, (sender, e) => { e.Service = new SimpleService(); }); SimpleService service = (SimpleService)s.GetService(ServiceID); SimpleService nonExistingService = (SimpleService)s.GetService(NonExistingServiceID); Assert.IsNotNull(service); Assert.IsNull(nonExistingService); }
// 改變訂單使用狀態 private void ChangeOrderInfoStatus(int id, int NowEnCount, int status, int IsCheck) { string message = ""; try { SimpleService nfu_service = new SimpleService(); bool isSuccess = nfu_service.OrderChangeOrderInfoStatus(id, NowEnCount, status, IsCheck, out message); } catch (Exception ex) { MessageBox.Show("無法取得【更改訂單狀態】服務"); } }
public void CanRegisterDeclared() { var tested = new ServiceCollection(); var instance = new SimpleService(); tested.Register(r => r .Instance <object>(instance) .WithServices.AllInterfaces()); Assert.Single(tested); Assert.All(tested, service => { Assert.Equal(typeof(ISimpleService), service.ServiceType); Assert.Same(instance, service.ImplementationInstance); }); }
public void CanRegister() { var tested = new ServiceCollection(); var simpleService = new SimpleService(); tested.Register(r => r .For <ISimpleService>() .Instance(simpleService)); Assert.Single(tested); Assert.All(tested, service => { Assert.Equal(typeof(ISimpleService), service.ServiceType); Assert.Same(simpleService, service.ImplementationInstance); }); }
private string SearchOrderInfo() { SimpleService sv = new SimpleService(); string OrderInfoData = ""; string message = ""; bool IsGet = sv.OrderSearchOrderInfo(out OrderInfoData, out message); if (IsGet) { return(OrderInfoData); } else { return(message); } }
public void WhenUsingServiceWithoutProxyThenReturnsService() { // Arrange SimpleService service = new SimpleService(); this.dependencyResolver.Setup(d => d.GetService(typeof(ISimpleService))).Returns(service); this.configuration.ServiceProxyCreationEnabled = false; MessageProcessor processor = this.CreatTestableProcessor(); // Act var serviceDirect = processor.Use <ISimpleService>(); // Assert Assert.NotNull(serviceDirect); Assert.IsType(service.GetType(), serviceDirect); Assert.True(serviceDirect.GetType() == service.GetType()); }
public async Task GetValue_NoParameters_ShouldReturnValue() { // Arrange var database = DatabaseFactory.CreateContext(); var mapper = MapperFactory.Create(); var simpleService = new SimpleService(database, mapper); database.TestModels.Add(new TestModel { Id = 1, Name = "value" }); database.SaveChanges(); // Act var result = await simpleService.GetValue(); // Assert Assert.Equal("value", result.Name); }
public void GlobalSetup() { var definitionsProvider = new RpcServiceDefinitionsBuilder(); switch (this.ConnectionType) { case RpcConnectionType.Grpc: this.server = new GrpcCore.Server { Services = { SimpleService.BindService(new GrpcSimpleService()) }, Ports = { new GrpcCore.ServerPort("localhost", 50051, GrpcCore.ServerCredentials.Insecure) } }; this.server.Start(); this.channel = new GrpcCore.Channel("127.0.0.1:50051", GrpcCore.ChannelCredentials.Insecure); this.clientService = new SimpleService.SimpleServiceClient(this.channel); break; #if COREFX case RpcConnectionType.NetGrpc: this.host = CreateNetGrpcHost(); host.Start(); var handler = new System.Net.Http.HttpClientHandler(); handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => { return(true); }; var channelOptions = new GrpcNet.Client.GrpcChannelOptions() { HttpClient = new System.Net.Http.HttpClient(handler), DisposeHttpClient = true }; this.channel = GrpcChannel.ForAddress("https://localhost:50051", channelOptions); this.clientService = new SimpleService.SimpleServiceClient(channel); break; #endif } }
public void RegisterServiceViaObject() { var s = new ServiceLocator(); var service = new SimpleService(); s.Register(service); // since now on, the service should be available via number of ways // let's try most of them if we receive the same object: ITestService result = s.GetService <ITestService>(); Assert.AreEqual(result, service); result = s.GetService(typeof(ITestService)) as ITestService; Assert.AreEqual(result, service); // registering service via object shouldn't automatically register classes, // but we always let the object to be instantiated, if not abstract: result = s.GetService <SimpleService>(); Assert.IsNotNull(result); }
private void OrderLogSave(int order_id, int order_info_id, string message) { try { SimpleService nfu_service = new SimpleService(); bool isSuccess = nfu_service.OrderLogSave(order_id, order_info_id, ref message); if (isSuccess) { //MessageBox.Show("儲存log"); //throw new Exception("ggtest"); } else { MessageBox.Show(message); } } catch (Exception ex) { richTextBox1.AppendText("無法取得【儲存log】服務\n"); //MessageBox.Show("無法取得【儲存log】服務"); //MessageBox.Show(ex.Message); } }
static void Main(string[] args) { using (ServiceHost host = new ServiceHost(typeof(SimpleService))) { host.Open(); Console.WriteLine("Simple service started....Press any key to start publishing message"); Console.ReadKey(); int c = 0; while (true) { Console.WriteLine($"Time:{DateTime.Now}, Published:{c * 100} Messages"); c++; for (int i = 0; i < 100; i++) { Console.Write(i); SimpleService.Publish(new Msg { Id = i, Name = $"Name{DateTime.Now}" }); } System.Threading.Thread.Sleep(300); } } }
static void Main(string[] args) { var _service = new SimpleService(); }
public static int Main(string[] args) { if (args.Length == 0) { SimpleService.RunService(); return(0); } var op = args[0]; var opr = $"|{op}|"; var argc = args.Length - 1; var arg1 = argc == 1 ? args[1] : null; if (op == "version" || op == "--version" || op == "-v") { if (argc != 0) { Libs.Abort(USAGE); } Console.WriteLine(VERSION); return(0); } if (op == "create") { if (argc != 1) { Libs.Abort(USAGE); } CreateProject(arg1); return(0); } if (op == "list" || op == "ls") { if (argc != 0) { Libs.Abort(USAGE); } SvcUtils.ListAllEasyServices(); return(0); } var commands = "|check|status|test-worker|install|stop|start|remove|restart|log|"; if (!commands.Contains(opr) || argc > 1) { Libs.Abort(USAGE); } if (arg1 != null && (arg1.Contains('/') || arg1.Contains('\\'))) { if (!Directory.Exists(arg1)) { Libs.Abort($"Directory \"{arg1}\" not exists"); } Libs.SetCwd(arg1); arg1 = null; } if (op == "test-worker") { if (arg1 != null && arg1 != "--popup") { Libs.Abort($"Directory argument \"{arg1}\" should contain '/' or '\\'"); } TestWorker(arg1 == "--popup"); return(0); } if ("|check|status|install|".Contains(opr) && arg1 != null) { Libs.Abort($"Directory argument \"{arg1}\" should contain '/' or '\\'"); } if ("|restart|log|".Contains(opr) && arg1 == "all") { Libs.Abort(USAGE); } if (arg1 == null) { ManageOneByConfFile(op); } else if (arg1 != "all") { ManageOneBySvrIdentity(op, arg1); } else { SvcUtils.ManageAll(op); } return(0); }
public SimpleCommandHandler(SimpleService simpleService) { _simpleService = simpleService; }
public SimpleController(SimpleService simpleService) { this.simpleService = simpleService; }
public JavaScriptProxyBuilder(SimpleService service) { Service = service; }
public SubscriberWithDependency(SimpleService genericService) { _genericService = genericService; }
public SimpleRequestHandler(SimpleService simpleService) { _simpleService = simpleService; }
public void TestServiceEvent() { SimpleService service = new SimpleService(); service.OnSaved += new ServiceEventHandler<SimpleService, string>(OnServiceEvent); service.Save(); }
public void RegisterServiceViaGuid() { var s = new ServiceLocator(); var service = new SimpleService(); s.Register(TestGuid, service); // since now on, the service should be available via number of ways // let's try most of them if we receive the same object: ITestService result = s.GetService<ITestService>(TestGuid); Assert.AreEqual(result, service); Assert.AreEqual(s.GetService(TestGuid), service); result = s.GetService(typeof(ITestService)) as ITestService; Assert.IsNull(result); // registering service via object shouldn't automatically register classes, // but we always let the object to be instantiated, if not abstract: result = s.GetService<SimpleService>(); Assert.IsNotNull(result); }
public void TestFireInfoEvent() { SimpleService service = new SimpleService(); service.Execute(); }
public void TestGenericServiceEvent() { SimpleService service = new SimpleService(); service.OnServiceEvent += new GenericServiceEventHandler(OnGenericServiceEvent); service.DoSomething(); }
// 搜尋已繳費及未完成之訂單info帳號未使用及以驗證 private bool SearchOrderNotUse() { bool success = false; string message = ""; orderDataJson = ""; try { SimpleService nfu_service = new SimpleService(); orderDataJson = nfu_service.OrderSearchNotUse(out success, out message); if (success) { JObject LinqSearchOrder = JObject.Parse(orderDataJson); // {} 物件json LINQ查詢 //MessageBox.Show(LinqSearchOrder["order_id"].ToString()); return true; } else { richTextBox1.AppendText(message + "\n"); return false; } } catch(Exception ex) { richTextBox1.AppendText("無法取得【搜尋未使用訂單之帳號】服務\n"); //MessageBox.Show("無法取得【搜尋未使用訂單之帳號】服務"); return false; } }
/// <summary> /// /// </summary> /// /// <param name="service"></param> /// <param name="args"></param> /// private void OnServiceEvent(SimpleService service, ServiceEventArgs<string> args) { Assert.IsNotNull(service); Assert.IsNotNull(args); service.DisplayMessage("recieved service event!"); }
/// <summary> /// Initializes the instance of the module. /// </summary> /// <param name="serviceLocator"><see cref="IServiceLocator"/> /// Nomad's IServieLocator which will be provided (injected by framework) to module. /// </param> public RegisteringModule(IServiceLocator serviceLocator) { _serviceLocator = serviceLocator; _myOfferedService = new SimpleService(); }
public void RegisterAndUnregisterService() { var s = new ServiceLocator(); var service = new SimpleService(); s.Register(TestGuid, service); s.Register(TestGuidString, service); s.Register(service); s.Register(TestId, service); // check if was added: Assert.AreEqual(service, s.GetService<ITestService>()); Assert.AreEqual(service, s.GetService(TestGuid)); Assert.AreEqual(service, s.GetService(TestGuidString)); Assert.AreEqual(service, s.GetService(TestId)); // passing the null value instead of real service, will release // service object: s.Register(typeof(ITestService), null); s.Register(TestGuid, null); s.Register(TestGuidString, null); s.Register(TestId, null); // validate if service is no more available: Assert.IsNull(s.GetService<ITestService>()); Assert.IsNull(s.GetService(TestGuid)); Assert.IsNull(s.GetService(TestGuidString)); Assert.IsNull(s.GetService(TestId)); }
public ScopeController(SimpleService service) => _service = service;
public void TestGetLogger() { SimpleService service = new SimpleService(); service.DisplayMessage("Logger test passed!"); }