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


C# ContentItem.GetContentType方法代码示例

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


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

示例1: IsSelectable

        internal static bool IsSelectable(ContentItem item, string selectableTypes, string selectableExtensions)
        {
            var baseTypesAndInterfaceNames = item.GetContentType().GetInterfaces().Select(i => i.Name)
                .Union(Utility.GetBaseTypesAndSelf(item.GetContentType()).Select(t => t.Name));

            bool isSelectableType = string.IsNullOrEmpty(selectableTypes)
                || selectableTypes.Split(',').Intersect(baseTypesAndInterfaceNames).Any();

            bool isSelectableExtension = string.IsNullOrEmpty(selectableExtensions)
                || selectableExtensions.Split(',').Contains(item.Url.ToUrl().Extension, StringComparer.InvariantCultureIgnoreCase);

            return isSelectableType && isSelectableExtension;
        }
开发者ID:ikvm,项目名称:n2cms,代码行数:13,代码来源:TreeUtility.cs

示例2: IsIndexable

		public virtual bool IsIndexable(ContentItem item)
		{
			if (item.GetContentType().GetCustomAttributes(true).OfType<IIndexableType>().Any(it => !it.IsIndexable))
				return false;

			return true;
		}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:7,代码来源:TextExtractor.cs

示例3: CopyAutoImplementedProperties

 private static void CopyAutoImplementedProperties(ContentItem source, ContentItem destination)
 {
     foreach (var property in source.GetContentType().GetProperties().Where(pi => pi.IsInterceptable()))
     {
         destination[property.Name] = TryClone(source[property.Name]);
     }
 }
开发者ID:nicklv,项目名称:n2cms,代码行数:7,代码来源:VersioningExtensions.cs

示例4: BuildLink

        internal static ILinkBuilder BuildLink(NodeAdapter adapter, ContentItem item, bool isSelected, string target, bool isSelectable)
        {
            INode node = item;
            string className = node.ClassNames;
            if (isSelected)
                className += "selected ";
            if (isSelectable)
                className += "selectable ";
            else
                className += "unselectable ";

            ILinkBuilder builder = Link.To(node)
                .Target(target)
                .Class(className)
                .Href(adapter.GetPreviewUrl(item))
                .Text("<img src='" + adapter.GetIconUrl(item) + "'/>" + node.Contents)
                .Attribute("id", item.Path.Replace('/', '_'))
                .Attribute("title", "#" + item.ID + ": " + N2.Context.Current.Definitions.GetDefinition(item).Title)
                .Attribute("data-id", item.ID.ToString())
                .Attribute("data-type", item.GetContentType().Name)
                .Attribute("data-path", item.Path)
                .Attribute("data-url", item.Url)
                .Attribute("data-page", item.IsPage.ToString().ToLower())
                .Attribute("data-zone", item.ZoneName)
                .Attribute("data-permission", adapter.GetMaximumPermission(item).ToString());

            if (isSelected)
                builder.Attribute("data-selected", "true");
            if (isSelectable)
                builder.Attribute("data-selectable", "true");

            builder.Href(adapter.GetPreviewUrl(item));

            return builder;
        }
开发者ID:ikvm,项目名称:n2cms,代码行数:35,代码来源:TreeUtility.cs

示例5: GetPath

        public PathData GetPath(ContentItem item, string remainingUrl)
        {
            int slashIndex = remainingUrl.IndexOf('/');

            string action = remainingUrl;
            string arguments = null;
            if(slashIndex > 0)
            {
                action = remainingUrl.Substring(0, slashIndex);
                arguments = remainingUrl.Substring(slashIndex + 1);
            }

            var controllerName = controllerMapper.GetControllerName(item.GetContentType());
            if (string.IsNullOrEmpty(action) || string.Equals(action, "Default.aspx", StringComparison.InvariantCultureIgnoreCase))
                action = "Index";

            foreach (string method in methods)
            {
                if (string.Equals(method, action, StringComparison.InvariantCultureIgnoreCase))
                {
                    return new PathData(item, null, action, arguments)
                    {
                        IsRewritable = false,
                        TemplateUrl = string.Format("~/{0}/{1}", controllerName, method, item.ID) // workaround for start pages
                    };
                }
            }

            return null;
        }
