Пример #1
0
        private void RegisterServicesAndProviders()
        {
            container.Register <Noanet.XamArch.Mvvm.Services.IDialogService, Services.DialogService>();

            var loadedAssemblies   = AppDomain.CurrentDomain.GetAssemblies();
            var repositoryAssembly = loadedAssemblies.SingleOrDefault(x => x.GetName().Name == "Unir.TFG.MeterMAX.MDM.Repository") ?? System.Reflection.Assembly.LoadFrom(Path.Combine(Environment.CurrentDirectory, "Unir.TFG.MeterMAX.MDM.Repository.dll"));
            var logicAssembly      = loadedAssemblies.SingleOrDefault(x => x.GetName().Name == "Unir.TFG.MeterMAX.MDM.Logic") ?? System.Reflection.Assembly.LoadFrom(Path.Combine(Environment.CurrentDirectory, "Unir.TFG.MeterMAX.MDM.Logic.dll"));

            container.AutoRegister(new System.Reflection.Assembly[] { repositoryAssembly, logicAssembly });
            container.AutoRegister(new System.Reflection.Assembly[] { System.Reflection.Assembly.GetExecutingAssembly() }, x => x.Namespace == "Unir.TFG.MeterMAX.MDM.App.Wpf.ViewModels" || x.Namespace == "Unir.TFG.MeterMAX.MDM.App.Wpf.Services");
            InitializeLogginService();
        }
Пример #2
0
        public IocHelper()
        {
            //接口dll路径
            string assembleFileName1 = Assembly.GetExecutingAssembly().CodeBase.Replace("Hengtex.Data.Repository.DLL", "Hengtex.Data.dll").Replace("file:///", "");
            //实现dll路径
            string assembleFileName2 = Assembly.GetExecutingAssembly().CodeBase.Replace("Hengtex.Data.Repository.DLL", "Hengtex.Data.EF.dll").Replace("file:///", "");

            _container = new TinyIoCContainer();
            _container.AutoRegister(new[] { Assembly.LoadFrom(assembleFileName1) },
                                    DuplicateImplementationActions.RegisterSingle);
            _container.AutoRegister(new[] { Assembly.LoadFrom(assembleFileName2) },
                                    DuplicateImplementationActions.RegisterSingle);
        }
Пример #3
0
        private async void Init(PlayerWindow playerWindow)
        {
            var uriString = "http://localhost:8090/tvcontrolapi/";

            this.Host = new NancyHost(new CustomNancyBoostrapper(), new HostConfiguration {
                UrlReservations = new UrlReservations {
                    CreateAutomatically = true
                }
            }, new Uri(uriString));
            this.Host.Start();

            TinyIoCContainer ioc = TinyIoCContainer.Current;

            ioc.AutoRegister();
            ioc.Register <ITasksService>((container, overloads) => new LocalTasksServiceDecorator(new FirebaseTasksService()));

            var playbackControl = new MediaElementPlaybackControl(playerWindow);

            ioc.Register <IPlaybackControl>(playbackControl);
            TvControlViewModel viewModel;

            this.DataContext = playerWindow.DataContext = viewModel = new TvControlViewModel(new TvStations(), playbackControl);

            ioc.Register <ILogger>(viewModel.Log);

            viewModel.Log.Write($"API Running on {uriString}", LogLevel.Info);

            new TasksWindow {
                DataContext = ioc.Resolve <TasksViewModel>()
            }.Show();

            this.udpListener = new UDPListener(11011, s => viewModel.Log.Write(s, LogLevel.Debug));
            await this.udpListener.StartAsync();
        }
Пример #4
0
 protected void RegisterAssemblies(TinyIoCContainer container)
 {
     if (Api.ApiBasicConfiguration?.AutoRegisterAssemblies?.Any() == true)
     {
         container.AutoRegister(Api.ApiBasicConfiguration.AutoRegisterAssemblies);
     }
 }
Пример #5
0
 private bool AutoRegisterAssemblySpecified(TinyIoCContainer container, ILogger logger)
 {
     logger.WriteLine("AutoRegisterAssemblySpecified");
     container.AutoRegister(new[] { this.GetType().Assembly });
     container.Resolve <ITestInterface>();
     return(true);
 }
