本文整理汇总了C#中SPFieldLookupValue.EnhancedCompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# SPFieldLookupValue.EnhancedCompareTo方法的具体用法?C# SPFieldLookupValue.EnhancedCompareTo怎么用?C# SPFieldLookupValue.EnhancedCompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPFieldLookupValue
的用法示例。
在下文中一共展示了SPFieldLookupValue.EnhancedCompareTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateItemProperty
public static bool ValidateItemProperty(SPListItem item, Guid fieldId, Criteria criteria, string itemValueString)
{
switch (item.Fields[fieldId].Type)
{
case SPFieldType.Boolean:
return Boolean.Parse(itemValueString).EnhancedCompareTo(criteria);
case SPFieldType.User:
SPFieldUser userField = (SPFieldUser)item.Fields[fieldId];
SPPrincipal spPrincipal = item.ParentList.ParentWeb.Site.FindUserOrSiteGroup(itemValueString);
if (userField.AllowMultipleValues)
{
//SPFieldLookupValueCollection userValues = new SPFieldLookupValueCollection(itemValueString);
//return userValues.EnhancedCompareTo(criteria);
return false;
}
SPFieldLookupValue userValue = new SPFieldLookupValue(spPrincipal.ID, spPrincipal.Name);
return userValue.EnhancedCompareTo(criteria);
case SPFieldType.Lookup:
SPFieldLookup lookupField = (SPFieldLookup)item.Fields[fieldId];
if (lookupField.AllowMultipleValues)
{
SPFieldLookupValueCollection itemValueCol = new SPFieldLookupValueCollection(itemValueString);
return itemValueCol.EnhancedCompareTo(criteria);
}
SPFieldLookupValue itemFieldValue = (SPFieldLookupValue)lookupField.GetFieldValue(itemValueString);
return itemFieldValue.EnhancedCompareTo(criteria);
case SPFieldType.Computed:
case SPFieldType.Note:
case SPFieldType.Text:
return itemValueString.EnhancedCompareTo(criteria);
case SPFieldType.Currency:
case SPFieldType.Integer:
case SPFieldType.Number:
long itemValue;
if (long.TryParse(itemValueString, out itemValue))
{
return itemValue.EnhancedCompareTo(criteria);
}
break;
case SPFieldType.DateTime:
DateTime itemDateTimeValue;
if (DateTime.TryParse(itemValueString, out itemDateTimeValue))
{
return itemDateTimeValue.EnhancedCompareTo(criteria);
}
break;
default:
return itemValueString.EnhancedCompareTo(criteria);
}
return false;
}