Example #1
0
        public OtherController(IServiceProvider serviceProvider, IOptions <MyConfig> config)
        {
            this.config = config;

            _otherService    = serviceProvider.GetService <IOtherService>();
            _identityService = serviceProvider.GetService <IIdentityService>();
            _validateService = serviceProvider.GetService <IValidateService>();
        }
Example #2
0
 public IngredientService(IHopService hopService, IFermentableService fermentableService,
                          IOtherService otherService, IYeastService yeastService, IIngredientElasticsearch ingredientElasticsearch)
 {
     _hopService              = hopService;
     _fermentableService      = fermentableService;
     _otherService            = otherService;
     _yeastService            = yeastService;
     _ingredientElasticsearch = ingredientElasticsearch;
 }
        public void TestSelectiveHook()
        {
            ITestService test = Simply.Do[ConfigKey].Resolve <ITestService>();

            test.ReturnString().Should().Not.Be("123456");

            IOtherService other = Simply.Do[ConfigKey].Resolve <IOtherService>();

            other.ReturnString().Should().Be("123456");
        }
 public CreateCompoundEntityCommand(
     IDateService dateService,
     IDatabaseService database,
     ICompoundEntityFactory factory,
     IOtherService inventory)
 {
     _dateService = dateService;
     _database    = database;
     _factory     = factory;
     _inventory   = inventory;
 }
 public void Init()
 {
     TestUtil.DeleteDataInDatabase();
     TestUtil.InsertDataDatabase();
     AutoMapperConfiguration.Configure();
     _repository         = new OtherRepository();
     _context            = new MicrobrewitContext();
     _otherElasticsearch = new OtherElasticsearch();
     _service            = new OtherService(_otherElasticsearch, _repository);
     _controller         = new OtherController(_service);
 }
 public PatientController(IPatientService patientService,
                          IOtherService otherService,
                          ITestsService testService,
                          IDhlRegistrationService dhlRegistrationService,
                          IMaintenanceService maintenanceService)
 {
     this.patientService         = patientService;
     this.otherService           = otherService;
     this.testService            = testService;
     this.dhlRegistrationService = dhlRegistrationService;
     this.maintenanceService     = maintenanceService;
 }
Example #7
0
 public IndexModel(Service2 service2, Service3 service3,
                   IService service, IFoo foo, IBar bar,
                   INewService newService, IOtherService otherService, IOtherService2 otherService2)
 {
     Service2      = service2 ?? throw new System.ArgumentNullException(nameof(service2));
     Service3      = service3 ?? throw new System.ArgumentNullException(nameof(service3));
     Service       = service ?? throw new System.ArgumentNullException(nameof(service));
     Foo           = foo ?? throw new System.ArgumentNullException(nameof(foo));
     Bar           = bar ?? throw new System.ArgumentNullException(nameof(bar));
     NewService    = newService ?? throw new System.ArgumentNullException(nameof(newService));
     OtherService  = otherService ?? throw new System.ArgumentNullException(nameof(otherService));
     OtherService2 = otherService2 ?? throw new System.ArgumentNullException(nameof(otherService2));
 }
        public void Init()
        {
            TestUtil.DeleteDataInDatabase();
            TestUtil.InsertDataDatabase();
            AutoMapperConfiguration.Configure();
            _repository = new OtherRepository();
            _context = new MicrobrewitContext();
            _otherElasticsearch = new OtherElasticsearch();
            _service = new OtherService(_otherElasticsearch,_repository);
            _controller = new OtherController(_service);


        }
 public BeerXmlResolver(IOptions <DatabaseSettings> databaseSettings, IOptions <ElasticSearchSettings> elasticSearchSettings,
                        IFermentableElasticsearch fermentableElasticsearch, IHopElasticsearch hopElasticsearch, IHopRepository hopRepository,
                        IOtherElasticsearch otherElasticsearch, IYeastElasticsearch yeastElasticsearch, IOtherRepository otherRepository, IOtherService otherService)
 {
     _databaseSettings         = databaseSettings;
     _elasticSearchSettings    = elasticSearchSettings;
     _fermentableElasticsearch = fermentableElasticsearch;
     _hopElasticsearch         = hopElasticsearch;
     _hopRepository            = hopRepository;
     _otherElasticsearch       = otherElasticsearch;
     _yeastElasticsearch       = yeastElasticsearch;
     _otherRepository          = otherRepository;
     _otherService             = otherService;
 }
Example #10
0
 public MyService(IOtherService otherService)
 {
     OtherService = otherService;
 }
