public void TestDuplicateAdd()
        {
            var dict = new ConcurrentDictionary<int, string>();

            dict.Add(3, string.Empty);
            dict.Add(3, string.Empty);
        }
Example #2
0
        public void ActivateLocalActor(ActorIdentity localActor)
        {
            if (localActor == null)
            {
                throw new ArgumentNullException("localActor");
            }
            if (_localActor != null)
            {
                throw new InvalidOperationException("The local actor has already been activated.");
            }

            var channel = _factory.BuildLocalActor(localActor);

            channel.Connected    += OnActorConnected;
            channel.Disconnected += OnActorDisconnected;
            channel.DataReceived += OnActorDataReceived;

            try
            {
                channel.Open();

                _localActor = localActor;
                _channels.Add(_localActor.GetKey(), channel);
                _actorKeys.Add(_localActor.GetKey(), _localActor);

                _log.DebugFormat("Local actor [{0}] is activated.", _localActor);
            }
            catch
            {
                CloseChannel(channel);
                throw;
            }
        }
Example #3
0
        public void TestDuplicateAdd()
        {
            var dict = new ConcurrentDictionary <int, string>();

            dict.Add(3, string.Empty);
            dict.Add(3, string.Empty);
        }
Example #4
0
        static void Main(string[] args)
        {
            //Add and Remove method in Concurrent Dictionary has been used explicitly. So unless the IDictionary interface is used, Add() and Remove() method cannot be used on ConcurrentDictionary.
            //Initializers dont work in ConcurrentDictionary, becasue under the hood, initializer calls the constructor for ConcurrentDictionary, which in turn calls the Add method. Since the Add method of ConcurrentDictionary cannot be called without a cast (explicitly), the initializer wont work.
            //Add value works only when the key that is getting added must not have been added earlier. Keys must be unique in dictionary. So for adding a key in dictionary using add() method the user needs to know the state of the Dictioanry (i.e. it must know/ assume that the key that he is trying to add has not been already added. Same thing as Remove, the use must know that the key has already been added before.
            //In a sinngle threaded mode it might be possible to know this information, but in multithreaded it is often impossible to know whether a key is already present.
            IDictionary <string, int> stock = new ConcurrentDictionary <string, int>();

            stock.Add("ECO t-shirts", 4);
            stock.Add("ISRM t-shirts", 5);

            Console.WriteLine(string.Format("No. of T-Shirts in stock = {0}", stock.Count));

            stock.Add("MPSIT t-shirts", 6);
            stock["ESSIT t-shirts"] = 7;

            stock["MPSIT t-shirts"] = 8; //Update if exists
            Console.WriteLine(string.Format("\r\nstock[MPSIT t-shirts] = {0}", stock["MPSIT t-shirts"]));

            stock.Remove("ISRM t-shirts");

            Console.WriteLine("\r\nEnumerating");
            foreach (var keyValPair in stock)
            {
                Console.WriteLine("{0} : {1}", keyValPair.Key, keyValPair.Value);
            }
            Console.ReadLine();
        }
Example #5
0
        /// <summary>
        /// Executes <see cref="RegisterFileForBuildManifestCommand"/>. Checks if Cache contains SHA-256 Hash for given
        /// <see cref="RegisterFileForBuildManifestCommand.Hash"/> and returns true if SHA-256 ContentHash exists.
        /// Else the file is materialized using <see cref="ExecuteMaterializeFileAsync"/>, the build manifest hash is computed and stored into cache.
        /// </summary>
        private async Task <IIpcResult> ExecuteGetBuildManifestHashFromCacheAsync(RegisterFileForBuildManifestCommand cmd)
        {
            Contract.Requires(cmd != null);

            if (m_inMemoryBuildManifestStore.TryGetValue(cmd.Hash, out var buildManifestHash))
            {
                RecordFileForBuildManifestInXLG(cmd.DropName, cmd.RelativePath, cmd.Hash, buildManifestHash);
                return(IpcResult.Success(cmd.RenderResult(true)));
            }

            ContentHash?sha256Hash = await TryGetBuildManifestHashAsync(cmd.Hash);

            if (sha256Hash.HasValue)
            {
                m_inMemoryBuildManifestStore.Add(cmd.Hash, sha256Hash.Value);
                RecordFileForBuildManifestInXLG(cmd.DropName, cmd.RelativePath, cmd.Hash, sha256Hash.Value);
                return(IpcResult.Success(cmd.RenderResult(true)));
            }

            var computeHashResult = await ComputeBuildManifestHashFromCacheAsync(cmd);

            if (computeHashResult.Succeeded)
            {
                m_inMemoryBuildManifestStore.Add(cmd.Hash, computeHashResult.Result);
                RecordFileForBuildManifestInXLG(cmd.DropName, cmd.RelativePath, cmd.Hash, computeHashResult.Result);
                await StoreBuildManifestHashAsync(cmd.Hash, computeHashResult.Result);

                return(IpcResult.Success(cmd.RenderResult(true)));
            }

            Tracing.Logger.Log.ErrorApiServerGetBuildManifestHashFromCacheFailed(m_loggingContext, cmd.Hash.Serialize(), computeHashResult.Failure.DescribeIncludingInnerFailures());
            return(IpcResult.Success(cmd.RenderResult(false)));
        }
Example #6
0
        /// <summary>
        /// Gets the metadata for the indicated type.
        /// </summary>
        /// <param name="type">The type of interest</param>
        /// <returns>A thread-safe copy of the class's metadata</returns>
        /// <remarks>Actually fetching the metadata requires taking a lock. Therefore it is advisable to locally cache the metadata as well.</remarks>
        public static ClassMetadata GetMetadata(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type), $"{nameof(type)} is null.");
            }

            lock (s_SyncRoot)
            {
                ClassMetadata result;
                if (s_ModelInfo.TryGetValue(type, out result))
                {
                    return(result);
                }


                var typeInfo = type.GetTypeInfo();
                result = new ClassMetadata(typeInfo);

                //Cache both the Type and TypeInfo object
                s_ModelInfo.Add(type, result);
                s_ModelInfo.Add(typeInfo, result);
                return(result);
            }
        }
        public void TestLockFreeDictionary()
        {
            IDictionary<int, Guid> dict = new ConcurrentDictionary<int, Guid>();

            KeyValuePair<int, Guid> test = new KeyValuePair<int, Guid>(-64, Guid.NewGuid());

            dict.Add(42, Guid.NewGuid());
            dict.Add(22, Guid.NewGuid());
            dict.Add(test);
            dict.Add(55, Guid.NewGuid());

            Assert.IsTrue(dict.ContainsKey(-64));
            Assert.IsTrue(dict.Contains(test));
            Assert.IsFalse(dict.Contains(new KeyValuePair<int, Guid>(-64, new Guid())));

            dict[-64] = Guid.NewGuid();
            Assert.IsFalse(dict.Contains(test));

            Guid newID = Guid.NewGuid();
            dict[12] = newID;
            Guid id = dict[12];

            Assert.IsTrue(newID == id);

            Assert.IsTrue(dict.Count == 5);

            dict.Remove(-64);
            Assert.IsTrue(dict.Count == 4);

        }
Example #8
0
        public static void InjectContainer(int key, IUnityContainer unity)
        {
            if (unity == null)
            {
                throw new ArgumentNullException("unity");
            }

            containerMapping.Add(key, unity);
        }
        public void TestAdd()
        {
            var dictionary = new ConcurrentDictionary <int, int>();

            dictionary.Add(0, 0);
            Assert.Equal(0, dictionary[0]);

            Assert.Throws <ArgumentException>(() => dictionary.Add(0, 0));
        }
Example #10
0
        public AppBuilderFixture()
        {
            var tokenSource = new CancellationTokenSource();

            Properties = new ConcurrentDictionary <string, object>();
            Properties.Add("server.OnDispose", tokenSource.Token);
            //See http://sourcebrowser.io/Browse/jchannon/katanaproject/src/Microsoft.Owin/Extensions/AppBuilderExtensions.cs#78
            Properties.Add("builder.AddSignatureConversion", DelegateAction);
        }
        /// <summary>
        /// Create a test database with two players.
        /// </summary>
        public void CreateTestDatabase()
        {
            IDictionary <String, Player> players = new ConcurrentDictionary <String, Player>();

            players.Add("James", new Player(new Position(200, 200), new Velocity(0, 0), "James", "jamespass"));
            players.Add("Gleb", new Player(new Position(400, 300), new Velocity(0, 0), "Gleb", "glebpass"));

            CreateDatabase(players);
        }
Example #12
0
 public Manager()
 {
     _errorData = new StringBuilder();
     _managers  = new ConcurrentDictionary <DbAccessType, Func <IManagerImplementation> >();
     _managers.Add(DbAccessType.MsSql, () => new MsSqlManager());
     _managers.Add(DbAccessType.SqLite, () => new SqLiteManager());
     _managers.Add(DbAccessType.MySql, () => new MySqlManager());
     AllTestContextHelper.TestSetup(null);
 }