Пример #6
0
 private bool AutoRegisterAppDomain(TinyIoCContainer container, ILogger logger)
 {
     logger.WriteLine("AutoRegisterAppDomain");
     container.AutoRegister();
     container.Resolve <ITestInterface>();
     return(true);
 }
Пример #7
0
        public App32Context(params Assembly[] assemblies)
        {
            container = new TinyIoCContainer();
            var result = container.AutoRegister(GetRegisterAssemblies(assemblies), DuplicateImplementationActions.Fail, HandleRegisterType);

            ApplyAttributeSettings(result);
        }
Пример #8
0
        public TinyIoCContainer GetContainer()
        {
            var container = new TinyIoCContainer();

            container.AutoRegister();

            return(container);
        }
        private static TinyIoCContainer GetContainer()
        {
            var container = new TinyIoCContainer();

            container.AutoRegister();
            container.Register <ILogger, ConsoleLogger>();
            return(container);
        }
Пример #10
0
 public TinyIoCBootstrapper(IHostConfiguration hostConfiguration, ILogger logger)
 {
     _container = TinyIoCContainer.Current;
     _container.Register<IHostConfiguration>(hostConfiguration);
     _container.Register<ILogger>(logger);
     _container.AutoRegister(AutoRegisterAssemblies(), DuplicateImplementationActions.RegisterMultiple, ExcludedTypes);
     RegisterNegotiator();
     _container.Register<IStyxEngine>(new SecureSocketStyxEngine(Logger, Engine, HostConfiguration));
 }
        /// <summary>
        /// Creates a new TinyIoC instance with the default validation configuration.
        /// </summary>
        /// <returns></returns>
        static TinyIoCContainer CreateDefaultIoCContainer()
        {
            var c = new TinyIoCContainer();

            c.AutoRegister(
                new[] { typeof(JSchemaExpressionBuilder).Assembly },
                DuplicateImplementationActions.RegisterMultiple,
                i => i.Namespace.StartsWith("Cogito.Json.Schema.Validation"));

            return(c);
        }
Пример #12
0
        private ServiceLocatorProvider Configure(TinyIoCContainer container)
        {
            container.AutoRegister(new[] { GetType().Assembly });
            container.Register(DefaultJwt4NetConfig.Instance);
            container.Register(DefaultJwt4NetConfig.Instance.ReaderSettings);
            container.Register(DefaultJwt4NetConfig.Instance.Issuer);
            container.Register(DefaultJwt4NetConfig.Instance.Issuer.Key);

            container.RegisterMultiple <ITokenValidationRule>(new[] { typeof(IssuerMustBeTrustedRule), typeof(SignatureMustBeValidRule), typeof(ExpiryDateMustBeInThePastRule) });
            _configured = true;
            return(() => this);
        }
Пример #13
0
        protected ViewModelLocator(bool isAgent)
        {
            _container = new TinyIoCContainer();
            var assms   = new [] { typeof(ViewModelLocator).GetTypeInfo().Assembly };
            var typeinf = typeof(IToolViewModel).GetTypeInfo();

            if (isAgent)
            {
                var src = typeof(ClientMainService);
                _container.AutoRegister(assms, t => t != src && !typeinf.IsAssignableFrom(t.GetTypeInfo())); // skip the client service in agent mode
                Mode = AppMode.Agent;
            }
            else
            {
                var arc = typeof(AgentMainService);
                _container.AutoRegister(assms, t => t != arc && !typeinf.IsAssignableFrom(t.GetTypeInfo())); // skip the agent service in client mode
                Mode = AppMode.Client;
            }

            _container.Register <IViewModelLocator>(this);

            var tools = new []
            {
                //typeof(SampleToolViewModel),
                typeof(TypesOfInsuranceViewModel),
                typeof(DividendInterestRatesViewModel),
                typeof(BasicInformationToolViewModel),
                typeof(LifetimeEconomicValueViewModel),
                //typeof(AnotherSampleToolViewModel),
            };


            _container.RegisterMultiple <IToolViewModel>(tools).AsMultiInstance();


            InitializeTypes();

            _container.Resolve <INavigationService>().Initialize();
        }
