Пример #1
0
 public HomeViewModel(IMvxLogProvider logProvider, IMvxNavigationService navigationService, IExampleService exampleService) : base(logProvider, navigationService)
 {
     _exampleService    = exampleService;
     _navigationService = navigationService;
     _logProvider       = logProvider;
     _exampleChanged    = _messageService.Subscribe <ExampleChangedMessage>((msg) => { OnChangeCollection(msg); });
 }
Пример #2
0
        public Handler(ILambdaContext context)
        {
            var container = DependencyModule.BuildContainer(context);

            _exampleService = container.Resolve <IExampleService>();
            _logger         = container.Resolve <ILogger <Handler> >();
        }
Пример #3
0
        public void TestInit()
        {
            di = new UnityRegistrar();
            di.ConnectToServiceLocator();

            var context = Ax.FakeContext <IExampleDomainContext>();

            di.RegisterAsSingleInstance(context);

            examples = new List <ExampleModel>();
            Ax.UseList(() => context.Examples, examples);

            A.CallTo(() => context.Examples.Update(A <ExampleModel> .Ignored)).Invokes(call =>
            {
                var example = (ExampleModel)call.Arguments[0];
                examples.RemoveAll(x => x.Id == example.Id);
                examples.Add(example);
            });

            A.CallTo(() => context.Examples.Delete(A <Expression <Func <ExampleModel, bool> > > .Ignored)).Invokes(
                call =>
            {
                var predicate = (Expression <Func <ExampleModel, bool> >)call.Arguments[0];
                examples.RemoveAll(x => predicate.Compile()(x));
            });

            service = new ExampleService();
        }
 public static async Task <IActionResult> ShowInjection(
     [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)]
     HttpRequest req,
     [Inject]
     IExampleService exampleService)
 {
     return(await exampleService.ShowInjection(req));
 }
Пример #5
0
 public ProductsController(IGenericRepository <Product> productsRepo, IGenericRepository <ProductBrand> productBrand, IGenericRepository <ProductType> productTypeRepo, IMapper mapper, IExampleService example)
 {
     _mapper          = mapper;
     _example         = example;
     _productTypeRepo = productTypeRepo;
     _productBrand    = productBrand;
     _productsRepo    = productsRepo;
 }
 public OtherValuesController(
     IExampleService service,
     IOptions <ExampleOptions> options
     )
 {
     _service = service;
     _options = options.Value;
 }
Пример #7
0
        public void Configure(
            IApplicationBuilder app,
            // Additional dependencies
            IExampleService service)
        {
            app.UseExample();

            service.Execute();
        }
        public void ExampleService_TestMethod()
        {
            IExampleService mockExampleService = MockRepository.GenerateMock <IExampleService>();

            mockExampleService.Stub(s => s.GetPerson(Arg <Guid> .Is.Anything)).Return(_filledPerson);

            Assert.IsNotNull(_filledPerson.Id);
            Assert.IsNotNull(_filledPerson.FirstName);
            Assert.IsNotNull(_filledPerson.LastName);
            Assert.IsNotNull(_filledPerson.Address.StreetName);
            Assert.IsNotNull(_filledPerson.Address.Country);
        }
        protected override void CreateIdentity(string auth)
        {
            // Configure identity
            base.CreateIdentity(auth);

            // Inject
            service    = new ExampleService(factory, http);
            controller = new ExampleController(null, mapper, service)
            {
                ControllerContext = controllerContext,
            };
        }
Пример #10
0
 public ExampleApiController(ILogger <ExampleApiController> logger,
                             IWordService wordService,
                             IExampleService exampleService,
                             CachedService <ExampleDto> cachedService,
                             IMapper mapper)
 {
     _logger         = logger;
     _wordService    = wordService;
     _exampleService = exampleService;
     _cachedService  = cachedService;
     _mapper         = mapper;
 }
