Exemplo n.º 1
0
 public void SetDefaultLogger(ILog logger)
 {
     if (logger != null)
     {
         _register.RegisterInstance(logger, "Log");
     }
 }
Exemplo n.º 2
0
        public static void RegisterNetXPStandard(this IRegister uc)
        {
            //cnf
            uc.Register <IConfigFactory, ConfigFactory>();

            //cmpr
            uc.Register <ICompression, DeflateCompress>(DILifeTime.Singleton);

            #region Processes

            //Process
            uc.Register <NetStandard.Processes.IIOTerminal, IOTerminal>();

            #endregion

            //Reflect
            uc.Register <IReflector, Reflector>(DILifeTime.Singleton);

            //System Information
            //ISysInfo need to be implemented in their os system.
            uc.Register <NetStandard.SystemInformation.IStorageInfo, SystemInformation.Implementations.SysInfo>();
            var customDateTime = new CustomDateTime(0);
            uc.RegisterInstance <ICustomDateTime>(customDateTime);
            uc.Register <IServiceInformer, ServiceInformer>(DILifeTime.Singleton);

            //System Managers
            uc.Register <IServiceManager, ServiceManagerForWindows>(OSPlatformType.Windows.ToString(), DILifeTime.Singleton);
            uc.Register <IServiceManager, ServiceManagerForLinux>(OSPlatformType.Linux.ToString(), DILifeTime.Singleton);
            uc.Register <IServiceManager, ServiceManager>(DILifeTime.Singleton);
            uc.Register <IServiceManagerFactory, ServiceManagerFactory>(DILifeTime.Singleton);

            //Operative System
            uc.Register <IOperativeSystem, OperativeSystem>(DILifeTime.Singleton);
        }
Exemplo n.º 3
0
        public static void RegisterAllNetXP(this IRegister cfg)
        {
            cfg.RegisterInstance(Options.Create(new PersistenPrivateKeyConfiguration()));
            cfg.RegisterInstance(Options.Create(new TCPOption()));

            cfg.RegisterNetXPStandard();

            cfg.RegisterSerialization();
            cfg.RegisterCryptography();
            cfg.RegisterAuditory();
            cfg.RegisterNetwork();
            cfg.RegisterNetworkServices();

            //Process
            cfg.Register <SystemInformation.ISystemInformation, SystemInformation.Implementations.SysInfo>();
        }
        public void ForAll(IRegister r)
        {
            var rpyProcess = new LiveProcess($"{PluginContext.Dir}/rwy/rwy.py");

            r.RegisterInstance <IPyProcess>(rpyProcess, DILifeTime.Singleton);

            r.Register <IInitializer, Initializer>(DILifeTime.Singleton);
        }
Exemplo n.º 5
0
        public void Compile()
        {
            var items = new Dictionary <string, ISpecificCultureTranslations>();

            foreach (var culture in SupportedCultures)
            {
                var diKey    = "culture_" + culture.LCID;
                var instance = _resolver.Resolve <ISpecificCultureTranslations>("DEFAULT");
                instance.CultureInfo  = culture;
                instance.LCID         = culture.LCID;
                instance.Translations = new Dictionary <string, string>();
                items.Add(diKey, instance);
                _register.RegisterInstance(instance, diKey);
            }

            foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
            {
                if (asm.FullName.Contains("NeonTetra"))
                {
                    try
                    {
                        foreach (var resourceName in asm.GetManifestResourceNames())
                        {
                            try
                            {
                                var name = resourceName;
                                if (name.EndsWith(".resources", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    name = name.Substring(0, name.Length - ".resources".Length);
                                }

                                var rm = new ResourceManager(name, asm);

                                foreach (var culture in SupportedCultures)
                                {
                                    var diKey = "culture_" + culture.LCID;
                                    var languageSpecificTranslation = items[diKey];
                                    LoadCacheFromResourceManager(rm, culture, languageSpecificTranslation);
                                }

                                rm.ReleaseAllResources();
                            }
                            catch (Exception /*e1*/)
                            {
                            }
                        }
                    }
                    catch (Exception /*e*/)
                    {
                    }
                }
            }
        }
Exemplo n.º 6
0
 public void Instances_Leaves_One()
 {
     register.RegisterInstance(typeof(IAbstraction), new Concrete());
     register.RegisterInstance(typeof(IAbstraction), new AnotherConcrete());
     VerifyRegisteredCount(1);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Registers a service with an implementing instance.
 /// </summary>
 public static void RegisterInstance <TService>(this IRegister register, TService instance)
     where TService : class
 => register.RegisterInstance(typeof(TService), instance);
 public void Instances_Resolves_Last_Registered()
 {
     register.RegisterInstance(typeof(IAbstraction), new Concrete());
     register.RegisterInstance(typeof(IAbstraction), new AnotherConcrete());
     AssertDefaultInstance <AnotherConcrete>();
 }