Example #11
0
 public OtherController(ILogger <OtherController> logger, IOtherService otherService) : base(logger)
 {
     _otherService = otherService;
 }
Example #12
0
 public BookService(IContextFactory contextFactory, Context scopedContext, IOtherService otherService)
 {
     _contextFactory = contextFactory;
     _scopedContext  = scopedContext;
     _otherService   = otherService;
 }
 public Consumer(IService service, IOtherService otherService)
 {
 }
        protected override RecipeDto ResolveCore(Recipe source)
        {
            _otherService = new OtherService(_otherElasticsearch, _otherRepository);

            var    boilSize  = (int)double.Parse(source.BoilSize, CultureInfo.InvariantCulture);
            var    batchSize = (int)double.Parse(source.BatchSize, CultureInfo.InvariantCulture);
            double fg        = 0;

            if (source.Fg != null)
            {
                fg = double.Parse(source.Fg, CultureInfo.InvariantCulture);
            }

            var recipeDto = new RecipeDto
            {
                MashSteps         = new List <MashStepDto>(),
                BoilSteps         = new List <BoilStepDto>(),
                FermentationSteps = new List <FermentationStepDto>(),
                SpargeStep        = null, //new SpargeStepDto(),
                Notes             = source.Taste_Notes,
                //Sets 60min as standard.
                TotalBoilTime = (source.Boil_Time != null) ? double.Parse(source.Boil_Time, CultureInfo.InvariantCulture) : 60,
                Volume        = (batchSize <= 0) ? boilSize : batchSize,
            };

            // <PRIMARY_AGE>
            if (source.PrimaryAge != null)
            {
                var primaryAge       = (int)double.Parse(source.PrimaryAge, CultureInfo.InvariantCulture);
                var primaryTemp      = (source.Primary_Temp == null) ? 0 : (int)double.Parse(source.Primary_Temp, CultureInfo.InvariantCulture);
                var fermentationStep = GetFermentationStepDto(recipeDto, primaryAge);
                if (fermentationStep != null)
                {
                    fermentationStep.Temperature = primaryTemp;
                    recipeDto.FermentationSteps.Add(fermentationStep);
                }
            }

            //<SECONDAY_AGE>
            if (source.Secondary_Age != null)
            {
                var secondaryAge     = (int)double.Parse(source.Secondary_Age, CultureInfo.InvariantCulture);
                var primaryTemp      = (source.Secondary_Temp == null) ? 0 : (int)double.Parse(source.Secondary_Temp, CultureInfo.InvariantCulture);
                var fermentationStep = GetFermentationStepDto(recipeDto, secondaryAge);
                if (fermentationStep != null)
                {
                    fermentationStep.Temperature = primaryTemp;
                    recipeDto.FermentationSteps.Add(fermentationStep);
                }
            }
            // <TERTIARYAGE>
            if (source.TertiaryAge != null)
            {
                var tertiaryAge      = (int)double.Parse(source.TertiaryAge, CultureInfo.InvariantCulture);
                var tertiaryTemp     = (source.TertiaryTemp == null) ? 0 : (int)double.Parse(source.TertiaryTemp, CultureInfo.InvariantCulture);
                var fermentationStep = GetFermentationStepDto(recipeDto, tertiaryAge);
                if (fermentationStep != null)
                {
                    fermentationStep.Temperature = tertiaryTemp;
                    recipeDto.FermentationSteps.Add(fermentationStep);
                }
            }

            if (!recipeDto.FermentationSteps.Any())
            {
                recipeDto.FermentationSteps.Add(new FermentationStepDto
                {
                    Length       = 14,
                    Hops         = new List <HopStepDto>(),
                    Fermentables = new List <FermentableStepDto>(),
                    Others       = new List <OtherStepDto>(),
                    Yeasts       = new List <YeastStepDto>()
                });
            }



            //Mash step from <MASH> <MASH_STEPS>
            if (source.Mash != null)
            {
                foreach (var mashStep in source.Mash.MashSteps)
                {
                    var mashStepDto = GetMashStepDto(mashStep);
                    recipeDto.MashSteps.Add(mashStepDto);
                }
            }
            else
            {
                recipeDto.MashSteps.Add(new MashStepDto
                {
                    Length       = 60,
                    Temperature  = 0,
                    Type         = "",
                    Notes        = "",
                    Hops         = new List <HopStepDto>(),
                    Fermentables = new List <FermentableStepDto>(),
                    Others       = new List <OtherStepDto>(),
                });
            }
            //Fermentable
            if (source.Fermentables != null)
            {
                var mashStep = GetMashStepDto(recipeDto, (int)recipeDto.TotalBoilTime) ??
                               recipeDto.MashSteps.FirstOrDefault();
                foreach (var fermentable in source.Fermentables)
                {
                    if (mashStep != null && (string.IsNullOrEmpty(fermentable.AddAfterBoil) || fermentable.AddAfterBoil.ToLower() == "false"))
                    {
                        var fermentableStepDto = GetFermentableStepDto(fermentable, mashStep);
                        mashStep.Fermentables.Add(fermentableStepDto);
                        break;
                    }
                    var fermentationStep = recipeDto.FermentationSteps.FirstOrDefault();
                    if (fermentationStep != null && fermentable.AddAfterBoil.ToLower() == "true")
                    {
                        var fermentableStepDto = GetFermentableStepDto(fermentable, fermentationStep);
                        fermentationStep.Fermentables.Add(fermentableStepDto);
                    }
                }
            }
            //Hops
            if (source.Hops != null)
            {
                foreach (var hop in source.Hops)
                {
                    var time       = (int)double.Parse(hop.Time, CultureInfo.InvariantCulture);
                    var hopStepDto = GetHopStepDto(hop);
                    if (string.Equals(hop.Use, "Boil", StringComparison.OrdinalIgnoreCase) || hop.Use == "")
                    {
                        var boilStep = GetBoilStepDto(recipeDto, time);
                        if (hopStepDto != null)
                        {
                            boilStep.Hops.Add(hopStepDto);
                        }
                    }

                    if (string.Equals(hop.Use, "First Wort"))
                    {
                        //TODO: add support for first wort.
                    }

                    if (string.Equals(hop.Use, "Mash") && string.Equals(hop.Use, "Aroma"))
                    {
                        var mashStep = GetMashStepDto(recipeDto, time) ?? recipeDto.MashSteps.FirstOrDefault();
                        if (hopStepDto != null)
                        {
                            mashStep.Hops.Add(hopStepDto);
                        }
                    }

                    if (hop.Use == "Dry Hop")
                    {
                        var fermentationStep = GetFermentationStepDto(recipeDto, time) ??
                                               recipeDto.FermentationSteps.FirstOrDefault();
                        if (hopStepDto != null)
                        {
                            fermentationStep.Hops.Add(hopStepDto);
                        }
                    }
                }
            }

            if (source.Miscs != null)
            {
                foreach (var misc in source.Miscs)
                {
                    int time = 0;
                    if (misc.Time.Any())
                    {
                        time = (int)double.Parse(misc.Time, CultureInfo.InvariantCulture);
                    }
                    var othersStepDto = GetOthersStepDto(misc);
                    if (string.Equals(misc.Use, "Boil", StringComparison.OrdinalIgnoreCase))
                    {
                        var boilStep = GetBoilStepDto(recipeDto, time);
                        if (othersStepDto != null)
                        {
                            boilStep.Others.Add(othersStepDto);
                        }
                    }
                    if (string.Equals(misc.Use, "Mash", StringComparison.OrdinalIgnoreCase))
                    {
                        var mashStep = GetMashStepDto(recipeDto, time) ?? recipeDto.MashSteps.FirstOrDefault();

                        if (othersStepDto != null)
                        {
                            mashStep.Others.Add(othersStepDto);
                        }
                    }
                    if (string.Equals(misc.Use, "Primary", StringComparison.OrdinalIgnoreCase) || string.Equals(misc.Use, "Secondary", StringComparison.OrdinalIgnoreCase))
                    {
                        var fermentationStepDto = GetFermentationStepDto(recipeDto, time) ??
                                                  recipeDto.FermentationSteps.FirstOrDefault();
                        if (othersStepDto != null)
                        {
                            fermentationStepDto.Others.Add(othersStepDto);
                        }
                    }
                    if (string.Equals(misc.Use, "Bottling", StringComparison.OrdinalIgnoreCase))
                    {
                        //TODO: botteling step, beta shit.
                    }
                }
            }

            if (source.Yeasts != null)
            {
                foreach (var yeast in source.Yeasts)
                {
                    var yeastStepDto = GetYeastStepDto(yeast);
                    var inSecondary  = string.Equals(yeast.Add_To_Secondary, "false", StringComparison.OrdinalIgnoreCase);
                    if (!inSecondary)
                    {
                        var fermentationStepDto = (recipeDto.FermentationSteps.FirstOrDefault() ?? GetFermentationStepDto(recipeDto, 0)) ??
                                                  recipeDto.FermentationSteps.FirstOrDefault();
                        fermentationStepDto.Yeasts.Add(yeastStepDto);
                    }
                    else
                    {
                        var fermentationStepDto = (recipeDto.FermentationSteps.Skip(1).FirstOrDefault() ?? GetFermentationStepDto(recipeDto, 0)) ?? recipeDto.FermentationSteps.FirstOrDefault();
                        fermentationStepDto.Yeasts.Add(yeastStepDto);
                    }
                }
            }

            SetStepNumber(recipeDto);

            return(recipeDto);
        }
 public OtherController(IOtherService otherService)
 {
     _otherService = otherService;
 }
        public void TestHookExceptionOnFinally()
        {
            IOtherService other = Simply.Do[ConfigKey].Resolve <IOtherService>();

            other.ThrowExceptionOnFinally();
        }