开发者ID:AnonymousRetard,项目名称:n2cms,代码行数:30,代码来源:ActionResolver.cs

示例6: GetRouteValues

        /// <summary>Gets route data for for items this route handles.</summary>
        /// <param name="item">The item whose route to get.</param>
        /// <param name="routeValues">The route values to apply to the route data.</param>
        /// <returns>A route data object or null.</returns>
        public virtual RouteValueDictionary GetRouteValues(ContentItem item, RouteValueDictionary routeValues)
        {
            string actionName = "Index";
            if (routeValues.ContainsKey(ActionKey))
                actionName = (string)routeValues[ActionKey];

            string id = null;
            if (routeValues.ContainsKey(IdKey))
                id = (string)routeValues[IdKey];

            string controllerName = controllerMapper.GetControllerName(item.GetContentType());
            if (controllerName == null || !controllerMapper.ControllerHasAction(controllerName, actionName))
                return null;

            var values = new RouteValueDictionary(routeValues);

            foreach (var kvp in innerRoute.Defaults)
                if(!values.ContainsKey(kvp.Key))
                    values[kvp.Key] = kvp.Value;

            values[ControllerKey] = controllerName;
            values[ActionKey] = actionName;
            values[ContentItemKey] = item.ID;
            values[AreaKey] = innerRoute.DataTokens["area"];

            if (!string.IsNullOrEmpty(id))
            {
                values[IdKey] = id;
            }

            return values;
        }
开发者ID:EzyWebwerkstaden,项目名称:n2cms,代码行数:36,代码来源:ContentRoute.cs

示例7: IsVersionable

        /// <summary>Checks whether an item  may have versions.</summary>
        /// <param name="item">The item to check.</param>
        /// <returns>True if the item is allowed to have versions.</returns>
        public bool IsVersionable(ContentItem item)
        {
            var versionables = (VersionableAttribute[])item.GetContentType().GetCustomAttributes(typeof(VersionableAttribute), true);
            bool isVersionable = versionables.Length == 0 || versionables[0].Versionable == N2.Definitions.AllowVersions.Yes;

            return isVersionable;
        }
开发者ID:spmason,项目名称:n2cms,代码行数:10,代码来源:VersionManager.cs

示例8: GetRouteValues

		private RouteValueDictionary GetRouteValues(HtmlHelper helper, ContentItem item)
		{
			Type itemType = item.GetContentType();
			string controllerName = controllerMapper.GetControllerName(itemType);
			if (string.IsNullOrEmpty(controllerName))
			{
				Engine.Logger.WarnFormat("Found no controller for type {0}", itemType);
				return null;
			}

			var values = new RouteValueDictionary();
			values[ContentRoute.ActionKey] = "Index";
			values[ContentRoute.ControllerKey] = controllerName;
			if (item.ID != 0)
				values[ContentRoute.ContentItemKey] = item.ID;
			else
				values[ContentRoute.ContentItemKey] = item;

			// retrieve the virtual path so we can figure out if this item is routed through an area
			var vpd = helper.RouteCollection.GetVirtualPath(helper.ViewContext.RequestContext, values);
			if (vpd == null)
				throw new InvalidOperationException("Unable to render " + item + " (" + controllerName + " did not match any route)");

			values["area"] = vpd.DataTokens["area"];
			return values;
		}
开发者ID:meixger,项目名称:n2cms,代码行数:26,代码来源:TemplateRenderer.cs

