• [kooboo] 应用程序启动分析


    从 Niject Loader 看到过 , [assembly: System.Web.PreApplicationStartMethod ….]

    这次再看一下 kooboo , 也同样通过这样的方式,启动代码方式,有意思,

    先是注册启动方法

    [assembly: System.Web.PreApplicationStartMethod(typeof(Kooboo.CMS.Sites.Providers.SqlServer.AssemblyInitializer), "Initialize")]
    namespace Kooboo.CMS.Sites.Providers.SqlServer
    {
        public static class AssemblyInitializer
        {
            public static void Initialize()
            {
                ApplicationInitialization.RegisterInitializerMethod(delegate()
                {
                    ResetProviders();
                }, 1);
            }
    //.......
    }
    }

    然后在 Global.asax ,

       protected void Application_Start()
            {
                //execute the initializer method.
                ApplicationInitialization.Execute();      
     // .....
     }

    namespace Kooboo
    {
        public static class ApplicationInitialization
        {
            private class InitializationItem
            {
                public Action InitializeMethod { get; set; }
                public int Priority { get; set; }
            }
            private static List<InitializationItem> items = new List<InitializationItem>();
            public static void RegisterInitializerMethod(Action method, int priority)
            {
                items.Add(new InitializationItem() { InitializeMethod = method, Priority = priority });
            }
            public static void Execute()
            {
                lock (items)
                {
                    foreach (var item in items.OrderBy(it => it.Priority))
                    {
                        item.InitializeMethod();
                    }
                    items.Clear();
                }
     
            }
        }
    }

  • 相关阅读:
    使用库项目实现Android程序代码的复用 java程序员
    编译触摸tslib出错:libtool: link: only absolute runpaths are allowed java程序员
    Linux下的TFTP软件的安装设置(TQ210)ubuntu11.10 java程序员
    拥有超过1200个PNG格式图标的免费图标集 Cosmo Mini java程序员
    Android Develop Training中文翻译06《Starting Another Activity》 java程序员
    周记二
    周记三
    周记
    周记
    周记
  • 原文地址:https://www.cnblogs.com/zbw911/p/2859398.html
Copyright © 2020-2023  润新知