public static void tokenRemove(string user, string token) { if (dicUserToken.ContainsKey(user)) { dicUserToken.Remove(user, token); } }
public ClassDescriptor ChildClassDescriptor(string currentTagName) { if (!IsPolymorphic) { return(_elementClassDescriptor); } if (polymorphClassDescriptors == null) { ResolveUnresolvedClassesAnnotation(); ResolveUnresolvedScopeAnnotation(); } if (polymorphClassDescriptors == null) { Debug.WriteLine("The " + this.Name + " field is declared polymorphic, but its polymorphic ClassDescriptor don't exist! Check annotation and is simplTypesScopes defined?"); return(null); } if (polymorphClassDescriptors.ContainsKey(currentTagName)) { ClassDescriptor result = polymorphClassDescriptors[currentTagName]; return(polymorphClassDescriptors[currentTagName]); } return(null); }
public int CatIndex(object Key) { if (!categories.ContainsKey(Key)) { return(-1); } int i = 0; foreach (res_category rc in inner_data) { if (rc.table_id == Key.ToString()) { return(i); } i++; } return(-1); }
/// <summary> /// リソースのゲット /// 無い場合はロード /// </summary> /// <typeparam name="T"></typeparam> /// <param name="directryName"></param> /// <param name="PrefabName"></param> /// <returns></returns> public T Get <T>(string directryName, string PrefabName) { // 既にロード済みなら if (DictionaryList.ContainsKey(PrefabName)) { return(DictionaryList[PrefabName].GetComponent <T>()); } else { var obj = Load(directryName, PrefabName); return(obj.GetComponent <T>()); } }
public static void clear(string key_group) { if (dicKeys.ContainsKey(key_group)) { List <string> ls = new List <string>() { }; dicKeys.TryGetValue(key_group, out ls); ObjectCache ca = MemoryCache.Default; if (ls != null && ls.Count > 0) { foreach (string li in ls) { ca.Remove(li); } } dicKeys.Remove(key_group); } }
public void LoadCustomSettings() { string _file = Utils.ConfigFile(); if (!File.Exists(_file)) { return; } string json = File.ReadAllText(_file); List <CustomPluginConfig> _configs = Utils.FromJsonToList <CustomPluginConfig>(json); foreach (CustomPluginConfig config in _configs) { if (_Plugins.ContainsKey(config.PluginId.ToString())) { PluginContainer pluginContainer = _Plugins[config.PluginId.ToString()]; pluginContainer.CustomShortcutKeys = config.CustomShortCutKeys; pluginContainer.Category = config.Category; } } }
// #TODO GetPath will be expensive !!!! public List <CodeSnippet> FindNodes(string find) { DictionaryList <CodeSnippet, string> _items = CodeLib.Instance.CodeSnippets.Where(p => LocalUtils.LastPart(p.GetPath()).ToLower().Contains(find.ToLower())).ToDictionaryList(p => p.Id); _items.RegisterLookup("PATH", p => p.GetPath()); DictionaryList <CodeSnippet, string> _paths = new DictionaryList <CodeSnippet, string>(p => p.GetPath()); foreach (CodeSnippet item in _items) { List <CodeSnippet> _parents = GetParents(item.GetPath()); foreach (CodeSnippet parent in _parents) { if (!_paths.ContainsKey(parent.GetPath()) && (_items.Lookup("PATH", parent.GetPath()).FirstOrDefault() == null)) { _paths.Add(parent); } } } _items.AddRange(_paths); return(_items.ToList()); }
public static void load() { if (!Directory.Exists(path_node)) { Directory.CreateDirectory(path_node); } else { var ds = Directory.GetFiles(path_node, "*.mmf"); for (int k = 0; k < ds.Length; k++) { m_node o = hostFile.read_MMF <m_node>(ds[k]); if (o.id != 0) { if (dic_node.ContainsKey(o.id) == false) { dic_node.Add(o.id, o); } if (dic_node_code.ContainsKey(o.code) == false) { dic_node_code.Add(o.code, o.id); } } } } if (!Directory.Exists(path_ID_parent)) { Directory.CreateDirectory(path_ID_parent); } else { var ds = Directory.GetFiles(path_ID_parent, "*.mmf"); for (int k = 0; k < ds.Length; k++) { List <long> ls = hostFile.read_file_MMF <long>(ds[k]).Distinct().ToList(); if (ls.Count > 0) { long id = ls[0]; ls = ls.Where(x => x != 0 && x != id).ToList(); if (dic_ID_parent.ContainsKey(id) == false) { dic_ID_parent.AddListDistinct(id, ls.ToArray()); } } } } if (!Directory.Exists(path_ID_node)) { Directory.CreateDirectory(path_ID_node); } else { var ds = Directory.GetFiles(path_ID_node, "*.mmf"); for (int k = 0; k < ds.Length; k++) { List <long> ls = hostFile.read_file_MMF <long>(ds[k]).Distinct().ToList(); if (ls.Count > 0) { long id = ls[0]; ls = ls.Where(x => x != 0 && x != id).ToList(); if (dic_ID_node.ContainsKey(id) == false) { dic_ID_node.AddListDistinct(id, ls.ToArray()); } } } } if (!Directory.Exists(path_ID_device_all)) { Directory.CreateDirectory(path_ID_device_all); } else { var ds = Directory.GetFiles(path_ID_device_all, "*.mmf"); for (int k = 0; k < ds.Length; k++) { List <long> ls = hostFile.read_file_MMF <long>(ds[k]).Distinct().ToList(); if (ls.Count > 0) { long id = ls[0]; ls = ls.Where(x => x != 0 && x != id).ToList(); if (dic_ID_device_all.ContainsKey(id) == false) { dic_ID_device_all.AddListDistinct(id, ls.ToArray()); } } } } if (!Directory.Exists(path_ID_device_near)) { Directory.CreateDirectory(path_ID_device_near); } else { var ds = Directory.GetFiles(path_ID_device_near, "*.mmf"); for (int k = 0; k < ds.Length; k++) { List <long> ls = hostFile.read_file_MMF <long>(ds[k]).Distinct().ToList(); if (ls.Count > 0) { long id = ls[0]; ls = ls.Where(x => x != 0 && x != id).ToList(); if (dic_ID_device_near.ContainsKey(id) == false) { dic_ID_device_near.AddListDistinct(id, ls.ToArray()); } } } } cache_node_id(1); }
public void TickServer(float dt, byte[] recvBuffer, ref NetIOMetrics reliableChannelMetrics, ref NetIOMetrics unreliableChannelMetrics) { Perf.Begin("SocketNetDriver.TickServer"); for (;;) { Socket newSocket; try { newSocket = _serverSock[0].Accept(); } catch (SocketException) { break; } if (_tcpConnections.ContainsKey(newSocket.RemoteEndPoint)) { Debug.LogError("Connection attempt from already connected client!"); newSocket.Close(); continue; } var clientSocks = new Socket[2]; clientSocks[0] = newSocket; clientSocks[1] = _serverSock[1]; newSocket.Blocking = false; //newSocket.NoDelay = true; newSocket.SendBufferSize = World.MAX_RELIABLE_MESSAGE_SIZE * 8; newSocket.SendTimeout = 500; var newConn = new SocketNetDriverConnection(this, clientSocks, nextChannelID++); _tcpConnections.Add(newSocket.RemoteEndPoint, newConn); SendTcpControl(newConn); } for (int i = 0; i < _tcpConnections.Values.Count;) { var c = _tcpConnections.Values[i]; bool wasReset = false; bool isDisposed = false; try { wasReset = c.sockets[0].Poll(0, SelectMode.SelectRead); } catch (Exception) { isDisposed = true; } if (isDisposed || (wasReset && (c.sockets[0].Available == 0))) { c.Dispose(); continue; } Recv(c, _serverCallbacks, c.sockets[0], recvBuffer, ref reliableChannelMetrics, false); if (c.isValid && !c.didHandshake) { c.handshakeTime += dt; if (c.handshakeTime > UDP_CONTROL_DISCONNECT_TIMEOUT) { // handshake failed Debug.LogError("Disconnecting " + c.tcpEndpoint.ToString() + ": udp handshake timed out"); c.Dispose(); } } if (c.isValid) { ++i; } } RecvFrom(_serverCallbacks, _serverSock[1], recvBuffer, ref unreliableChannelMetrics); Perf.End(); }
public static void load() { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string path_file = path + file_name + ".mmf"; list = hostFile.read_file_MMF <m_kh_nhom>(path_file).ToList(); string p_index = hostServer.pathRoot + @"db_kh_nhom_index\"; if (!Directory.Exists(p_index)) { Directory.CreateDirectory(p_index); } else { var ds = Directory.GetFiles(p_index, "*.mmf"); for (int k = 0; k < ds.Length; k++) { string arr = hostFile.readFile(ds[k], Encoding.ASCII); string key = arr.Split(';')[0]; long id = key.TryParseToLong(); arr = arr.Substring(key.Length, arr.Length - key.Length); if (!dic_Nhom_Index.ContainsKey(id)) { dic_Nhom_Index.Add(id, arr); } } } string p_item = hostServer.pathRoot + @"db_kh_nhom_item\"; if (!Directory.Exists(p_item)) { Directory.CreateDirectory(p_item); } else { var ds = Directory.GetFiles(p_item, "*.mmf"); for (int k = 0; k < ds.Length; k++) { string arr = hostFile.readFile(ds[k], Encoding.ASCII); string key = arr.Split(';')[0]; List <long> aids = arr.Split(';').Select(x => x.TryParseToLong()).ToList(); if (aids.Count > 0) { aids.RemoveAt(0); if (aids.Count > 0) { long id = key.TryParseToLong(); arr = arr.Substring(key.Length, arr.Length - key.Length); if (!dic_Nhom_Item.ContainsKey(id)) { dic_Nhom_Item.Add(id, aids); } } } } } }
public void CtorOrdinalIgnoreCaseComparerCopiesItemsFromAnotherDictionaryList() { var sample = new DictionaryList<string, object>(new DictionaryList<string, object> { { "key1", new List<object> { "value1"} }, { "key2", new List<object> { "value2"} }, { "key3", new List<object> { 33} } }, StringComparer.OrdinalIgnoreCase); Assert.AreEqual(3, sample.Count); Assert.IsTrue(sample.ContainsKey("key1")); Assert.IsTrue(sample.ContainsKey("key2")); Assert.IsTrue(sample.ContainsKey("key3")); Assert.IsTrue(sample.ContainsKey("KEY1")); Assert.IsTrue(sample.ContainsKey("KEy2")); Assert.IsTrue(sample.ContainsKey("kEY3")); }
public void CtorCopiesItemsFromAnotherDictionary() { var sample = new DictionaryList<string, object>(new Dictionary<string, IList<object>> { { "key1", new List<object>{ "value1"} }, { "key2", new List<object>{ "value2"} }, { "key3", new List<object>{ 33 } } }); Assert.AreEqual(3, sample.Count); Assert.IsTrue(sample.ContainsKey("key1")); Assert.IsTrue(sample.ContainsKey("key2")); Assert.IsTrue(sample.ContainsKey("key3")); Assert.IsFalse(sample.ContainsKey("KEY1")); Assert.IsFalse(sample.ContainsKey("KEy2")); Assert.IsFalse(sample.ContainsKey("kEY3")); }
public void CtorWithCapacityAndOrdinalIgnoreCaseComparerCorrectlyInitializesDictionary() { var sample = new DictionaryList<string, object>(100, StringComparer.OrdinalIgnoreCase) { { "key1", "value1" }, { "key2", "value2" }, { "key3", 33 } }; Assert.AreEqual(3, sample.Count); Assert.IsTrue(sample.ContainsKey("key1")); Assert.IsTrue(sample.ContainsKey("key2")); Assert.IsTrue(sample.ContainsKey("key3")); Assert.IsTrue(sample.ContainsKey("KEY1")); Assert.IsTrue(sample.ContainsKey("KEy2")); Assert.IsTrue(sample.ContainsKey("kEY3")); }
public void CtorWithCapacityCorrectlyInitializesDictionary() { var sample = new DictionaryList<string, object>(100) { { "key1", "value1" }, { "key2", "value2" }, { "key3", 33 } }; Assert.AreEqual(3, sample.Count); Assert.IsTrue(sample.ContainsKey("key1")); Assert.IsTrue(sample.ContainsKey("key2")); Assert.IsTrue(sample.ContainsKey("key3")); Assert.IsFalse(sample.ContainsKey("KEY1")); Assert.IsFalse(sample.ContainsKey("KEy2")); Assert.IsFalse(sample.ContainsKey("kEY3")); }