public static object[] get_parameters(VALUE v) { if (v.type == get_type(YDEF.sx_function)) { VALUE find = v.FindValueByTravarse(get_type(YDEF.sx_param_list)); if (find != null && find.list != null) { List <object> olist = new List <object>(); foreach (var i in find.list) { var o = i.GetTerminalObject_ascent(); if (o == null) { sys.error("Runtime/get_parameters"); } olist.Add(o); } return(olist.ToArray()); } find = v.FindValueByTravarse(get_type(YDEF.sx_param)); if (find != null) { var o = find.GetTerminalObject_ascent(); if (o == null) { sys.error("Runtime/get_parameters"); } return(new object[1] { o }); } } sys.error("Runtime/get_funcname", v); return(null); }
private void ClearGame() { ACount = 0; HCount = 0; button1.Image = null; button1.Tag = VALUE.E; button2.Image = null; button2.Tag = VALUE.E; button3.Image = null; button3.Tag = VALUE.E; button4.Image = null; button4.Tag = VALUE.E; button5.Image = null; button5.Tag = VALUE.E; button6.Image = null; button6.Tag = VALUE.E; button7.Image = null; button7.Tag = VALUE.E; button8.Image = null; button8.Tag = VALUE.E; button9.Image = null; button9.Tag = VALUE.E; button10.BackColor = SystemColors.Control; button10.Text = ""; NextValue = VALUE.H; WeHaveAWinner = false; resetMatrix(); }
/// <summary><inheritDoc/></summary> public virtual VALUE Set <Value>(Type key, VALUE value) { // search array for existing value to replace for (int i = 0; i < size; i++) { if (keys[i] == key) { VALUE rv = (VALUE)values[i]; values[i] = value; return(rv); } } // not found in arrays, add to end ... // increment capacity of arrays if necessary if (size >= keys.Length) { int capacity = keys.Length + (keys.Length < 16 ? 4 : 8); Type[] newKeys = new Type[capacity]; object[] newValues = new object[capacity]; System.Array.Copy(keys, 0, newKeys, 0, size); System.Array.Copy(values, 0, newValues, 0, size); keys = newKeys; values = newValues; } // store value keys[size] = key; values[size] = value; size++; return(null); }
public static object ExecuteSentence(List <VALUE> l) { if (l == null || l.Count != 1) { return(null); } var v = l[0]; VALUE find = null; find = v.FindValueByTravarse(FuncUtil.get_type(YDEF.sx_screen_sentence)); if (find != null) { sys.logline("Exec Screen Sentence"); return(null); } find = v.FindValueByTravarse(FuncUtil.get_type(YDEF.sx_layer_sentence)); if (find != null) { sys.logline("Exec Layer Sentence"); return(null); } find = v.FindValueByTravarse(FuncUtil.get_type(YDEF.sx_display_sentence)); if (find != null) { sys.logline("Exec Display Sentence"); return(null); } return(null); }
public void Extract_DateTime_ShouldMapFromDate() { // Arrange const string VALUE = "20200405"; RfcErrorInfo errorInfo; _interopMock .Setup(x => x.GetDate(It.IsAny <IntPtr>(), It.IsAny <string>(), It.IsAny <char[]>(), out errorInfo)) .Callback(new GetDateCallback((IntPtr dataHandle, string name, char[] buffer, out RfcErrorInfo ei) => { Array.Copy(VALUE.ToCharArray(), buffer, VALUE.Length); ei = default; })); // Act DateTimeModel result = OutputMapper.Extract <DateTimeModel>(_interopMock.Object, DataHandle); // Assert _interopMock.Verify( x => x.GetDate(DataHandle, "DATETIMEVALUE", It.IsAny <char[]>(), out errorInfo), Times.Once); _interopMock.Verify( x => x.GetDate(DataHandle, "NULLABLEDATETIMEVALUE", It.IsAny <char[]>(), out errorInfo), Times.Once); result.Should().NotBeNull(); result.DateTimeValue.Should().Be(new DateTime(2020, 04, 05)); result.NullableDateTimeValue.Should().Be(new DateTime(2020, 04, 05)); }
public async Task TryWorksCorrectlyWithSuccess() { const int VALUE = 1337; var valueInput = Result.Success <int, string>(VALUE); var valueExceptionInput = Result.Success <int, Exception>(VALUE); valueInput .TrySelect(i => i.ToString(), ex => throw new InvalidOperationException()) .AssertSuccess() .Should() .Be(VALUE.ToString()); valueExceptionInput .TrySelect(i => i.ToString()) .AssertSuccess() .Should() .Be(VALUE.ToString()); await Task .FromResult(valueInput) .TrySelect(i => i.ToString(), ex => throw new InvalidOperationException()) .AssertSuccess() .Should() .Be(VALUE.ToString()); await Task .FromResult(valueExceptionInput) .TrySelect(i => i.ToString()) .AssertSuccess() .Should() .Be(VALUE.ToString()); }
public void LockVariable(long _id, bool _lock) { VALUE _v = new VALUE(); _v.BOOL = _lock; //LCU.SetValueSub(_id, (int)Prop_ANY.State_Property,StatusBar.); }
public void FunctionForEachWithResult() { const string VALUE = "This8Value17MayHave6Digits"; //Arrange (char Character, bool IsDigit) IsDigit(char character) { var isDigit = char.IsDigit(character); return(character, isDigit); } //Act var result = VALUE.ForEach(IsDigit).ToArray(); //Assert result.Should().NotBeNullOrEmpty(); result.Length.Should().Be(VALUE.Length); var nonDigitsCount = result.Count(item => !item.IsDigit); nonDigitsCount.Should().Be(22); var digitCount = result.Count(item => item.IsDigit); digitCount.Should().Be(4); }
public void Extract_TimeSpan_ShouldMapFromTime() { // Arrange const string VALUE = "123456"; RfcErrorInfo errorInfo; _interopMock .Setup(x => x.GetTime(It.IsAny <IntPtr>(), It.IsAny <string>(), It.IsAny <char[]>(), out errorInfo)) .Callback(new GetTimeCallback((IntPtr dataHandle, string name, char[] buffer, out RfcErrorInfo ei) => { Array.Copy(VALUE.ToCharArray(), buffer, VALUE.Length); ei = default; })); // Act TimeSpanModel result = OutputMapper.Extract <TimeSpanModel>(_interopMock.Object, DataHandle); // Assert _interopMock.Verify( x => x.GetTime(DataHandle, "TIMESPANVALUE", It.IsAny <char[]>(), out errorInfo), Times.Once); _interopMock.Verify( x => x.GetTime(DataHandle, "NULLABLETIMESPANVALUE", It.IsAny <char[]>(), out errorInfo), Times.Once); result.Should().NotBeNull(); result.TimeSpanValue.Should().Be(new TimeSpan(12, 34, 56)); result.NullableTimeSpanValue.Should().Be(new TimeSpan(12, 34, 56)); }
/// <summary> /// Sets the value associated with the given key; if the the key is one /// of the hashable keys, throws an exception. /// </summary> /// <exception cref="HashableCoreMapException"> /// Attempting to set the value for an /// immutable, hashable key. /// </exception> public override VALUE Set <Value>(Type key, VALUE value) { if (immutableKeys.Contains(key)) { throw new HashableCoreMap.HashableCoreMapException("Attempt to change value " + "of immutable field " + key.GetSimpleName()); } return(base.Set(key, value)); }
public Result(PARSER parser, int index, int length, string input, VALUE value) // {{value == 'XmlNode'}} public Result(PARSER parser, int index, int length, string input, ref VALUE value) // {{value != 'void' and value != 'XmlNode'}} { m_parser = parser; m_index = index; m_length = length; m_input = input; Value = value; // {{value != 'void'}} }
//> DoNAssert //< DoParse private State DoParse(State state, List <Result> results, int nonterminal) { int startIndex = state.Index; CacheValue cache; long key = CacheValue.CalcKey(nonterminal, startIndex); if (!m_cache.TryGetValue(key, out cache)) { if (nonterminal < 0 || nonterminal >= (int)NonTerminalEnum.NonTerminalNum) { throw new Exception("Couldn't find a " + nonterminal + " parse method"); } ParseMethod[] methods = m_nonterminals[(int)nonterminal]; int oldCount = null == results ? 0 : results.Count; // {{value != 'void'}} state = DoChoice(state, results, methods); bool hasResult = state.Parsed && null != results && results.Count > oldCount; // {{value != 'void'}} VALUE value = hasResult ? results[results.Count - 1].Value : default(VALUE); // {{value != 'void'}} cache = new CacheValue(ref state, ref value, hasResult); // {{value != 'void'}} cache = new CacheValue(ref state, state.Parsed); // {{value == 'void'}} m_cache.Add(key, cache); } else { Console.WriteLine(nonterminal); // {{debug != 'none'}} if (cache.HasResult && null != results) { results.Add(new Result(this, startIndex, cache.State.Index - startIndex, m_input, cache.Value)); // {{value == 'XmlNode'}} } results.Add(new Result(this, startIndex, cache.State.Index - startIndex, m_input, ref cache.Value)); // {{value != 'void' and value != 'XmlNode'}} results.Add(new Result(this, startIndex, cache.State.Index - startIndex, m_input)); // {{value == 'void'}} string name = string.Format("cached '{0}' ", nonterminal); // {{debug != 'none'}} if (m_file == m_debugFile) // {{debugging and has-debug-file}} { // {{debugging and has-debug-file}} if (cache.State.Parsed) // {{(debug == 'matches' or debug == 'both') and has-debug-file}} { DoDebugMatch(startIndex, cache.State.Index, name + "parsed"); // {{(debug == 'matches' or debug == 'both') and has-debug-file}} } if (!cache.State.Parsed) // {{(debug == 'failures' or debug == 'both') and has-debug-file}} { DoDebugFailure(startIndex, name + DoEscapeAll(cache.State.Errors.ToString())); // {{(debug == 'failures' or debug == 'both') and has-debug-file}} } } // {{debugging and has-debug-file}} if (cache.State.Parsed) // {{(debug == 'matches' or debug == 'both') and not has-debug-file}} { DoDebugMatch(startIndex, cache.State.Index, name + "parsed"); // {{(debug == 'matches' or debug == 'both') and not has-debug-file}} } if (!cache.State.Parsed) // {{(debug == 'failures' or debug == 'both') and not has-debug-file}} { DoDebugFailure(startIndex, name + DoEscapeAll(cache.State.Errors.ToString())); // {{(debug == 'failures' or debug == 'both') and not has-debug-file}} } } return(cache.State); }
public void ShouldMapAParsableStringOnToAnInt() { const int VALUE = 63476387; var source = new PublicField <string> { Value = VALUE.ToString(CultureInfo.InvariantCulture) }; var result = Mapper.Map(source).OnTo(new PublicSetMethod <int>()); result.Value.ShouldBe(VALUE); }
public void ShouldMapAParsableStringOverANullableInt() { const int VALUE = 9282625; var source = new PublicField <string> { Value = VALUE.ToString(CultureInfo.InvariantCulture) }; var result = Mapper.Map(source).Over(new PublicSetMethod <int?>()); result.Value.ShouldBe(VALUE); }
/*private FigureMeta DetectPair() * { * FigureMeta result = new FigureMeta(); * for (int i = 0; i < cardsSet.Count - 1; i++) * { * if (cardsSet[i].Value_Enum == cardsSet[i + 1].Value_Enum) * { * result.HIGH_CARD = cardsSet[i].Value_Enum; * break; * } * } * }*/ private static bool CollectionContainsCardWithValue(Card[] collection, VALUE val) { foreach (Card c in collection) { if (c.Value_Enum == val) { return(true); } } return(false); }
public VALUE RUNCondition() { VALUE m_val = new VALUE(); m_val.BOOL = false; for (int i = 0; i < instructionlist.Count; i++) { m_val.BOOL = instructionlist[i].RunInstruction().BOOL; } return(m_val); }
private bool ThreeOfKind() { if (Array.FindAll(cards, element => element.count == 3).Length == 1) { VALUE total = Array.FindAll(cards, element => element.count == 3)[0].MyValue; handValue.Total = (int)total * 4; handValue.HighCard = (int)Array.FindAll(cards, element => element.MyValue != total)[Array.FindAll(cards, element => element.MyValue != total).Length - 1].MyValue; return(true); } return(false); }
public static string get_funcname(VALUE v) { if (v.type == get_type(YDEF.sx_function)) { if (v.list != null && v.list.Count > 0) { return(v.list[0].GetString()); } } sys.error("Runtime/get_funcname", v); return(null); }
/// <exception cref="System.IO.IOException"/> private void WriteSkippedRec(KEY key, VALUE value) { if (this.skipWriter == null) { Path skipDir = SkipBadRecords.GetSkipOutputPath(this._enclosing.conf); Path skipFile = new Path(skipDir, this._enclosing.GetTaskID().ToString()); this.skipWriter = SequenceFile.CreateWriter(skipFile.GetFileSystem(this._enclosing .conf), this._enclosing.conf, skipFile, this.keyClass, this.valClass, SequenceFile.CompressionType .Block, this.reporter); } this.skipWriter.Append(key, value); }
private double getConstraint(VALUE value, OP op, double defaultAnswer) { Constraint c = findConstraint(value, op); if (c == null) { return(defaultAnswer); } else { return(c.Target); } }
private double getConstraint(VALUE value, OP op) { Constraint c = findConstraint(value, op); if (c == null) { string msg = String.Format("Can't find constraint for Value=\"{0}\" and Op=\"{1}\"", value, op); throw new Exception(msg); } else { return(c.Target); } }
public void ByteClearBits() { const byte VALUE = 255; const byte MASK_A = 0xFE; // Clear bit 0. const byte MASK_B = 0xEF; // Clear bit 4. const byte MASK_C = 0x3F; // Clear bits 7 and 6. const byte EXPECTED_A = 254; const byte EXPECTED_B = 239; const byte EXPECTED_C = 63; Assert.AreEqual(EXPECTED_A, VALUE.ClearBits(MASK_A)); Assert.AreEqual(EXPECTED_B, VALUE.ClearBits(MASK_B)); Assert.AreEqual(EXPECTED_C, VALUE.ClearBits(MASK_C)); }
//VALUE m_val = new VALUE(); public bool RunField(enumDynamicGraphicalProperty _prop, ref VALUE m_val) { foreach (DisplayObjectDynamicProperty displayobjectdynamicproperty in objDisplayObjectDynamicPropertys.list) { if (displayobjectdynamicproperty.ObjectType == _prop) { foreach (DisplayObjectDynamicPropertyCondition cs in displayobjectdynamicproperty.ConditionList) { if (cs.SimpleOperation.RUNCondition().BOOL) { switch (displayobjectdynamicproperty.Type) { case VarType.BOOL: m_val.BOOL = cs.m_Value.BOOL; return(true); case VarType.INT: m_val.INT = cs.m_Value.INT; return(true); case VarType.DINT: if (displayobjectdynamicproperty.IsColor) { Color _color = Color.FromArgb(cs.m_Value.DINT); m_val.DINT = _color.ToArgb(); return(true); } else { m_val.DINT = cs.m_Value.DINT; return(true); } case VarType.REAL: m_val.REAL = cs.m_Value.REAL; return(true); } break; } } break; } } return(false); }
private bool OnePair() { if (Array.FindAll(cards, element => element.count == 2).Length == 1) { VALUE total = Array.FindAll(cards, element => element.count == 2)[0].MyValue; handValue.Total = (int)total * 2; //string str = "Picbox" + Array.FindAll(cards, element => element.count == 2)[0].MyValue + "_" + Array.FindAll(cards, element => element.count == 2)[0].MySuit; //PictureBox pic = Control.Find(str, true).FirstOrDefault() as PictureBox; //pic.Location = new System.Drawing.Point(pic.Location.X, pic.Location.Y - 20); //str = "Picbox" + Array.FindAll(cards, element => element.count == 2)[1].MyValue + "_" + Array.FindAll(cards, element => element.count == 2)[1].MySuit; //pic = Control.Find(str, true).FirstOrDefault() as PictureBox; //pic.Location = new System.Drawing.Point(pic.Location.X, pic.Location.Y - 20); handValue.HighCard = (int)Array.FindAll(cards, element => element.MyValue != total)[Array.FindAll(cards, element => element.MyValue != total).Length - 1].MyValue; return(true); } return(false); }
public void ActionForEach() { //Arrange var count = 0; const string VALUE = "123456789"; void DoWork(char character) { WriteLine($"Counting Character {character}."); count++; } //Act VALUE.ForEach(DoWork); //Assert count.Should().Be(9); }
private void BGSwitcher(Button button, int i, int j) { if (WeHaveAWinner) { string message = "We already have a Winner!"; string caption = "Start New Game"; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult result = MessageBox.Show(message, caption, buttons); return; } if (button10.Text == "") { button10.Text = "Start New Game?"; } if (button.Image == null) { switch (NextValue) { case VALUE.A: button.Image = Image.FromFile(A); matrix[i, j] = (int)VALUE.A; ACount++; button.Tag = VALUE.A; NextValue = VALUE.H; break; case VALUE.H: button.Image = Image.FromFile(H); matrix[i, j] = (int)VALUE.H; HCount++; button.Tag = VALUE.H; NextValue = VALUE.A; break; } } if (ACount >= 3 || HCount >= 3) { Check(i, j); } }
private Constraint findConstraint(VALUE value, OP op) { // Problem constraints might say that Temp <= x or Temp < x, treat these the same here, same goes for // other constraint boundaries, e.g. strength >= x or strength > x. OP alternateOp; switch (op) { case OP.GE: alternateOp = OP.GT; // consider GT and GE equivalent break; case OP.GT: alternateOp = OP.GE; // consider GT and GE equivalent break; case OP.LE: alternateOp = OP.LT; // consider LT and LE equivalent break; case OP.LT: alternateOp = OP.LE; // consider LT and LE equivalent break; default: alternateOp = op; // this op has no equivalent break; } foreach (Constraint c in constraints) { if (c.Value == value && (c.Op == op || c.Op == alternateOp)) { return(c); } } return(null); }
/// <exception cref="System.IO.IOException"/> private void MayBeSkip() { this.hasNext = this.skipIt.HasNext(); if (!this.hasNext) { ReduceTask.Log.Warn("Further groups got skipped."); return; } this.grpIndex++; long nextGrpIndex = this.skipIt.Next(); long skip = 0; long skipRec = 0; while (this.grpIndex < nextGrpIndex && base.More()) { while (this._enclosing._enclosing.HasNext()) { VALUE value = this.MoveToNext(); if (this.toWriteSkipRecs) { this.WriteSkippedRec(this._enclosing._enclosing.GetKey(), value); } skipRec++; } base.NextKey(); this.grpIndex++; skip++; } //close the skip writer once all the ranges are skipped if (skip > 0 && this.skipIt.SkippedAllRanges() && this.skipWriter != null) { this.skipWriter.Close(); } this.skipGroupCounter.Increment(skip); this.skipRecCounter.Increment(skipRec); this._enclosing.ReportNextRecordRange(this.umbilical, this.grpIndex); }
internal Entry(TimedRepository <KEY, VALUE> outerInstance, VALUE value) { this._outerInstance = outerInstance; this.Value = value; this.LatestActivityTimestamp = outerInstance.clock.millis(); }
public void Add(KEY key, VALUE value) { int bucket = (GetSecondaryHashCode(key) & 0x7FFFFFFF) % dictionaries.Length; dictionaries[bucket].Add(key, value); }