public override string ToString() { if (cf_root.Key == null || cf_lstLexems == null || cf_arrDirLexems == null) { return("NULL"); } else { string _retStr = cf_root.ToString() + " -> "; foreach (KeyValuePair <cLexem, int> _kvp in cf_lstLexems) { _retStr += _kvp.ToString() + " "; } _retStr += "{"; foreach (cLexem _lex in cf_arrDirLexems) { _retStr += _lex.ToString() + ", "; } if (cf_arrDirLexems.Length > 0) { _retStr = _retStr.Remove(_retStr.Length - 2); } _retStr += "}"; return(_retStr); } }
public virtual string ToString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(!this.UseFakeInput() ? "Input: Touch" : "Input: Faked"); if (this.UseFakeInput()) { PointerEventData pointerEventData1 = this.GetLastPointerEventData(-1); if (pointerEventData1 != null) stringBuilder.AppendLine(pointerEventData1.ToString()); PointerEventData pointerEventData2 = this.GetLastPointerEventData(-2); if (pointerEventData2 != null) stringBuilder.AppendLine(pointerEventData2.ToString()); PointerEventData pointerEventData3 = this.GetLastPointerEventData(-3); if (pointerEventData3 != null) stringBuilder.AppendLine(pointerEventData3.ToString()); } else { using (Dictionary<int, PointerEventData>.Enumerator enumerator = ((Dictionary<int, PointerEventData>) this.m_PointerData).GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair<int, PointerEventData> current = enumerator.Current; stringBuilder.AppendLine(current.ToString()); } } } return stringBuilder.ToString(); }
} //checkGameOver() /// <summary> /// Searches all theme files on disk. /// </summary> public static void determineThemeFilesOnDisk() { String[] files; files = Directory.GetFiles("themes", "theme*.png"); themesFound.Clear(); foreach (String f in files) { ///TODO: extract theme names from filenames if (System.Text.RegularExpressions.Regex.IsMatch(f, "theme-([A-Za-z]*?)-([0-9]{2}).png")) { String themeName; KeyValuePair <string, string> combi; System.Text.RegularExpressions.MatchCollection matches; matches = System.Text.RegularExpressions.Regex.Matches(f, "theme-([A-Za-z]*?)-([0-9]{2}).png"); themeName = matches[0].Groups[1].Value; if (!themesFound.Contains(themeName)) { themesFound.Add(themeName); } combi = new KeyValuePair <string, String>(themeName, f); themeImageFiles.Add(combi); Console.WriteLine(themeName, combi.ToString()); } } //for each file } //determineThemeFilesOnDisk()
public override async Task UpdateObjectAsync(KeyValuePair <string, object> kvp) { Log.WriteLine("\t\t\t\t\t\tI2C UpdateObjectAsync override kvp = {0}", kvp.ToString()); if (kvp.Key == Keys.Orientation) { // output the event stream var msgvalue = new OrientationMessage(); msgvalue.OriginalEventUTCTime = DateTime.SpecifyKind(DateTime.UtcNow, DateTimeKind.Utc).ToString("o"); msgvalue.OrientationState = (Orientation)kvp.Value; byte[] msgbody = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(msgvalue)); lock (_lastOBody) { _lastOBody = msgbody; } await Task.WhenAll( Task.Run(async() => { await Module.SendMessageAsync(Keys.OutputOrientation, msgbody); } ), Task.Run(async() => { await Module.SendMessageAsync(Keys.OutputUpstream, msgbody); } ) ); Log.WriteLine("\t\t\t\t\t\tI2C UpdateObjectAsync orientation sent local and upstream"); } }
// Returns true if the expected result is right // Returns false if the expected result is wrong public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest2: Create a new instance of KeyValuePair.key is string and value is int"); try { string ExpectValue1 = "HELLO"; int ExpectValue2 = 1; KeyValuePair <int, string> myKeValuePair = new KeyValuePair <int, string>(ExpectValue2, ExpectValue1); string expectValue = "[1, HELLO]"; string actualValue = myKeValuePair.ToString(); if (actualValue != expectValue) { TestLibrary.TestFramework.LogError("002.1", "calling tostring method should return " + expectValue); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e); retVal = false; } return(retVal); }
/// <summary> /// /// </summary> /// <exception cref="System.ArgumentException"></exception> /// <param name="filename"></param> /// <param name="preScan"></param> /// <param name="tag"></param> /// <returns></returns> public static PullSoundStreamBase CreateFileStreamPrimitive(string filename, bool preScan = false, List <KeyValuePair <string, object> > tag = null) { PullSoundStreamBase self = new BASSDecodeStreamAdapter(filename, true, preScan); if (tag == null) { tag = Tags.MetaTag.readTagByFilename(filename, false); } if (tag != null) { KeyValuePair <string, object> gain = tag.Find((match) => match.Key == "REPLAYGAIN_ALBUM_GAIN"); if (gain.Value != null) { self = new ReplayGainOverrideFilter(self, Util.Util.parseDouble(gain.ToString())); } } var range = RetrieveAccurateRange(filename, self.LengthSample, tag); if ((range != null) && self.LengthSample > (range.Item1 + range.Item2)) { self = new RangeFilter(self, range.Item1, range.Item2); } return(self); }
public override string ToString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(!this.UseFakeInput() ? "Input: Touch" : "Input: Faked"); if (this.UseFakeInput()) { PointerEventData pointerEventData = this.GetLastPointerEventData(-1); if (pointerEventData != null) { stringBuilder.AppendLine(pointerEventData.ToString()); } } else { using (Dictionary <int, PointerEventData> .Enumerator enumerator = this.m_PointerData.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <int, PointerEventData> current = enumerator.Current; stringBuilder.AppendLine(current.ToString()); } } } return(stringBuilder.ToString()); }
// Returns true if the expected result is right // Returns false if the expected result is wrong public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest2: Create a new instance of KeyValuePair.key is string and value is int"); try { string ExpectValue1 = "HELLO"; int ExpectValue2 = 1; KeyValuePair<int, string> myKeValuePair = new KeyValuePair<int, string>(ExpectValue2, ExpectValue1); string expectValue = "[1, HELLO]"; string actualValue = myKeValuePair.ToString(); if (actualValue != expectValue) { TestLibrary.TestFramework.LogError("002.1", "calling tostring method should return " + expectValue); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e); retVal = false; } return retVal; }
void ICollection <KeyValuePair <TK1, TK2> > .Add(KeyValuePair <TK1, TK2> item) { if (!TryAdd(item.Key, item.Value)) { throw new InvalidOperationException($"重复的键值对:{item.ToString()}"); } }
public void FoodDrawStrategyBase_WhenCalledDrawFoodWithinWallsAndNotOnSnake_GenerateFood() { // Arrange var foodDrawStrategyBase = new FoodDrawStrategyBase(); var keyPairs = new List <KeyValuePair <int, int> > { new KeyValuePair <int, int>(15, 16), new KeyValuePair <int, int>(16, 16), new KeyValuePair <int, int>(17, 16), new KeyValuePair <int, int>(18, 16), new KeyValuePair <int, int>(19, 16), }; // Act var(foodX, foodY) = foodDrawStrategyBase.DrawFoodWithinWallsAndNotOnSnake(keyPairs); var resultPair = new KeyValuePair <int, int>(foodX, foodY); // Assert for (var i = 0; i < keyPairs.Count; i++) { Assert.NotEqual(keyPairs[i].ToString(), resultPair.ToString()); } Assert.NotEqual(60, foodX); Assert.NotEqual(20, foodY); }
/// <summary> /// 检查键值对是否为空 /// </summary> /// <typeparam name="TKey"></typeparam> /// <typeparam name="TValue"></typeparam> /// <param name="argument"></param> /// <param name="argumentName"></param> /// <param name="message"></param> public static void CheckNull <TKey, TValue>(this KeyValuePair <TKey, TValue> argument, string argumentName, string message = null) { if (string.IsNullOrWhiteSpace(argument.ToString())) { throw new ArgumentNullException(argumentName, message ?? $"{nameof(argument)} contains nothing."); } }
public static void TestUseCase() { var pair = new KeyValuePair<int, string>(1, "value"); Assert.AreEqual(pair.Key, 1, "Bridge479 Key"); Assert.AreEqual(pair.Value, "value", "Bridge479 Value"); Assert.AreEqual(pair.ToString(), "[1, value]", "Bridge479 ToString"); }
public static void TestUseCase() { var pair = new KeyValuePair <int, string>(1, "value"); Assert.AreEqual(pair.Key, 1, "Bridge479 Key"); Assert.AreEqual(pair.Value, "value", "Bridge479 Value"); Assert.AreEqual(pair.ToString(), "[1, value]", "Bridge479 ToString"); }
static int ToString(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); KeyValuePair <uint, BadgeSlotBaseConfig> obj = (KeyValuePair <uint, BadgeSlotBaseConfig>)LuaScriptMgr.GetNetObjectSelf(L, 1, "KeyValuePair<uint,BadgeSlotBaseConfig>"); string o = obj.ToString(); LuaScriptMgr.Push(L, o); return(1); }
static int ToString(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); KeyValuePair <uint, List <StoreGoodsData> > obj = (KeyValuePair <uint, List <StoreGoodsData> >)LuaScriptMgr.GetNetObjectSelf(L, 1, "KeyValuePair<uint,List<StoreGoodsData>>"); string o = obj.ToString(); LuaScriptMgr.Push(L, o); return(1); }
static int ToString(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); KeyValuePair <uint, BullFightLevel> obj = (KeyValuePair <uint, BullFightLevel>)LuaScriptMgr.GetNetObjectSelf(L, 1, "KeyValuePair<uint,BullFightLevel>"); string o = obj.ToString(); LuaScriptMgr.Push(L, o); return(1); }
public static void TestUseCase(Assert assert) { assert.Expect(3); var pair = new KeyValuePair<int, string>(1, "value"); assert.Equal(pair.Key, 1, "Bridge479 Key"); assert.Equal(pair.Value, "value", "Bridge479 Value"); assert.Equal(pair.ToString(), "[1, value]", "Bridge479 ToString"); }
static int ToString(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); KeyValuePair <uint, NewComerSignData> obj = (KeyValuePair <uint, NewComerSignData>)LuaScriptMgr.GetNetObjectSelf(L, 1, "KeyValuePair<uint,NewComerSignData>"); string o = obj.ToString(); LuaScriptMgr.Push(L, o); return(1); }
static int ToString(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); KeyValuePair <uint, List <fogs.proto.msg.ExerciseInfo> > obj = (KeyValuePair <uint, List <fogs.proto.msg.ExerciseInfo> >)LuaScriptMgr.GetNetObjectSelf(L, 1, "KeyValuePair<uint,List<fogs.proto.msg.ExerciseInfo>>"); string o = obj.ToString(); LuaScriptMgr.Push(L, o); return(1); }
static int ToString(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); KeyValuePair <uint, fogs.proto.config.GoodsAttrConfig> obj = (KeyValuePair <uint, fogs.proto.config.GoodsAttrConfig>)LuaScriptMgr.GetNetObjectSelf(L, 1, "KeyValuePair<uint,fogs.proto.config.GoodsAttrConfig>"); string o = obj.ToString(); LuaScriptMgr.Push(L, o); return(1); }
static int ToString(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); KeyValuePair <uint, Dictionary <uint, uint> > obj = (KeyValuePair <uint, Dictionary <uint, uint> >)LuaScriptMgr.GetNetObjectSelf(L, 1, "KeyValuePair<uint,Dictionary<uint,uint>>"); string o = obj.ToString(); LuaScriptMgr.Push(L, o); return(1); }
public static void TestUseCase(Assert assert) { assert.Expect(3); var pair = new KeyValuePair <int, string>(1, "value"); assert.Equal(pair.Key, 1, "Bridge479 Key"); assert.Equal(pair.Value, "value", "Bridge479 Value"); assert.Equal(pair.ToString(), "[1, value]", "Bridge479 ToString"); }
public IEnumerator AsynchronousReadFromArduino(Action <KeyValuePair <char, Vector3> > callback, Action fail = null) { string axis_string = ""; //string wherein the command is recreated do { int new_value; //values come in as INTs that represent characters in ascii. for every loop we try to retreive a new one try { new_value = stream.ReadChar(); //read int from the arduino } catch (TimeoutException) { new_value = 0; //if the arduino does not send an int } if (new_value != 0) //when a new character is send { char new_axis_char = (char)new_value; //convert newly retreived int to a char if (IsEnglishLetter(new_axis_char)) //if end of the command send to axis to the body part new_axis_char { try { string[] axis_string_split = axis_string.Split(','); //split up the axis string to seperate angles XYZ if (axis_string_split.Length == 3) //if the axis have the right amount of axis { Vector3 axis = new Vector3(float.Parse(axis_string_split[0]), float.Parse(axis_string_split[1]), float.Parse(axis_string_split[2])); //Parse string angles to a axis vector KeyValuePair <char, Vector3> command = new KeyValuePair <char, Vector3>(new_axis_char, axis); //create dictinary entry for body part represented by the character in new_axis_char callback(command); Debug.Log("command" + command.ToString()); } } catch (FormatException e) //catch when string cannot be converted to float { Debug.Log("value" + axis_string); Debug.Log(e); } axis_string = ""; //reset axis for retreiving a new one yield return(null); } else { axis_string += new_axis_char; //if axis string is not completed add to the rest } } else //nothing is detected wait a little bit 1/60fps for next try { yield return(new WaitForSeconds(0.05f)); } } while (true);//run all the time }
//添加一组状态 public void Add(KeyValuePair <string, object> pair) { if (!conditions.ContainsKey(pair.Key)) { conditions.Add(pair.Key, pair.Value); } else { Debug.Log("You tried to add and existing key to dictionary" + pair.ToString()); } }
public static string SantizeData(Entity c, KeyValuePair <string, object> field) { string data = ""; if (c.Attributes.ContainsKey(field.Key)) { if (field.ToString().Contains("OptionSetValue")) { data = ((Microsoft.Xrm.Sdk.OptionSetValue)field.Value).Value.ToString(); } else if (field.ToString().Contains("EntityReference")) { data = ((Microsoft.Xrm.Sdk.EntityReference)field.Value).LogicalName + " : " + ((Microsoft.Xrm.Sdk.EntityReference)field.Value).Name + " : " + ((Microsoft.Xrm.Sdk.EntityReference)field.Value).Id; } else { data = c.Attributes[field.Key].ToString(); } } return(data); }
public void FloatTest() { FileStreamer fileStreamer = new FileStreamer(); Machine machine = fileStreamer.GetMachine("floatmachine.txt"); string inputString = "yui-1.45e2iop"; int offset = 3; KeyValuePair <bool, int> supposedPair = new KeyValuePair <bool, int>(true, 7); var supposedString = "-1.45e2"; KeyValuePair <bool, int> realPair = machine.GetIntValues(inputString, offset); string realString = inputString.Substring(offset, realPair.Value); Console.WriteLine("Float test:"); Console.WriteLine("pairs: {0}", realPair.ToString().Equals(supposedPair.ToString())); Console.WriteLine("strings: {0}", realString.Equals(supposedString)); }
public void BooleanTest() { FileStreamer fileStreamer = new FileStreamer(); Machine machine = fileStreamer.GetMachine("booleanmachine.txt"); string inputString = "7896false"; int offset = 4; KeyValuePair <bool, int> supposedPair = new KeyValuePair <bool, int>(true, 5); var supposedString = "false"; KeyValuePair <bool, int> realPair = machine.GetIntValues(inputString, offset); string realString = inputString.Substring(offset, realPair.Value); Console.WriteLine("Boolean test:"); Console.WriteLine("pairs: {0}", realPair.ToString().Equals(supposedPair.ToString())); Console.WriteLine("strings: {0}", realString.Equals(supposedString)); }
public void ToString_RandomPair_ContainsKeyBeforeValue() { // Arrange var key = Random.Next(); var value = Random.GetString(10); var kvp = new KeyValuePair <int, string>(key, value); var toString = kvp.ToString(); // Act var keyIndex = toString.IndexOf(key.ToString(), StringComparison.Ordinal); var valueIndex = toString.IndexOf(value, StringComparison.Ordinal); // Assert Assert.That(keyIndex, Is.Not.Negative.And.LessThan(valueIndex)); }
public virtual async Task <Context> SetValue(KeyValuePair <string, string> entry) { Console.WriteLine("\n\n{0}\n\n", entry.ToString()); State.Prefs.Add(entry); await updateOtherGrainState(); Context cntxt; cntxt.timestamp = DateTime.Now; cntxt.id = 0; State.currentContext.timestamp = cntxt.timestamp; return(cntxt); }
public static string writeCropUnits(KeyValuePair <CropUnits, double> value) { if (value.Key == CropUnits.Custom) { return(value.Value.ToString()); } else if (value.Key == CropUnits.SourcePixels) { return("sourcepixels"); } else { throw new NotImplementedException("Unrecognized CropUnits value: " + value.ToString()); } }
public void IntegerTest() { FileStreamer fileStreamer = new FileStreamer(); Machine machine = fileStreamer.GetMachine("integermachine.txt"); int offset = 6; string inputString = "qwerty12345ghkk"; KeyValuePair <bool, int> supposedPair = new KeyValuePair <bool, int>(true, 5); string supposedString = "12345"; KeyValuePair <bool, int> realPair = machine.GetIntValues(inputString, offset); string realString = inputString.Substring(offset, realPair.Value); Console.WriteLine("Integer test:"); Console.WriteLine("pairs: {0}", realPair.ToString().Equals(supposedPair.ToString())); Console.WriteLine("strings: {0}", realString.Equals(supposedString)); }
public override string ToString() { StringBuilder sb = new StringBuilder("{"); for (IEnumerator <KeyValuePair <K, double> > i = this.EntrySet().GetEnumerator(); i.MoveNext();) { KeyValuePair <K, double> e = i.Current; sb.Append(e.ToString()); if (i.MoveNext()) { sb.Append(","); } } sb.Append("}"); return(sb.ToString()); }
private string[] handleValueNode(ref string[] scene, MergeNode currentMergeNode, string yamlNodeKey, int line, KeyValuePair <YamlNode, YamlNode> yamlNode) { if (!string.IsNullOrEmpty(currentMergeNode.NameToExportTo)) { scene[line] = scene[line] .ReplaceFirst(currentMergeNode.OriginalValue, currentMergeNode.NameToExportTo); } else { Debug.Log("Mapping failed for : " + yamlNodeKey + " node : " + yamlNode.ToString()); } return(scene); }
public KeyValuePair<Move, RotationDirection> getMove() { KeyValuePair<Move, RotationDirection> retval = new KeyValuePair<Move,RotationDirection>(Move.None, RotationDirection.None); if(swipedFaces.Count < 3){ return retval; } CubeFace f = getDominantFace(); if (f == CubeFace.None) { return retval; } filterMoves(f); SwipeDirection dir = getSingleDirection(); if (dir == SwipeDirection.None) { return retval; } SwipedFace swipedFace = getSingleSwipedFace(dir); //Debug.Print("face: {0}{1}{2}", swipedFace.face, swipedFace.direction, swipedFace.layer); Move m = Move.None; switch(swipedFace.face){ case CubeFace.F: case CubeFace.B: switch(swipedFace.direction){ case SwipeDirection.H: switch(swipedFace.layer){ case 0: m = Move.U; break; case 1: m = Move.E; break; case 2: m = Move.D; break; } break; case SwipeDirection.V: switch (swipedFace.layer) { case 0: m = Move.L; break; case 1: m = Move.M; break; case 2: m = Move.R; break; } break; } break; case CubeFace.R: case CubeFace.L: switch (swipedFace.direction) { case SwipeDirection.H: switch(swipedFace.layer){ case 0: m = Move.D; break; case 1: m = Move.E; break; case 2: m = Move.U; break; } break; case SwipeDirection.V: switch (swipedFace.layer) { case 0: m = Move.B; break; case 1: m = Move.S; break; case 2: m = Move.F; break; } break; } break; case CubeFace.U: case CubeFace.D: switch (swipedFace.direction) { case SwipeDirection.H: switch (swipedFace.layer) { case 0: m = Move.B; break; case 1: m = Move.S; break; case 2: m = Move.F; break; } break; case SwipeDirection.V: switch (swipedFace.layer) { case 0: m = Move.L; break; case 1: m = Move.M; break; case 2: m = Move.R; break; } break; } break; } retval = new KeyValuePair<Move,RotationDirection>(m, getRotationDirection(swipedFace)); Debug.Print("Move: " + retval.ToString()); return retval; }
public void KVPToString() { KeyValuePair<Char, String> input1 = new KeyValuePair<char, string>('A', "alpha"); Assert.AreEqual("A -> alpha", input1.ToString(" -> ", true)); Assert.AreEqual("alphaA", input1.ToString("", false)); }
// Returns true if the expected result is right // Returns false if the expected result is wrong public bool PosTest3() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest3: Create a new instance of KeyValuePair,key is 0 and value is null."); try { KeyValuePair<int, string> myKeValuePair = new KeyValuePair<int, string>(); string expectValue = "[0, ]"; string actualValue = myKeValuePair.ToString(); if (expectValue != actualValue) { TestLibrary.TestFramework.LogError("003.1", "the key of KeyValuePair should return " + actualValue); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("003.0", "Unexpected exception: " + e); retVal = false; } return retVal; }