Ejemplo n.º 1
0
        private void LoadDictionaries()
        {
            string sql = "SELECT [ID],[Prefix],[Key],[ParentID] FROM IDTable";
            string connectionString =
                ConfigurationManager.ConnectionStrings[_databaseConnectionStringName].ConnectionString;

            List <IDTableEntry> idTableEntries = new List <IDTableEntry>();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();

                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            idTableEntries.Add(
                                new IDTableEntry(
                                    reader.GetString(1),
                                    reader.GetString(2),
                                    ID.Parse(reader.GetGuid(0)),
                                    ID.Parse(reader.GetGuid(3)),
                                    ""
                                    ));
                        }
                    }
                }
            }

            _idByKey = new Dictionary <IdTableStringKey, IDTableEntry>();

            _idById = new Dictionary <IdTableIdKey, List <IDTableEntry> >();

            foreach (IDTableEntry entry in idTableEntries)
            {
                IdTableStringKey idTableStringKey = new IdTableStringKey(entry.Prefix, entry.Key);

                if (!_idByKey.ContainsKey(idTableStringKey))
                {
                    _idByKey.Add(idTableStringKey, entry);
                }

                IdTableIdKey idTableIdKey = new IdTableIdKey(entry.Prefix, entry.ID.Guid);

                if (!_idById.ContainsKey(idTableIdKey))
                {
                    _idById.Add(idTableIdKey, new List <IDTableEntry> {
                        entry
                    });
                }
                else
                {
                    _idById[idTableIdKey].Add(entry);
                }
            }
        }
Ejemplo n.º 2
0
        public override bool Equals(object obj)
        {
            IdTableStringKey idTableStringKey = obj as IdTableStringKey;

            if (idTableStringKey != null)
            {
                return(idTableStringKey.InternalKey == this.InternalKey);
            }

            return(false);
        }
Ejemplo n.º 3
0
        public override IDTableEntry GetID(string prefix, string key)
        {
            var idTableStringKey = new IdTableStringKey(prefix, key);

            if (_idByKey.ContainsKey(idTableStringKey))
            {
                return _idByKey[idTableStringKey];
            }

            return null;
        }
Ejemplo n.º 4
0
        public override IDTableEntry GetID(string prefix, string key)
        {
            var idTableStringKey = new IdTableStringKey(prefix, key);

            if (_idByKey.ContainsKey(idTableStringKey))
            {
                return(_idByKey[idTableStringKey]);
            }

            return(null);
        }
Ejemplo n.º 5
0
        public IDTableEntry GetID(string prefix, string key)
        {
            var idTableStringKey = new IdTableStringKey(prefix, key);

            //if (_idByKey.ContainsKey(idTableStringKey))
            //{
            //    return _idByKey[idTableStringKey];
            //}

            _idByKey[idTableStringKey] = IDTable.GetID(prefix, key);

            return _idByKey[idTableStringKey];
        }
Ejemplo n.º 6
0
        public IDTableEntry GetID(string prefix, string key)
        {
            var idTableStringKey = new IdTableStringKey(prefix, key);

            //if (_idByKey.ContainsKey(idTableStringKey))
            //{
            //    return _idByKey[idTableStringKey];
            //}

            _idByKey[idTableStringKey] = IDTable.GetID(prefix, key);

            return(_idByKey[idTableStringKey]);
        }
Ejemplo n.º 7
0
        public override void Add(IDTableEntry entry)
        {
            var idTableStringKey = new IdTableStringKey(entry.Prefix, entry.Key);

            if (!_idByKey.ContainsKey(idTableStringKey))
            {
                _idByKey[idTableStringKey] = entry;
            }

            var key = new IdTableIdKey(entry.Prefix, entry.ID.Guid);

            if (!_idById.ContainsKey(key))
            {
                _idById.Add(key, new List<IDTableEntry> {entry});
            }
        }
