当前位置: 首页>>代码示例>>C#>>正文


C# Collections.Remove方法代码示例

本文整理汇总了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);
				}
			}

		}
开发者ID:andy4711,项目名称:n2cms,代码行数:38,代码来源:Updater.cs

示例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);
				}
			}
		}
开发者ID:andy4711,项目名称:n2cms,代码行数:63,代码来源:Updater.cs


注:本文中的Collections.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。