Example #17
0
 public MyService(IOtherService otherService, IOptions <ConfigurationSettings> configurationSettings)
 {
     // read config value from here.
 }
 public OtherController(IOtherService otherService, IConfiguration configuration)
 {
     _otherService = otherService;
     Configuration = configuration;
 }
Example #19
0
 public ContentController(IOtherService service)
 {
Example #20
0
 private record Component(IOtherService service, IOtherService2 service2);
Example #21
0
 public RootService(IOtherService otherService, IInjectedService injectedService)
 {
     this.OtherService    = otherService;
     this.InjectedService = injectedService;
 }
Example #22
0
 public MyService(IOtherService otherService)
 {
     OtherService = otherService;
 }
 public ServiceImplementation(IOtherService os, IThirdService ts)
 {
 public OtherController(IOtherService otherService)
 {
     _otherService = otherService;
 }
Example #25
0
        private static void Main()
        {
            //var configuration = new ConfigurationBuilder()
            //    .SetBasePath(Directory.GetCurrentDirectory())
            //    .AddJsonFile("appsettings.json")
            //    .Build();
            //var logger = new LoggerConfiguration()
            //    .ReadFrom.Configuration(configuration)
            //    .CreateLogger();

            //Juicer.AddLogging(new SerilogLoggerFactory(logger: logger));

            IInjector injector  = Juicer.CreateInjector(new TestModule().Override(new ModuleToOverride()));
            IInjector injector2 = injector.Get <IInjector>();
            IInjector injector3 = injector.CreateChildInjector();

            Console.WriteLine($"Injector was able to inject itself: {injector == injector2}.");

            Console.WriteLine();
            IService    service  = injector.Get <IService>();
            ServiceImpl service2 = injector.Get <ServiceImpl>();
            IService    service3 = injector3.Get <IService>();

            service.DoThing();
            Console.WriteLine($"Same instance of service when using untargeted vs targeted binding: {service == service2}.");
            Console.WriteLine($"Same instance of service retrieved from the child injector: {service == service3}");

            Console.WriteLine();
            Console.WriteLine($"Number from IService: {service.GetNumber()}");

            Console.WriteLine();
            HashSet <IMultiImplService> services = injector.Get <HashSet <IMultiImplService> >();

            Console.WriteLine($"Number of services created for IMultiImplService: {services?.Count}");

            Console.WriteLine();
            IOtherServiceFactory serviceFactory = injector.Get <IOtherServiceFactory>();
            IOtherService        otherService   = serviceFactory.CreateService(5);

            Console.WriteLine($"Factory service numbers: {otherService.GetNumber1()} | {otherService.GetNumber2()}");

            Console.WriteLine();
            NoInterfaceService noInterfaceService = injector.Get <NoInterfaceService>();

            noInterfaceService.PrintString();

            Console.WriteLine();
            Console.WriteLine($"Doubled Num1: {injector.Get<int>("DoubledNum1")}");

            Console.WriteLine();
            var externallyProvidedService = injector.Get <IExternallyProvidedService>();

            Console.WriteLine($"String from externally provided service: {externallyProvidedService.GetPrintString()}");
            Console.WriteLine($"Same instance of externally provided service received: {externallyProvidedService == injector.Get<IExternallyProvidedService>()}.");

            Console.WriteLine();
            var mappedServices = injector.Get <Dictionary <MappedServiceTypes, IMappedService> >();

            foreach (var type in Enum.GetValues(typeof(MappedServiceTypes)).Cast <MappedServiceTypes>())
            {
                var mappedService = mappedServices[type];
                mappedService.DoSomething();
            }
#if DEBUG
            Console.ReadLine();
#endif
        }