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


C# ContentItem.GetDetailCollection方法代码示例

本文整理汇总了C#中ContentItem.GetDetailCollection方法的典型用法代码示例。如果您正苦于以下问题:C# ContentItem.GetDetailCollection方法的具体用法?C# ContentItem.GetDetailCollection怎么用?C# ContentItem.GetDetailCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContentItem的用法示例。


在下文中一共展示了ContentItem.GetDetailCollection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Transform

        public bool Transform(ContentItem item)
        {
            string text = item[Name] as string;
            if(text != null)
            {
                string detailName = Name + "_Tokens";
                int i = 0;
                var p = new Parser(new TemplateAnalyzer());
                foreach (var c in p.Parse(text).Where(c => c.Command != Parser.TextCommand))
                {
                    var dc = item.GetDetailCollection(detailName, true);
                    var cd = ContentDetail.Multi(detailName, stringValue: c.Tokens.Select(t => t.Fragment).StringJoin(), integerValue: c.Tokens.First().Index);
                    cd.EnclosingItem = item;
                    cd.EnclosingCollection = dc;

                    if (dc.Details.Count > i)
                        dc.Details[i] = cd;
                    else
                        dc.Details.Add(cd);
                    i++;
                }
                if (i > 0)
                {
                    var dc = item.GetDetailCollection(detailName, true);
                    for (int j = dc.Details.Count - 1; j >= i; j--)
                    {
                        dc.Details.RemoveAt(j);
                    }
                    return true;
                }
            }
            return false;
        }
开发者ID:timothyyip,项目名称:n2cms,代码行数:33,代码来源:DisplayableTokensAttribute.cs

示例2: UpdateLinks

		public virtual void UpdateLinks(ContentItem item)
		{
			var referencedItems = FindLinkedObjects(item).ToList();
			DetailCollection links = item.GetDetailCollection(LinkDetailName, false);
			if (links == null && referencedItems.Count == 0)
				return;

			if (links == null)
				links = item.GetDetailCollection(LinkDetailName, true);

			// replace existing items
			for (int i = 0; i < referencedItems.Count && i < links.Count; i++)
			{
				if (links.Details[i].StringValue == referencedItems[i].StringValue)
					// this prevents clearing item references to children when moving hierarchies
					continue;
				links.Details[i].Extract(referencedItems[i]);
			}
			// add any new items
			for (int i = links.Details.Count; i < referencedItems.Count; i++)
			{
				links.Add(referencedItems[i]);
			}
			// remove any extra items
			while (links.Count > referencedItems.Count)
			{
				links.RemoveAt(links.Count - 1);
			}
		}
开发者ID:navneetccna,项目名称:n2cms,代码行数:29,代码来源:Tracker.cs

示例3: ApplyChanges

        private void ApplyChanges(AppliedTags change, ContentItem item)
        {
            DetailCollection links = item.GetDetailCollection(Name, false);
            if (links == null)
            {
                if (change.Tags.Count == 0)
                    return;
                links = item.GetDetailCollection(Name, true);
            }

            List<ITag> currentTags = GetCurrentTags(change.Group, links);

            IEnumerable<string> addedTags = GetAddedTags(currentTags, change.Tags);
            foreach(string tagName in addedTags)
            {
                ITag tag = change.Group.GetOrCreateTag(tagName);
                links.Add(tag);
            }
            
            foreach(ContentItem tag in currentTags)
            {
                if (!change.Tags.Contains(tag.Title))
                    links.Remove(tag);
            }
        }
开发者ID:EzyWebwerkstaden,项目名称:n2cms,代码行数:25,代码来源:EditableTagsAttribute.cs

示例4: GetRoles

        /// <summary>Gets roles allowed for a certain permission stored in a content item.</summary>
        /// <param name="item">The item whose permitted roles get.</param>
        /// <param name="permission">The permission asked for.</param>
        /// <returns>Permitted roles.</returns>
        public static IEnumerable<string> GetRoles(ContentItem item, Permission permission)
        {
            List<string> roles = null;
            foreach (Permission permissionLevel in SplitPermission(permission))
            {
                if(permissionLevel == Permission.Read)
                {
                    foreach(AuthorizedRole role in item.AuthorizedRoles)
                    {
                        AddTo(ref roles, role.Role);
                    }
                    continue;
                }

                DetailCollection roleDetails = item.GetDetailCollection(AuthorizedRolesPrefix + permissionLevel, false);
                if (roleDetails == null)
                    continue;

                foreach(string role in roleDetails)
                {
                    roles = AddTo(ref roles, role);
                }
            }
            return roles;
        }