Пример #11
0
        static async Task ServiceExampleAsync(IExampleService service)
        {
            Person jamesBond = new Person
            {
                FirstName = "James",
                LastName  = "Bond",
                BirthDate = new DateTime(1962, 3, 18)
            };
            Person adeleGoldberg = new Person
            {
                FirstName = "Adele",
                LastName  = "Goldberg",
                BirthDate = new DateTime(1945, 7, 22)
            };

            // Creating...
            Console.WriteLine("[Person] Service creating...");
            _ = await service.AddPeopleAsync(new[] { jamesBond, adeleGoldberg });

            // Reading...
            Person james = await service.ReadPersonByIdAsync(jamesBond.Id, jamesBond.SyntheticPartitionKey);

            Person adele = (await service.ReadPeopleAsync(p => p.LastName == "Goldberg")).Single();

            Console.WriteLine($"[Person] Read: {james}");
            Console.WriteLine($"[Person] Read: {adele}");

            // Updating...
            Console.WriteLine("[Person] Service updating...");
            james.BirthDate = new DateTime(1973, 7, 21); // Oops, Mary was actually born in 1973
            adele.BirthDate = new DateTime(1982, 2, 14); // And Calvin was born in 1982...

            _ = service.UpdatePersonAsync(james);
            _ = service.UpdatePersonAsync(adele);

            // Read again / verify updates
            IEnumerable <Person> peopleWithoutMiddleNames = await service.ReadPeopleAsync(p => p.MiddleName == null);

            foreach (Person person in peopleWithoutMiddleNames)
            {
                Console.WriteLine($"[Person] Updated: {person}");
            }

            // Deleting...
            Console.WriteLine("[Person] Service deleting...");
            await Task.WhenAll(new[]
            {
                service.DeletePersonAsync(james).AsTask(),
                service.DeletePersonAsync(adele).AsTask()
            });
        }
Пример #12
0
        public override void Define()
        {
            Sale            sale    = null;
            IExampleService service = null;

            Dependency()
            .Resolve(() => service);

            When()
            .Match <Sale>(() => sale, c => c.Name == "A");

            Then()
            .Do(_ => service.Notify());
        }
        public void ExampleService_List_TestMethod()
        {
            IExampleService mockExampleService = MockRepository.GenerateMock <IExampleService>();

            mockExampleService.Stub(s => s.GetAllPeople()).Return(_filledPeople);

            foreach (Person person in _filledPeople)
            {
                Assert.IsNotNull(person.Id);
                Assert.IsNotNull(person.FirstName);
                Assert.IsNotNull(person.LastName);
                Assert.IsNotNull(person.Address.StreetName);
                Assert.IsNotNull(person.Address.Country);
            }
        }
Пример #14
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IExampleService exampleService)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async(context) =>
            {
                var result = exampleService.RandomizeOneString();
                var json   = JsonSerializer.Serialize(result);

                context.Response.Headers.Add("Content-Type", "application/json");
                await context.Response.WriteAsync(json);
            });
        }