Ejemplo n.º 8
0
        public override void Add(IDTableEntry entry)
        {
            var idTableStringKey = new IdTableStringKey(entry.Prefix, entry.Key);

            if (!_idByKey.ContainsKey(idTableStringKey))
            {
                _idByKey[idTableStringKey] = entry;
            }

            var key = new IdTableIdKey(entry.Prefix, entry.ID.Guid);

            if (!_idById.ContainsKey(key))
            {
                _idById.Add(key, new List <IDTableEntry> {
                    entry
                });
            }
        }
Ejemplo n.º 9
0
        internal IDTableEntry Add(string prefix, string key, ID id, ID parentId)
        {
            var idTableIdKey = new IdTableIdKey(prefix, id.Guid);

            var tableEntry = new IDTableEntry(prefix, key, id, parentId, "");

            if (!_idById.ContainsKey(idTableIdKey))
            {
                _idById.Add(idTableIdKey, new List <IDTableEntry> {
                    tableEntry
                });
            }

            var idTableStringKey = new IdTableStringKey(prefix, key);

            if (!_idByKey.ContainsKey(idTableStringKey))
            {
                _idByKey[idTableStringKey] = tableEntry;
            }

            return(IDTable.Add(prefix, key, id, parentId));
        }
Ejemplo n.º 10
0
        internal IDTableEntry Add(string prefix, string key, ID id, ID parentId)
        {
            var idTableIdKey = new IdTableIdKey(prefix, id.Guid);

            var tableEntry = new IDTableEntry(prefix, key, id, parentId, "");

            if (!_idById.ContainsKey(idTableIdKey))
            {
                _idById.Add(idTableIdKey, new List<IDTableEntry> { tableEntry });
            }

            var idTableStringKey = new IdTableStringKey(prefix, key);

            if (!_idByKey.ContainsKey(idTableStringKey))
            {
                _idByKey[idTableStringKey] = tableEntry;
            }

            return IDTable.Add(prefix, key, id, parentId);
        }
Ejemplo n.º 11
0
        private void LoadDictionaries()
        {
            string sql = "SELECT [ID],[Prefix],[Key],[ParentID] FROM IDTable";
            string connectionString =
                ConfigurationManager.ConnectionStrings[_databaseConnectionStringName].ConnectionString;

            List<IDTableEntry> idTableEntries = new List<IDTableEntry>();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();

                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            idTableEntries.Add(
                                new IDTableEntry(
                                    reader.GetString(1),
                                    reader.GetString(2),
                                    ID.Parse(reader.GetGuid(0)),
                                    ID.Parse(reader.GetGuid(3)),
                                    ""
                                    ));
                        }
                    }
                }
            }

            _idByKey = new Dictionary<IdTableStringKey, IDTableEntry>();

            _idById = new Dictionary<IdTableIdKey, List<IDTableEntry>>();

            foreach (IDTableEntry entry in idTableEntries)
            {
                IdTableStringKey idTableStringKey = new IdTableStringKey(entry.Prefix, entry.Key);

                if (!_idByKey.ContainsKey(idTableStringKey))
                {
                    _idByKey.Add(idTableStringKey, entry);
                }

                IdTableIdKey idTableIdKey = new IdTableIdKey(entry.Prefix, entry.ID.Guid);

                if (!_idById.ContainsKey(idTableIdKey))
                {
                    _idById.Add(idTableIdKey, new List<IDTableEntry> { entry });
                }
                else
                {
                    _idById[idTableIdKey].Add(entry);
                }
            }
        }
Ejemplo n.º 12
0
        public override void Remove(string prefix, string key)
        {
            var idTableStringKey = new IdTableStringKey(prefix, key);

            _idByKey.Remove(idTableStringKey);
        }
Ejemplo n.º 13
0
        public override void Remove(string prefix, string key)
        {
            var idTableStringKey = new IdTableStringKey(prefix, key);

            _idByKey.Remove(idTableStringKey);
        }