public override int GetHashCode() { unchecked { return((EqualityComparer <T> .Default.GetHashCode(_value) * 397) ^ HasValue.GetHashCode()); } }
public override int GetHashCode() { var hashCode = 229333804; hashCode = hashCode * -1521134295 + HasValue.GetHashCode(); hashCode = hashCode * -1521134295 + Key.GetHashCode(); return(hashCode); }
public override Int32 GetHashCode() { if (OnNotHasValue) { return(0); } return(HasValue.GetHashCode()); }
/// <summary> /// Gets the hashcode for the optional value. /// </summary> /// <returns>An integer.</returns> public override int GetHashCode() { int hashCode = 299404170; hashCode = hashCode * -1521134295 + HasValue.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <T> .Default.GetHashCode(Value); return(hashCode); }
public override int GetHashCode() { var hashCode = 1814622215; hashCode = hashCode * -1521134295 + base.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <T> .Default.GetHashCode(_value); hashCode = hashCode * -1521134295 + HasValue.GetHashCode(); return(hashCode); }
public override int GetHashCode() { unchecked { var hashCode = EqualityComparer <T> .Default.GetHashCode(Value); hashCode = (hashCode * 397) ^ (Error != null ? Error.GetHashCode() : 0); hashCode = (hashCode * 397) ^ HasValue.GetHashCode(); return(hashCode); } }
public override int GetHashCode() { if (HasValue) { return(HasValue.GetHashCode() ^ GetHashCode(Value)); } else { return(HasValue.GetHashCode() ^ GetHashCode(Error)); } }
/// <inheritdoc /> public override int GetHashCode() { unchecked { if (_value is null) { return(0); } return((HasValue.GetHashCode() * 397) ^ EqualityComparer <T> .Default.GetHashCode(_value)); } }
public bool Equals(Maybe <T> other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(HasValue.Equals(other.HasValue) && EqualityComparer <T> .Default.Equals(Value, other.Value)); }
public override int GetHashCode() { // When implementing IEquatable<T>, it is important to override GetHashCode(). // This way, the type can be used as a key in an IDictionary<K,V>, or HashSet<T>, etc., // because GetHashCode() is used to group instances of the type into buckets // (unless a custom IEqualityComparer<T> is available). unchecked { var hash = 27; hash = 13 * hash + HasValue.GetHashCode(); hash = 13 * hash + EqualityComparer <T> .Default.GetHashCode(_value); return(hash); } }
public void OnBeginDrag(PointerEventData eventData) { SetIsDragging(true); soundEffects.PlayPickUpSfx(); // create gap when dragging object placeholder = new GameObject(); placeholder.transform.SetParent(this.transform.parent); LayoutElement le = placeholder.AddComponent <LayoutElement>(); placeholder.AddComponent <CanvasGroup>(); HasValue hasValue = placeholder.AddComponent <HasValue>(); hasValue.typeOfItem = Slot.Dummy; Draggable draggable = placeholder.AddComponent <Draggable>(); draggable.typeOfItem = Slot.Dummy; placeholder.GetComponent <RectTransform>().sizeDelta = new Vector2(this.GetComponent <RectTransform>().sizeDelta.x, this.GetComponent <RectTransform>().sizeDelta.y); le.preferredWidth = this.GetComponent <LayoutElement>().preferredWidth; le.preferredHeight = this.GetComponent <LayoutElement>().preferredHeight; le.flexibleWidth = 0; le.flexibleHeight = 0; placeholder.transform.SetSiblingIndex(this.transform.GetSiblingIndex()); // set parent to return to so that if you let go while it's not on a valid side // it returns to its previous side parentToReturnTo = this.transform.parent; this.transform.SetParent(this.transform.parent.parent.parent); this.transform.SetSiblingIndex(seesaw.transform.GetSiblingIndex() + 1); // set blockRaycasts to false while dragging so pointer can be detected // so object can be detected on drop zones GetComponent <CanvasGroup>().blocksRaycasts = false; parentName = parentToReturnTo.parent.name; if (parentName == "Workbench") { parentName = parentToReturnTo.name; } dragData = this.transform.name + " dragged from " + parentName; }
/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// </returns> public override int GetHashCode() { if (typeof(IEnumerable).IsAssignableFrom(typeof(T))) { var enumerable = (IEnumerable)_value; if (enumerable != null) { IEnumerator enumerator = enumerable.GetEnumerator(); int hashCode = HasValue.GetHashCode(); while (enumerator.MoveNext()) { hashCode ^= EqualityComparer <object> .Default.GetHashCode(enumerator.Current); } return(hashCode ^ typeof(T).GetHashCode()); } } return(HasValue.GetHashCode() ^ EqualityComparer <T> .Default.GetHashCode(_value) ^ typeof(T).GetHashCode()); }
public override int GetHashCode() { unchecked { var hashCode = HasVariousPropertyBits.GetHashCode(); hashCode = (hashCode * 397) ^ HasBackColor.GetHashCode(); hashCode = (hashCode * 397) ^ HasForeColor.GetHashCode(); hashCode = (hashCode * 397) ^ HasMaxLength.GetHashCode(); hashCode = (hashCode * 397) ^ HasBorderStyle.GetHashCode(); hashCode = (hashCode * 397) ^ HasScrollBars.GetHashCode(); hashCode = (hashCode * 397) ^ HasDisplayStyle.GetHashCode(); hashCode = (hashCode * 397) ^ HasMousePointer.GetHashCode(); hashCode = (hashCode * 397) ^ HasSize.GetHashCode(); hashCode = (hashCode * 397) ^ HasPasswordChar.GetHashCode(); hashCode = (hashCode * 397) ^ HasListWidth.GetHashCode(); hashCode = (hashCode * 397) ^ HasBoundColumn.GetHashCode(); hashCode = (hashCode * 397) ^ HasTextColumn.GetHashCode(); hashCode = (hashCode * 397) ^ HasColumnCount.GetHashCode(); hashCode = (hashCode * 397) ^ HasListRows.GetHashCode(); hashCode = (hashCode * 397) ^ HasColumnInfoCount.GetHashCode(); hashCode = (hashCode * 397) ^ HasMatchEntry.GetHashCode(); hashCode = (hashCode * 397) ^ HasListStyle.GetHashCode(); hashCode = (hashCode * 397) ^ HasShowDropDownWhen.GetHashCode(); hashCode = (hashCode * 397) ^ HasDropButtonStyle.GetHashCode(); hashCode = (hashCode * 397) ^ HasMultiSelect.GetHashCode(); hashCode = (hashCode * 397) ^ HasValue.GetHashCode(); hashCode = (hashCode * 397) ^ HasCaption.GetHashCode(); hashCode = (hashCode * 397) ^ HasPicturePosition.GetHashCode(); hashCode = (hashCode * 397) ^ HasBorderColor.GetHashCode(); hashCode = (hashCode * 397) ^ HasSpecialEffect.GetHashCode(); hashCode = (hashCode * 397) ^ HasMouseIcon.GetHashCode(); hashCode = (hashCode * 397) ^ HasPicture.GetHashCode(); hashCode = (hashCode * 397) ^ HasAccelerator.GetHashCode(); hashCode = (hashCode * 397) ^ HasGroupName.GetHashCode(); return(hashCode); } }
/// <summary> /// Determines whether the specified <see cref="Optional{T}" /> is equal to this instance. /// </summary> /// <param name="other">The <see cref="Optional{T}" /> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="Optional{T}" /> is equal to this instance; otherwise, <c>false</c>. /// </returns> public bool Equals(Optional <T> other) { if (HasValue.Equals(other.HasValue)) { if (typeof(IEnumerable).IsAssignableFrom(typeof(T))) { var enumerable1 = (IEnumerable)_value; var enumerable2 = (IEnumerable)other._value; if (enumerable1 == null && enumerable2 == null) { return(true); } if (enumerable1 == null || enumerable2 == null) { return(false); } IEnumerator enumerator1 = enumerable1.GetEnumerator(); IEnumerator enumerator2 = enumerable2.GetEnumerator(); while (enumerator1.MoveNext()) { if (!(enumerator2.MoveNext() && EqualityComparer <object> .Default.Equals(enumerator1.Current, enumerator2.Current))) { return(false); } } return(!enumerator2.MoveNext()); } return(EqualityComparer <T> .Default.Equals(_value, other._value)); } return(false); }
/// <inheritdoc /> public bool Equals(Optional <T> other) { if (!HasValue) { return(!other.HasValue); } if (!other.HasValue) { return(false); } if (_value is null && other._value is null) { return(true); } if (_value is null || other._value is null) { return(false); } return(HasValue.Equals(other.HasValue) && EqualityComparer <T> .Default.Equals(_value, other._value)); }
/// <inheritdoc /> protected override void Execute(Context context) { HasValue.Set(context, false); ValueType.Set(context, null); StringValue.Set(context, null); JsonValue.Set(context, null); BooleanValue.Set(context, default(bool)); DateTimeValue.Set(context, default(DateTime)); DecimalValue.Set(context, default(decimal)); MoneyValue.Set(context, default(Money)); DoubleValue.Set(context, default(double)); IntegerValue.Set(context, default(int)); var variableName = VariableName.Get(context); if (string.IsNullOrWhiteSpace(variableName)) { throw new InvalidWorkflowExecutionException("Variable Name is empty."); } if (!context.SourceContext.SharedVariables.ContainsKey(variableName)) { return; } var value = context.SourceContext.SharedVariables[variableName]; if (value == null) { ValueType.Set(context, "Null"); return; } ValueType.Set(context, value.GetType().Name); HasValue.Set(context, true); var stringValue = value as string ?? value.ToString(); StringValue.Set(context, stringValue); var booleanValue = value as bool? ?? !(stringValue.Equals("false", StringComparison.OrdinalIgnoreCase) || stringValue.Equals("0") || stringValue.Equals("+0") || stringValue.Equals("-0")); BooleanValue.Set(context, booleanValue); DateTime dateTimeValue; if (value is DateTime) { DateTimeValue.Set(context, (DateTime)value); } else if (DateTime.TryParse(stringValue, out dateTimeValue)) { DateTimeValue.Set(context, dateTimeValue); } decimal decimalValue; if (value is decimal) { decimalValue = (decimal)value; DecimalValue.Set(context, decimalValue); MoneyValue.Set(context, new Money(decimalValue)); } else if (decimal.TryParse(stringValue, out decimalValue)) { DecimalValue.Set(context, decimalValue); MoneyValue.Set(context, new Money(decimalValue)); } var moneyValue = value as Money; if (moneyValue != null) { DecimalValue.Set(context, moneyValue.Value); MoneyValue.Set(context, moneyValue); } double doubleValue; if (value is double) { DoubleValue.Set(context, (double)value); } else if (double.TryParse(stringValue, out doubleValue)) { DoubleValue.Set(context, doubleValue); } int integerValue; if (value is int) { IntegerValue.Set(context, (int)value); } else if (int.TryParse(stringValue, out integerValue)) { IntegerValue.Set(context, integerValue); } JsonValue.Set(context, JsonConvert.SerializeObject(value, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore, DateFormatHandling = DateFormatHandling.IsoDateFormat, NullValueHandling = NullValueHandling.Ignore })); }
protected override void Execute(Context context) { HasValue.Set(context, false); StringValue.Set(context, null); BooleanValue.Set(context, default(bool)); DateTimeValue.Set(context, default(DateTime)); DecimalValue.Set(context, default(decimal)); MoneyValue.Set(context, default(Money)); DoubleValue.Set(context, default(double)); IntegerValue.Set(context, default(int)); var key = GetKey(context); if (!context.SourceContext.SharedVariables.ContainsKey(key)) { return; } var value = context.SourceContext.SharedVariables[key]; if (value == null) { return; } HasValue.Set(context, true); var stringValue = value.ToString().Trim(); StringValue.Set(context, stringValue); var booleanValue = !(stringValue.Equals("false", StringComparison.OrdinalIgnoreCase) || stringValue.Equals("0") || stringValue.Equals("+0") || stringValue.Equals("-0")); BooleanValue.Set(context, booleanValue); DateTime dateTimeValue; if (DateTime.TryParse(stringValue, out dateTimeValue)) { DateTimeValue.Set(context, dateTimeValue); } decimal decimalValue; if (decimal.TryParse(stringValue, out decimalValue)) { DecimalValue.Set(context, decimalValue); MoneyValue.Set(context, new Money(decimalValue)); } double doubleValue; if (double.TryParse(stringValue, out doubleValue)) { DoubleValue.Set(context, doubleValue); } int integerValue; if (int.TryParse(stringValue, out integerValue)) { IntegerValue.Set(context, integerValue); } }
/// <summary>Returns the hash code for this instance.</summary> /// <returns>A 32-bit signed integer that is the hash code for this instance.</returns> public override int GetHashCode() => HashCode.Combine(HasValue.GetHashCode(), EqualityComparer <T> .Default.GetHashCode(_value));
public override int GetHashCode() => unchecked ( _value == null ? 0 : EqualityComparer <T> .Default.GetHashCode(_value) * 439 ^ HasValue.GetHashCode() );
public bool Equals(Optional <T> other) { return(HasValue.Equals(other.HasValue) && EqualityComparer <T> .Default.Equals(_value, other._value)); }
protected bool Equals(Maybe <T> other) { return(EqualityComparer <T> .Default.Equals(Value, other.Value) && string.Equals(Error, other.Error) && HasValue.Equals(other.HasValue)); }
public override int GetHashCode() { unchecked { return((HasValue.GetHashCode() * 397) ^ (_value?.GetHashCode() ?? 0)); } }
/// <summary> /// Called when the pane is initialized. /// </summary> protected override async Task InitializeAsync() { await base.InitializeAsync(); ShowCategory = new RelayCommand(SetActive, () => true); HasValue = CurrentCode.Select(x => x.ToString().Length == 6).ToReactiveProperty(); SetClipboard = HasValue.ToReactiveCommand() .WithSubscribe(() => Clipboard.SetText(CurrentCode.Value.ToString())); Expanded = CurrentCode.Select(x => x < 10).ToReactiveProperty(); UpdateSearch = InputCode.Select(x => x) .Throttle(TimeSpan.FromMilliseconds(200)) .ObserveOn(Application.Current.Dispatcher) .Do(async x => await FilterNaicsByString(x)) .ToReactiveProperty(); SetInputCode = new RelayCommand(x => { InputCode.Value = x.ToString(); }, () => true); var codeColumn = 1; var titleColumn = 2; var skipRows = 2; var currentRow = 0; try { using (var stream = File.Open(_twoDigitCodesPath, FileMode.Open, FileAccess.Read)) { using (var reader = ExcelReaderFactory.CreateReader(stream)) { do { while (reader.Read()) { currentRow += 1; if (currentRow <= skipRows) { continue; } try { NaicsCodes.Add(new NaicsModel(reader.GetDouble(codeColumn), reader.GetString(titleColumn))); } catch (InvalidCastException) { NaicsCodes.AddRange(NaicsModel.CreateNaicsFromRange(reader.GetString(codeColumn), reader.GetString(titleColumn))); } } } while (reader.NextResult()); } } } catch (Exception) { } currentRow = 0; skipRows = 1; codeColumn = 0; titleColumn = 1; try { using (var stream = File.Open(_allNaicsPath, FileMode.Open, FileAccess.Read)) { using (var reader = ExcelReaderFactory.CreateReader(stream)) { do { while (reader.Read()) { currentRow += 1; if (currentRow <= skipRows) { continue; } AllNaicsCodes.Add(new NaicsModel(reader.GetDouble(codeColumn), reader.GetString(titleColumn))); } } while (reader.NextResult()); } } } catch (Exception) { } }
/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// </returns> public override int GetHashCode() => HashUtilities.Combine(HasValue.GetHashCode(), Value?.GetHashCode() ?? 0);
public T Get() { HasValue.AssertTrue("Value isn't set"); return((T)myCurrentValue); }
public bool Equals(Maybe <T> other) => EqualityComparer <T> .Default.Equals(_value, other._value) && HasValue.Equals(other.HasValue);
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { // get the value of property from the model var modelValue = validationContext.ObjectInstance.GetType().GetProperty(Property).GetValue(validationContext.ObjectInstance); // The value of the model property needs to match the value set for HasValue // In that case, validation will fail if the value parameter is null // Check if HasValue contains a comma and split the values so each can be compared bool valid = true; if (NotHasValue != null) { var strNotHasValue = NotHasValue.ToString(); if (strNotHasValue.Contains(",")) { bool matchFound = false; foreach (var val in strNotHasValue.Split(",")) { if (modelValue != null) { if (IsNumber(val)) { modelValue = modelValue.ToString(); } if (modelValue.Equals(val)) { matchFound = true; } } } if (!matchFound && value == null) { valid = false; } } else { if (modelValue != null && !modelValue.Equals(NotHasValue) && value == null) { valid = false; } if (string.Equals(modelValue?.ToString(), NotHasValue?.ToString(), StringComparison.InvariantCultureIgnoreCase)) { valid = true; } } } else { if (HasValue != null) { var strHasValue = HasValue.ToString(); if (strHasValue.Contains(",")) { bool matchFound = false; foreach (var val in strHasValue.Split(",")) { if (modelValue != null) { if (IsNumber(val)) { modelValue = modelValue.ToString(); } if (modelValue.Equals(val)) { matchFound = true; } } } if (matchFound && value == null) { valid = false; } } else { if (modelValue != null && modelValue.Equals(HasValue) && value == null) { valid = false; } } } else { if (modelValue != null && modelValue.Equals(HasValue) && value == null) { valid = false; } } } return(valid ? ValidationResult.Success : new ValidationResult(ErrorMessage)); }
public override int GetHashCode() { return(HasValue.GetHashCode() + value?.GetHashCode() ?? 0); }
protected override void Execute(Context context) { HasValue.Set(context, false); StringValue.Set(context, null); BooleanValue.Set(context, default(bool)); DateTimeValue.Set(context, default(DateTime)); DecimalValue.Set(context, default(decimal)); MoneyValue.Set(context, default(Money)); DoubleValue.Set(context, default(double)); IntegerValue.Set(context, default(int)); var json = Json.Get(context); Dictionary <string, object> node; try { node = JsonConvert.DeserializeObject <Dictionary <string, object> >(json); } catch (Exception ex) { throw new InvalidWorkflowExecutionException($"Не удалось произвести разбор строки JSON. {ex.Message}", ex); } var names = ValuePath.Get(context).Split('.').ToArray(); foreach (var name in names.Take(names.Length - 1)) { if (!node.ContainsKey(name)) { return; } var jObj = node[name] as JObject; if (jObj == null) { return; } node = jObj.ToObject <Dictionary <string, object> >(); if (node == null) { return; } } var lastName = names.Last(); if (!node.ContainsKey(lastName)) { return; } var value = node[lastName]; if (value == null) { return; } HasValue.Set(context, true); var stringValue = value.ToString().Trim(); StringValue.Set(context, stringValue); var booleanValue = !(stringValue.Equals("false", StringComparison.OrdinalIgnoreCase) || stringValue.Equals("0") || stringValue.Equals("+0") || stringValue.Equals("-0")); BooleanValue.Set(context, booleanValue); DateTime dateTimeValue; if (DateTime.TryParse(stringValue, out dateTimeValue)) { DateTimeValue.Set(context, dateTimeValue); } decimal decimalValue; if (decimal.TryParse(stringValue, out decimalValue)) { DecimalValue.Set(context, decimalValue); MoneyValue.Set(context, new Money(decimalValue)); } double doubleValue; if (double.TryParse(stringValue, out doubleValue)) { DoubleValue.Set(context, doubleValue); } int integerValue; if (int.TryParse(stringValue, out integerValue)) { IntegerValue.Set(context, integerValue); } }