Example #13
0
        public void Add(TFirst first, TSecond second)
        {
            if (_firstToSecond.ContainsKey(first) || _secondToFirst.ContainsKey(second))
            {
                throw new ArgumentException("Duplicate first or second");
            }

            _firstToSecond.Add(first, second);
            _secondToFirst.Add(second, first);
        }
        public void Add(TKey key, TValue value)
        {
#if !PORTABLE
            if (_dictionary.TryAdd(key, value))
            {
                OnChanged(new ChangedEventArgs <KeyValuePair <TKey, TValue> >(new KeyValuePair <TKey, TValue>(key, value), ChangedAction.Add));
            }
#else
            _dictionary.Add(key, value);
            OnChanged(new ChangedEventArgs <KeyValuePair <TKey, TValue> >(new KeyValuePair <TKey, TValue>(key, value), ChangedAction.Add));
#endif
        }
        /// <summary>
        /// 申请处理
        /// </summary>
        /// <param name="swaggerDoc"></param>
        /// <param name="schemaRegistry"></param>
        /// <param name="apiExplorer"></param>
        public void Apply(SwaggerDocument swaggerDoc, SchemaRegistry schemaRegistry, IApiExplorer apiExplorer)
        {
            IDictionary <string, PathItem> replacePaths = new ConcurrentDictionary <string, PathItem>();
            var nplen = 1; //程序集的命名空间用.分隔之后数组长度 应用程序的命名空间(如WeixinApi表示1   WeixinApi.Swagger表示2)

            foreach (var item in swaggerDoc.paths)
            {
                string key   = item.Key;
                var    value = item.Value;
                var    keys  = key.Split('/');

                if (keys[3].IndexOf('.') != -1)
                {
                    // 区域路径
                    string areasName         = keys[2];
                    string namespaceFullName = keys[3];
                    var    directoryNames    = namespaceFullName.Split('.');
                    string namespaceName     = directoryNames[nplen + 1];
                    if (areasName.Equals(namespaceName, StringComparison.OrdinalIgnoreCase))
                    {
                        string controllerName = directoryNames[nplen + 3];
                        replacePaths.Add(
                            item.Key.Replace(namespaceFullName,
                                             controllerName.Substring(0,
                                                                      controllerName.Length - DefaultHttpControllerSelector.ControllerSuffix.Length)),
                            value);
                    }
                }
                else if (keys[2].IndexOf('.') != -1)
                {
                    // 基础路径
                    string namespaceFullName = keys[2];
                    var    directoryNames    = namespaceFullName.Split('.');
                    bool   isControllers     = directoryNames[nplen].Equals("ApiControllers", StringComparison.OrdinalIgnoreCase);
                    string controllerName    = directoryNames[nplen + 1];
                    if (isControllers)
                    {
                        if (controllerName.Contains(DefaultHttpControllerSelector.ControllerSuffix))
                        {
                            replacePaths.Add(item.Key.Replace(namespaceFullName,
                                                              controllerName.Substring(0,
                                                                                       controllerName.Length - DefaultHttpControllerSelector.ControllerSuffix.Length)), value);
                        }
                        else
                        {
                            replacePaths.Add(controllerName, value);
                        }
                    }
                }
            }
            swaggerDoc.paths = replacePaths;
        }
Example #16
0
        public void PairCollide()
        {
            var firstPair  = new KeyValuePair <string, string>("key", "validValue");
            var secondPair = new KeyValuePair <string, string>("key", "wrongValue");

            IDictionary <string, string> dict = new ConcurrentDictionary <string, string>();

            dict.Add(firstPair); // Do not change to object initialization
            Assert.Throws <ArgumentException>(() => dict.Add(secondPair));

            Assert.IsTrue(dict.Contains(firstPair));
            Assert.IsFalse(dict.Contains(secondPair));
        }
Example #17
0
        public void ActivateLocalActor(ActorDescription localActor)
        {
            var channel = _factory.BuildLocalActor(localActor);

            channel.Connected    += OnActorConnected;
            channel.Disconnected += OnActorDisconnected;
            channel.DataReceived += OnActorDataReceived;
            channel.Open();

            _localActor = localActor;
            _channels.Add(_localActor.GetKey(), channel);
            _actorKeys.Add(_localActor.GetKey(), _localActor);
        }
Example #18
0
        /// <summary>
        /// 申请处理
        /// </summary>
        /// <param name="swaggerDoc"></param>
        /// <param name="schemaRegistry"></param>
        /// <param name="apiExplorer"></param>
        public void Apply(SwaggerDocument swaggerDoc, SchemaRegistry schemaRegistry, IApiExplorer apiExplorer)
        {
            IDictionary <string, PathItem> replacePaths = new ConcurrentDictionary <string, PathItem>();

            foreach (var item in swaggerDoc.paths)
            {
                string key = item.Key;
                if (key.Contains("/token"))
                {
                    replacePaths.Add(item.Key, item.Value);
                    continue;
                }
                var value = item.Value;
                var keys  = key.Split('/');

                if (keys[3].IndexOf('.') != -1)
                {
                    // 区域路径
                    string areasName         = keys[2];
                    string namespaceFullName = keys[3];
                    var    directoryNames    = namespaceFullName.Split('.');
                    string namespaceName     = directoryNames[4];
                    if (areasName.Equals(namespaceName, StringComparison.OrdinalIgnoreCase))
                    {
                        string controllerName = directoryNames[6];
                        replacePaths.Add(
                            item.Key.Replace(namespaceFullName,
                                             controllerName.Substring(0,
                                                                      controllerName.Length - DefaultHttpControllerSelector.ControllerSuffix.Length)),
                            value);
                    }
                }
                else if (keys[2].IndexOf('.') != -1)
                {
                    // 基础路径
                    string namespaceFullName = keys[2];
                    var    directoryNames    = namespaceFullName.Split('.');
                    bool   isControllers     = directoryNames[3].Equals("Controllers", StringComparison.OrdinalIgnoreCase);
                    string controllerName    = directoryNames[4];
                    if (isControllers)
                    {
                        replacePaths.Add(
                            item.Key.Replace(namespaceFullName,
                                             controllerName.Substring(0,
                                                                      controllerName.Length - DefaultHttpControllerSelector.ControllerSuffix.Length)), value);
                    }
                }
            }
            swaggerDoc.paths = replacePaths;
        }
        internal static BitmapImage GetMapImage(string mapName, FormatSize size = FormatSize.Medium_256)
        {
            if (String.IsNullOrEmpty(mapName))
            {
                logger.Warn("Map name is null or empty");
                return(null);
            }
            // Try to get cached image
            if (imageCache.TryGetValue(mapName, out var img))
            {
                return(img);
            }
            // Get image path
            var path = MapFilePath(mapName, size);

            // Check for invalid path
            if (String.IsNullOrEmpty(path) || !File.Exists(path))
            {
                logger.Error("Map image not found. Path: \"" + path + "\"");
                return(null);
            }
            // Open filestream to image at path
            using var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            // Initialize BitmapImage
            img = new BitmapImage();
            img.BeginInit();
            img.StreamSource = fs;
            img.CacheOption  = BitmapCacheOption.OnLoad;
            img.EndInit();
            // Add image to cache
            imageCache.Add(mapName, img);
            return(img);
        }
        public IDictionary <string, FileData> GetInitializedDirectoryListAsDictionary()
        {
            IDictionary <string, FileData> bag = new ConcurrentDictionary <string, FileData>();

            GetDirectoryAsFileInfoList().ForEach(item => bag.Add(item.FullName, GetInitializedFileData(item)));
            return(bag);
        }
Example #21
0
        public Dictionary <string, System.Reflection.PropertyInfo> GetTypeProperty(Type type)
        {
            lock (lockobj)
            {
                if (PropertyTable.ContainsKey(type))
                {
                    return(PropertyTable[type]);
                }
                else
                {
                    System.Reflection.PropertyInfo[] propertyArray = type.GetProperties(BindingFlags.Instance | BindingFlags.Public);

                    Dictionary <string, System.Reflection.PropertyInfo> tmp = new Dictionary <string, System.Reflection.PropertyInfo>(propertyArray.Length);

                    foreach (var item in propertyArray)
                    {
                        tmp[item.Name] = item;
                    }


                    PropertyTable.Add(type, tmp);
                    return(tmp);
                }
            }
        }
Example #22
0
        private List <ILifecycleConcern> GetComponentConcerns(Type type)
        {
#if DOTNET40
            return(concernsCache.GetOrAdd(type, BuildConcernCache));
#else
            List <ILifecycleConcern> componentConcerns;
            using (var @lock = cacheLock.ForReadingUpgradeable())
            {
                if (concernsCache.TryGetValue(type, out componentConcerns))
                {
                    return(componentConcerns);
                }

                @lock.Upgrade();
                if (concernsCache.TryGetValue(type, out componentConcerns))
                {
                    return(componentConcerns);
                }

                componentConcerns = BuildConcernCache(type);
                concernsCache.Add(type, componentConcerns);
                return(componentConcerns);
            }
#endif
        }
        public P SendMessage <R, P>(string remoteActorType, MessageEnvelope <R> request, TimeSpan timeout)
        {
            P          response = default(P);
            Action <P> callback = (r) => { response = r; };

            try
            {
                ManualResetEvent waiter = new ManualResetEvent(false);
                _callbacks.Add(request.MessageID, new BlockingCallbackHolder(request.MessageID, waiter, callback));

                this.SendAsync(remoteActorType, request.ToBytes(this.Encoder));

                if (!waiter.WaitOne(timeout))
                {
                    _log.ErrorFormat("Timeout when waiting message [{0}] after {1} seconds.",
                                     request.MessageType, timeout.TotalSeconds);
                }
                waiter.Reset();
                waiter.Dispose();
                BlockingCallbackHolder throwAway = null;
                _callbacks.TryRemove(request.MessageID, out throwAway);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }

            return(response);
        }
Example #24
0
        /// <summary>
        /// 尝试从远程配置中心读取配置信息
        /// </summary>
        public async override void Load()
        {
            var response = "";

            try
            {
                var serverAddress = "http://localhost:5001";
                var client        = new HttpClient();
                client.BaseAddress = new Uri(serverAddress);
                response           = await client.GetStringAsync("/weatherforecast");
            }
            catch (Exception)
            {
                // 异常
            }

            if (string.IsNullOrEmpty(response))
            {
                throw new Exception("数据未响应.");
            }

            var configs = JsonConvert.DeserializeObject <List <KeyValuePair <string, string> > >(response);

            Data = new ConcurrentDictionary <string, string>();

            configs.ForEach(c =>
            {
                Data.Add(c);
            });
        }
