本文整理汇总了C#中Difference类的典型用法代码示例。如果您正苦于以下问题:C# Difference类的具体用法?C# Difference怎么用?C# Difference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Difference类属于命名空间,在下文中一共展示了Difference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareType
/// <summary>
/// Compare two URIs
/// </summary>
public override void CompareType(CompareParms parms)
{
Uri uri1 = parms.Object1 as Uri;
Uri uri2 = parms.Object2 as Uri;
//This should never happen, null check happens one level up
if (uri1 == null || uri2 == null)
return;
if (uri1.OriginalString != uri2.OriginalString)
{
Difference difference = new Difference
{
ParentObject1 = new WeakReference(parms.ParentObject1),
ParentObject2 = new WeakReference(parms.ParentObject2),
PropertyName = parms.BreadCrumb,
Object1Value = NiceString(uri1.OriginalString),
Object2Value = NiceString(uri2.OriginalString),
ChildPropertyName = "OriginalString",
Object1 = new WeakReference(parms.Object1),
Object2 = new WeakReference(parms.Object2)
};
AddDifference(parms.Result, difference);
}
}
示例2: Clone
public void Clone()
{
Difference diff = new Difference(
new ScrReference(1, 1, 1, Paratext.ScrVers.English),
new ScrReference(1, 1, 30, Paratext.ScrVers.English),
4711, 1, 99, 4712, 11, 88,
DifferenceType.PictureDifference,
null, null, "Whatever", "Whateverelse", "Esperanto", "Latvian",
null, null);
//diff.HvosSectionsCurr = new int[] {6, 7, 8};
Difference clonedDiff = diff.Clone();
Assert.AreEqual(1001001, clonedDiff.RefStart);
Assert.AreEqual(1001030, clonedDiff.RefEnd);
Assert.AreEqual(4711, clonedDiff.HvoCurr);
Assert.AreEqual(1, clonedDiff.IchMinCurr);
Assert.AreEqual(99, clonedDiff.IchLimCurr);
Assert.AreEqual(4712, clonedDiff.HvoRev);
Assert.AreEqual(11, clonedDiff.IchMinRev);
Assert.AreEqual(88, clonedDiff.IchLimRev);
//Assert.AreEqual(987654321, clonedDiff.hvoAddedSection);
Assert.AreEqual(DifferenceType.PictureDifference, clonedDiff.DiffType);
Assert.IsNull(clonedDiff.SubDiffsForParas);
Assert.IsNull(clonedDiff.SubDiffsForORCs);
Assert.AreEqual("Whatever", clonedDiff.StyleNameCurr);
Assert.AreEqual("Whateverelse", clonedDiff.StyleNameRev);
Assert.AreEqual("Esperanto", clonedDiff.WsNameCurr);
Assert.AreEqual("Latvian", clonedDiff.WsNameRev);
}
示例3: Equals
protected bool Equals(Difference other)
{
return string.Equals(Breadcrumb, other.Breadcrumb)
&& string.Equals(ChildProperty, other.ChildProperty)
&& Equals(Value1, other.Value1)
&& Equals(Value2, other.Value2);
}
示例4: Visit
public override void Visit(Difference difference)
{
_differences.Add(difference);
// For now use this to set the ExitCode to 2 if there are any differences
DifferenceWriter.ExitCode = 2;
}
示例5: ListsHaveDifferentCounts
private bool ListsHaveDifferentCounts(CompareParms parms)
{
IList ilist1 = parms.Object1 as IList;
IList ilist2 = parms.Object2 as IList;
if (ilist1 == null)
throw new ArgumentException("parms.Object1");
if (ilist2 == null)
throw new ArgumentException("parms.Object2");
//Objects must be the same length
if (ilist1.Count != ilist2.Count)
{
Difference difference = new Difference
{
ParentObject1 = new WeakReference(parms.ParentObject1),
ParentObject2 = new WeakReference(parms.ParentObject2),
PropertyName = parms.BreadCrumb,
Object1Value = ilist1.Count.ToString(CultureInfo.InvariantCulture),
Object2Value = ilist2.Count.ToString(CultureInfo.InvariantCulture),
ChildPropertyName = "Count",
Object1 = new WeakReference(ilist1),
Object2 = new WeakReference(ilist2)
};
AddDifference(parms.Result, difference);
if (parms.Result.ExceededDifferences)
return true;
}
return false;
}
示例6: Format
public override string Format(Difference difference)
{
var setDifference = (SetDifference) difference;
var sb = new StringBuilder();
sb.AppendFormat("Actual{0} != Expected{0}", setDifference.Breadcrumb);
if (setDifference.Extra.Count != 0)
{
sb.AppendLine();
sb.AppendFormat("Actual{0} contains the following unmatched elements:", setDifference.Breadcrumb);
foreach (var o in setDifference.Extra)
{
sb.AppendLine();
sb.AppendFormat("\t{0}", Prettify(o));
}
}
if (setDifference.Expected.Count != 0)
{
sb.AppendLine();
sb.AppendFormat("Expected{0} contains the following unmatched elements:", setDifference.Breadcrumb);
foreach (var o in setDifference.Expected)
{
sb.AppendLine();
sb.AppendFormat("\t{0}", Prettify(o));
}
}
return sb.ToString();
}
示例7: CreateDiffResult
public void CreateDiffResult()
{
_result = new DiffResult();
_diff = new XmlDiff("<a/>", "<b/>");
_majorDifference = new Difference(DifferenceType.ElementTagName, XmlNodeType.Element, XmlNodeType.Element);
_minorDifference = new Difference(DifferenceType.AttributeSequence, XmlNodeType.Comment, XmlNodeType.Comment);
}
示例8: Clone
public void Clone()
{
IScrTxtPara[] paras = DiffTestHelper.CreateDummyParas(2, Cache);
Difference diff = new Difference(
new ScrReference(1, 1, 1, ScrVers.English),
new ScrReference(1, 1, 30, ScrVers.English),
paras[0], 1, 99, paras[1], 11, 88,
DifferenceType.PictureDifference,
null, null, "Whatever", "Whateverelse", "Esperanto", "Latvian",
null, null);
//diff.SectionsCurr = new int[] {6, 7, 8};
Difference clonedDiff = diff.Clone();
Assert.AreEqual(1001001, clonedDiff.RefStart);
Assert.AreEqual(1001030, clonedDiff.RefEnd);
Assert.AreSame(paras[0], clonedDiff.ParaCurr);
Assert.AreEqual(1, clonedDiff.IchMinCurr);
Assert.AreEqual(99, clonedDiff.IchLimCurr);
Assert.AreSame(paras[1], clonedDiff.ParaRev);
Assert.AreEqual(11, clonedDiff.IchMinRev);
Assert.AreEqual(88, clonedDiff.IchLimRev);
//Assert.AreEqual(987654321, clonedDiff.hvoAddedSection);
Assert.AreEqual(DifferenceType.PictureDifference, clonedDiff.DiffType);
Assert.IsNull(clonedDiff.SubDiffsForParas);
Assert.IsNull(clonedDiff.SubDiffsForORCs);
Assert.AreEqual("Whatever", clonedDiff.StyleNameCurr);
Assert.AreEqual("Whateverelse", clonedDiff.StyleNameRev);
Assert.AreEqual("Esperanto", clonedDiff.WsNameCurr);
Assert.AreEqual("Latvian", clonedDiff.WsNameRev);
}
示例9: DiffResultTests
public DiffResultTests()
{
_result = new DiffResult();
_diff = new XmlDiff("<a/>", "<b/>");
_majorDifference = new Difference(DifferenceType.ELEMENT_TAG_NAME_ID, XmlNodeType.Element,
XmlNodeType.Element);
_minorDifference = new Difference(DifferenceType.ATTR_SEQUENCE_ID, XmlNodeType.Comment, XmlNodeType.Comment);
}
示例10: ThrowsExceptionCgpNull
public void ThrowsExceptionCgpNull()
{
var instance = new Difference();
var ex = Assert.Throws<ArgumentNullException>(() => instance.Generate(null));
Assert.Equal("cgp", ex.ParamName);
}
示例11: OperationTypeConflict
public OperationTypeConflict(
Difference differenceInSourceBranch,
Difference differenceInDestinationBranch)
: base(differenceInSourceBranch.Identifier)
{
r_differenceInSourceBranch = differenceInSourceBranch;
r_differenceInDestinationBranch = differenceInDestinationBranch;
}
示例12: VerifyParaDiff
/// <summary>overload for same end ref</summary>
public static void VerifyParaDiff(Difference diff,
BCVRef startAndEnd, DifferenceType type,
StTxtPara paraCurr, int ichMinCurr, int ichLimCurr,
StTxtPara paraRev, int ichMinRev, int ichLimRev)
{
VerifyParaDiff(diff, startAndEnd, startAndEnd, type,
paraCurr, ichMinCurr, ichLimCurr,
paraRev, ichMinRev, ichLimRev);
}
示例13: UndoDifferenceAction
/// ------------------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <param name="differenceList"></param>
/// <param name="reviewedList"></param>
/// <param name="fRevert"><code>true</code> if we are reverting the difference (as
/// opposed to keeping the current). If <c>true</c> a revert action is being created</param>
/// ------------------------------------------------------------------------------------
public UndoDifferenceAction(DifferenceList differenceList, DifferenceList reviewedList,
bool fRevert)
{
m_differenceList = differenceList;
m_reviewedList = reviewedList;
m_differenceRef = m_differenceList.CurrentDifference;
m_differenceClone = m_differenceList.CurrentDifference.Clone();
m_index = m_differenceList.CurrentDifferenceIndex;
m_fReverted = fRevert;
}
示例14: m_buttonAccept_Click
private void m_buttonAccept_Click(object sender, EventArgs e)
{
if (m_radioKeepSource.Checked)
{
m_result = (Difference)m_radioKeepSource.Tag;
}
else
{
m_result = (Difference)m_radioKeepDestination.Tag;
}
}
示例15: Main
static void Main(string[] args)
{
int.Parse(Console.ReadLine());
int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
Difference d = new Difference(a);
d.computeDifference();
Console.Write(d.maximumDifference);
}