Esempio n. 1
0
        /// <summary>
        /// 服务端
        /// </summary>
        /// <param name="startup"></param>
        /// <param name="shareFiles"></param>
        /// <param name="shareFileEventHandler"></param>
        /// <param name="fileChangeTimer">fileChangeTimer</param>
        /// <param name="appFiles"></param>
        /// <param name="keyValueFinder"></param>
        /// <param name="listenPoint"></param>
        /// <param name="configFileServer"></param>
        /// <param name="configurationWatcher"></param>
        /// <returns></returns>
        public static ApplicationStartup UseJsonConfigServer(this ApplicationStartup startup, IEnumerable <ConfigFileInfo> shareFiles, EventHandler <ShareFileEventArgs> shareFileEventHandler, IEnumerable <ConfigFileInfo> appFiles, ICustomKeyValueFinder keyValueFinder, EndPoint listenPoint, TimeSpan fileChangeTimer, out ConfigFileServer configFileServer, out ConfigurationWatcher configurationWatcher)
        {
            var shareBuilders = shareFiles == null ? new List <ShareConfigurationBuilder>() : shareFiles.Select(ta => new Never.Configuration.ConfigCenter.ShareConfigurationBuilder(ta)).ToList();

            shareBuilders.UseForEach(builder =>
            {
                if (shareFileEventHandler != null)
                {
                    builder.OnBuilding += shareFileEventHandler;
                }

                builder.Build();
            });

            var jsonBuilders = appFiles == null ? new List <JsonConfigurationBuilder>() : appFiles.Select(ta => new Never.Configuration.ConfigCenter.JsonConfigurationBuilder(shareBuilders, ta, keyValueFinder)).ToList();

            jsonBuilders.UseForEach(builder => { builder.Build(); });

            configurationWatcher = new Never.Configuration.ConfigCenter.ConfigurationWatcher(shareBuilders, jsonBuilders, keyValueFinder, fileChangeTimer)
            {
                ShareFileEventHandler = shareFileEventHandler,
            };
            var server = new Never.Configuration.ConfigCenter.Remoting.ConfigFileServer(listenPoint, configurationWatcher);

            configFileServer = server;
            return(startup);
        }
Esempio n. 2
0
 /// <summary>
 /// 服务端
 /// </summary>
 /// <param name="startup"></param>
 /// <param name="shareFiles"></param>
 /// <param name="shareFileEventHandler"></param>
 /// <param name="appFiles"></param>
 /// <param name="keyValueFinder"></param>
 /// <param name="listenPoint"></param>
 /// <param name="configFileServer"></param>
 /// <param name="configurationWatcher"></param>
 /// <returns></returns>
 public static ApplicationStartup UseJsonConfigServer(this ApplicationStartup startup, IEnumerable <ConfigFileInfo> shareFiles, EventHandler <ShareFileEventArgs> shareFileEventHandler, IEnumerable <ConfigFileInfo> appFiles, ICustomKeyValueFinder keyValueFinder, EndPoint listenPoint, out ConfigFileServer configFileServer, out ConfigurationWatcher configurationWatcher)
 {
     return(UseJsonConfigServer(startup, shareFiles, shareFileEventHandler, appFiles, keyValueFinder, listenPoint, TimeSpan.FromMinutes(1), out configFileServer, out configurationWatcher));
 }