WhenAll <U, V, W, X>(Func <Action <U>, CoroutToken, IEnumerator> rout01, Func <Action <V>, CoroutToken, IEnumerator> rout02, Func <Action <W>, CoroutToken, IEnumerator> rout03, Func <Action <X>, CoroutToken, IEnumerator> rout04) { if (rout01 == null) { throw new ArgumentNullException("rout01"); } if (rout02 == null) { throw new ArgumentNullException("rout02"); } if (rout03 == null) { throw new ArgumentNullException("rout03"); } if (rout04 == null) { throw new ArgumentNullException("rout04"); } if (rout01.Equals(rout02) || rout01.Equals(rout03) || rout01.Equals(rout04) || rout02.Equals(rout03) || rout02.Equals(rout04) || rout03.Equals(rout04)) { throw new ArgumentException("routines could not be equal."); } var corout01 = new Corout <U>(rout01); var corout02 = new Corout <V>(rout02); var corout03 = new Corout <W>(rout03); var corout04 = new Corout <X>(rout04); return(new CoroutInterlace <U, V, W, X>(corout01, corout02, corout03, corout04)); }
//function returns the values of size and version number based upon the input from filename public String GetFileData(Func <string> TestValue, String Filename) { FileDetails fileDetails = new FileDetails(); String returnvalue = null; if (TestValue.Equals("v")) { returnvalue = fileDetails.Version(Filename); } else if (TestValue.Equals("s")) { returnvalue = fileDetails.Size(Filename).ToString(); } return(returnvalue); }
public void Equality() { var d1 = new Func <int>(f1); var d2 = new Func <int>(f1); var d3 = new Func <int>(f1m); IsTrue((object)d1 == (object)d2); IsTrue(d1 == d2); IsTrue(d1.Equals(d2)); IsTrue(d1.Equals((object)d2)); IsTrue(d1 != null); IsFalse(d1 == d3); IsFalse((object)d1 == (object)d3); IsTrue(d1 != d3); }
/// <summary> /// Выполняет сотрировку массива строк по указанному предикату /// </summary> /// <param name="compareWay"> Предикат</param> /// <returns></returns> public bool Sort(Func <string, string, int> compareWay) { if (compareWay.Equals(null)) { return(false); } int j; for (int i = 0; i < this.array.Length; i++) { j = i + 1; while (j < this.array.Length) { if (compareWay.Invoke(this.array[i], this.array[j]) > 0) { this.Swap(i, j); } j++; } } return(true); }
/// <inheritdoc /> public bool Equals([AllowNull] Aggregation other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Target == other.Target || Target != null && Target.Equals(other.Target) ) && ( Func == other.Func || Func != null && Func.Equals(other.Func) ) && ( FuncMode == other.FuncMode || FuncMode != null && FuncMode.Equals(other.FuncMode) ) && ( Enabled == other.Enabled || Enabled != null && Enabled.Equals(other.Enabled) )); }
/// <summary> /// Converts an enumerable to a dictionary. If it can't, then gives a good reason why /// </summary> /// <typeparam name="TSource"></typeparam> /// <typeparam name="TKey"></typeparam> /// <typeparam name="TElement"></typeparam> /// <param name="source"></param> /// <param name="keySelector"></param> /// <param name="elementSelector"></param> /// <returns></returns> public static Dictionary <TKey, TElement> ToDictionaryExplicit <TSource, TKey, TElement>(this IEnumerable <TSource> source, Func <TSource, TKey> keySelector, Func <TSource, TElement> elementSelector) { if (source == null) { throw new ArgumentNullException("source"); } if (keySelector.Equals(null)) { throw new ArgumentNullException("keySelector"); } if (elementSelector.Equals(null)) { throw new ArgumentNullException("keySelector"); } try { return(source.ToDictionary(keySelector, elementSelector)); } catch (ArgumentException exception) { var duplicates = source.GroupBy(keySelector).Where(g => g.Count() > 1).Select(g => g.Key).ToArray(); var duplicateMessage = string.Join(",", duplicates); var message = "Unable to convert to dictionary since keys are not unique. Duplicate keys are: {0}".StringFormat(duplicateMessage); throw new ArgumentException(message, exception); } }
public static Func <double, double> GetGraduitForActivationFunction(Func <double, double> fn) { if (fn.Equals(((Func <double, double>)ActivationFunction.LogSigmoid))) { return(ActivationFunction.GradientLogSigmoid); } if (fn.Equals(((Func <double, double>)ActivationFunction.HyperbolicTangtent))) { return(ActivationFunction.GradientHyperbolicTangtent); } if (fn.Equals(((Func <double, double>)ActivationFunction.Relu))) { return(ActivationFunction.GradientRelu); } throw new NotImplementedException("can't found the gradian for the func " + fn.Method.Name); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj is Func <IDataResults, T> asFunc) { return(_materialize.Equals(asFunc)); } if (obj is DelegateResultMaterializer <T> asMaterializer) { return(_materialize.Equals(asMaterializer._materialize)); } return(false); }
public bool Equals(HqlField field) { if (this.FieldType != field.FieldType) { // hack this is an optimization if (FieldType == HqlFieldType.LITERAL_STRING && field.FieldType == HqlFieldType.STAR && Name.Equals("*")) { return(true); } if (field.FieldType == HqlFieldType.LITERAL_STRING && this.FieldType == HqlFieldType.STAR && field.Name.Equals("*")) { return(true); } // end hack this is an optimization return(false); } // this is safe because if neither have them, they will be both string.empty if (this.FieldType != HqlFieldType.SCALAR && this.FieldType != HqlFieldType.FUNCTION) { if (!field.TableReference.Equals(TableReference)) { return(false); } } switch (_type) { case HqlFieldType.ROWNUM: case HqlFieldType.FILENAME: case HqlFieldType.STAR: return(true); case HqlFieldType.FIELDNUM: return(Fieldnum == field.Fieldnum); case HqlFieldType.FIXEDWIDTH: return(Name.Equals(field.Name) && Start == field.Start && Length == field.Length); case HqlFieldType.LITERAL_STRING: return(Name.Equals(field.Name)); case HqlFieldType.FUNCTION: return(Func.Equals(field.Func)); case HqlFieldType.SCALAR: return(Scalar.Equals(field.Scalar)); case HqlFieldType.LITERAL_INT: return(this.IntValue == field.IntValue); default: throw new Exception("Unknown type of Field"); } return(false); }
public void WakeUp(Func <T> getValueFunc) { if (getValueFunc.Equals(null)) { throw new ArgumentNullException("getValueFunc"); } _getValueFunc = getValueFunc; _eventHandler.Set(); }
public bool Merge(Func f) { if (f.Equals(this) && !f.IsEmptyBody() && this.IsEmptyBody()) { this.SetBody(f.body); this.SetTable(f.table); return(true); } return(false); }
public static int Main(string[] args) { DerivedClass o = new DerivedClass(); Func <string> del1 = GetDel1(o); Func <string> del2 = GetDel2(o); Console.WriteLine("Action\n======\nReflected type: {0}\nDeclaring type: {1}\nAttributes: {2}\nResult: {3}", del1.Method.ReflectedType, del1.Method.DeclaringType, del1.Method.Attributes, del1()); Console.WriteLine(); Console.WriteLine("Delegate\n========\nReflected type: {0}\nDeclaring type: {1}\nAttributes: {2}\nResult: {3}", del2.Method.ReflectedType, del2.Method.DeclaringType, del2.Method.Attributes, del2()); if (del1.Method.ReflectedType != typeof(DerivedClass)) { return(10); } if (del1.Method.DeclaringType != typeof(DerivedClass)) { return(11); } if (del1() != "Derived method") { return(12); } if (del2.Method.ReflectedType != typeof(DerivedClass)) { return(20); } if (del2.Method.DeclaringType != typeof(DerivedClass)) { return(21); } if (del2() != "Derived method") { return(22); } if (!del1.Equals(del2)) { return(30); } if (!del2.Equals(del1)) { return(31); } return(0); }
/// <summary> /// Determines whether the specified object is equal to the current object. /// NOT thread safe. /// </summary> /// <param name="obj">Object to compare to.</param> /// <returns>True if objects are equal, esle - false.</returns> public override bool Equals(object obj) { if (obj is LazySingleThreaded <T> && obj != null) { var that = obj as LazySingleThreaded <T>; return(instance.Equals(that.instance) && supplier.Equals(that.supplier)); } return(false); }
/// <summary> /// Determines whether the specified object is equal to the current object. /// NOT thread safe. /// </summary> /// <param name="obj">Object to compare to.</param> /// <returns>True if objects are equal, esle - false.</returns> public override bool Equals(object obj) { if (obj is LazyMultiThreaded <T> && obj != null) { var that = obj as LazyMultiThreaded <T>; return(instance.Equals(that.instance) && isInitialized.Equals(that.isInitialized) && supplier.Equals(that.supplier)); } return(false); }
static bool TryRemoveThreadedTask(List <KSPTSTaskGroup> taskGroupList, Func <object, object> threadedTask) { for (int i = 0; i < taskGroupList.Count; i++) { KSPTSTaskGroup tmpTaskGroup = taskGroupList[i]; if (threadedTask.Equals(tmpTaskGroup.threadedTask)) { taskGroupList.Remove(tmpTaskGroup); return(true); } } return(false); }
/// <summary> /// Determines whether the specified <see cref="System.Object" />, is equal to this instance. /// </summary> /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>. /// </returns> public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null || this.GetType() != obj.GetType()) { return(false); } return(func.Equals(((DelegateExpression)obj).func)); }
public void FunctionTest() { // Funcs are only equal by reference. Assert.AreNotEqual(new Func <object, bool>(_ => true), new Func <object, bool>(_ => true)); Func <object, bool> func = _ => true; Assert.AreEqual(func, func); Func <object, bool> func2 = _ => true; Assert.AreNotEqual(func, func2); Assert.IsFalse(func.Equals(func2)); Func <object, bool> func3 = func; Assert.AreEqual(func, func3); }
public static ListItem <T> Remove <T>(ListItem <T> node, Func <T, bool> pred) { if (node.IsEmpty) { return(node); } var result = node; var left = node.Left.IsEmpty ? node.Left : Remove(node.Left, pred); var right = node.Right.IsEmpty ? node.Right : Remove(node.Right, pred); if (pred.Equals(node.Key)) { if (right.IsEmpty && left.IsEmpty) { result = ListItem <T> .Empty; } else if (right.IsEmpty && !left.IsEmpty) { result = left; } else if (!right.IsEmpty && left.IsEmpty) { result = Balance(right); } else { var next = right; while (!next.Left.IsEmpty) { next = next.Left; } right = Remove(right, 0); result = Balance(Make(next.Key, left, right)); } } else { if (!ReferenceEquals(left, node.Left) || !ReferenceEquals(right, node.Right)) { result = Balance(Make(node.Key, left, right)); } } return(result.IsEmpty || result.IsBalanced ? result : Balance(result)); }
public void SetsPropertyGetters() { Func <string, List <string> > listAccessor = x => new List <string>(); Func <string, string> columnNameAccessor = x => x; Func <string, string> columnValueAccessor = x => x; var pivot = new ListPivot <string, string>( "test", listAccessor, columnNameAccessor, columnValueAccessor); Assert.Equal("test", pivot.PropertyName); Assert.True(listAccessor.Equals(pivot.ListAccess)); Assert.True(columnNameAccessor.Equals(pivot.ColumnNameAccess)); Assert.True(columnValueAccessor.Equals(pivot.ColumnValueAccess)); }
WhenAll <U, V>(Func <Action <U>, CoroutToken, IEnumerator> rout01, Func <Action <V>, CoroutToken, IEnumerator> rout02) { if (rout01 == null) { throw new ArgumentNullException("rout01"); } if (rout02 == null) { throw new ArgumentNullException("rout02"); } if (rout01.Equals(rout02)) { throw new ArgumentException("routines could not be equal."); } var corout01 = new Corout <U>(rout01); var corout02 = new Corout <V>(rout02); return(new CoroutInterlace <U, V>(corout01, corout02)); }
public bool Merge(Func f) { if (f.Equals(this) && !f.IsEmptyBody() && this.IsEmptyBody()) { this.SetBody(f.body); this.SetTable(f.table); return true; } return false; }
/// <summary> /// Determines whether this instance and a specified object have the same value. /// </summary> /// <param name="other">The <see cref="AlternateCharChecker"/> to compare with the current <see cref="Node"/>.</param> /// <returns><c>true</c> if the specified <see cref="Node"/> is equal to the current <see cref="Node"/>; otherwise, <c>false</c>.</ public Boolean Equals(AlternateCharChecker other) => Left.Equals(other.Left) && Right.Equals(other.Right);
static bool TryRemoveThreadedTask(List<KSPTSTaskGroup> taskGroupList, Func<object, object> threadedTask) { for(int i = 0; i < taskGroupList.Count; i++) { KSPTSTaskGroup tmpTaskGroup = taskGroupList[i]; if(threadedTask.Equals(tmpTaskGroup.threadedTask)) { taskGroupList.Remove(tmpTaskGroup); return true; } } return false; }
protected bool Equals(RatioPropertyDescriptor other) { return(base.Equals(other) && _componentType == other._componentType && _getterFunc.Equals(other._getterFunc)); }
/// <summary> /// Indicates whether the current object is equal to another object of type <see cref="FunctionalSchedule"/>. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns> /// true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false. /// </returns> public virtual bool Equals(FunctionalSchedule other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(_options == other._options && string.Equals(_name, other._name) && _function.Equals(other._function)); }
/// <summary> /// Determines whether this instance and a specified object have the same value. /// </summary> /// <param name="other">The <see cref="RepeatCharChecker"/> to compare with the current <see cref="Node"/>.</param> /// <returns><c>true</c> if the specified <see cref="Node"/> is equal to the current <see cref="Node"/>; otherwise, <c>false</c>. public Boolean Equals(RepeatCharChecker other) => Check.Equals(other.Check) && Count.Equals(other.Count);
public Boolean Equals(RepeatCharChecker other) => Check.Equals(other.Check) && Length.Equals(other.Length);
public bool Equals(Direction other) { return(NormalizedVector.Equals(other.NormalizedVector) && Angle.Equals(other.Angle) && axisSelector.Equals(other.axisSelector)); }
public bool ActionEquals(object action) { return(_action.Equals(action)); }
public bool IsActive() { return(!ShouldRun.Equals(new Func <Row, bool>(row => true))); }
/// <summary> /// Determines whether this instance and a specified object have the same value. /// </summary> /// <param name="other">The <see cref="AlternateCharChecker"/> to compare with the current <see cref="Node"/>.</param> /// <returns><c>true</c> if the specified <see cref="Node"/> is equal to the current <see cref="Node"/>; otherwise, <c>false</c public Boolean Equals(WordChecker other) => Bias.Equals(other.Bias) && HeadCheck.Equals(other.HeadCheck) && BodyCheck.Equals(other.BodyCheck) && TailCheck.Equals(other.TailCheck);
public bool Equals(IO <TSource> other) => _functor.Equals(other._functor);