Example #25
0
        public async Task <IDictionary <string, byte[]> > LoadManifestStreams(string assemblyFullFilePath, string assemblyName, bool isolate = true)
        {
            IDictionary <string, byte[]> items = new ConcurrentDictionary <string, byte[]>();

            var file = new FileInfo(assemblyFullFilePath);

            if (file.Exists)
            {
                var domain = AppDomain.CurrentDomain;
                if (isolate)
                {
                    domain = AppDomain.CreateDomain("loader");
                }

                domain.Load(File.ReadAllBytes(file.FullName));
                var asm = (from a in domain.GetAssemblies()
                           where a.FullName.IndexOf(assemblyName, StringComparison.InvariantCultureIgnoreCase) >= 0
                           select a)?.FirstOrDefault();

                IList <Task> tasks = new List <Task>();

                foreach (var name in asm.GetManifestResourceNames())
                {
                    tasks.Add(
                        Task.Factory.StartNew(fn =>
                    {
                        try
                        {
                            var n = fn.ToString();

                            using (var res = asm.GetManifestResourceStream(n))
                            {
                                using (var stm = new MemoryStream())
                                {
                                    res.CopyTo(stm);
                                    if (stm.CanSeek && stm.Position > 0)
                                    {
                                        stm.Seek(0, SeekOrigin.Begin);
                                    }
                                    items.Add(n, stm.ToArray());
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }, name)
                        );
                }
                await Task.WhenAll(tasks.ToArray());

                if (isolate)
                {
                    AppDomain.Unload(domain);
                }
            }

            return(items);
        }
Example #26
0
        public static bool Ensure(this ConcurrentDictionary <long, int> claims, int scope, int type, int claimIndex)
        {
            var subjectClaimIndex = new SubjectClaimIndex(scope, type);

            claims.Add(subjectClaimIndex.Value, claimIndex);
            return(true);
        }
Example #27
0
        private void OnTransportConnected(object sender, ActorTransportSessionConnectedEventArgs e)
        {
            var session = new ActorSessionChannel(_localActor, _channelConfiguration, e.Session);

            OpenSession(session);
            _sessions.Add(session.SessionKey, new SessionItem(session.SessionKey, session));
        }
        protected List <TConcern> GetComponentConcerns(Type type)
        {
#if !(DOTNET35 || SILVERLIGHT)
            return(concernsCache.GetOrAdd(type, BuildConcernCache));
#else
            List <TConcern> componentConcerns;
            using (var @lock = cacheLock.ForReadingUpgradeable())
            {
                if (concernsCache.TryGetValue(type, out componentConcerns))
                {
                    return(componentConcerns);
                }

                @lock.Upgrade();
                if (concernsCache.TryGetValue(type, out componentConcerns))
                {
                    return(componentConcerns);
                }

                componentConcerns = BuildConcernCache(type);
                concernsCache.Add(type, componentConcerns);
                return(componentConcerns);
            }
#endif
        }
        /// <summary>
        /// Gets the applied changes already in the database
        /// </summary>
        /// <returns>
        /// A dictionary containing the change logs and the ids for those change logs
        /// </returns>
        public IDictionary <int, IChangeLog> GetAppliedChanges()
        {
            if (log.IsDebugEnabled)
            {
                log.Debug(LogUtility.GetContext());
            }

            IDictionary <int, IChangeLog> result = new ConcurrentDictionary <int, IChangeLog>();

            this.EnsureChangelogExists();

            DataSet changeLogDataSet = this.GetChangelog();

            // we're assuming that this will return a single table.  Can't be sure what the name will be so using the index.
            foreach (DataRow row in changeLogDataSet.Tables[0].Rows)
            {
                IChangeLog changeLog = new ChangeLog();
                changeLog.Parse(row);
                result.Add(changeLog.ChangeNumber, changeLog);
            }

            if (log.IsDebugEnabled)
            {
                log.Debug(LogUtility.GetResult(result));
            }

            return(result);
        }
Example #30
0
        private void InitSystemFields()
        {
            SystemFields = new ConcurrentDictionary <string, string>();

            try
            {
                var dataModelAssembly = Assembly.LoadFile(_options.DataModel);

                foreach (var exportedType in dataModelAssembly.ExportedTypes.Where(e => e.FullName.Contains(".SystemFields.") && !e.FullName.Contains("MDLListValues")).OrderBy(e => e.Name))
                {
                    try
                    {
                        var fieldKey  = exportedType.GetField("Name").GetValue(exportedType);
                        var fieldName = exportedType.Name;

                        SystemFields.Add(fieldKey.ToString(), fieldName);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Data model not loaded; SystemFields will be null");
            }
        }
        internal static ObjectSerializer GetSerializer(Type type)
        {
            if (type == typeof(object) || type.IsInterface || type.IsAbstract)
            {
                return(baseSerializer);
            }

            ObjectSerializer serializer;

                        #if NET_4
            serializer = Serializers.GetOrAdd(type, t => new ObjectSerializer(t));
                        #else
            bool exists;
            lock (Serializers)
                exists = Serializers.TryGetValue(type, out serializer);

            if (!exists)
            {
                serializer = new ObjectSerializer(type);
                lock (Serializers)
                {
                    if (!Serializers.ContainsKey(type))
                    {
                        Serializers.Add(type, serializer);
                    }
                }
            }
                        #endif

            return(serializer);
        }
Example #32
0
        public async Task <TReply> Send <TArg, TReply>(Request <TArg, TReply> request, IContext icontext)
        {
            // TODO IContext is a placeholder now.
            ClientContext context = icontext as ClientContext;

            if (context == null)
            {
                context = ClientContext.Default;
            }

            await _sendMutex.WaitAsync();

            try
            {
                if (_stop)
                {
                    throw s_clientStoppedException;
                }
                request.ID = _nextRequestID;
                _nextRequestID++;

                _codec.WriteRequest(request.Arg, request.ID, request.ServiceID, request.MethodID, out ReadOnlyMemory <byte> tmpBuffer);
                await _conn.Output.WriteAsync(tmpBuffer);

                _pendingRequests.Add(request.ID, request);
            }
            finally
            {
                _sendMutex.Release();
            }

            await request.Task;

            return(request.Task.Result);
        }
 public DefaultIdComponentConverterContainer()
 {
     ValueConverters = new ConcurrentDictionary<Type, IIdComponentConverter>();
     ValueConverters.Add(typeof(DateTimeIdComponentConverter), new DateTimeIdComponentConverter());
     ValueConverters.Add(typeof (GuidIdComponentConverter), new GuidIdComponentConverter());
     ValueConverters.Add(typeof(EnumIdComponentConverter), new EnumIdComponentConverter());
     ValueConverters.Add(typeof(IntIdComponentConverter), new IntIdComponentConverter());
     ValueConverters.Add(typeof(LongIdComponentConverter), new LongIdComponentConverter());
     ValueConverters.Add(typeof (StringIdComponentConverter), new StringIdComponentConverter());
 }
        /// <summary>Compiles the referenced XSLT for all templates.</summary>
        private IDictionary<Template, Task<XslCompiledTransform>> GetTemplateCompilationTaskMap() {
            IDictionary<Template, Task<XslCompiledTransform>> templateTransformTaskMap = new ConcurrentDictionary<Template, Task<XslCompiledTransform>>();

            foreach (Template template in this.TemplateOutputs.Keys) {
                OnTemplateGenerationStatus(TemplateGenerationStatusEventArgs.CreateCompiling(template));

                try {
                    templateTransformTaskMap.Add(template, CompileTemplateAsync(template));
                }
                catch (Exception ex) {
                    Generator.Logger.Error(ex);
                    OnTemplateGenerationStatus(TemplateGenerationStatusEventArgs.CreateError(template, new ApplicationException("Unable to load XSLT.", ex)));
                    break;
                }

                OnTemplateGenerationStatus(TemplateGenerationStatusEventArgs.CreateWaiting(template));
            }

            return templateTransformTaskMap;
        }
Example #35
0
        /// <summary>
        /// 讀取指定路徑的Xml設定檔,轉成來源端列表與目的端列表的字典檔
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public IDictionary<IList<IPEndPoint>, IList<IPEndPoint>> LoadSettings(string filePath)
        {
            IDictionary<IList<IPEndPoint>, IList<IPEndPoint>> ipEndPointDic = new ConcurrentDictionary<IList<IPEndPoint>, IList<IPEndPoint>>();
            //load xml file
            XDocument doc = XDocument.Load(filePath, LoadOptions.None);

            IEnumerable<XElement> ipEndPointList = doc.Root.Elements("IPEndPoint");
            IEnumerable<XElement> originNodes = null;
            IEnumerable<XElement> destinationNodes = null;
            //loop all Tag that name is IPEndPoint
            foreach (var ipEndPointNode in ipEndPointList)
            {
                if (ipEndPointNode.HasElements)
                {
                    //get this endpoint inner settings
                    //loading origin ip list setting
                    originNodes = ipEndPointNode.Elements("Origin");
                    //loading destination ip list setting
                    destinationNodes = ipEndPointNode.Elements("Destination");
                    //parse origin ip list setting
                    IList<IPEndPoint> originlist = GetIpEndPointList(originNodes, "Origin");
                    //parse destination ip list setting
                    IList<IPEndPoint> destinationlist = GetIpEndPointList(destinationNodes, "Destination");
                    //insert to dictionary
                    ipEndPointDic.Add(originlist, destinationlist);
                }
            }
            return ipEndPointDic;
        }
Example #36
0
        /// <summary>
        /// IP Details From IP Address
        /// </summary>
        /// <param name="ip">
        /// The ip.
        /// </param>
        /// <param name="format">
        /// The format.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="culture">
        /// The culture.
        /// </param>
        /// <param name="browser">
        /// The browser.
        /// </param>
        /// <param name="os">
        /// The os.
        /// </param>
        /// <returns>
        /// IPLocator Class
        /// </returns>
        public IDictionary<string, string> GetData([CanBeNull] string ip, [CanBeNull] string format, bool callback, string culture, string browser, string os)
        {
            CodeContracts.ArgumentNotNull(ip, "ip");

            IDictionary<string, string> res = new ConcurrentDictionary<string, string>();

            if (YafContext.Current.Get<YafBoardSettings>().IPLocatorResultsMap.IsNotSet() ||
                YafContext.Current.Get<YafBoardSettings>().IPLocatorUrlPath.IsNotSet())
            {
                return res;
            }

            if (YafContext.Current.Get<YafBoardSettings>().EnableIPInfoService)
            {
                switch (format)
                {
                    case "raw":
                        try
                        {
                            string path =
                                YafContext.Current.Get<YafBoardSettings>()
                                    .IPLocatorUrlPath.FormatWith(VZF.Utils.Helpers.IPHelper.GetIp4Address(ip));
                            var client = new WebClient();
                            string[] result = client.DownloadString(path).Split(';');
                            string[] sray =
                                YafContext.Current.Get<YafBoardSettings>().IPLocatorResultsMap.Trim().Split(',');
                            if (result.Length > 0 && result.Length == sray.Length)
                            {
                                int i = 0;
                                bool oldproperty = false;
                                foreach (string str in result)
                                {
                                    if (sray.Any(strDef => string.Equals(str, strDef, StringComparison.InvariantCultureIgnoreCase)))
                                    {
                                        res.Add(sray[i].Trim(), str);
                                        i++;
                                        oldproperty = true;
                                    }

                                    if (!oldproperty)
                                    {
                                        CommonDb.eventlog_create(YafContext.Current.PageModuleID, this, "Undefined property {0} in your HostSettings IP Info Geolocation Web Service arguments mapping string. Automatically added to the string.".FormatWith(str), EventLogTypes.Information);
                                        string oldProperties =
                                            YafContext.Current.Get<YafBoardSettings>().IPLocatorResultsMap;
                                        YafContext.Current.Get<YafBoardSettings>().IPLocatorResultsMap = oldProperties
                                                                                                             + ","
                                                                                                             + str;
                                    }

                                    oldproperty = false;
                                }
                            }
                        }
                        catch
                        {
                            return res;
                        }

                        break;
                    case "xml":
                        break;
                    case "json":
                        break;
                }
            }

            return res;
        }
Example #37
0
        /// <summary>
        /// IP Details From IP Address
        /// </summary>
        /// <param name="ip">
        /// The ip.
        /// </param>
        /// <param name="format">
        /// The format.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <param name="culture">
        /// The culture.
        /// </param>
        /// <param name="browser">
        /// The browser.
        /// </param>
        /// <param name="os">
        /// The os.
        /// </param>
        /// <returns>
        /// IPLocator Class
        /// </returns>
        public IDictionary<string, string> GetData([CanBeNull] string ip, [CanBeNull] string format, bool callback, string culture, string browser, string os)
        {
            CodeContracts.VerifyNotNull(ip, "ip");

            IDictionary<string, string> res = new ConcurrentDictionary<string, string>();

            if (YafContext.Current.Get<YafBoardSettings>().IPLocatorResultsMapping.IsNotSet() ||
                YafContext.Current.Get<YafBoardSettings>().IPLocatorUrlPath.IsNotSet())
            {
                return res;
            }

            if (!YafContext.Current.Get<YafBoardSettings>().EnableIPInfoService)
            {
                return res;
            }

            try
            {
                string path = YafContext.Current.Get<YafBoardSettings>().IPLocatorUrlPath.FormatWith(Utils.Helpers.IPHelper.GetIp4Address(ip));
                var client = new WebClient();
                string[] result = client.DownloadString(path).Split(';');
                string[] sray = YafContext.Current.Get<YafBoardSettings>().IPLocatorResultsMapping.Trim().Split(',');
                if (result.Length > 0 && result.Length == sray.Length)
                {
                    int i = 0;
                    foreach (string str in result)
                    {
                        res.Add(sray[i].Trim(), str);
                        i++;
                    }
                }
            }
            catch
            {
                return res;
            }

            return res;
        }
        public void Add_KeyValuePairThrowsNotImplementedException()
        {
            // Arrange
            ConcurrentDictionary<int, int> dictionary = new ConcurrentDictionary<int, int>();

            // Act/Assert
            Assert.Throws<NotImplementedException>(() => dictionary.Add(new KeyValuePair<int, int>(0, 0)));
        }
Example #39
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Artefacts.Service.ArtefactRepository"/> class.
        /// </summary>
        public Repository()
        {
            Context = this;
            _randomGenerator = new Random(DateTime.Now.Second);
            _artefactCache = new Dictionary<int, Artefact>();
            _countCache = new Dictionary<object, int>();
            //_queryResultCache = new Dictionary<object, QueryResult<Artefact>>();
            _queryExecuteQueue = new ConcurrentQueue<object>();
            _nhQueryProvider = new DefaultQueryProvider(Session.GetSessionImplementation());
            _binaryFormatter = new BinaryFormatter();

            Configuration = new ArtefactServiceConfiguration();
            QueryVisitor = new ServerQueryVisitor(this);
            QueryFormatterVisitor = new ToStringVisitor();
            QueryCache = new Dictionary<object, IQueryable>();
            Artefacts = Session.Query<Artefact>();
            Queryables = new ConcurrentDictionary<Type, IQueryable>();
            Queryables.Add(typeof(Artefact), Artefacts);
        }
        /// <summary>
        /// Create a test database with two players.
        /// </summary>
        public void CreateTestDatabase()
        {
            IDictionary<String, Player> players = new ConcurrentDictionary<String, Player>();
            players.Add("James", new Player(new Position(200, 200), new Velocity(0, 0), "James", "jamespass"));
            players.Add("Gleb", new Player(new Position(400, 300), new Velocity(0, 0), "Gleb", "glebpass"));

            CreateDatabase(players);
        }
Example #41
0
 protected static IDictionary<Guid, DateTime> SelectAllMediaItemAspectMetadataCreationDates()
 {
   var database = ServiceRegistration.Get<ISQLDatabase>();
   var transaction = database.BeginTransaction();
   try
   {
     int miamIdIndex;
     int creationDateIndex;
     using (var command = MediaLibrary_SubSchema.SelectAllMediaItemAspectMetadataCreationDatesCommand(transaction, out miamIdIndex, out creationDateIndex))
     using (var reader = command.ExecuteReader())
     {
       IDictionary<Guid, DateTime> result = new ConcurrentDictionary<Guid, DateTime>();
       while (reader.Read())
         result.Add(database.ReadDBValue<Guid>(reader, miamIdIndex),
             database.ReadDBValue<DateTime>(reader, creationDateIndex));
       return result;
     }
   }
   finally
   {
     transaction.Dispose();
   }      
 }
        private static bool RunDictionaryTest_Add1(int cLevel, int initSize, int threads, int addsPerThread)
        {
            TestHarness.TestLog(
                "* RunDictionaryTest_Add1(cLevel={0}, initSize={1}, threads={2}, addsPerThread={3})",
                cLevel, initSize, threads, addsPerThread);

            IDictionary<int, int> dict = new ConcurrentDictionary<int, int>(cLevel, 1);

            int count = threads;
            using (ManualResetEvent mre = new ManualResetEvent(false))
            {
                for (int i = 0; i < threads; i++)
                {
                    int ii = i;
                    ThreadPool.QueueUserWorkItem(
                        (o) =>
                        {
                            for (int j = 0; j < addsPerThread; j++)
                            {
                                dict.Add(j + ii * addsPerThread, -(j + ii * addsPerThread));
                            }
                            if (Interlocked.Decrement(ref count) == 0) mre.Set();
                        });
                }
                mre.WaitOne();
            }

            if (dict.Any(pair => pair.Key != -pair.Value))
            {
                TestHarness.TestLog("  > Invalid value for some key in the dictionary.");
                return false;
            }

            var gotKeys = dict.Select(pair => pair.Key).OrderBy(i => i).ToArray();
            var expectKeys = Enumerable.Range(0, threads * addsPerThread);

            if (!gotKeys.SequenceEqual(expectKeys))
            {
                TestHarness.TestLog("  > The set of keys in the dictionary is invalid.");
                return false;
            }

            // Finally, let's verify that the count is reported correctly.
            int expectedCount = threads * addsPerThread;
            if (dict.Count != expectedCount || dict.ToArray().Length != expectedCount || dict.ToList().Count() != expectedCount)
            {
                TestHarness.TestLog("  > Incorrect count of elements reported for the dictionary.");
                return false;
            }

            return true;
        }
Example #43
0
        /// <summary>
        /// Initializes static members of the <see cref="HtmlEntity"/> class.
        /// </summary>
        static HtmlEntity()
        {
            EntityValue = new ConcurrentDictionary<string, int>();
            EntityName = new ConcurrentDictionary<int, string>();

            EntityValue.Add("nbsp", 160); // no-break space = non-breaking space, U+00A0 ISOnum
            EntityName.Add(160, "nbsp");
            EntityValue.Add("iexcl", 161); // inverted exclamation mark, U+00A1 ISOnum
            EntityName.Add(161, "iexcl");
            EntityValue.Add("cent", 162); // cent sign, U+00A2 ISOnum
            EntityName.Add(162, "cent");
            EntityValue.Add("pound", 163); // pound sign, U+00A3 ISOnum
            EntityName.Add(163, "pound");
            EntityValue.Add("curren", 164); // currency sign, U+00A4 ISOnum
            EntityName.Add(164, "curren");
            EntityValue.Add("yen", 165); // yen sign = yuan sign, U+00A5 ISOnum
            EntityName.Add(165, "yen");
            EntityValue.Add("brvbar", 166); // broken bar = broken vertical bar, U+00A6 ISOnum
            EntityName.Add(166, "brvbar");
            EntityValue.Add("sect", 167); // section sign, U+00A7 ISOnum
            EntityName.Add(167, "sect");
            EntityValue.Add("uml", 168); // diaeresis = spacing diaeresis, U+00A8 ISOdia
            EntityName.Add(168, "uml");
            EntityValue.Add("copy", 169); // copyright sign, U+00A9 ISOnum
            EntityName.Add(169, "copy");
            EntityValue.Add("ordf", 170); // feminine ordinal indicator, U+00AA ISOnum
            EntityName.Add(170, "ordf");
            EntityValue.Add("laquo", 171);

            // left-pointing double angle quotation mark = left pointing guillemet, U+00AB ISOnum
            EntityName.Add(171, "laquo");
            EntityValue.Add("not", 172); // not sign, U+00AC ISOnum
            EntityName.Add(172, "not");
            EntityValue.Add("shy", 173); // soft hyphen = discretionary hyphen, U+00AD ISOnum
            EntityName.Add(173, "shy");
            EntityValue.Add("reg", 174); // registered sign = registered trade mark sign, U+00AE ISOnum
            EntityName.Add(174, "reg");
            EntityValue.Add("macr", 175); // macron = spacing macron = overline = APL overbar, U+00AF ISOdia
            EntityName.Add(175, "macr");
            EntityValue.Add("deg", 176); // degree sign, U+00B0 ISOnum
            EntityName.Add(176, "deg");
            EntityValue.Add("plusmn", 177); // plus-minus sign = plus-or-minus sign, U+00B1 ISOnum
            EntityName.Add(177, "plusmn");
            EntityValue.Add("sup2", 178); // superscript two = superscript digit two = squared, U+00B2 ISOnum
            EntityName.Add(178, "sup2");
            EntityValue.Add("sup3", 179); // superscript three = superscript digit three = cubed, U+00B3 ISOnum
            EntityName.Add(179, "sup3");
            EntityValue.Add("acute", 180); // acute accent = spacing acute, U+00B4 ISOdia
            EntityName.Add(180, "acute");
            EntityValue.Add("micro", 181); // micro sign, U+00B5 ISOnum
            EntityName.Add(181, "micro");
            EntityValue.Add("para", 182); // pilcrow sign = paragraph sign, U+00B6 ISOnum
            EntityName.Add(182, "para");
            EntityValue.Add("middot", 183); // middle dot = Georgian comma = Greek middle dot, U+00B7 ISOnum
            EntityName.Add(183, "middot");
            EntityValue.Add("cedil", 184); // cedilla = spacing cedilla, U+00B8 ISOdia
            EntityName.Add(184, "cedil");
            EntityValue.Add("sup1", 185); // superscript one = superscript digit one, U+00B9 ISOnum
            EntityName.Add(185, "sup1");
            EntityValue.Add("ordm", 186); // masculine ordinal indicator, U+00BA ISOnum
            EntityName.Add(186, "ordm");
            EntityValue.Add("raquo", 187);

            // right-pointing double angle quotation mark = right pointing guillemet, U+00BB ISOnum
            EntityName.Add(187, "raquo");
            EntityValue.Add("frac14", 188); // vulgar fraction one quarter = fraction one quarter, U+00BC ISOnum
            EntityName.Add(188, "frac14");
            EntityValue.Add("frac12", 189); // vulgar fraction one half = fraction one half, U+00BD ISOnum
            EntityName.Add(189, "frac12");
            EntityValue.Add("frac34", 190); // vulgar fraction three quarters = fraction three quarters, U+00BE ISOnum
            EntityName.Add(190, "frac34");
            EntityValue.Add("iquest", 191); // inverted question mark = turned question mark, U+00BF ISOnum
            EntityName.Add(191, "iquest");
            EntityValue.Add("Agrave", 192);

            // latin capital letter A with grave = latin capital letter A grave, U+00C0 ISOlat1
            EntityName.Add(192, "Agrave");
            EntityValue.Add("Aacute", 193); // latin capital letter A with acute, U+00C1 ISOlat1
            EntityName.Add(193, "Aacute");
            EntityValue.Add("Acirc", 194); // latin capital letter A with circumflex, U+00C2 ISOlat1
            EntityName.Add(194, "Acirc");
            EntityValue.Add("Atilde", 195); // latin capital letter A with tilde, U+00C3 ISOlat1
            EntityName.Add(195, "Atilde");
            EntityValue.Add("Auml", 196); // latin capital letter A with diaeresis, U+00C4 ISOlat1
            EntityName.Add(196, "Auml");
            EntityValue.Add("Aring", 197);

            // latin capital letter A with ring above = latin capital letter A ring, U+00C5 ISOlat1
            EntityName.Add(197, "Aring");
            EntityValue.Add("AElig", 198); // latin capital letter AE = latin capital ligature AE, U+00C6 ISOlat1
            EntityName.Add(198, "AElig");
            EntityValue.Add("Ccedil", 199); // latin capital letter C with cedilla, U+00C7 ISOlat1
            EntityName.Add(199, "Ccedil");
            EntityValue.Add("Egrave", 200); // latin capital letter E with grave, U+00C8 ISOlat1
            EntityName.Add(200, "Egrave");
            EntityValue.Add("Eacute", 201); // latin capital letter E with acute, U+00C9 ISOlat1
            EntityName.Add(201, "Eacute");
            EntityValue.Add("Ecirc", 202); // latin capital letter E with circumflex, U+00CA ISOlat1
            EntityName.Add(202, "Ecirc");
            EntityValue.Add("Euml", 203); // latin capital letter E with diaeresis, U+00CB ISOlat1
            EntityName.Add(203, "Euml");
            EntityValue.Add("Igrave", 204); // latin capital letter I with grave, U+00CC ISOlat1
            EntityName.Add(204, "Igrave");
            EntityValue.Add("Iacute", 205); // latin capital letter I with acute, U+00CD ISOlat1
            EntityName.Add(205, "Iacute");
            EntityValue.Add("Icirc", 206); // latin capital letter I with circumflex, U+00CE ISOlat1
            EntityName.Add(206, "Icirc");
            EntityValue.Add("Iuml", 207); // latin capital letter I with diaeresis, U+00CF ISOlat1
            EntityName.Add(207, "Iuml");
            EntityValue.Add("ETH", 208); // latin capital letter ETH, U+00D0 ISOlat1
            EntityName.Add(208, "ETH");
            EntityValue.Add("Ntilde", 209); // latin capital letter N with tilde, U+00D1 ISOlat1
            EntityName.Add(209, "Ntilde");
            EntityValue.Add("Ograve", 210); // latin capital letter O with grave, U+00D2 ISOlat1
            EntityName.Add(210, "Ograve");
            EntityValue.Add("Oacute", 211); // latin capital letter O with acute, U+00D3 ISOlat1
            EntityName.Add(211, "Oacute");
            EntityValue.Add("Ocirc", 212); // latin capital letter O with circumflex, U+00D4 ISOlat1
            EntityName.Add(212, "Ocirc");
            EntityValue.Add("Otilde", 213); // latin capital letter O with tilde, U+00D5 ISOlat1
            EntityName.Add(213, "Otilde");
            EntityValue.Add("Ouml", 214); // latin capital letter O with diaeresis, U+00D6 ISOlat1
            EntityName.Add(214, "Ouml");
            EntityValue.Add("times", 215); // multiplication sign, U+00D7 ISOnum
            EntityName.Add(215, "times");
            EntityValue.Add("Oslash", 216);

            // latin capital letter O with stroke = latin capital letter O slash, U+00D8 ISOlat1
            EntityName.Add(216, "Oslash");
            EntityValue.Add("Ugrave", 217); // latin capital letter U with grave, U+00D9 ISOlat1
            EntityName.Add(217, "Ugrave");
            EntityValue.Add("Uacute", 218); // latin capital letter U with acute, U+00DA ISOlat1
            EntityName.Add(218, "Uacute");
            EntityValue.Add("Ucirc", 219); // latin capital letter U with circumflex, U+00DB ISOlat1
            EntityName.Add(219, "Ucirc");
            EntityValue.Add("Uuml", 220); // latin capital letter U with diaeresis, U+00DC ISOlat1
            EntityName.Add(220, "Uuml");
            EntityValue.Add("Yacute", 221); // latin capital letter Y with acute, U+00DD ISOlat1
            EntityName.Add(221, "Yacute");
            EntityValue.Add("THORN", 222); // latin capital letter THORN, U+00DE ISOlat1
            EntityName.Add(222, "THORN");
            EntityValue.Add("szlig", 223); // latin small letter sharp s = ess-zed, U+00DF ISOlat1
            EntityName.Add(223, "szlig");
            EntityValue.Add("agrave", 224);

            // latin small letter a with grave = latin small letter a grave, U+00E0 ISOlat1
            EntityName.Add(224, "agrave");
            EntityValue.Add("aacute", 225); // latin small letter a with acute, U+00E1 ISOlat1
            EntityName.Add(225, "aacute");
            EntityValue.Add("acirc", 226); // latin small letter a with circumflex, U+00E2 ISOlat1
            EntityName.Add(226, "acirc");
            EntityValue.Add("atilde", 227); // latin small letter a with tilde, U+00E3 ISOlat1
            EntityName.Add(227, "atilde");
            EntityValue.Add("auml", 228); // latin small letter a with diaeresis, U+00E4 ISOlat1
            EntityName.Add(228, "auml");
            EntityValue.Add("aring", 229);

            // latin small letter a with ring above = latin small letter a ring, U+00E5 ISOlat1
            EntityName.Add(229, "aring");
            EntityValue.Add("aelig", 230); // latin small letter ae = latin small ligature ae, U+00E6 ISOlat1
            EntityName.Add(230, "aelig");
            EntityValue.Add("ccedil", 231); // latin small letter c with cedilla, U+00E7 ISOlat1
            EntityName.Add(231, "ccedil");
            EntityValue.Add("egrave", 232); // latin small letter e with grave, U+00E8 ISOlat1
            EntityName.Add(232, "egrave");
            EntityValue.Add("eacute", 233); // latin small letter e with acute, U+00E9 ISOlat1
            EntityName.Add(233, "eacute");
            EntityValue.Add("ecirc", 234); // latin small letter e with circumflex, U+00EA ISOlat1
            EntityName.Add(234, "ecirc");
            EntityValue.Add("euml", 235); // latin small letter e with diaeresis, U+00EB ISOlat1
            EntityName.Add(235, "euml");
            EntityValue.Add("igrave", 236); // latin small letter i with grave, U+00EC ISOlat1
            EntityName.Add(236, "igrave");
            EntityValue.Add("iacute", 237); // latin small letter i with acute, U+00ED ISOlat1
            EntityName.Add(237, "iacute");
            EntityValue.Add("icirc", 238); // latin small letter i with circumflex, U+00EE ISOlat1
            EntityName.Add(238, "icirc");
            EntityValue.Add("iuml", 239); // latin small letter i with diaeresis, U+00EF ISOlat1
            EntityName.Add(239, "iuml");
            EntityValue.Add("eth", 240); // latin small letter eth, U+00F0 ISOlat1
            EntityName.Add(240, "eth");
            EntityValue.Add("ntilde", 241); // latin small letter n with tilde, U+00F1 ISOlat1
            EntityName.Add(241, "ntilde");
            EntityValue.Add("ograve", 242); // latin small letter o with grave, U+00F2 ISOlat1
            EntityName.Add(242, "ograve");
            EntityValue.Add("oacute", 243); // latin small letter o with acute, U+00F3 ISOlat1
            EntityName.Add(243, "oacute");
            EntityValue.Add("ocirc", 244); // latin small letter o with circumflex, U+00F4 ISOlat1
            EntityName.Add(244, "ocirc");
            EntityValue.Add("otilde", 245); // latin small letter o with tilde, U+00F5 ISOlat1
            EntityName.Add(245, "otilde");
            EntityValue.Add("ouml", 246); // latin small letter o with diaeresis, U+00F6 ISOlat1
            EntityName.Add(246, "ouml");
            EntityValue.Add("divide", 247); // division sign, U+00F7 ISOnum
            EntityName.Add(247, "divide");
            EntityValue.Add("oslash", 248);

            // latin small letter o with stroke, = latin small letter o slash, U+00F8 ISOlat1
            EntityName.Add(248, "oslash");
            EntityValue.Add("ugrave", 249); // latin small letter u with grave, U+00F9 ISOlat1
            EntityName.Add(249, "ugrave");
            EntityValue.Add("uacute", 250); // latin small letter u with acute, U+00FA ISOlat1
            EntityName.Add(250, "uacute");
            EntityValue.Add("ucirc", 251); // latin small letter u with circumflex, U+00FB ISOlat1
            EntityName.Add(251, "ucirc");
            EntityValue.Add("uuml", 252); // latin small letter u with diaeresis, U+00FC ISOlat1
            EntityName.Add(252, "uuml");
            EntityValue.Add("yacute", 253); // latin small letter y with acute, U+00FD ISOlat1
            EntityName.Add(253, "yacute");
            EntityValue.Add("thorn", 254); // latin small letter thorn, U+00FE ISOlat1
            EntityName.Add(254, "thorn");
            EntityValue.Add("yuml", 255); // latin small letter y with diaeresis, U+00FF ISOlat1
            EntityName.Add(255, "yuml");
            EntityValue.Add("fnof", 402); // latin small f with hook = function = florin, U+0192 ISOtech
            EntityName.Add(402, "fnof");
            EntityValue.Add("Alpha", 913); // greek capital letter alpha, U+0391
            EntityName.Add(913, "Alpha");
            EntityValue.Add("Beta", 914); // greek capital letter beta, U+0392
            EntityName.Add(914, "Beta");
            EntityValue.Add("Gamma", 915); // greek capital letter gamma, U+0393 ISOgrk3
            EntityName.Add(915, "Gamma");
            EntityValue.Add("Delta", 916); // greek capital letter delta, U+0394 ISOgrk3
            EntityName.Add(916, "Delta");
            EntityValue.Add("Epsilon", 917); // greek capital letter epsilon, U+0395
            EntityName.Add(917, "Epsilon");
            EntityValue.Add("Zeta", 918); // greek capital letter zeta, U+0396
            EntityName.Add(918, "Zeta");
            EntityValue.Add("Eta", 919); // greek capital letter eta, U+0397
            EntityName.Add(919, "Eta");
            EntityValue.Add("Theta", 920); // greek capital letter theta, U+0398 ISOgrk3
            EntityName.Add(920, "Theta");
            EntityValue.Add("Iota", 921); // greek capital letter iota, U+0399
            EntityName.Add(921, "Iota");
            EntityValue.Add("Kappa", 922); // greek capital letter kappa, U+039A
            EntityName.Add(922, "Kappa");
            EntityValue.Add("Lambda", 923); // greek capital letter lambda, U+039B ISOgrk3
            EntityName.Add(923, "Lambda");
            EntityValue.Add("Mu", 924); // greek capital letter mu, U+039C
            EntityName.Add(924, "Mu");
            EntityValue.Add("Nu", 925); // greek capital letter nu, U+039D
            EntityName.Add(925, "Nu");
            EntityValue.Add("Xi", 926); // greek capital letter xi, U+039E ISOgrk3
            EntityName.Add(926, "Xi");
            EntityValue.Add("Omicron", 927); // greek capital letter omicron, U+039F
            EntityName.Add(927, "Omicron");
            EntityValue.Add("Pi", 928); // greek capital letter pi, U+03A0 ISOgrk3
            EntityName.Add(928, "Pi");
            EntityValue.Add("Rho", 929); // greek capital letter rho, U+03A1
            EntityName.Add(929, "Rho");
            EntityValue.Add("Sigma", 931); // greek capital letter sigma, U+03A3 ISOgrk3
            EntityName.Add(931, "Sigma");
            EntityValue.Add("Tau", 932); // greek capital letter tau, U+03A4
            EntityName.Add(932, "Tau");
            EntityValue.Add("Upsilon", 933); // greek capital letter upsilon, U+03A5 ISOgrk3
            EntityName.Add(933, "Upsilon");
            EntityValue.Add("Phi", 934); // greek capital letter phi, U+03A6 ISOgrk3
            EntityName.Add(934, "Phi");
            EntityValue.Add("Chi", 935); // greek capital letter chi, U+03A7
            EntityName.Add(935, "Chi");
            EntityValue.Add("Psi", 936); // greek capital letter psi, U+03A8 ISOgrk3
            EntityName.Add(936, "Psi");
            EntityValue.Add("Omega", 937); // greek capital letter omega, U+03A9 ISOgrk3
            EntityName.Add(937, "Omega");
            EntityValue.Add("alpha", 945); // greek small letter alpha, U+03B1 ISOgrk3
            EntityName.Add(945, "alpha");
            EntityValue.Add("beta", 946); // greek small letter beta, U+03B2 ISOgrk3
            EntityName.Add(946, "beta");
            EntityValue.Add("gamma", 947); // greek small letter gamma, U+03B3 ISOgrk3
            EntityName.Add(947, "gamma");
            EntityValue.Add("delta", 948); // greek small letter delta, U+03B4 ISOgrk3
            EntityName.Add(948, "delta");
            EntityValue.Add("epsilon", 949); // greek small letter epsilon, U+03B5 ISOgrk3
            EntityName.Add(949, "epsilon");
            EntityValue.Add("zeta", 950); // greek small letter zeta, U+03B6 ISOgrk3
            EntityName.Add(950, "zeta");
            EntityValue.Add("eta", 951); // greek small letter eta, U+03B7 ISOgrk3
            EntityName.Add(951, "eta");
            EntityValue.Add("theta", 952); // greek small letter theta, U+03B8 ISOgrk3
            EntityName.Add(952, "theta");
            EntityValue.Add("iota", 953); // greek small letter iota, U+03B9 ISOgrk3
            EntityName.Add(953, "iota");
            EntityValue.Add("kappa", 954); // greek small letter kappa, U+03BA ISOgrk3
            EntityName.Add(954, "kappa");
            EntityValue.Add("lambda", 955); // greek small letter lambda, U+03BB ISOgrk3
            EntityName.Add(955, "lambda");
            EntityValue.Add("mu", 956); // greek small letter mu, U+03BC ISOgrk3
            EntityName.Add(956, "mu");
            EntityValue.Add("nu", 957); // greek small letter nu, U+03BD ISOgrk3
            EntityName.Add(957, "nu");
            EntityValue.Add("xi", 958); // greek small letter xi, U+03BE ISOgrk3
            EntityName.Add(958, "xi");
            EntityValue.Add("omicron", 959); // greek small letter omicron, U+03BF NEW
            EntityName.Add(959, "omicron");
            EntityValue.Add("pi", 960); // greek small letter pi, U+03C0 ISOgrk3
            EntityName.Add(960, "pi");
            EntityValue.Add("rho", 961); // greek small letter rho, U+03C1 ISOgrk3
            EntityName.Add(961, "rho");
            EntityValue.Add("sigmaf", 962); // greek small letter final sigma, U+03C2 ISOgrk3
            EntityName.Add(962, "sigmaf");
            EntityValue.Add("sigma", 963); // greek small letter sigma, U+03C3 ISOgrk3
            EntityName.Add(963, "sigma");
            EntityValue.Add("tau", 964); // greek small letter tau, U+03C4 ISOgrk3
            EntityName.Add(964, "tau");
            EntityValue.Add("upsilon", 965); // greek small letter upsilon, U+03C5 ISOgrk3
            EntityName.Add(965, "upsilon");
            EntityValue.Add("phi", 966); // greek small letter phi, U+03C6 ISOgrk3
            EntityName.Add(966, "phi");
            EntityValue.Add("chi", 967); // greek small letter chi, U+03C7 ISOgrk3
            EntityName.Add(967, "chi");
            EntityValue.Add("psi", 968); // greek small letter psi, U+03C8 ISOgrk3
            EntityName.Add(968, "psi");
            EntityValue.Add("omega", 969); // greek small letter omega, U+03C9 ISOgrk3
            EntityName.Add(969, "omega");
            EntityValue.Add("thetasym", 977); // greek small letter theta symbol, U+03D1 NEW
            EntityName.Add(977, "thetasym");
            EntityValue.Add("upsih", 978); // greek upsilon with hook symbol, U+03D2 NEW
            EntityName.Add(978, "upsih");
            EntityValue.Add("piv", 982); // greek pi symbol, U+03D6 ISOgrk3
            EntityName.Add(982, "piv");
            EntityValue.Add("bull", 8226); // bullet = black small circle, U+2022 ISOpub
            EntityName.Add(8226, "bull");
            EntityValue.Add("hellip", 8230); // horizontal ellipsis = three dot leader, U+2026 ISOpub
            EntityName.Add(8230, "hellip");
            EntityValue.Add("prime", 8242); // prime = minutes = feet, U+2032 ISOtech
            EntityName.Add(8242, "prime");
            EntityValue.Add("Prime", 8243); // double prime = seconds = inches, U+2033 ISOtech
            EntityName.Add(8243, "Prime");
            EntityValue.Add("oline", 8254); // overline = spacing overscore, U+203E NEW
            EntityName.Add(8254, "oline");
            EntityValue.Add("frasl", 8260); // fraction slash, U+2044 NEW
            EntityName.Add(8260, "frasl");
            EntityValue.Add("weierp", 8472); // script capital P = power set = Weierstrass p, U+2118 ISOamso
            EntityName.Add(8472, "weierp");
            EntityValue.Add("image", 8465); // blackletter capital I = imaginary part, U+2111 ISOamso
            EntityName.Add(8465, "image");
            EntityValue.Add("real", 8476); // blackletter capital R = real part symbol, U+211C ISOamso
            EntityName.Add(8476, "real");
            EntityValue.Add("trade", 8482); // trade mark sign, U+2122 ISOnum
            EntityName.Add(8482, "trade");
            EntityValue.Add("alefsym", 8501); // alef symbol = first transfinite cardinal, U+2135 NEW
            EntityName.Add(8501, "alefsym");
            EntityValue.Add("larr", 8592); // leftwards arrow, U+2190 ISOnum
            EntityName.Add(8592, "larr");
            EntityValue.Add("uarr", 8593); // upwards arrow, U+2191 ISOnum
            EntityName.Add(8593, "uarr");
            EntityValue.Add("rarr", 8594); // rightwards arrow, U+2192 ISOnum
            EntityName.Add(8594, "rarr");
            EntityValue.Add("darr", 8595); // downwards arrow, U+2193 ISOnum
            EntityName.Add(8595, "darr");
            EntityValue.Add("harr", 8596); // left right arrow, U+2194 ISOamsa
            EntityName.Add(8596, "harr");
            EntityValue.Add("crarr", 8629); // downwards arrow with corner leftwards = carriage return, U+21B5 NEW
            EntityName.Add(8629, "crarr");
            EntityValue.Add("lArr", 8656); // leftwards double arrow, U+21D0 ISOtech
            EntityName.Add(8656, "lArr");
            EntityValue.Add("uArr", 8657); // upwards double arrow, U+21D1 ISOamsa
            EntityName.Add(8657, "uArr");
            EntityValue.Add("rArr", 8658); // rightwards double arrow, U+21D2 ISOtech
            EntityName.Add(8658, "rArr");
            EntityValue.Add("dArr", 8659); // downwards double arrow, U+21D3 ISOamsa
            EntityName.Add(8659, "dArr");
            EntityValue.Add("hArr", 8660); // left right double arrow, U+21D4 ISOamsa
            EntityName.Add(8660, "hArr");
            EntityValue.Add("forall", 8704); // for all, U+2200 ISOtech
            EntityName.Add(8704, "forall");
            EntityValue.Add("part", 8706); // partial differential, U+2202 ISOtech
            EntityName.Add(8706, "part");
            EntityValue.Add("exist", 8707); // there exists, U+2203 ISOtech
            EntityName.Add(8707, "exist");
            EntityValue.Add("empty", 8709); // empty set = null set = diameter, U+2205 ISOamso
            EntityName.Add(8709, "empty");
            EntityValue.Add("nabla", 8711); // nabla = backward difference, U+2207 ISOtech
            EntityName.Add(8711, "nabla");
            EntityValue.Add("isin", 8712); // element of, U+2208 ISOtech
            EntityName.Add(8712, "isin");
            EntityValue.Add("notin", 8713); // not an element of, U+2209 ISOtech
            EntityName.Add(8713, "notin");
            EntityValue.Add("ni", 8715); // contains as member, U+220B ISOtech
            EntityName.Add(8715, "ni");
            EntityValue.Add("prod", 8719); // n-ary product = product sign, U+220F ISOamsb
            EntityName.Add(8719, "prod");
            EntityValue.Add("sum", 8721); // n-ary sumation, U+2211 ISOamsb
            EntityName.Add(8721, "sum");
            EntityValue.Add("minus", 8722); // minus sign, U+2212 ISOtech
            EntityName.Add(8722, "minus");
            EntityValue.Add("lowast", 8727); // asterisk operator, U+2217 ISOtech
            EntityName.Add(8727, "lowast");
            EntityValue.Add("radic", 8730); // square root = radical sign, U+221A ISOtech
            EntityName.Add(8730, "radic");
            EntityValue.Add("prop", 8733); // proportional to, U+221D ISOtech
            EntityName.Add(8733, "prop");
            EntityValue.Add("infin", 8734); // infinity, U+221E ISOtech
            EntityName.Add(8734, "infin");
            EntityValue.Add("ang", 8736); // angle, U+2220 ISOamso
            EntityName.Add(8736, "ang");
            EntityValue.Add("and", 8743); // logical and = wedge, U+2227 ISOtech
            EntityName.Add(8743, "and");
            EntityValue.Add("or", 8744); // logical or = vee, U+2228 ISOtech
            EntityName.Add(8744, "or");
            EntityValue.Add("cap", 8745); // intersection = cap, U+2229 ISOtech
            EntityName.Add(8745, "cap");
            EntityValue.Add("cup", 8746); // union = cup, U+222A ISOtech
            EntityName.Add(8746, "cup");
            EntityValue.Add("int", 8747); // integral, U+222B ISOtech
            EntityName.Add(8747, "int");
            EntityValue.Add("there4", 8756); // therefore, U+2234 ISOtech
            EntityName.Add(8756, "there4");
            EntityValue.Add("sim", 8764); // tilde operator = varies with = similar to, U+223C ISOtech
            EntityName.Add(8764, "sim");
            EntityValue.Add("cong", 8773); // approximately equal to, U+2245 ISOtech
            EntityName.Add(8773, "cong");
            EntityValue.Add("asymp", 8776); // almost equal to = asymptotic to, U+2248 ISOamsr
            EntityName.Add(8776, "asymp");
            EntityValue.Add("ne", 8800); // not equal to, U+2260 ISOtech
            EntityName.Add(8800, "ne");
            EntityValue.Add("equiv", 8801); // identical to, U+2261 ISOtech
            EntityName.Add(8801, "equiv");
            EntityValue.Add("le", 8804); // less-than or equal to, U+2264 ISOtech
            EntityName.Add(8804, "le");
            EntityValue.Add("ge", 8805); // greater-than or equal to, U+2265 ISOtech
            EntityName.Add(8805, "ge");
            EntityValue.Add("sub", 8834); // subset of, U+2282 ISOtech
            EntityName.Add(8834, "sub");
            EntityValue.Add("sup", 8835); // superset of, U+2283 ISOtech
            EntityName.Add(8835, "sup");
            EntityValue.Add("nsub", 8836); // not a subset of, U+2284 ISOamsn
            EntityName.Add(8836, "nsub");
            EntityValue.Add("sube", 8838); // subset of or equal to, U+2286 ISOtech
            EntityName.Add(8838, "sube");
            EntityValue.Add("supe", 8839); // superset of or equal to, U+2287 ISOtech
            EntityName.Add(8839, "supe");
            EntityValue.Add("oplus", 8853); // circled plus = direct sum, U+2295 ISOamsb
            EntityName.Add(8853, "oplus");
            EntityValue.Add("otimes", 8855); // circled times = vector product, U+2297 ISOamsb
            EntityName.Add(8855, "otimes");
            EntityValue.Add("perp", 8869); // up tack = orthogonal to = perpendicular, U+22A5 ISOtech
            EntityName.Add(8869, "perp");
            EntityValue.Add("sdot", 8901); // dot operator, U+22C5 ISOamsb
            EntityName.Add(8901, "sdot");
            EntityValue.Add("lceil", 8968); // left ceiling = apl upstile, U+2308 ISOamsc
            EntityName.Add(8968, "lceil");
            EntityValue.Add("rceil", 8969); // right ceiling, U+2309 ISOamsc
            EntityName.Add(8969, "rceil");
            EntityValue.Add("lfloor", 8970); // left floor = apl downstile, U+230A ISOamsc
            EntityName.Add(8970, "lfloor");
            EntityValue.Add("rfloor", 8971); // right floor, U+230B ISOamsc
            EntityName.Add(8971, "rfloor");
            EntityValue.Add("lang", 9001); // left-pointing angle bracket = bra, U+2329 ISOtech
            EntityName.Add(9001, "lang");
            EntityValue.Add("rang", 9002); // right-pointing angle bracket = ket, U+232A ISOtech
            EntityName.Add(9002, "rang");
            EntityValue.Add("loz", 9674); // lozenge, U+25CA ISOpub
            EntityName.Add(9674, "loz");
            EntityValue.Add("spades", 9824); // black spade suit, U+2660 ISOpub
            EntityName.Add(9824, "spades");
            EntityValue.Add("clubs", 9827); // black club suit = shamrock, U+2663 ISOpub
            EntityName.Add(9827, "clubs");
            EntityValue.Add("hearts", 9829); // black heart suit = valentine, U+2665 ISOpub
            EntityName.Add(9829, "hearts");
            EntityValue.Add("diams", 9830); // black diamond suit, U+2666 ISOpub
            EntityName.Add(9830, "diams");
            EntityValue.Add("quot", 34); // quotation mark = APL quote, U+0022 ISOnum
            EntityName.Add(34, "quot");
            EntityValue.Add("amp", 38); // ampersand, U+0026 ISOnum
            EntityName.Add(38, "amp");
            EntityValue.Add("lt", 60); // less-than sign, U+003C ISOnum
            EntityName.Add(60, "lt");
            EntityValue.Add("gt", 62); // greater-than sign, U+003E ISOnum
            EntityName.Add(62, "gt");
            EntityValue.Add("OElig", 338); // latin capital ligature OE, U+0152 ISOlat2
            EntityName.Add(338, "OElig");
            EntityValue.Add("oelig", 339); // latin small ligature oe, U+0153 ISOlat2
            EntityName.Add(339, "oelig");
            EntityValue.Add("Scaron", 352); // latin capital letter S with caron, U+0160 ISOlat2
            EntityName.Add(352, "Scaron");
            EntityValue.Add("scaron", 353); // latin small letter s with caron, U+0161 ISOlat2
            EntityName.Add(353, "scaron");
            EntityValue.Add("Yuml", 376); // latin capital letter Y with diaeresis, U+0178 ISOlat2
            EntityName.Add(376, "Yuml");
            EntityValue.Add("circ", 710); // modifier letter circumflex accent, U+02C6 ISOpub
            EntityName.Add(710, "circ");
            EntityValue.Add("tilde", 732); // small tilde, U+02DC ISOdia
            EntityName.Add(732, "tilde");
            EntityValue.Add("ensp", 8194); // en space, U+2002 ISOpub
            EntityName.Add(8194, "ensp");
            EntityValue.Add("emsp", 8195); // em space, U+2003 ISOpub
            EntityName.Add(8195, "emsp");
            EntityValue.Add("thinsp", 8201); // thin space, U+2009 ISOpub
            EntityName.Add(8201, "thinsp");
            EntityValue.Add("zwnj", 8204); // zero width non-joiner, U+200C NEW RFC 2070
            EntityName.Add(8204, "zwnj");
            EntityValue.Add("zwj", 8205); // zero width joiner, U+200D NEW RFC 2070
            EntityName.Add(8205, "zwj");
            EntityValue.Add("lrm", 8206); // left-to-right mark, U+200E NEW RFC 2070
            EntityName.Add(8206, "lrm");
            EntityValue.Add("rlm", 8207); // right-to-left mark, U+200F NEW RFC 2070
            EntityName.Add(8207, "rlm");
            EntityValue.Add("ndash", 8211); // en dash, U+2013 ISOpub
            EntityName.Add(8211, "ndash");
            EntityValue.Add("mdash", 8212); // em dash, U+2014 ISOpub
            EntityName.Add(8212, "mdash");
            EntityValue.Add("lsquo", 8216); // left single quotation mark, U+2018 ISOnum
            EntityName.Add(8216, "lsquo");
            EntityValue.Add("rsquo", 8217); // right single quotation mark, U+2019 ISOnum
            EntityName.Add(8217, "rsquo");
            EntityValue.Add("sbquo", 8218); // single low-9 quotation mark, U+201A NEW
            EntityName.Add(8218, "sbquo");
            EntityValue.Add("ldquo", 8220); // left double quotation mark, U+201C ISOnum
            EntityName.Add(8220, "ldquo");
            EntityValue.Add("rdquo", 8221); // right double quotation mark, U+201D ISOnum
            EntityName.Add(8221, "rdquo");
            EntityValue.Add("bdquo", 8222); // double low-9 quotation mark, U+201E NEW
            EntityName.Add(8222, "bdquo");
            EntityValue.Add("dagger", 8224); // dagger, U+2020 ISOpub
            EntityName.Add(8224, "dagger");
            EntityValue.Add("Dagger", 8225); // double dagger, U+2021 ISOpub
            EntityName.Add(8225, "Dagger");
            EntityValue.Add("permil", 8240); // per mille sign, U+2030 ISOtech
            EntityName.Add(8240, "permil");
            EntityValue.Add("lsaquo", 8249); // single left-pointing angle quotation mark, U+2039 ISO proposed
            EntityName.Add(8249, "lsaquo");
            EntityValue.Add("rsaquo", 8250); // single right-pointing angle quotation mark, U+203A ISO proposed
            EntityName.Add(8250, "rsaquo");
            EntityValue.Add("euro", 8364); // euro sign, U+20AC NEW
            EntityName.Add(8364, "euro");

            MaxEntitySize = 8 + 1; // we add the # char
        }
		static ValuesController()
		{
			DefaultItems = new ConcurrentDictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
			DefaultItems.Add("key1", "value1");
			DefaultItems.Add("key2", "value2");
		}
Example #45
0
        /// <summary>
        /// Initializes the data feed for the specified job and algorithm
        /// </summary>
        public void Initialize(IAlgorithm algorithm, AlgorithmNodePacket job, IResultHandler resultHandler, IMapFileProvider mapFileProvider, IFactorFileProvider factorFileProvider)
        {
            if (!(job is LiveNodePacket))
            {
                throw new ArgumentException("The LiveTradingDataFeed requires a LiveNodePacket.");
            }

            _cancellationTokenSource = new CancellationTokenSource();

            _algorithm = algorithm;
            _job = (LiveNodePacket) job;
            _resultHandler = resultHandler;
            _timeProvider = GetTimeProvider();
            _dataQueueHandler = GetDataQueueHandler();

            _frontierTimeProvider = new ManualTimeProvider(_timeProvider.GetUtcNow());
            _customExchange = new BaseDataExchange("CustomDataExchange") {SleepInterval = 10};
            // sleep is controlled on this exchange via the GetNextTicksEnumerator
            _exchange = new BaseDataExchange("DataQueueExchange"){SleepInterval = 0};
            _exchange.AddEnumerator(DataQueueHandlerSymbol, GetNextTicksEnumerator());
            _subscriptions = new ConcurrentDictionary<Symbol, List<Subscription>>();

            _bridge = new BusyBlockingCollection<TimeSlice>();
            _universeSelection = new UniverseSelection(this, algorithm, job.Controls);

            // run the exchanges
            Task.Run(() => _exchange.Start(_cancellationTokenSource.Token));
            Task.Run(() => _customExchange.Start(_cancellationTokenSource.Token));

            // this value will be modified via calls to AddSubscription/RemoveSubscription
            var ffres = Time.OneMinute;
            _fillForwardResolution = Ref.Create(() => ffres, v => ffres = v);

            // wire ourselves up to receive notifications when universes are added/removed
            var start = _timeProvider.GetUtcNow();
            algorithm.UniverseManager.CollectionChanged += (sender, args) =>
            {
                switch (args.Action)
                {
                    case NotifyCollectionChangedAction.Add:
                        foreach (var universe in args.NewItems.OfType<Universe>())
                        {
                            _subscriptions.Add(universe.Configuration.Symbol, CreateUniverseSubscription(universe, start, Time.EndOfTime));
                            UpdateFillForwardResolution();
                        }
                        break;

                    case NotifyCollectionChangedAction.Remove:
                        foreach (var universe in args.OldItems.OfType<Universe>())
                        {
                            RemoveSubscription(universe.Configuration.Symbol);
                        }
                        break;

                    default:
                        throw new NotImplementedException("The specified action is not implemented: " + args.Action);
                }
            };
        }
        public void PairCollide()
        {
            var firstPair = new KeyValuePair<string, string>("key", "validValue");
            var secondPair = new KeyValuePair<string, string>("key", "wrongValue");

            IDictionary<string, string> dict = new ConcurrentDictionary<string, string>();
            dict.Add(firstPair);
            Assert.Throws<ArgumentException>(() => dict.Add(secondPair));

            Assert.IsTrue(dict.Contains(firstPair));
            Assert.IsFalse(dict.Contains(secondPair));
        }