Пример #14
0
        public virtual void Setup()
        {
            _testInstance = null;

            Container = new TinyIoCContainer();
            Container.AutoRegister(DuplicateImplementationActions.RegisterSingle);

            Container.Register <ISecretKeyProvider, Base32SecretKeyProvider>();
            Container.Register <ITotpTokenProvider, ManualTotpTokenProvider>();

            DateTime = CreateMockDateTime();
            Container.Register((c, p) => DateTime.Object);
        }
Пример #15
0
        private bool AutoRegisterPredicateExclusion(TinyIoCContainer container, ILogger logger)
        {
            logger.WriteLine("AutoRegisterPredicateExclusion");
            container.AutoRegister(t => t != typeof(ITestInterface));

            try
            {
                container.Resolve <ITestInterface>();
                return(false);
            }
            catch (TinyIoCResolutionException)
            {
            }

            return(true);
        }
        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            container.AutoRegister(new[]
            {
                typeof(IPackageRepository).Assembly,
                typeof(InstallerModule).Assembly,
                typeof(PackageHistoryRepository).Assembly
            });

            container.Register(typeof(PackageInstallationSettings), new PackageInstallationConfigurationProvider().Settings);

            var assembly = GetType().Assembly;

            ResourceViewLocationProvider
            .RootNamespaces
            .Add(assembly, "Sitecore.Ship.About.Views");
        }
Пример #17
0
        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            base.ConfigureApplicationContainer(container);

            container.AutoRegister(new[]
            {
                typeof (IPackageRepository).Assembly, 
                typeof (InstallerModule).Assembly,
                typeof (PackageHistoryRepository).Assembly
            });

            container.Register(typeof(PackageInstallationSettings), new PackageInstallationConfigurationProvider().Settings);

            var assembly = GetType().Assembly;
            ResourceViewLocationProvider
                .RootNamespaces
                .Add(assembly, "Sitecore.Ship.About.Views");
        }
Пример #18
0
        public RESTClient(TinyIoCContainer container = null)
        {
            if (container == null)
            {
                Container = new TinyIoCContainer();

                ApplicationRegistar.ProcessRegistrations(Container);
                Container.AutoRegister(AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetReferencedAssemblies().Any(name => name.Name == "DRC") || a == typeof(ApplicationRegistar).Assembly));
            }
            else
            {
                Container = container;
                ApplicationRegistar.ProcessRegistrations(Container);
            }

            //create input pipeline and store response
            InputPipeLine  = new Dictionary <double, Tuple <string, Action <Response> > >();
            OutputPipeLine = new Dictionary <double, Tuple <string, Action <Request> > >();

            ClientCertificateParameters = null;
        }