示例9: WriteDefaultAttributes

 protected virtual void WriteDefaultAttributes(ElementWriter itemElement, ContentItem item)
 {
     itemElement.WriteAttribute("id", item.ID);
     itemElement.WriteAttribute("name", item.ID.ToString() == item.Name ? "" : item.Name);
     itemElement.WriteAttribute("parent", item.Parent != null ? item.Parent.ID.ToString() : string.Empty);
     itemElement.WriteAttribute("title", item.Title);
     itemElement.WriteAttribute("zoneName", item.ZoneName);
     itemElement.WriteAttribute("created", item.Created);
     itemElement.WriteAttribute("updated", item.Updated);
     itemElement.WriteAttribute("published", item.Published);
     itemElement.WriteAttribute("expires", item.Expires);
     itemElement.WriteAttribute("sortOrder", item.SortOrder);
     itemElement.WriteAttribute("url", parser.BuildUrl(item));
     itemElement.WriteAttribute("visible", item.Visible);
     itemElement.WriteAttribute("savedBy", item.SavedBy);
     itemElement.WriteAttribute("typeName", SerializationUtility.GetTypeAndAssemblyName(item.GetContentType()));
     itemElement.WriteAttribute("discriminator", definitions.GetDefinition(item.GetContentType()).Discriminator);
 }
开发者ID:spmason,项目名称:n2cms,代码行数:18,代码来源:ItemXmlWriter.cs

示例10: FilfilDependencies

 public virtual bool FilfilDependencies(ContentItem item)
 {
     bool dependenciesInjted = false;
     foreach (var provider in GetSetters(item.GetContentType()))
     {
         provider.Fulfil(item);
         dependenciesInjted = true;
     }
     return dependenciesInjted;
 }
开发者ID:joaohortencio,项目名称:n2cms,代码行数:10,代码来源:ContentDependencyInjector.cs

示例11: UpdateEditor

		public override void UpdateEditor(ContentItem item, Control editor)
		{
			ListControl lc = editor as ListControl;
			if (!editor.Page.IsPostBack)
			{
				lc.Items.Clear();
				lc.Items.AddRange(Engine.Definitions.GetTemplates(item.GetContentType()).Select(t => new ListItem(t.Title, t.Name ?? "")).ToArray());
			}

			base.UpdateEditor(item, editor);
		}
开发者ID:navneetccna,项目名称:n2cms,代码行数:11,代码来源:WithEditableTemplateSelectionAttribute.cs

示例12: ControllerWrapper

			public ControllerWrapper(ContentItem item, IControllerMapper controllerMapper)
			{
				this.ID = "cw" + item.ID;
				ViewData = new ViewDataDictionary(item);
				this.item = item;
				this.controllerMapper = controllerMapper;
				itemType = item.GetContentType();
				controllerName = controllerMapper.GetControllerName(itemType);
				routes = RouteTable.Routes;
				httpContext = new HttpContextWrapper(HttpContext.Current);
			}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:11,代码来源:MvcOnWebFormPartAdapter.cs

示例13: RenderTemplate

		public virtual void RenderTemplate(HtmlHelper html, ContentItem model)
		{
			var renderer = model as Rendering.IContentRenderer
				?? RendererSelector.ResolveRenderer(model.GetContentType());
			if (renderer != null)
			{
				renderer.Render(new Rendering.ContentRenderingContext { Content = model, Html = html }, html.ViewContext.Writer);
				return;
			}

			Renderer.RenderTemplate(model, html);
		}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:12,代码来源:MvcAdapter.cs

示例14: GetPath

        public PathData GetPath(ContentItem item, string remainingUrl)
        {
            if(string.IsNullOrEmpty(remainingUrl))
            {
                Type itemType = item.GetContentType();
                string virtualDirectory = ConventionTemplateDirectoryAttribute.GetDirectory(itemType);

                string templateName = otherTemplateName ?? itemType.Name;
                return new PathData(item, virtualDirectory + templateName + ".aspx");
            }
            return null;
        }
开发者ID:Jobu,项目名称:n2cms,代码行数:12,代码来源:ConventionTemplateAttribute.cs

示例15: GetTemplate

        public TemplateDefinition GetTemplate(ContentItem item)
        {
            string templateKey = item.TemplateKey;
            if(templateKey == null)
                return null;

            return GetTemplates(item.GetContentType()).Where(t => t.Name == templateKey).Select(t =>
            {
                t.OriginalFactory = t.TemplateFactory;
                t.TemplateFactory = () => item;
                return t;
            }).FirstOrDefault();
        }
开发者ID:GrimaceOfDespair,项目名称:n2cms,代码行数:13,代码来源:ContentTemplateProvider.cs


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