コード例 #1
0
        public static IChoProfileBackingStore GetProfileBackingStore(string name, string startActions, string stopActions)
        {
            if (_profileBackingStoreCache.ContainsKey(name))
            {
                return(_profileBackingStoreCache[name]);
            }

            lock (_padLock)
            {
                if (!_profileBackingStoreCache.ContainsKey(name))
                {
                    try
                    {
                        XmlNode configNode = ChoProfileBackingStoreConfigManager.Load(name, ref startActions, ref stopActions);
                        IChoProfileBackingStore profileBackingStore = null;                         //ChoObjectFactory.CreateInstance<IChoProfileBackingStore>(new object[] { name, startActions, stopActions, configNode });
                        if (profileBackingStore == null)
                        {
                            Trace.TraceInformation("Failed to create '{0}' profile backingstore, using default one.", name);
                            profileBackingStore = _defaultProfileBackingStore.Value;
                        }

                        _profileBackingStoreCache.Add(name, profileBackingStore);
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError("Failed to create '{0}' profile backingstore, using default one. {2}{1}", name, ex.ToString(), Environment.NewLine);
                        _profileBackingStoreCache.Add(name, _defaultProfileBackingStore.Value);
                    }
                }
            }

            return(_profileBackingStoreCache[name]);
        }
コード例 #2
0
        public static IChoProfileBackingStore GetProfileBackingStore(string name, string startActions, string stopActions)
        {
            if (_profileBackingStoreCache.ContainsKey(name))
            {
                return(_profileBackingStoreCache[name]);
            }

            lock (_padLock)
            {
                if (!_profileBackingStoreCache.ContainsKey(name))
                {
                    try
                    {
                        string configStartActions = null;
                        string configStopActions  = null;

                        IChoProfileBackingStore profileBackingStore = null;

                        if (!ChoProfileBackingStoreConfigManager.TryGetProfileBackingStore(name, ref configStartActions, ref configStopActions, ref profileBackingStore))
                        {
                            Trace.TraceInformation("Failed to create '{0}' profile backingstore, using default one.", name);
                            profileBackingStore = _defaultProfileBackingStore.Value;
                        }
                        else
                        {
                            profileBackingStore.Start(configStartActions.IsNullOrWhiteSpace() ? startActions : configStartActions);
                        }

                        _profileBackingStoreCache.Add(name, profileBackingStore);
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError("Failed to create '{0}' profile backingstore, using default one. {2}{1}", name, ex.ToString(), Environment.NewLine);
                        _profileBackingStoreCache.Add(name, _defaultProfileBackingStore.Value);
                    }
                }
            }

            return(_profileBackingStoreCache[name]);
        }