Пример #15
0
        static void Main(string[] args)
        {
            //Set up DI
            Autofac.IContainer _container = BuildContainer();
            ConfigureServices(_container);

            //Accomplish something using our example service which depends on an external library
            //Resolve the service with dependencies injected - e.g. loggers
            using (var scope = _container.BeginLifetimeScope())
            {
                IExampleService service = scope.Resolve <IExampleService>();
                service.DoSomethingAsync().GetAwaiter().GetResult();
            }

            //Wait to exit
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Пример #16
0
        private static async Task Test()
        {
            var qConfig = new QueueConfig();

            _configuration.GetSection("RabbitExpress").Bind(qConfig);
            using (var qc = new QueueClient <MsgPackSerializer>(qConfig))
            {
                IExampleService client = qc.RpcClient <IExampleService>();
                Console.WriteLine(client.Calculate(2, 4));
                var input = new ExampleMessage {
                    Text = "RabbitExpress Test"
                };
                client.Process(input);
                ExampleMessage msg = await client.EncodeMessage(input);

                Console.WriteLine(msg.Text);
                ExampleMessage decmsg = await client.DecodeMessage(msg);

                Console.WriteLine(decmsg.Text);
                Console.ReadLine();
            }
        }
 public Task DoSomething(IExampleService exampleService, CancellationToken cancellationToken = default)
 {
     return(this.Raise(new ExampleFirstEvent()));
 }
 public Task Handle(IExampleService exampleService, ExampleFirstEvent @event, CancellationToken cancellationToken = default)
 {
     return(DoSomething(exampleService));
 }
 public Task DoSomething(IExampleService exampleService)
 {
     return(this.Raise(new ExampleSecondEvent()));
 }
Пример #20
0
 public ExampleFilter(IExampleService exampleService)
 {
     _exampleService = exampleService;
 }
 public TestController(IExampleService exampleService)
 {
     this.exampleService = exampleService;
 }
Пример #22
0
 // (Optional) An example of injecting a service. As a default constructor is called by Lambda
 // this constructor has to be called from default constructor
 public Function(IExampleService exampleService)
 {
     _exampleService = exampleService;
 }
Пример #23
0
 public HomeController(ILogger <HomeController> logger, IExampleService service)
 {
     _logger  = logger;
     _service = service;
 }
 public InjectionExampleController(IExampleService service)
 {
     _service = service;
 }
Пример #25
0
 public WcfController(IExampleService service, IDatabaseService databaseService)
 {
     _service = service;
     _databaseService = databaseService;
 }
        private static ExampleController GetClientsController(ILogger <ExampleController> logger, IHostingEnvironment environment, IExampleService clientsService)
        {
            var clientsController = new Mock <ExampleController>(logger, environment, clientsService)
            {
                CallBase = true
            };

            return(clientsController.Object);
        }
 public SitecoreExampleController(IExampleService exampleService)
 {
     _exampleService = exampleService;
 }
 public SampleController(IExampleService exampleService, IOptions<ExampleOptions> options)
 {
     _exampleService = exampleService;
     _options = options;
 }
 public Task Handle(ExampleSecondEvent @event, IExampleService exampleService, CancellationToken cancellationToken = default)
 {
     return(Task.CompletedTask);
 }
Пример #30
0
 public HomeController(IExampleService myLittleService)
 {
     _myLittleService = myLittleService;
 }
Пример #31
0
 public ExampleController(IExampleService exampleService)
 {
     _exampleService = exampleService;
 }
Пример #32
0
 public ExampleController(IExampleService exampleService, IConfiguration Config)
 {
     _exampleService = exampleService;
     config          = Config;
 }
 public SitecoreExampleController(IExampleService exampleService)
 {
     _exampleService = exampleService;
 }
Пример #34
0
 public HomeController(IExampleService _exampleService)
 {
     this.exampleService = _exampleService;
     this.exampleService.register(this);
 }
Пример #35
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="service">Example Service instance</param>
 /// <param name="logger">Logger instance</param>
 /// <param name="mapper">AutoMapper instance</param>
 public ExampleController(IExampleService service, ILogger <ExampleController> logger, IMapper mapper)
 {
     _service = service;
     _logger  = logger;
     _mapper  = mapper;
 }
Пример #36
0
 public HomeController(IExampleService exampleService)
 {
     this._exampleService = exampleService;
 }
 public TestController(IExampleService exampleService)
 {
     this.exampleService = exampleService;
 }
 public WebFormPage()
 {
     var container = HttpContext.Current.GetContainer();
     _exampleService = container.GetService<IExampleService>();
 }
Пример #39
0
 public HomeController(IExampleService exampleService)
 {
     this._exampleService = exampleService;
 }
 public RouteExampleController(IExampleService service)
 {
     _service = service;
 }