本文整理汇总了C#中Tuple.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Tuple.Equals方法的具体用法?C# Tuple.Equals怎么用?C# Tuple.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tuple
的用法示例。
在下文中一共展示了Tuple.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EqualsOperatorReturnsFalseIfTuplesContainDifferentItem2
public void EqualsOperatorReturnsFalseIfTuplesContainDifferentItem2()
{
var tuple1 = new Tuple<string, int>("this is a test", 42);
var tuple2 = new Tuple<string, int>("this is a test", 9);
Assert.IsFalse(tuple1.Equals(tuple2));
}
示例2: EqualsOperatorReturnsTrueIfTuplesComposedOfSamePieces
public void EqualsOperatorReturnsTrueIfTuplesComposedOfSamePieces()
{
var tuple1 = new Tuple<string, int>("this is a test", 42);
var tuple2 = new Tuple<string, int>("this is a test", 42);
Assert.IsTrue(tuple1.Equals(tuple2));
}
示例3: OneNullOneNotSameData
public void OneNullOneNotSameData()
{
var one = new Tuple<string, string>("Hi", null);
var two = new Tuple<string, string>("Hi", null);
var equalsOutput = one.Equals(two);
var operatorOutput = one == two;
Assert.True(equalsOutput, "Different tuples with same values should compare to true");
Assert.True(operatorOutput, "Different tuples with same values should compare to true");
}
示例4: OneNullOneNotDifferentData
public void OneNullOneNotDifferentData()
{
var one = new Tuple<string, string>("Hi", null);
var two = new Tuple<string, string>("Hi", "Hi");
var equalsOutput = one.Equals(two);
var operatorOutput = one == two;
Assert.False(equalsOutput, "Different tuples with different values should compare to false");
Assert.False(operatorOutput, "Different tuples with different values should compare to false");
}
示例5: DifferentTripleCompare
public void DifferentTripleCompare()
{
var tripleOne = new Tuple<int, int, int>(5, 5, 5);
var tripleTwo = new Tuple<int, int, int>(5, 1, 5);
var equalsOutput = tripleOne.Equals(tripleTwo);
var operatorOutput = tripleOne == tripleTwo;
Assert.False(equalsOutput, "Different tuples with different values should compare to false");
Assert.False(operatorOutput, "Different tuples with different values should compare to false");
}
示例6: Test
public void Test()
{
BinarySerializer serializer = new BinarySerializer();
var message = new Tuple<string, string>("Name", "Cool");
string subject = serializer.GetObjectSubject(message);
var array = serializer.Serialize(message);
var messageDeserialized = serializer.Deserialize(subject, array.Array, array.Offset, array.Count);
Assert.That(message.Equals(messageDeserialized));
}
示例7: Main
static void Main(string[] args)
{
// a set of generic classes for holding a set of differently typed elements
var t1 = new Tuple<int, string>(123, "Hello");
Tuple<int, string> t2 = Tuple.Create(123, "Hello");
var t3 = Tuple.Create(123, "Hello");
Console.WriteLine(t1.Item1 * 2);
Console.WriteLine(t2.Item2.ToUpper());
Console.WriteLine(t1 == t2);
// False for reference types
Console.WriteLine(t1.Equals(t2));
// True
}
示例8: Sample
public void Sample()
{
// Создание кортежа
var tuple = new Tuple<int, string, bool>(42, "abc", true);
// Доступ к компонентам кортежа:
Assert.That(tuple.Item1, Is.EqualTo(42));
Assert.That(tuple.Item2, Is.EqualTo("abc"));
Assert.That(tuple.Item3, Is.EqualTo(true));
//Переопределенный ToString
Assert.That(tuple.ToString(), Is.EqualTo("(42, abc, True)"));
// Переопределенный Equals сравнивает значения компонент кортежа
var otherTuple = new Tuple<int, string, bool>(42, "abc", true);
Assert.IsTrue(tuple.Equals(otherTuple));
}
示例9: OutputAndDebugWriter
public void OutputAndDebugWriter ()
{
//Interesting fact... Debug.Write(""); produces log entry
//but Console.Write(""); does not
InitializeTest ();
AddBreakpoint ("5070ed1c-593d-4cbe-b4fa-b2b0c7b25289");
var errorsList = new List<string> ();
errorsList.Add ("ErrorText");
var outputList = new HashSet<string> ();
outputList.Add ("NormalText");
var debugList = new List<Tuple<int,string,string>> ();
debugList.Add (new Tuple<int,string,string> (0, "", "DebugText"));
debugList.Add (new Tuple<int, string, string> (3, "SomeCategory", "DebugText2"));
var unexpectedOutput = new List<string> ();
var unexpectedError = new List<string> ();
var unexpectedDebug = new List<Tuple<int,string,string>> ();
Session.DebugWriter = delegate(int level, string category, string message) {
var entry = new Tuple<int,string,string> (level, category, message);
if (entry.Equals (new Tuple<int,string,string> (0, "", "")))//Sdb is emitting some empty messages :S
return;
if (debugList.Contains (entry)) {
debugList.Remove (entry);
} else {
unexpectedDebug.Add (entry);
}
};
Session.OutputWriter = delegate(bool isStderr, string text) {
if (isStderr) {
if (errorsList.Contains (text))
errorsList.Remove (text);
else
unexpectedError.Add (text);
} else {
if (outputList.Contains (text))
outputList.Remove (text);
else
unexpectedOutput.Add (text);
}
};
StartTest ("OutputAndDebugWriter");
CheckPosition ("5070ed1c-593d-4cbe-b4fa-b2b0c7b25289");
if (outputList.Count > 0)
Assert.Fail ("Output list still has following items:" + string.Join (",", outputList));
if (errorsList.Count > 0)
Assert.Fail ("Error list still has following items:" + string.Join (",", errorsList));
if (debugList.Count > 0)
Assert.Fail ("Debug list still has following items:" + string.Join (",", debugList));
if (unexpectedOutput.Count > 0)
Assert.Fail ("Unexcpected Output list has following items:" + string.Join (",", unexpectedOutput));
if (unexpectedError.Count > 0)
Assert.Fail ("Unexcpected Error list has following items:" + string.Join (",", unexpectedError));
if (unexpectedDebug.Count > 0)
Assert.Fail ("Unexcpected Debug list has following items:" + string.Join (",", unexpectedDebug));
}
示例10: SameTripleCompare
public void SameTripleCompare()
{
var tripleOne = new Tuple<int, int, int>(5, 5, 5);
var equalsOutput = tripleOne.Equals(tripleOne);
var operatorOutput = tripleOne == tripleOne;
Assert.True(equalsOutput, "Same tuple should compare to true");
Assert.True(operatorOutput, "Same tuple should compare to true");
}
示例11: CheckNextVerticesOfLeftSide
private HashSet<List<Tuple<long, long>>> CheckNextVerticesOfLeftSide(ref IVertex myCurrentVertexLeft, ref Node myCurrentNodeLeft)
{
//get all referenced ObjectUUIDs using the given Edge
var leftVertices = myCurrentVertexLeft.GetOutgoingEdge(_AttributeDefinition.ID).GetTargetVertices();
#region check left friends
foreach (var nextLeftVertex in leftVertices)
{
Node nextLeftNode = null;
Tuple<long, long> nextLeft = new Tuple<long, long>(nextLeftVertex.VertexTypeID, nextLeftVertex.VertexID);
#region if the child is the _Target
if (nextLeft.Equals(_Target.Key))
{
if (TargetFoundCheckAbort(nextLeft, ref myCurrentNodeLeft, ref nextLeftNode, nextLeftVertex))
return new TargetAnalyzer(_Root, _Target, _ShortestPathLength, _ShortestOnly, _FindAll).GetPaths();
}
#endregion
#region already visited from right side
else if (_VisitedNodesRight.ContainsKey(nextLeft))
{
if (VisitedByRightSide(nextLeft, ref myCurrentNodeLeft))
return new TargetAnalyzer(_Root, _Target, _ShortestPathLength, _ShortestOnly, _FindAll).GetPaths();
}
#endregion already visited from right side
#region already visited
else if (_VisitedNodesLeft.ContainsKey(nextLeft))
{
UpdateVisitedLeft(nextLeft, ref myCurrentNodeLeft);
}
#endregion already visited
#region set as visited
else
{
SetAsVisitedLeft(nextLeft, ref myCurrentNodeLeft, ref nextLeftNode, nextLeftVertex);
}
#endregion set as visited
}
#endregion check left friends
return null;
}
示例12: Find
//.........这里部分代码省略.........
currentVertexLeft.VertexID);
if (_VisitedNodesLeft.ContainsKey(currentLeft))
currentNodeLeft = _VisitedNodesLeft[currentLeft];
else
currentNodeLeft = new Node(currentLeft);
//get the first Object of the queue
currentVertexRight = _QueueRight.Dequeue();
currentRight = new Tuple<long, long>(currentVertexRight.VertexTypeID,
currentVertexRight.VertexID);
if (_VisitedNodesRight.ContainsKey(currentRight))
currentNodeRight = _VisitedNodesRight[currentRight];
else
currentNodeRight = new Node(currentRight);
#endregion
#region the edge and the backwardedge are existing
if (currentVertexLeft.HasOutgoingEdge(_AttributeDefinition.ID)
&& HasIncomingVertices(currentVertexRight))
{
//get all referenced ObjectUUIDs using the given Edge
var leftVertices = currentVertexLeft.GetOutgoingEdge(_AttributeDefinition.ID).GetTargetVertices();
#region check left friends
foreach (var nextLeftVertex in leftVertices)
{
Node nextLeftNode = null;
Tuple<long, long> nextLeft = new Tuple<long, long>(nextLeftVertex.VertexTypeID, nextLeftVertex.VertexID);
#region if the child is the _Target
if (nextLeft.Equals(_Target.Key))
{
if (TargetFoundCheckAbort(nextLeft, ref currentNodeLeft, ref nextLeftNode, nextLeftVertex))
return new TargetAnalyzer(_Root, _Target, _ShortestPathLength, _ShortestOnly, _FindAll).GetPaths();
}
#endregion
#region already visited
else if (_VisitedNodesLeft.ContainsKey(nextLeft))
{
UpdateVisitedLeft(nextLeft, ref currentNodeLeft);
}
#endregion already visited
#region set as visited
else
{
SetAsVisitedLeft(nextLeft, ref currentNodeLeft, ref nextLeftNode, nextLeftVertex);
}
#endregion set as visited
}
#endregion check left friends
//get all referenced ObjectUUIDs using the given Edge
var rightVertices = GetIncomingVertices(currentVertexRight);
#region check right friends
foreach (var nextRightVertex in rightVertices)
{
Node nextRightNode = null;
Tuple<long, long> nextRight = new Tuple<long, long>(nextRightVertex.VertexTypeID, nextRightVertex.VertexID);
#region if the child is the _Target
if (_Root.Key.Equals(nextRight))
{
示例13: TupleEqualsNullReturnsFalse
public void TupleEqualsNullReturnsFalse()
{
var testTuple = new Tuple<string, int>("this is a test", 42);
Assert.IsFalse(testTuple.Equals(null));
}
示例14: TupleEqualsItselfReturnsTrue
public void TupleEqualsItselfReturnsTrue()
{
var testTuple = new Tuple<string, int>("this is a test", 42);
Assert.IsTrue(testTuple.Equals(testTuple));
}
示例15: CalculateMro
protected override Tuple CalculateMro(Tuple baseClasses)
{
// should always be the same for ReflectedTypes
Debug.Assert(baseClasses.Equals(BaseClasses));
if (effectivePythonType != null) {
return effectivePythonType.MethodResolutionOrder;
} else {
return base.CalculateMro(baseClasses);
}
}