public HomeController(IDemoService demoService, IOptionsSnapshot <DemoSettings> demoSettings, ILogger <HomeController> logger, IConfiguration config) { _demoService = demoService; _settings = demoSettings.Value; _logger = logger; _config = config; }
public HomeController( IDemoService demoService, ILogger <HomeController> logger) { _service = demoService; _logger = logger; }
static void Main(string[] args) { //ServiceReference1.DemoServiceClient client = new ServiceReference1.DemoServiceClient(); DemoRequest dr = new DemoRequest() { Foo = "A", Bar = "B" }; //DemoResponse result = client.DoTheThing(dr); //Console.WriteLine($"{result.Baz}\t{result.Quux}"); ChannelFactory <IDemoService> factory = new ChannelFactory <IDemoService>("test"); IDemoService service = factory.CreateChannel(); try { var result = service.DoTheThing(dr); Console.WriteLine($"{result.Baz}\t{result.Quux}"); } catch (Exception) { throw; } Console.ReadLine(); }
public GridViewModel(IDemoService demoService, IOFDialogue ioService) { _demoService = demoService; _ioService = ioService; //try //{ // SQLiteDB.Init(); //} //catch (Exception e) //{ // LogTo.ErrorException("Error initializing DB",e); // throw; //} if (IsInDesignMode) { } else { if (Members.Count == 0) { Members = SQLiteDB.GetAllMembers(); LogTo.Info("Getting Members INIT"); } LogTo.Info("GridViewModel initialized"); } }
public ValuesController(Func <string, IDemoService> serviceAccessor) { this._serviceAccessor = serviceAccessor; _serviceA = _serviceAccessor("ServiceA"); _serviceB = _serviceAccessor("ServiceB"); }
/// <summary> /// 构造函数 /// </summary> /// <param name="demoService"></param> /// <param name="memoryCache"></param> /// <param name="redisCache"></param> /// <param name="logger"></param> public DemoController(IDemoService demoService, ICacheService memoryCache, ICacheService redisCache, ILogger <DemoController> logger) { _demoService = demoService; _memoryCache = memoryCache; _redisCache = redisCache; _logger = logger; }
public virtual void SetUp() { _testinghost = new NonOrleansServiceTester <TestingHost <IDemoService> >(); _insecureClient = _testinghost.GetServiceProxy <IDemoService>(); Metric.ShutdownContext("Service"); TracingContext.SetRequestID("1"); }
static void Main(string[] args) { // Client Channel Factory EndpointAddress serviceAddress = new EndpointAddress("http://localhost:3333/DemoService/"); // Binding BasicHttpBinding httpBinding = new BasicHttpBinding(); httpBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; ChannelFactory <IDemoService> myChannelFacotry = new ChannelFactory <IDemoService>(httpBinding, serviceAddress); myChannelFacotry.Credentials.UserName.UserName = "******"; myChannelFacotry.Credentials.UserName.Password = "******"; // Proxy Erstellung IDemoService proxy = myChannelFacotry.CreateChannel(); var ergebnis = proxy.Addition(2, 3); Console.WriteLine($"Ergebnis: {ergebnis.ToString()}"); ((IClientChannel)proxy).Close(); Console.ReadKey(); }
public DemoResponse DoTheThing(DemoRequest request) { request.Bar += "-Proxied"; IDemoService service = factory.CreateChannel(); using (OperationContextScope scope = new OperationContextScope((IContextChannel)service)) { WebOperationContext woc = WebOperationContext.Current; woc.OutgoingRequest.ContentType = "application/json; charset=utf-8"; var result = service.DoTheThing(request); try { return(result); } finally { if (result is System.ServiceModel.ICommunicationObject client) { if (client.State == System.ServiceModel.CommunicationState.Faulted) { client.Abort(); } else { client.Close(); } } } } }
public DemoController( IDemoService demoService, IOptionsSnapshot <DemoSettings> demoSettings, IConfiguration configuration) { _demoService = demoService; _settings = demoSettings.Value; }
public DemoChannelProvider() { var endpoint = new EndpointAddress($"http://localhost:8888/RemoteQueryableDemo/DemoService"); this.demoService = ChannelFactory <IDemoService> .CreateChannel(new BasicHttpBinding() { ReceiveTimeout = TimeSpan.FromSeconds(30) }, endpoint); }
public DemoController ( IDemoService DemoService, ILogger <DemoController> logger ) { _demoService = DemoService; _logger = logger; }
public override void Close() { if (ChannelFactory == null) { return; } Channel = null; ChannelFactory.Close(); ChannelFactory = null; }
private readonly IOptions <Infrastructure.Dtos.Config.AppSettings> appSettings; //配置文件数据 /// <summary> /// DemoController /// </summary> public TestController(DapperDBContext _context , IDemoService _iDemoService, AutoMapper.IMapper _modelMapper, IHostingEnvironment hostingEnv , IOptions <Infrastructure.Dtos.Config.AppSettings> _appSettings) { context = _context; iDemoService = _iDemoService; modelMapper = _modelMapper; this.Log = LogManager.GetLogger(Startup.Repository.Name, typeof(HomeController)); appSettings = _appSettings; }
public virtual void SetUp() { _insecureClient = _kernel.Get <IDemoService>(); _exceptionSerializer = _kernel.Get <JsonExceptionSerializer>(); Metric.ShutdownContext("Service"); TracingContext.SetUpStorage(); TracingContext.SetRequestID("1"); _testinghost = new TestingHost <IDemoService>(); _stopTask = _testinghost.RunAsync(new ServiceArguments(ServiceStartupMode.CommandLineNonInteractive)); }
public void SetUp() { Metric.ShutdownContext("Service"); TracingContext.SetUpStorage(); TracingContext.SetRequestID("1"); var kernel = new TestingKernel <ConsoleLog>(); _proxyInstance = kernel.Get <IDemoService>(); }
public async Task <int> OnExecute( ILogger <App> logger, IOptions <AppSettings> appSettings, IDemoService demoService) { logger.LogInformation($"AppSetting1: {appSettings.Value.AppSetting1}"); logger.LogInformation($"Argument1: {Argument1}"); logger.LogInformation($"Option1: {Option1}"); await demoService.ExecuteAsync(); return(Constants.OK); }
public void DefaultThrowsException() { try { DynamicProxyInvoker target = new DynamicProxyInvoker(); IDemoService proxy1 = DynamicProxy.CreateInstance <IDemoService>(target); proxy1.Foo(0, ""); Assert.Fail("a NotImplementedException should have been thrown, but didnt!"); } catch (NotImplementedException ex) { Assert.AreEqual("There is no Implementation for Method Foo(bar, suffix)", ex.Message); } }
public virtual void SetUp() { var kernel = new TestingKernel<ConsoleLog>(); _insecureClient = kernel.Get<IDemoService>(); _exceptionSerializer = kernel.Get<JsonExceptionSerializer>(); Metric.ShutdownContext("Service"); TracingContext.SetUpStorage(); TracingContext.SetRequestID("1"); _testinghost = new TestingHost<IDemoService>(); _stopTask = _testinghost.RunAsync(); }
public static IActionResult Run( [HttpTrigger( AuthorizationLevel.Anonymous, "get", Route = "demo") ] HttpRequest req, [Inject] IDemoService demoService, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); var res = demoService.GetResponse(); return(new OkObjectResult(res)); }
public async Task Invoke(HttpContext httpContext) { IDemoService d = httpContext.RequestServices.GetService <IDemoService>(); Console.WriteLine("FROM MIDDLEWARE GetService {0}", d.GetNum()); Console.WriteLine($"Request for {httpContext.Request.Path} received ({httpContext.Request.ContentLength ?? 0} bytes)"); try { await _next.Invoke(httpContext); } catch (Exception e) { await httpContext.Response.WriteAsync(String.Format("CAUGHT EXCEPTION {0}", e)); } }
public ValuesController(ILogger <ValuesController> logger, IDemoService demoService, IServiceScopeFactory serviceScopeFactory, IUnitOfWorkManager unitOfWorkManager, IBackgroundJobManager backgroundJobManager, IServiceProvider serviceProvider, IConfiguration configuration, ILocalEventBus localEventBus, ICapEventPublisher capEventPublisher) { _logger = logger; _demoService = demoService; _serviceProvider = serviceProvider; _unitOfWorkManager = unitOfWorkManager; _configuration = configuration; _localEventBus = localEventBus; _serviceScopeFactory = serviceScopeFactory; _capEventPublisher = capEventPublisher; _backgroundJobManager = backgroundJobManager; Logger = NullLogger <ValuesController> .Instance;//Controller 无法进行属性注入?? }
public void DynamicImplementationOfInterface() { DynamicProxyInvoker target = new DynamicProxyInvoker(); target.DefineMethod("Foo", (int bar, string suffix) => { return(bar.ToString() + " " + suffix); } ); IDemoService proxy1 = DynamicProxy.CreateInstance <IDemoService>(target); string result1 = proxy1.Foo(123, "Hello"); Assert.AreEqual("123 Hello", result1); }
public void DefaultWithCustomFallback() { DynamicProxyInvoker target = new DynamicProxyInvoker(); target.FallbackInvokeMethod = (method, args, names) => { Assert.AreEqual("Foo", method); Assert.AreEqual("booooo", args[1]); return("hihi"); }; IDemoService proxy1 = DynamicProxy.CreateInstance <IDemoService>(target); string result = proxy1.Foo(0, "booooo"); Assert.AreEqual("hihi", result); }
static async Task Main(string[] args) { IHost host = Host.CreateDefaultBuilder() .ConfigureServices((context, services) => { services.AddSingleton <IEmployeeDataAccess, DemoEmployeeDataAccess>(); services.AddTransient <IDemoService, DemoService>(); services.AddLogging(); services.AddMediatR(typeof(DemoEmployeeDataAccess).Assembly); }) .Build(); IDemoService service = host.Services.GetService <IDemoService>(); await service.RunAsync(); host.Dispose(); }
public MainPageViewModel(IDemoService demoService) { this.demoService = demoService; IsActive = true; if (Application.Current.MainWindow == null) { Message = "...*"; Messages = new Models.Messages(); Messages.Add(new Message() { MessageId = Guid.NewGuid(), CreateAt = DateTime.Now, Text = "test" }); } else { Message = "..."; Messages = demoService.Read(); } }
private static IDemoService CreateServiceProxyByCode() { WSHttpBinding binding = new WSHttpBinding(); binding.Security.Mode = SecurityMode.Message; binding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate; binding.Security.Message.NegotiateServiceCredential = false; EndpointAddress address = new EndpointAddress("http://localhost:8889/DemoService"); ChannelFactory <IDemoService> factory = new ChannelFactory <IDemoService>(binding, address); factory.Credentials.UseIdentityConfiguration = false; factory.Credentials.ClientCertificate.Certificate = Helpers.GetCertificate(); factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None; factory.Credentials.ServiceCertificate.DefaultCertificate = Helpers.GetCertificate(); IDemoService proxy = factory.CreateChannel(); return(proxy); }
public DemoController(IDemoService demoService, ISysUserService sysUserService) { this.demoService = demoService; this.sysUserService = sysUserService; }
public DemoController(IDemoService demoService, ISysLogService logService) { _demoService = demoService; _logService = logService; }
public RandomStringViewComponent(IDemoService demoService) // injected by ASP.NET Core built in dependency injection { _demoService = demoService; }