本文整理汇总了C#中IType.IsEqual方法的典型用法代码示例。如果您正苦于以下问题:C# IType.IsEqual方法的具体用法?C# IType.IsEqual怎么用?C# IType.IsEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IType
的用法示例。
在下文中一共展示了IType.IsEqual方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CountOccurrences
/// <summary>
/// Counts the number of times that the <paramref name="element"/> occurs
/// in the <paramref name="list"/>.
/// </summary>
/// <param name="element">The element to find in the list.</param>
/// <param name="list">The <see cref="IList"/> to search.</param>
/// <param name="elementType">The <see cref="IType"/> that can determine equality.</param>
/// <returns>
/// The number of occurrences of the element in the list.
/// </returns>
private int CountOccurrences(object element, IList list, IType elementType)
{
int result = 0;
foreach (object obj in list)
{
if (elementType.IsEqual(element, obj, EntityMode.Poco))
{
result++;
}
}
return result;
}
示例2: NeedsInserting
public override bool NeedsInserting(object entry, int i, IType elemType)
{
IList sn = (IList) GetSnapshot();
EntityMode entityMode = Session.EntityMode;
if (sn.Count > i && elemType.IsSame(sn[i], entry, entityMode))
{
// a shortcut if its location didn't change
return false;
}
else
{
//search for it
foreach (object old in sn)
{
if (elemType.IsEqual(old, entry, entityMode))
{
return false;
}
}
return true;
}
}
示例3: GetDeletes
// For a one-to-many, a <bag> is not really a bag;
// it is *really* a set, since it can't contain the
// same element twice. It could be considered a bug
// in the mapping dtd that <bag> allows <one-to-many>.
// Anyway, here we implement <set> semantics for a
// <one-to-many> <bag>!
public override IEnumerable GetDeletes(IType elemType, bool indexIsFormula)
{
ArrayList deletes = new ArrayList();
IList sn = (IList) GetSnapshot();
int i = 0;
foreach (object oldObject in sn)
{
bool found = false;
if (bag.Count > i && elemType.IsEqual(oldObject, bag[i++], EntityMode.Poco))
{
//a shortcut if its location didn't change!
found = true;
}
else
{
//search for it
foreach (object newObject in bag)
{
if (elemType.IsEqual(oldObject, newObject, EntityMode.Poco))
{
found = true;
break;
}
}
}
if (!found)
{
deletes.Add(oldObject);
}
}
return deletes;
}