private void Sort(long start, long number, KeyString keyfunction) { PTypeSequence pts = (PTypeSequence)typ; if (number < 2) { return; // сортировать не нужно } if (number < 10000000) { // Указатель на начальный элемент и размер головы записи PxEntry e = this.Element(start); long p0 = e.offset; int size = pts.ElementType.HeadSize; // организуем массивы ключей и индексов - номеров записей string[] keys = new string[number]; int[] indexes = Enumerable.Range(0, (int)number).ToArray(); // Вычислим и запишем ключи for (long ii = 0; ii < number; ii++) { keys[ii] = keyfunction(e); e.offset += size; } // Сортируем два массива Array.Sort(keys, indexes); ReorderSequenceArrayHeads(number, p0, size, indexes); } else { } }
private byte[] ValidateKeyString() { byte[] key; switch (KeyFormat) { case TextFormatEnum.PlainText: if (KeyString.Length >= 8) { key = Encoding.Default.GetBytes(KeyString).Take(8).ToArray(); // take 8 first bytes to get 64 bit key } else { throw new Exception("Key is too short"); } break; case TextFormatEnum.Hexadecimal: byte[] tmp = KeyString.ConvertHexadecimalStringToByteArray(); if (tmp.Count() == 8) { key = tmp; } else { throw new Exception("Key is too short"); } break; default: key = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; break; } return(key); }
public CaseModel Func_DeleteKey() { return(new CaseModel() { NameSign = @"删除键", ExeEvent = () => { string section = RandomData.Item(new List <string>(this.dic.Keys)); VerifyIList <KeyString, KeyString> verify = new VerifyIList <KeyString, KeyString>(CalcWayEnum.DoubleCycle) { Func_isEquals = (a, s) => a.Key == s.Key && a.Value == s.Value, }; verify.Answer = this.dic[section]; verify.Source = this.ini.GetKeyValues(section); if (!verify.Calc()) { return false; } KeyString ks = RandomData.Item(this.dic[section]); List <KeyString> kss = new List <KeyString>(this.dic[section]); kss.Remove(ks); this.dic[section] = kss.ToArray(); this.ini.DeleteKey(section, ks.Key); verify.Answer = this.dic[section]; verify.Source = this.ini.GetKeyValues(section); if (!verify.Calc()) { return false; } return true; }, }); }
public KeyString setString(string key, string value) { KeyString ks = getString(key, true); ks.value = value; return(ks); }
public CaseModel Func_GetValue_SetValue() { return(new CaseModel() { NameSign = @"获取/设置值", ExeEvent = () => { GS answer = new GS() { Age = RandomData.GetInt(), DateOfBirth = RandomData.GetDateTime(), Name = RandomData.GetChineseString(), Price = RandomData.GetDouble(), Sex = RandomData.Item(EnumInfo.GetALLItem <GS.SexEnum>()), }; GS result = new GS(); ShineUponParser parser = new ShineUponParser(typeof(GS)); foreach (ShineUponInfo info in parser.GetDictionary().Values) { KeyString ks = parser.GetValue_KeyString(info, answer); parser.SetValue_Object(info, result, ks.Value); } return true; }, }); }
public LookupModuleMessage(KeyString dataOwnerKey, KeyString moduleKey, SemanticVersionNumber dataOwnerVersion = null, SemanticVersionNumber moduleVersion = null) { DataOwnerKey = dataOwnerKey; DataOwnerVersion = dataOwnerVersion; ModuleKey = moduleKey; ModuleVersion = moduleVersion; }
public override void Runing() { GiveLast = false; OutRoom = LastRoom; KeyString.Clear(); KeyNames.Clear(); foreach (var item in Controller.ControllerKeys) { KeyString.Add(string.Format("<{0}>: <{1}>", item.Key, item.Value)); KeyNames.Add(item.Key); } SelectIndex = 0; DeBugRun(); SelectIndex = PrintHelper.PrintSelectText(KeyString, SelectIndex); if (SelectIndex > KeyString.Count - 1) { string KeySave = Newtonsoft.Json.JsonConvert.SerializeObject(Controller.ControllerKeys); JsonHelper.SaveMyJson(Directory.GetCurrentDirectory(), KeySave, "KeySetting"); return; } else { Console.Clear(); Console.WriteLine("请按下你想要使用的按键"); Controller.ControllerKeys[KeyNames[SelectIndex]] = Console.ReadKey().Key; OutRoom = this; } }
public void Sort(KeyString keyfunction) { if (typ.Vid != PTypeEnumeration.sequence) { throw new Exception("Sort can't be implemented to this vid"); } PTypeSequence pts = (PTypeSequence)typ; long llen = this.Count(); if (llen < 2) { return; // сортировать не нужно } // Указатель на нулевой элемент и размер головы записи long p0 = this.Element(0).offset; int size = pts.ElementType.HeadSize; // организуем массивы ключей и индексов - номеров записей string[] keys = new string[llen]; int[] indexes = Enumerable.Range(0, (int)llen).ToArray(); // Вычислим и запишем ключи int i = 0; foreach (PxEntry e in this.Elements()) { keys[i] = keyfunction(e); i++; } // Сортируем два массива Array.Sort(keys, indexes); ReorderSequenceArrayHeads(llen, p0, size, indexes); }
/// <summary> /// Looks up a possibly dormant saga child. /// </summary> /// <param name="workflowKey"></param> /// <param name="version"></param> /// <returns></returns> private IActorRef LookupSaga(KeyString sagaKey) { if (_sagas.TryGetValue(sagaKey, out IActorRef sagaActorRef)) { return(sagaActorRef); } return(ActorRefs.Nobody); }
public NodeData(string description, JsonSchema dataJsonSchema, KeyString behaviorModuleKey, KeyString behaviorKey, SemanticVersionNumber behaviorVersion, JsonValue behaviorConfiguration) { Description = description; BehaviorKey = behaviorKey; BehaviorVersion = behaviorVersion; BehaviorConfiguration = behaviorConfiguration; DataJsonSchema = dataJsonSchema; }
public void TextEscaped(string text) { this.text = text; pressed = false; KeyString.StopRecording(true); SetCatchUpdate(null); }
public LookupWorkflowMessage(KeyString dataOwnerKey, KeyString moduleKey, KeyString workflowKey, SemanticVersionNumber dataOwnerVersion = null, SemanticVersionNumber moduleVersion = null, SemanticVersionNumber workflowVersion = null) { DataOwnerKey = dataOwnerKey; DataOwnerVersion = dataOwnerVersion; ModuleKey = moduleKey; ModuleVersion = moduleVersion; WorkflowKey = workflowKey; WorkflowVersion = workflowVersion; }
public void KeyString_Serialization() { KeyString keyString = new KeyString(Guid.NewGuid().ToString()); string output = JsonConvert.SerializeObject(keyString); KeyString deserializedKeyString = JsonConvert.DeserializeObject <KeyString>(output); deserializedKeyString.ShouldBe(keyString); }
public void Enter() { //enter type mode pressed = true; KeyString.StartRecording(TextEntered, text, true, -1, keyCollection, maxLength); KeyString.KeyStringEscaped = TextEscaped; SetCatchUpdate(Update); }
internal const long InitialCacheVersion = 0; //初始的缓存数据CacheVersion /// <summary> /// 主键查找 /// </summary> /// <param name="msgId">数据类型ID</param> /// <param name="key">主键</param> /// <returns>查找成功返回对应数据对象,不存在返回null</returns> internal InnerCacheItem Find(int msgId, KeyString key) { InnerCacheTable cacheTable = null; m_CacheTableDict.TryGetValue(msgId, out cacheTable); if (cacheTable != null) { return(cacheTable.Find(key)); } return(null); }
/// <summary> /// 外键查找 /// </summary> /// <param name="msgId">数据类型ID</param> /// <param name="key">外键</param> /// <returns></returns> internal List <InnerCacheItem> FindByForeignKey(int msgId, KeyString foreignKey) { InnerCacheTable cacheTable = null; m_CacheTableDict.TryGetValue(msgId, out cacheTable); if (cacheTable != null) { return(cacheTable.FindByForeignKey(foreignKey)); } return(new List <InnerCacheItem>()); }
/// <summary> /// 删除 /// </summary> /// <param name="msgId">数据类型ID</param> /// <param name="key">Key</param> /// <returns>删除成功返回true,失败返回false</returns> internal bool Remove(int msgId, KeyString key) { InnerCacheTable cacheTable = null; m_CacheTableDict.TryGetValue(msgId, out cacheTable); if (cacheTable != null) { return(cacheTable.Remove(key)); } return(false); }
public void train(string xmlFile) { if (!(KeyString == "" && ContextBefore == "" && ContextAfter == "")) { EntityPattern entityP = EntityPattern.load(xmlFile); if (entityP.OnlyPattern) { string CA = $"(?=({ContextAfter}))"; string CB = $"(?<=({ContextBefore}))"; string pattern; string div; double keySize = KeyString.Split(' ').Length; if (KeyCounts) { pattern = KeyString; div = " "; } else { pattern = $" ([^ ]+ ){{{(int)(keySize/2)},{(int)(keySize*3/2)}}}?"; div = ""; } if (AfterContextCounts) { pattern = $"{pattern}{div}{CA}"; } if (BeforeContextCounts) { pattern = $"{CB}{div}{pattern}"; } entityP.Patterns.Add(pattern); } else { if (KeyCounts) { entityP.Patterns.Add(KeyString); } if (AfterContextCounts) { entityP.ContextsAfter.Add(ContextAfter); } if (BeforeContextCounts) { entityP.ContextsBefore.Add(ContextBefore); } } entityP.save(xmlFile); } }
/// <summary> /// Returns the SagaStepBehavior requested and null if /// </summary> /// <param name="behaviorName"></param> /// <param name="version"></param> /// <param name="behaviorConfiguration"></param> /// <returns></returns> public ISagaStepBehavior GetSagaStepBehavior(KeyString behaviorName, VersionNumber version, JsonValue behaviorConfiguration) { ISagaStepBehavior sagaStepBehavior = _pluginSagaStepBehaviorFactory.GetInstance(behaviorName, version); if (sagaStepBehavior != null) { if (!sagaStepBehavior.SetBehaviorConfiguration(behaviorConfiguration)) { throw new WorkflowRuntimeException($"The supplied behaviorConfiguration is not valid"); } } return(sagaStepBehavior); }
public void Throws_exception_for_string_keys(IDialect dialect) { using (var database = BlankDatabaseFactory.MakeDatabase(dialect)) { // Arrange var entity = new KeyString { Name = "Some Name", Age = 10 }; // Act / Assert Assert.Throws <InvalidPrimaryKeyException>(() => database.Insert <string>(entity)); } }
public void TextEntered(string text) { this.text = text; pressed = false; if (ValueChanged != null) { ValueChanged(text); } KeyString.StopRecording(true); SetCatchUpdate(null); }
/// <summary> /// 主键查询 /// </summary> /// <param name="key">主键</param> /// <returns>若查找到返回唯一对应数据值,否则返回null</returns> internal InnerCacheItem Find(KeyString key) { InnerCacheItem cacheItem = null; m_PrimaryDict.TryGetValue(key, out cacheItem); if (cacheItem != null && cacheItem.Valid) { return(cacheItem); } else { return(null); } }
/// <summary> /// Looks up an active Workflow child. If version is not supplied the highest version is returned /// </summary> /// <param name="workflowKey"></param> /// <param name="version"></param> /// <returns></returns> private IActorRef LookupWorkflow(KeyString workflowKey, SemanticVersionNumber version = null) { if (_workflows.TryGetValue(workflowKey, out Dictionary <SemanticVersionNumber, IActorRef> versions)) { if (version == null && versions != null) { return(versions[versions.Max(v => v.Key)]); } else if (versions != null && versions.TryGetValue(version, out IActorRef actorRef)) { return(actorRef); } } return(ActorRefs.Nobody); }
public void Inserts_entities_with_string_key(IDialect dialect) { using (var database = BlankDatabaseFactory.MakeDatabase(dialect)) { // Arrange var entity = new KeyString { Name = "Some Name", Age = 10 }; // Act database.Insert(entity); // Assert database.Count <KeyString>().Should().Be(1); } }
public void Does_not_allow_string_key_to_be_null(IDialect dialect) { using (var database = BlankDatabaseFactory.MakeDatabase(dialect)) { // Arrange var entity = new KeyString { Name = null, Age = 10 }; // Act Action act = () => database.Insert(entity); // Assert act.Should().Throw <Exception>(); } }
/// <summary> /// 添加或更新 /// </summary> /// <param name="msgId">数据类型ID</param> /// <param name="key">Key</param> /// <param name="dataMessage">待添加的数据对象</param> internal void AddOrUpdate(int msgId, KeyString key, KeyString foreignKey, byte[] dataMessage, long cacheVersion = InnerCacheSystem.InitialCacheVersion) { InnerCacheTable tableCache = null; m_CacheTableDict.TryGetValue(msgId, out tableCache); if (tableCache != null) { tableCache.AddOrUpdate(key, foreignKey, dataMessage, cacheVersion); } else { InnerCacheTable newTableCache = new InnerCacheTable(); newTableCache.AddOrUpdate(key, foreignKey, dataMessage, cacheVersion); m_CacheTableDict.Add(msgId, newTableCache); } }
public void Throws_exception_for_string_keys(IDialect dialect) { using (var database = BlankDatabaseFactory.MakeDatabase(dialect)) { // Arrange var entity = new KeyString { Name = "Some Name", Age = 10 }; // Act Func <Task> act = async() => await database.InsertAsync <string>(entity); // Assert act.Should().Throw <InvalidPrimaryKeyException>(); } }
public string Decrypt(string str, string k) { KeyString key = new KeyString(k); string res = ""; int tmp; for (int i = 0; i < str.Length; i++) { tmp = symbolTable.IndexOf(str[i]) - symbolTable.IndexOf(key.GetNextChar()); if (tmp < 0) { tmp += symbolTable.GetSize(); } res += symbolTable.CharAt(tmp); } return(res); }
/// <summary> /// 删除 /// </summary> /// <param name="key">主键</param> /// <returns>删除成功返回true,失败为false</returns> internal bool Remove(KeyString key) { KeyString foreignKey = null; m_PrimaryForeignDict.TryGetValue(key, out foreignKey); if (!KeyString.IsNullOrEmpty(foreignKey)) { HashSet <KeyString> priKeys = null; m_ForeignPrimaryDict.TryGetValue(foreignKey, out priKeys); if (priKeys != null) { priKeys.Remove(key); } m_ForeignPrimaryDict.Remove(foreignKey); } m_PrimaryForeignDict.Remove(key); return(m_PrimaryDict.Remove(key)); }
public override void Update() { if (visible) { UpdateBegin(); if (pressed) { if (!hover && Input.mbLeft._pressed) { TextEntered(KeyString.keyString); } else { if (hover && Input.mbLeft._pressed) { setCursor = true; } if (Input.mbLeft._released) { setCursor = false; } if (setCursor) { KeyString.UpdateMouse(mbPos - posG, font); } text = KeyString.keyString; } } else if (hover) { if (Input.mbLeft.pressed) { Enter(); } else if (Input.mbRight.pressed && PressRight != null) { PressRight(); } } } }
public void PropertySet(WorldObject wo) { ObjectClass = wo.ObjectClass.ToString(); foreach (var key in wo.BoolKeys) { KeyBool kb = new KeyBool(); kb.Key = key; kb.bValue = wo.Values((BoolValueKey)key); BoolVals.Add(kb); if(!MasterKeyClass.BoolKeys.Contains(key)){MasterKeyClass.BoolKeys.Add(key);} } foreach (var key in wo.DoubleKeys) { KeyDouble kd = new KeyDouble(); kd.Key = key; kd.dValue = wo.Values((DoubleValueKey)key); DoubleVals.Add(kd); if(!MasterKeyClass.DoubleKeys.Contains(key)){MasterKeyClass.DoubleKeys.Add(key);} } foreach (var key in wo.LongKeys) { KeyLong kl = new KeyLong(); kl.Key = key; kl.lValue = wo.Values((LongValueKey)key); LongVals.Add(kl); if(!MasterKeyClass.LongKeys.Contains(key)){MasterKeyClass.LongKeys.Add(key);} } foreach (var key in wo.StringKeys) { KeyString ks = new KeyString(); ks.Key = key; ks.sValue = wo.Values((StringValueKey)key); StringVals.Add(ks); if(!MasterKeyClass.StringKeys.Contains(key)){MasterKeyClass.StringKeys.Add(key);} } for (int i = 0; i < wo.SpellCount; i++) { SpellVals.Add(wo.Spell(i)); } }