开发者ID:Jobu,项目名称:n2cms,代码行数:29,代码来源:DynamicPermissionMap.cs

示例5: ReadDetailCollection

        protected void ReadDetailCollection(XPathNavigator navigator, ContentItem item, ReadingJournal journal)
        {
            Dictionary<string, string> attributes = GetAttributes(navigator);
            string name = attributes["name"];

            foreach (XPathNavigator detailElement in EnumerateChildren(navigator))
                ReadDetail(detailElement, item.GetDetailCollection(name, true), journal);
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:8,代码来源:PropertyCollectionXmlReader.cs

示例6: GetStoredSelection

        protected override HashSet<int> GetStoredSelection(ContentItem item)
        {
            var detailLinks = item.GetDetailCollection(Name, false);

            if (detailLinks == null)
                return new HashSet<int>();

            return new HashSet<int>(detailLinks.Details.Where(d => d.LinkValue.HasValue).Select(d => d.LinkValue.Value));
        }
开发者ID:Biswo,项目名称:n2cms,代码行数:9,代码来源:EditableMultipleItemSelectionAttribute.cs

示例7: Write

        public override void Write(ContentItem item, string propertyName, System.IO.TextWriter writer)
        {
            var items = item.GetDetailCollection(Name, false);

            if (items != null)
            {
                foreach (var referencedItem in items.OfType<ContentItem>())
                {
                    DisplayableAnchorAttribute.GetLinkBuilder(item, referencedItem, propertyName, null, null).WriteTo(writer);
                }
            }
        }
开发者ID:Biswo,项目名称:n2cms,代码行数:12,代码来源:EditableMultipleItemSelectionAttribute.cs

示例8: UpdateItem

		public override bool UpdateItem(ContentItem item, Control editor)
		{
			CheckBoxList cbl = editor as CheckBoxList;
			List<string> roles = new List<string>();
			foreach (ListItem li in cbl.Items)
				if (li.Selected)
					roles.Add(li.Value);

			DetailCollection dc = item.GetDetailCollection(Name, true);
			dc.Replace(roles);

			return true;
		}
开发者ID:navneetccna,项目名称:n2cms,代码行数:13,代码来源:EditableRolesAttribute.cs

示例9: UpdateLinks

		public virtual void UpdateLinks(ContentItem item)
		{
			logger.DebugFormat("Updating link: {0}", item);

			var referencedItems = FindLinkedObjects(item).ToList();
			DetailCollection links = item.GetDetailCollection(LinkDetailName, false);
			if (links == null && referencedItems.Count == 0)
			{
				logger.Debug("Exiting due to no links and none to update");
				return;
			}

			if (links == null)
				links = item.GetDetailCollection(LinkDetailName, true);

			logger.DebugFormat("Updating {0} links to {1} existing", referencedItems.Count, links.Count);

			// replace existing items
			for (int i = 0; i < referencedItems.Count && i < links.Count; i++)
			{
				var extracted = referencedItems[i];
				var stored = links.Details[i];
				if (stored.StringValue == extracted.StringValue && stored.Meta == extracted.Meta && stored.IntValue == extracted.IntValue && stored.BoolValue == extracted.BoolValue)
					// this prevents clearing item references to children when moving hierarchies
					continue;
				stored.Extract(extracted);
			}
			// add any new items
			for (int i = links.Details.Count; i < referencedItems.Count; i++)
			{
				links.Add(referencedItems[i]);
			}
			// remove any extra items
			while (links.Count > referencedItems.Count)
			{
				links.RemoveAt(links.Count - 1);
			}
		}
开发者ID:faester,项目名称:n2cms,代码行数:38,代码来源:Tracker.cs

示例10: UpdateLinksInternal

		private IEnumerable<ContentItem> UpdateLinksInternal(ContentItem item, bool recursive)
		{
			logger.DebugFormat("Updating link: {0}", item);

			if (recursive)
				foreach (var part in item.Children.FindParts())
					foreach (var updatedItem in UpdateLinksInternal(part, recursive))
						yield return updatedItem;

			var referencedItems = FindLinkedObjects(item).ToList();
			DetailCollection links = item.GetDetailCollection(LinkDetailName, false);
			if (links == null && referencedItems.Count == 0)
			{
				logger.Debug("Exiting due to no links and none to update");
				yield break;
			}

			if (links == null)
				links = item.GetDetailCollection(LinkDetailName, true);

			logger.DebugFormat("Updating {0} links to {1} existing", referencedItems.Count, links.Count);

			// replace existing items
			for (int i = 0; i < referencedItems.Count && i < links.Count; i++)
			{
				var extracted = referencedItems[i];
				var stored = links.Details[i];
				if (stored.StringValue == extracted.StringValue && stored.Meta == extracted.Meta && stored.IntValue == extracted.IntValue && stored.BoolValue == extracted.BoolValue)
					// this prevents clearing item references to children when moving hierarchies
					continue;
				stored.Extract(extracted);
			}
			// add any new items
			for (int i = links.Details.Count; i < referencedItems.Count; i++)
			{
				links.Add(referencedItems[i]);
			}
			// remove any extra items
			while (links.Count > referencedItems.Count)
			{
				links.RemoveAt(links.Count - 1);
			}

			yield return item;
		}
开发者ID:meixger,项目名称:n2cms,代码行数:45,代码来源:Tracker.cs

示例11: Authorizes

        public override bool Authorizes(IPrincipal user, ContentItem item, Permission permission)
        {
            if(permission == Permission.None)
                return true;
            if (!MapsTo(permission))
                return false;

            bool isContentAuthorized = false;

            foreach(Permission permissionLevel in SplitPermission(permission))
            {
                if(!MapsTo(permissionLevel))
                    continue;

                if ((item.AlteredPermissions & permissionLevel) == Permission.None)
                    continue;

                if(permissionLevel == Permission.Read)
                {
                    if(!item.IsAuthorized(user))
                        return false;
                    
                    isContentAuthorized = true;
                    continue;
                }

                DetailCollection details = item.GetDetailCollection(AuthorizedRolesPrefix + permissionLevel, false);
                if(details != null)
                {
                    string[] rolesAuthorizedByItem = details.ToArray<string>();
                    if (!IsInRoles(user, rolesAuthorizedByItem) && !IsInUsers(user.Identity.Name))
                        return false;

                    isContentAuthorized = true;
                }
            }

            return isContentAuthorized || base.Authorizes(user, item, permission);
        }
开发者ID:brianmatic,项目名称:n2cms,代码行数:39,代码来源:DynamicPermissionMap.cs

示例12: UpdateEditor

		public override void UpdateEditor(ContentItem item, Control editor)
		{
			CheckBoxList cbl = editor as CheckBoxList;
			DetailCollection dc = item.GetDetailCollection(Name, false);
			if (dc != null)
			{
				foreach (string role in dc)
				{
					ListItem li = cbl.Items.FindByValue(role);
					if (li != null)
					{
						li.Selected = true;
					}
					else
					{
						li = new ListItem(role);
						li.Selected = true;
						li.Attributes["style"] = "color:silver";
						cbl.Items.Add(li);
					}
				}
			}
		}
开发者ID:navneetccna,项目名称:n2cms,代码行数:23,代码来源:EditableRolesAttribute.cs

示例13: AddTagToItem

 public void AddTagToItem(Tag tag, ContentItem item)
 {
     PropertyCollection tags = item.GetDetailCollection("Tags", true);
     if (!tags.Contains(tag))
         tags.Add(tag);
 }
开发者ID:dpawatts,项目名称:zeus,代码行数:6,代码来源:TagService.cs

示例14: ReplaceStoredValue

 protected override void ReplaceStoredValue(ContentItem item, IEnumerable<ContentItem> linksToReplace)
 {
     item.GetDetailCollection(Name, true).Replace(linksToReplace);
 }
开发者ID:Biswo,项目名称:n2cms,代码行数:4,代码来源:EditableMultipleItemSelectionAttribute.cs

示例15: UpdateCurrentItemData

        private static void UpdateCurrentItemData(ContentItem currentItem, ContentItem replacementItem)
        {
            for (Type t = currentItem.GetType(); t.BaseType != null; t = t.BaseType)
            {
                foreach (PropertyInfo pi in t.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance))
                    if (pi.GetCustomAttributes(typeof(CopyAttribute), true).Length > 0)
                        pi.SetValue(currentItem, pi.GetValue(replacementItem, null), null);

                foreach (FieldInfo fi in t.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance))
                {
                    if (fi.GetCustomAttributes(typeof(CopyAttribute), true).Length > 0)
                        fi.SetValue(currentItem, fi.GetValue(replacementItem));
                    if (fi.Name == "_url")
                        fi.SetValue(currentItem, null);
                }
            }

            foreach (PropertyData detail in replacementItem.Details.Values)
                currentItem[detail.Name] = detail.Value;

            foreach (PropertyCollection collection in replacementItem.DetailCollections.Values)
            {
                PropertyCollection newCollection = currentItem.GetDetailCollection(collection.Name, true);
                foreach (PropertyData detail in collection.Details)
                    newCollection.Add(detail.Value);
            }
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:27,代码来源:VersionManager.cs


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