public void Add(ref keyType key, string text) { if (!string.IsNullOrEmpty(text)) { queue.Add(ref key, text); } }
/// <summary> /// 添加新的数据 /// </summary> /// <param name="key">数据标识</param> /// <param name="values">分词结果</param> public void Add(ref keyType key, ReusableDictionary <HashString, ResultIndexLeftArray> values) { WordCounterIndex counterIndex; ResultIndexArray resultIndex = default(ResultIndexArray); foreach (KeyValue <HashString, ResultIndexLeftArray> result in values.KeyValues) { if (!results.TryGetValue(result.Key, out counterIndex)) { counterIndex.Index = counterPool.Get(out counterIndex.Array); results.Set(result.Key, counterIndex); counterIndex.CreateResult(); } if ((flags & SearchFlags.ResultIndexs) == 0) { resultIndex.Set(EmptyArray <int> .Array, result.Value.TextLength); counterIndex.Add(key, result.Value.WordType, ref resultIndex); ++WordCount; } else { resultIndex.Set(result.Value.Indexs.GetArray(), result.Value.TextLength); counterIndex.Add(key, result.Value.WordType, ref resultIndex); WordCount += result.Value.Indexs.Length; } } ++Version; }
/// <summary> /// 获取数据 /// </summary> /// <param name="queue"></param> /// <param name="key"></param> /// <param name="isValue"></param> internal FindTask(QueueList <valueType, modelType, counterKeyType, keyType> queue, keyType key, Func <valueType, bool> isValue) { this.queue = queue; this.key = key; this.isValue = isValue; wait.Set(0); }
/// <summary> /// 获取缓存数据 /// </summary> /// <param name="queue"></param> /// <param name="key">关键字</param> /// <param name="dictionaryKey">字典关键字</param> /// <param name="nullValue">失败返回值</param> internal GetByKeyAwaiter(QueueDictionary <valueType, modelType, counterKeyType, keyType, dictionaryKeyType> queue, keyType key, dictionaryKeyType dictionaryKey, valueType nullValue) { this.queue = queue; this.key = key; this.dictionaryKey = dictionaryKey; this.nullValue = nullValue; }
/// <summary> /// 检索指定项关联的所有值 /// </summary> /// <param name="keytype">基项枚举</param> /// <param name="key">指定项字符串</param> /// <returns>返回指定项关联的所有值的字符串数组</returns> public string[] getValues(keyType keytype, string key) { RegistryKey rk = (RegistryKey)getRegistryKey(keytype); RegistryKey rkt = rk.OpenSubKey(key); if (rkt != null) { string[] names = rkt.GetValueNames(); if (names.Length == 0) { return(names); } else { string[] values = new string[names.Length]; int i = 0; foreach (string name in names) { values[i] = rkt.GetValue(name).ToString(); i++; } return(values); } } else { throw (new Exception("指定项不存在")); } }
/// <summary> /// 返回RegistryKey对象 /// </summary> /// <param name="keytype">注册表基项枚举</param> /// <returns></returns> private object getRegistryKey(keyType keytype) { RegistryKey rk = null; switch (keytype) { case keyType.HKEY_CLASS_ROOT: rk = Registry.ClassesRoot; break; case keyType.HKEY_CURRENT_USER: rk = Registry.CurrentUser; break; case keyType.HKEY_LOCAL_MACHINE: rk = Registry.LocalMachine; break; case keyType.HKEY_USERS: rk = Registry.Users; break; case keyType.HKEY_CURRENT_CONFIG: rk = Registry.CurrentConfig; break; } return(rk); }
/// <summary> /// 获取数据 /// </summary> /// <param name="queue"></param> /// <param name="key">关键字</param> /// <param name="dictionaryKey">字典关键字</param> internal GetTask(QueueDictionary <valueType, modelType, counterKeyType, keyType, dictionaryKeyType> queue, keyType key, dictionaryKeyType dictionaryKey) { this.queue = queue; this.key = key; this.dictionaryKey = dictionaryKey; wait.Set(0); }
/// <summary> /// 获取数据 /// </summary> /// <param name="queue"></param> /// <param name="node"></param> /// <param name="key"></param> internal GetTask(MemberQueue <valueType, modelType, memberCacheType, keyType> queue, memberCacheType node, keyType key) { this.queue = queue; this.node = node; this.key = key; wait.Set(0); }
/// <summary> /// 查找节点 /// </summary> /// <param name="node"></param> /// <param name="value"></param> internal SearchNode(ref Node node, out valueType value) { HashCode = node.HashCode; Key = node.Key; Index = int.MaxValue; value = node.Value; }
public dmParameters GetDataManagerParameters() { string tmpString = string.Format("<<{0}.{1}:{2}>>", new string[] { cmbField.Text, cmbModifier.Text, txtTextValue.Text }); keyType tmpKeyType = Global.GetKeyType(cmbField.Text); if (cmbModifier.Text == "Calc") { userInfo.AddAutoComplete(cmbField.Text + "_Calc", txtTextValue.Text); } else { switch (tmpKeyType) { case keyType.List: case keyType.String: userInfo.AddAutoComplete(cmbField.Text, txtTextValue.Text); break; } } if (this.ParameterTypeRestriction == ParameterType.Rule) { return(new dmRule(tmpString)); } else { return(new dmAction(tmpString)); } }
private static string[] GetAcceptedValues(keyType ktType) { List <string> arrAllowedValues = new List <string>(); switch (ktType) { case keyType.Bool: arrAllowedValues = new List <string>(new string[] { "True", "False" }); break; case keyType.LanguageISO: arrAllowedValues = new List <string>(LanguageISOs.Keys.ToArray()); break; case keyType.YesNo: arrAllowedValues = new List <string>(new string[] { "", "Yes", "No" }); break; case keyType.MangaYesNo: arrAllowedValues = new List <string>(new string[] { "", "Yes", "No", "YesAndRightToLeft" }); break; default: break; } return(arrAllowedValues.ToArray()); }
private void createNewKeyEvent(int pos, keyType type) { Key key = new Key(); key.pos = pos; key.type = type; _keyEvents.Add(key); }
public void Update(ref keyType key, string text, string oldText = null) { Remove(ref key, oldText); if (!string.IsNullOrEmpty(text)) { queue.Add(ref key, text); } }
internal int GetLinkWhereNull(keyType letter, ref int node, ref int link) { if (Nodes == null || Nodes.Count == 0 || !Nodes.TryGetValue(letter, out node)) { return(link = Link); } return(0); }
/// <summary> /// 设置数据 /// </summary> /// <param name="node"></param> /// <param name="value"></param> /// <param name="source"></param> internal void Set(ref SearchNode node, valueType value, uint source) { HashCode = node.HashCode; Next = int.MaxValue; Key = node.Key; Value = value; Source = source; }
internal int GetNodeOrLink(keyType letter, ref int node, ref int link, out valueType value) { value = Value; if (Nodes == null || Nodes.Count == 0 || !Nodes.TryGetValue(letter, out node)) { return(link = Link); } return(0); }
internal int GetLinkWhereNull(keyType letter, ref int node, ref int link) { if (Nodes.Length == 0 || (node = GetNode(letter)) == 0) { link = Link; return(0); } return(1); }
internal int GetNodeOrLink(keyType letter, ref int node, ref int link, out valueType value) { value = Value; if (Nodes.Length == 0 || (node = GetNode(letter)) == 0) { link = Link; return(0); } return(1); }
public FliterSettingPage(keyType _fliterType, string type, object value, string key) { InitializeComponent(); fliterType = _fliterType; this.Text = "设置过滤器 - " + key; switch (fliterType) { case keyType.KEY_STRING: if (type == "d") { fliterInputBox.Text = "请输入要查找的文字,所有包含这串文字的项目都会被显示出来。"; fliterTypeBox.Items.Remove(">"); fliterTypeBox.Items.Remove("<"); } else { fliterInputBox.Text = (string)value; fliterTypeBox.SelectedItem = fliterTypeBox.Items[0]; } break; case keyType.KEY_NUMBER: if (type == "d") { fliterInputBox.Text = "请输入要比较的数值并选择比较类型。所有符合条件的项目都会被显示。"; } else { fliterInputBox.Text = ((double)value).ToString(); fliterTypeBox.SelectedItem = fliterTypeBox.Items[fliterTypeBox.Items.IndexOf(type)]; } break; case keyType.KEY_DATETIME: if (type == "d") { fliterInputBox.Text = "请输入要比较的日期并选择比较类型。日期请用形如" + DateTime.Now.ToString("yyyy/MM/dd") + "的方式输入。"; } else { fliterInputBox.Text = ((DateTime)value).ToString("yyyy/MM/dd"); fliterTypeBox.SelectedItem = fliterTypeBox.Items[fliterTypeBox.Items.IndexOf(type)]; } break; } }
/// <summary> /// 添加数据 /// </summary> /// <param name="value">数据对象</param> public void onInserted(valueType value) { keyValue <keyType, list <valueType> > list; keyType key = getKey(value); if (!groups.TryGetValue(key, out list)) { groups.Add(key, list = new keyValue <keyType, list <valueType> >(key, new list <valueType>())); } list.Value.Add(value); }
/// <summary> /// 删除关键字 /// </summary> /// <param name="key">关键字</param> /// <returns>删除结果数量</returns> public int Remove(keyType key) { int[] indexs; if (Values.TryGetValue(key, out indexs)) { Values.Remove(key); Count -= indexs.Length; return(indexs.Length); } return(0); }
private void txtMultiValue_TextChanged(object sender, EventArgs e) { if (cmbField.SelectedIndex < 0 || cmbModifier.SelectedIndex < 0) { return; } keyType FieldType = Global.GetKeyType(cmbField.Text); switch (FieldType) { case keyType.Custom: case keyType.String: case keyType.List: switch (cmbModifier.Text) { case "IsAnyOf": case "NotIsAnyOf": case "StartsWithAnyOf": case "NotStartsWithAnyOf": case "ContainsAnyOf": case "NotContainsAnyOf": case "ContainsAllOf": case "Add": txtTextValue.Text = txtMultiValue.Text; break; default: break; } break; case keyType.Numeric: switch (cmbModifier.Text) { case "IsAnyOf": case "NotIsAnyOf": txtTextValue.Text = txtMultiValue.Text; break; default: break; } break; case keyType.LanguageISO: txtTextValue.Text = txtMultiValue.Text; break; default: break; } }
/// <summary> /// 添加数据 /// </summary> /// <param name="value">数据对象</param> /// <param name="cache">缓存对象</param> public void onInserted(valueType value, dictionaryList <valueType, memberType, keyType> cache) { keyValue <keyType, list <valueType> > list; keyType key = getKey(value); if (!groups.TryGetValue(key, out list)) { groups.Add(key, list = new keyValue <keyType, list <valueType> >(key, new list <valueType>())); ++cache.keyVersion; } list.Value.Add(value); }
/// <summary> /// 添加新的数据 /// </summary> /// <param name="key"></param> /// <param name="text"></param> internal void Add(ref keyType key, string text) { getResult(text); if (result.Count != 0) { searcher.add(ref key, text, result); indexArrays.PrepLength(result.Count); foreach (ResultIndexLeftArray indexArray in result.Values) { indexArrays.UnsafeAdd(indexArray.Indexs.Array); } } }
/// <summary> /// 判断指定项是否存在 /// </summary> /// <param name="keytype">基项枚举</param> /// <param name="key">指定项字符串</param> /// <returns>返回布尔值,说明指定项是否存在</returns> public bool isExist(keyType keytype, string key) { RegistryKey rk = (RegistryKey)getRegistryKey(keytype); if (rk.OpenSubKey(key) == null) { return(false); } else { return(true); } }
/// <summary> /// 添加数据 /// </summary> /// <param name="value">数据对象</param> public void onInserted(valueType value) { keyType key = getKey(value); group values; if (!groups.TryGetValue(key, out values)) { groups.Add(key, values = new group { Key = key, List = new list <valueType>(), Index = 0 }); } values.List.Add(value); }
/// <summary> /// 获取文本的匹配索引位置 /// </summary> /// <param name="key">数据关键字</param> /// <param name="text">数据文本</param> /// <param name="maxLength">最大长度</param> /// <returns>匹配索引位置集合</returns> public unsafe KeyValue <int, int>[] FormatTextIndexs(ref keyType key, ref SubString text, int maxLength) { int size = ((text.Length + 63) >> 3) & (int.MaxValue - 7); if (getResultIndexsMapBuffer.ByteSize < size) { Unmanaged.Free(ref getResultIndexsMapBuffer); getResultIndexsMapBuffer = Unmanaged.GetPointer(size, true); } int count = searcher.FormatTextIndexs(ref key, ref text, ref queryResult, maxLength, ref resultIndexs, ref getResultIndexsMapBuffer); return(new LeftArray <KeyValue <int, int> >(count, resultIndexs).GetArray()); }
/// <summary> /// 添加新的数据 /// </summary> /// <param name="key">数据标识</param> /// <param name="values">分词结果</param> public void Remove(ref keyType key, HashSet <HashString> values) { WordCounterIndex counterIndex; foreach (HashString result in values) { if (results.TryGetValue(result, out counterIndex)) { WordCount -= counterIndex.Remove(key); } } ++Version; }
/// <summary> /// 添加数据 /// </summary> /// <param name="value">数据对象</param> /// <param name="cache">缓存对象</param> public void onInserted(valueType value, dictionaryListOrderLady <valueType, modelType, keyType> cache) { keyType key = getKey(value); group values; if (!groups.TryGetValue(key, out values)) { groups.Add(key, values = new group { Key = key, List = new list <valueType>(), Index = 0 }); ++cache.keyVersion; } values.List.Add(value); }
private void txtReplaceNewValue_TextChanged(object sender, EventArgs e) { if (cmbField.SelectedIndex < 0 || cmbModifier.SelectedIndex < 0) { return; } keyType tmpKey = Global.GetKeyType(cmbField.Text); if ((tmpKey == keyType.List || tmpKey == keyType.String) && cmbModifier.Text.Contains("Replace")) { txtTextValue.Text = txtReplaceOldValue.Text + Global.DELIMITER + txtReplaceNewValue.Text; } }
/// <summary> /// 删除注册表中的指定项 /// </summary> /// <param name="keytype">注册表基项枚举</param> /// <param name="key">注册表中的项,不包括基项</param> /// <returns>返回布尔值,指定操作是否成功</returns> public bool deleteSubKey(keyType keytype, string key) { try { RegistryKey rk = (RegistryKey)getRegistryKey(keytype); rk.DeleteSubKeyTree(key); return true; } catch { return false; } }
/// <summary> /// 删除注册表中的指定项 /// </summary> /// <param name="keytype">注册表基项枚举</param> /// <param name="key">注册表中的项,不包括基项</param> /// <returns>返回布尔值,指定操作是否成功</returns> public bool deleteSubKey(keyType keytype, string key) { try { RegistryKey rk = (RegistryKey)getRegistryKey(keytype); RegistryKey software = rk.OpenSubKey("Software", true); software.DeleteSubKeyTree(key); return true; } catch { return false; } }
/// <summary> /// 判断指定项是否存在 /// </summary> /// <param name="keytype">基项枚举</param> /// <param name="key">指定项字符串</param> /// <returns>返回布尔值,说明指定项是否存在</returns> public bool isExist(keyType keytype, string key) { RegistryKey rk = (RegistryKey)getRegistryKey(keytype); if (rk.OpenSubKey(key) == null) return false; else return true; }
/// <summary> /// 读取注册表 /// </summary> /// <param name="keytype">注册表基项枚举</param> /// <param name="key">注册表项,不包括基项</param> /// <param name="name">值名称</param> /// <returns>返回字符串</returns> public string getValue(keyType keytype, string key, string name) { try { RegistryKey rk = (RegistryKey)getRegistryKey(keytype); RegistryKey software = rk.OpenSubKey("Software", true); RegistryKey rkt = software.OpenSubKey(key); if (rkt != null) return rkt.GetValue(name).ToString(); else throw (new Exception("无法找到指定项")); } catch (Exception ex) { return ex.Message; } }
/// <summary> /// 检索指定项关联的所有值 /// </summary> /// <param name="keytype">基项枚举</param> /// <param name="key">指定项字符串</param> /// <returns>返回指定项关联的所有值的字符串数组</returns> public string[] getValues(keyType keytype, string key) { RegistryKey rk = (RegistryKey)getRegistryKey(keytype); RegistryKey software = rk.OpenSubKey("Software", true); RegistryKey rkt = software.OpenSubKey(key); if (rkt != null) { string[] names = rkt.GetValueNames(); if (names.Length == 0) return names; else { string[] values = new string[names.Length]; int i = 0; foreach (string name in names) { values[i] = rkt.GetValue(name).ToString(); i++; } return values; } } else { throw (new Exception("指定项不存在")); } }
/// <summary> /// 判断指定项是否存在 /// </summary> /// <param name="keytype">基项枚举</param> /// <param name="key">指定项字符串</param> /// <returns>返回布尔值,说明指定项是否存在</returns> public bool isExist(keyType keytype, string key) { RegistryKey rk = (RegistryKey)getRegistryKey(keytype); RegistryKey software = rk.OpenSubKey("Software", true); if (software.OpenSubKey(key) == null) return false; else return true; }
/// <summary> /// 删除注册表中的值 /// </summary> /// <param name="keytype">注册表基项枚举</param> /// <param name="key">注册表项名称,不包括基项</param> /// <param name="name">值名称</param> /// <returns>返回布尔值,指定操作是否成功</returns> public bool deleteValue(keyType keytype, string key, string name) { try { RegistryKey rk = (RegistryKey)getRegistryKey(keytype); RegistryKey software = rk.OpenSubKey("Software", true); RegistryKey rkt = software.OpenSubKey(key, true); if (rkt != null) rkt.DeleteValue(name, true); else throw (new Exception("无法找到指定项")); return true; } catch { return false; } }
/// <summary> /// 返回RegistryKey对象 /// </summary> /// <param name="keytype">注册表基项枚举</param> /// <returns></returns> private object getRegistryKey(keyType keytype) { RegistryKey rk = null; switch (keytype) { case keyType.HKEY_CLASS_ROOT: rk = Registry.ClassesRoot; break; case keyType.HKEY_CURRENT_USER: rk = Registry.CurrentUser; break; case keyType.HKEY_LOCAL_MACHINE: rk = Registry.LocalMachine; break; case keyType.HKEY_USERS: rk = Registry.Users; break; case keyType.HKEY_CURRENT_CONFIG: rk = Registry.CurrentConfig; break; } return rk; }
/// <summary> /// 写入注册表,如果指定项已经存在,则修改指定项的值 /// </summary> /// <param name="keytype">注册表基项枚举</param> /// <param name="key">注册表项,不包括基项</param> /// <param name="name">值名称</param> /// <param name="values">值</param> /// <returns>返回布尔值,指定操作是否成功</returns> public bool setValue(keyType keytype, string key, string name, string values) { try { RegistryKey rk = (RegistryKey)getRegistryKey(keytype); RegistryKey software = rk.OpenSubKey("Software", true); RegistryKey rkt = software.CreateSubKey(key); if (rkt != null) rkt.SetValue(name, values); else { throw (new Exception("要写入的项不存在")); } return true; } catch { return false; } }