本文整理汇总了C#中Collections.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# Collections.Remove方法的具体用法?C# Collections.Remove怎么用?C# Collections.Remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collections
的用法示例。
在下文中一共展示了Collections.Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateDetailCollections
protected virtual void UpdateDetailCollections(Collections.IContentList<DetailCollection> target, Collections.IContentList<DetailCollection> source, ContentItem targetItem)
{
ReplaceDetailCollectionsEnclosingItem(targetItem, source);
List<string> keys = new List<string>(target.Keys);
foreach (string key in keys)
{
DetailCollection detailCollection = target[key];
if (detailCollection.Name == "TrackedLinks")
continue;
if (source.Keys.Contains(key))
{
UpdateDetails(detailCollection.Details as Collections.IContentList<ContentDetail>, source[key].Details as Collections.IContentList<ContentDetail>, targetItem);
}
else
target.Remove(detailCollection);
}
keys = new List<string>(source.Keys);
foreach (string key in keys)
{
DetailCollection detailCollection = source[key];
if (detailCollection.Name == "TrackedLinks")
continue;
if (target.Keys.Contains(key) == false)
{
detailCollection.ID = 0;
target.Add(detailCollection);
}
}
}
示例2: UpdateDetails
protected virtual void UpdateDetails(Collections.IContentList<ContentDetail> target, Collections.IContentList<ContentDetail> source, ContentItem targetItem)
{
ReplaceDetailsEnclosingItem(targetItem, source);
List<string> keys = new List<string>(target.Keys);
foreach (string key in keys)
{
ContentDetail detail = target[key];
//Don't update Parent and Versionkey
if (target[key].Name == "ParentID" || target[key].Name == "VersionKey")
continue;
//Update Values
if (source.Keys.Contains(key))
{
//Check Ignore Attribute
var prop = targetItem.GetType().GetProperty(key);
//Details left in db not used as property anymore check
if (prop != null)
{
if (Attribute.IsDefined(prop, typeof(N2.Details.XMLUpdaterIgnoreAttribute)))
continue;
}
target[key].ObjectValue = source[key].BoolValue;
target[key].DateTimeValue = source[key].DateTimeValue;
target[key].DoubleValue = source[key].DoubleValue;
target[key].IntValue = source[key].IntValue;
target[key].Meta = source[key].Meta;
target[key].ObjectValue = source[key].ObjectValue;
target[key].StringValue = source[key].StringValue;
target[key].Value = source[key].Value;
}
else
{
target.Remove(detail);
}
}
//Add none existing Details from source
keys = new List<string>(source.Keys);
foreach (string key in keys)
{
ContentDetail detail = source[key];
//Ignore Parent and Versionkey
if (detail.Name == "ParentID" && detail.Name == "VersionKey")
continue;
if (target.Keys.Contains(key) == false)
{
detail.ID = 0;
target.Add(detail);
}
}
}