Ejemplo n.º 1
0
        static EchoService()
        {
            initializeTracer();
            IDataStoreProvider provider = ConfigProviderBase.Open();

            GlobalCache.LoadConfigurationSettings(provider, true);
        }
Ejemplo n.º 2
0
        public static void Load()
        {
            IDataStoreProvider provider = ConfigProviderBase.Open();

#if _AZURE
            provider = new CloudSettingsProvider(provider);
#endif
            GlobalCache.LoadConfigurationSettings(provider, false);
        }
        public bool Initialize(ILogger logger, ConfigProviderBase configProvider)
        {
            this.logger = logger;

            try
            {
                this.discoveryServer = new DiscoveryServer();
            }
            catch (Exception e)
            {
                this.logger.Log("Error creating discovery server: " + e);
                return(false);
            }
            this.discoveryServerThread = new Thread(new ThreadStart(() =>
            {
                try
                {
                    this.discoveryServer.Run();
                }
                catch (Exception e)
                {
                    this.logger.Log("Error running discovery server: " + e);
                }
            }));

            try
            {
                this.encodingServer = new EncodingServer();
            }
            catch (Exception e)
            {
                this.logger.Log("Error creating encoding server: " + e);
                return(false);
            }
            this.encodingServerThread = new Thread(new ThreadStart(() =>
            {
                try
                {
                    this.encodingServer.Run();
                }
                catch (Exception e)
                {
                    this.logger.Log("Error running encoding server: " + e);
                }
            }));

            this.discoveryServerThread.Start();
            this.encodingServerThread.Start();

            this.logger.Log("Service started...");

            return(true);
        }
        public bool Initialize(ILogger logger, ConfigProviderBase configProvider)
        {
            this.logger = logger;

            try
            {
                this.discoveryServer = new DiscoveryServer();
            }
            catch (Exception e)
            {
                this.logger.Log("Error creating discovery server: " + e);
                return false;
            }
            this.discoveryServerThread = new Thread(new ThreadStart(() =>
            {
                try
                {
                    this.discoveryServer.Run();
                }
                catch (Exception e)
                {
                    this.logger.Log("Error running discovery server: " + e);
                }
            }));

            try
            {
                this.encodingServer = new EncodingServer();
            }
            catch (Exception e)
            {
                this.logger.Log("Error creating encoding server: " + e);
                return false;
            }
            this.encodingServerThread = new Thread(new ThreadStart(() =>
            {
                try
                {
                    this.encodingServer.Run();
                }
                catch (Exception e)
                {
                    this.logger.Log("Error running encoding server: " + e);
                }
            }));

            this.discoveryServerThread.Start();
            this.encodingServerThread.Start();

            this.logger.Log("Service started...");

            return true;
        }
Ejemplo n.º 5
0
        private static void initializeTracer()
        {
            IDataStoreProvider provider = ConfigProviderBase.Open();

#if _AZURE
            iconfig = new KeyedDataStore(new CloudSettingsProvider(provider));
#else
            iconfig = new KeyedDataStore(provider);
#endif
            _logPath = (iconfig["LogPath"] as string) ?? @"C:\Logs\HelloIndigo";
#if _AZURE
            // Running in the Cloud; look for the local drive
            if (!Path.IsPathRooted(_logPath) &&
                RoleEnvironment.IsAvailable &&
                !RoleEnvironment.IsEmulated)
            {
                LocalResource localResource = RoleEnvironment.GetLocalResource("LogFiles");
                _logPath = Path.Combine(localResource.RootPath, _logPath);
            }
#endif
            tracer = new AppTraceListener(_logPath);
        }
Ejemplo n.º 6
0
        static SubscriberService()
        {
            try
            {
                IDataStoreProvider provider = ConfigProviderBase.Open();
                GlobalCache.LoadConfigurationSettings(provider, true);

                string logPath = (GlobalCache.GetResolvedString("LogPath") ?? @"C:\Logs\HelloIndigo");

#if _AZURE
                // Running in the Cloud; look for the local drive
                if (!Path.IsPathRooted(logPath) &&
                    RoleEnvironment.IsAvailable &&
                    !RoleEnvironment.IsEmulated)
                {
                    LocalResource localResource = RoleEnvironment.GetLocalResource("LogFiles");
                    logPath = Path.Combine(localResource.RootPath, logPath);
                }
#endif
                tracer = new AppTraceListener(logPath);

                // Resolve streams out of resource fork.
                StreamFactory.Register("res", (path, args) =>
                {
                    Assembly assembly   = Assembly.GetExecutingAssembly();
                    string resourcePath = string.Format("{0}.{1}",
                                                        assembly.GetName().Name,
                                                        path);
                    Trace.WriteLine(string.Format("StreamFactory::Create(res://{0})", resourcePath));
                    Stream result = assembly.GetManifestResourceStream(resourcePath);
                    return(result);
                });
            }
            catch (Exception exp)
            {
                Trace.WriteLine(exp.ToString());
            }
        }
Ejemplo n.º 7
0
 private void ApplyConfigDefaults(ConfigProviderBase configProvider)
 {
     configProvider.SetDefaultInfoImportance(_defaultInfoImportance);
 }