Пример #19
0
 protected override void Onload()
 {
     try
     {
         if (!Directory.Exists(BaseDirectory))
         {
             return;
         }
         var assemblies       = new List <Assembly>();
         var files            = Directory.GetFiles(BaseDirectory, "*.dll", SearchOption.AllDirectories).Where(o => o.Contains("Protocal"));
         var moduleAssemblies = files.Select(Assembly.LoadFile);
         assemblies.AddRange(moduleAssemblies);
         _container.AutoRegister(assemblies, DuplicateImplementationActions.RegisterMultiple);
         _mainViewModel = _container.Resolve <MainViewModel>();
         _waitHandle.Set();
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
     }
 }
        /// <summary>
        /// Autos the register of the assembly.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        public void AutoRegister(Assembly assembly)
        {
            TinyIoCContainer container = TinyIoCContainer.Current;

            container.AutoRegister(assembly);
        }
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        internal static void Initialize()
        {
            TraceService.WriteLine("NinjaController::Initialize");

            try
            {
                if (initialized == false)
                {
                    TraceService.WriteLine("NinjaController::Initialize AutoRegister");

                    //// only auto register classes in this assembly.
                    TinyIoCContainer container = TinyIoCContainer.Current;

                    string location = Assembly.GetExecutingAssembly().Location;

                    TraceService.WriteLine("NinjaController::Initialize Assembly Location=" + location);

                    PathBase pathBase  = new PathWrapper();
                    string   directory = pathBase.GetDirectoryName(location);

                    TraceService.WriteLine("NinjaController::Initialize NinjaCoder.MvvmCross.dll");

                    string path = directory + @"\NinjaCoder.MvvmCross.dll";

                    if (File.Exists(path))
                    {
                        //// NinjaCoder for MvvmCross interfaces.
                        container.AutoRegister(Assembly.LoadFrom(path));
                    }
                    else
                    {
                        TraceService.WriteError(path + " does not exist");
                    }

                    //// we only want one instance of the VisualStudio class.
                    container.Register <VisualStudioService>().AsSingleton();

                    //// register the types that aren't auto-registered by TinyIoC.
                    container.Register <ITranslator <string, CodeConfig> >(new CodeConfigTranslator());
                    container.Register <ITranslator <string, CodeSnippet> >(new CodeSnippetTranslator());
                    container.Register <ITranslator <XElement, Plugin> >(new PluginTranslator());
                    container.Register <ITranslator <string, Plugins> >(new PluginsTranslator());
                    container.Register <ITranslator <string, CommandsList> >(new CommandsListTranslator());
                    container.Register <ITranslator <string, CustomRenderers> >(new CustomRenderersTranslator());

                    //// file io abstraction
                    container.Register <IFileSystem>(new FileSystem());

                    TraceService.WriteLine("NinjaController::Initialize Scorchio.Infrastructure.dll");

                    path = directory + @"\Scorchio.Infrastructure.dll";

                    if (File.Exists(path))
                    {
                        //// Scorchio.Infrastructure interfaces.
                        container.AutoRegister(Assembly.LoadFrom(path));
                    }
                    else
                    {
                        TraceService.WriteError(path + " does not exist");
                    }

                    TraceService.WriteLine("NinjaController::Initialize AccentTranslator");

                    //// register the types that aren't auto-registered by TinyIoC.
                    container.Register <ITranslator <IList <Accent>, IEnumerable <AccentColor> > >(new AccentTranslator());

                    TraceService.WriteLine("NinjaController::Initialize Scorchio.VisualStudio.dll");

                    path = directory + @"\Scorchio.VisualStudio.dll";

                    if (File.Exists(path))
                    {
                        //// Scorchio.VisualStudio interfaces.
                        container.AutoRegister(Assembly.LoadFrom(path));
                    }
                    else
                    {
                        TraceService.WriteError(path + " does not exist");
                    }

                    initialized = true;
                }

                TraceService.WriteLine("NinjaController::Initialize end");
            }
            catch (ReflectionTypeLoadException exception)
            {
                TraceService.WriteError("ReflectionTypeLoadException=" + exception);

                foreach (Exception ex in exception.LoaderExceptions)
                {
                    TraceService.WriteError("ReflectionTypeLoadException=" + ex);
                }
            }
            catch (Exception exception)
            {
                TraceService.WriteError("Exception=" + exception);

                if (exception.InnerException != null)
                {
                    ReflectionTypeLoadException loadException = exception.InnerException as ReflectionTypeLoadException;

                    if (loadException != null)
                    {
                        foreach (Exception ex in loadException.LoaderExceptions)
                        {
                            TraceService.WriteError("ReflectionTypeLoadException=" + ex);
                        }
                    }
                }
            }
        }
Пример #22
0
        private RestOptions InitializeWithDefaultDependencies(Assembly serviceAssembly, bool mockContext)
        {
            var container = new TinyIoCContainer();

            if (serviceAssembly != null)
            {
                container.AutoRegister(new[] { serviceAssembly });
            }

            RegisterDependencies(container, mockContext, null);

            return Initialize(new DefaultServiceLocator(container, null));
        }
 static DependencyManager()
 {
     _container.AutoRegister();
 }
Пример #24
0
 /// <summary>
 /// Register any additional items into the TinyIoc container or leave it as it is.
 /// </summary>
 /// <param name="container">The <see cref="TinyIoCContainer"/> container.</param>
 public override void ConfigureContainer(TinyIoCContainer container)
 {
     container.AutoRegister();
 }
Пример #25
0
 static DependencyService()
 {
     _container.AutoRegister();
 }