Example #1
0
        public static void PrepareCurrentDomain( )
        {
            if (!Loaded)
            {
                lock (StaticServiceProvider.ServiceCollection)
                {
                    if (!Loaded)
                    {
                        Loaded = true;
                    }
                    else
                    {
                        return;
                    }
                }

                AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad;

                Assembly [] assemblies = AppDomain.CurrentDomain.GetAssemblies( );

                int assembliesCount = assemblies.Length;

                for (int i = 0; i < assembliesCount; i++)
                {
                    Assembly assembly = assemblies [i];

                    lock (StaticServiceProvider.ServiceCollection)
                    {
                        assembly.Prepare( );
                    }
                }

                StaticServiceProvider.Update( );
            }
        }
Example #2
0
        private static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
        {
            lock (StaticServiceProvider.ServiceCollection)
            {
                args.LoadedAssembly.Prepare( );
            }

            StaticServiceProvider.Update( );
        }
Example #3
0
 public IServiceCollection CreateBuilder(IServiceCollection services)
 {
     StaticServiceProvider.ServiceCollection.Add(services);
     StaticServiceProvider.Update( );
     return(StaticServiceProvider.ServiceCollection);
 }