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


C# ContentItem.GetType方法代码示例

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


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

示例1: RenderTemplate

        public string RenderTemplate(HtmlHelper htmlHelper, ContentItem item, IContentItemContainer container, string action)
        {
            RouteValueDictionary routeValues = new RouteValueDictionary();
            routeValues.Add(ContentRoute.ContentItemKey, item);
            routeValues.Add(ContentRoute.AreaKey, _controllerMapper.GetAreaName(item.GetType()));

            return htmlHelper.Action(action,
                _controllerMapper.GetControllerName(item.GetType()),
                routeValues).ToString();
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:10,代码来源:TemplateRenderer.cs

示例2: WriteDetail

		public virtual void WriteDetail(ContentItem item, ContentDetail detail, XmlTextWriter writer)
		{
			using (ElementWriter detailElement = new ElementWriter("detail", writer))
			{
				detailElement.WriteAttribute("name", detail.Name);
				detailElement.WriteAttribute("typeName", SerializationUtility.GetTypeAndAssemblyName(detail.ValueType));
				detailElement.WriteAttribute("meta", detail.Meta);

				
				var prop = item.GetType().GetProperty(detail.Name);

				if (prop != null)
				{
					if (Attribute.IsDefined(prop, typeof(N2.Details.XMLTranslateAttribute)))
					{
						string translate = "Value";

						//if (options.HasFlag(ExportOptions.TranslateDetailName))
						//		translate += ",Name";

						//if (options.HasFlag(ExportOptions.TranslateDetailTitle))
						//		translate += ",Title";

						detailElement.WriteAttribute("xmlTranslate", translate);
					}
				}

				WriteInnerContents(item, detail, detail.ValueTypeKey, detailElement);

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

示例3: ComputeReplacement

		private static string ComputeReplacement(ContentItem item, Match match)
		{
			var pn = match.Groups[1].Value.Split(new[] {':'}, 2);
			try
			{
				var d1 = item.GetDetail(pn[0]);
				if (d1 == null)
				{
					// hard-coded a few properties here to avoid reflection
					if (pn[0] == "Title")
						d1 = item.Title;
					else if (pn[0] == "Url")
						d1 = item.Url;
					else if (pn[0] == "Id")
						d1 = item.ID;
					else if (pn[0] == "Published")
						d1 = item.Published;
					else if (pn[0] == "TranslationKey")
						d1 = item.TranslationKey;
					else if (pn[0] == "SavedBy")
						d1 = item.SavedBy;
					else if (pn[0] == "Updated")
						d1 = item.Updated;
					else if (pn[0] == "Published")
						d1 = item.Published;
					else if (pn[0] == "Path")
						d1 = item.Path;
					else
					{
						// Use Reflection to resolve property. 
						var type = item.GetType();
						var props =
							type.GetProperties().Where(f => f.Name == pn[0]).
								ToArray();
						if (props.Length > 0)
							d1 = props[0].GetValue(item, null);
							// it's a property
						else
						{
							var fields =
								type.GetFields().Where(f => f.Name == pn[0]).
									ToArray();
							if (fields.Length > 0)
								d1 = fields[0].GetValue(item); // it's a field
						}
					}
				}
				if (d1 == null)
					return String.Concat('{', pn[0], ":null}");
				return (pn.Length == 2
					        ? String.Format(
						        String.Concat("{0:", pn[1], '}'), d1)
					        : d1.ToString());
			}
			catch (Exception err)
			{
				return err.ToString();
			}
		}
开发者ID:meixger,项目名称:n2cms,代码行数:59,代码来源:VariableSubstituter.cs

示例4: GetAllowedDefinitions

        /// <summary>Retrieves allowed item definitions.</summary>
        /// <param name="parentItem">The parent item.</param>
        /// <param name="zoneName">The zone where children would be placed.</param>
        /// <param name="user">The user to restrict access for.</param>
        /// <returns>Item definitions allowed by zone, parent restrictions and security.</returns>
        public virtual IEnumerable<ContentType> GetAllowedDefinitions(ContentItem parentItem, string zoneName, IPrincipal user)
        {
            ContentType containerDefinition = Engine.ContentTypes.GetContentType(parentItem.GetType());

            foreach (ContentType childDefinition in containerDefinition.AllowedChildren)
                if (childDefinition.IsAllowedInZone(zoneName) && childDefinition.Enabled && childDefinition.IsAuthorized(user))
                    yield return childDefinition;
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:13,代码来源:PartsAdapter.cs

示例5: IsEnabled

        public override bool IsEnabled(ContentItem contentItem)
        {
            ContentType definition = Context.ContentTypes.GetContentType(contentItem.GetType());
            if (!definition.AvailableZones.Any())
                return false;

            return base.IsEnabled(contentItem);
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:8,代码来源:ManageZonesMenuPlugin.cs

示例6: UpdateEditor

 public override void UpdateEditor(ContentItem item, Control editor)
 {
     ItemSelector selector = (ItemSelector)editor;
     selector.SelectedItem = item[Name] as ContentItem;
     var pi = item.GetType().GetProperty(Name);
     if(pi != null)
         selector.RequiredType = pi.PropertyType;
 }
开发者ID:spmason,项目名称:n2cms,代码行数:8,代码来源:EditableLinkAttribute.cs

示例7: UpdateEditor

		public override void UpdateEditor(ContentItem item, Control editor)
		{
			ItemSelector selector = (ItemSelector)editor;
			selector.SelectedItem = item[Name] as ContentItem;
			var pi = item.GetType().GetProperty(Name);
			if(pi != null)
				selector.RequiredType = pi.PropertyType;
			selector.SelectableTypes = string.Join(",", (SelectableTypes ?? new[] { selector.RequiredType ?? typeof(ContentItem) }).Select(t => t.Name).ToArray());
		}
开发者ID:nagarjunachallapalli,项目名称:n2cms,代码行数:9,代码来源:EditableLinkAttribute.cs

示例8: GetCopyException

        /// <summary>Check if an item can be copied.</summary>
        /// <exception cref="NameOccupiedException"></exception>
        /// <exception cref="ZeusException"></exception>
        public virtual ZeusException GetCopyException(ContentItem source, ContentItem destination)
        {
            if (IsNameOccupiedOnDestination(source, destination))
                return new NameOccupiedException(source, destination);

            if (!IsTypeAllowedBelowDestination(source, destination))
                return new NotAllowedParentException(_contentTypeManager.GetContentType(source.GetType()), destination.GetType());

            return null;
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:13,代码来源:IntegrityManager.cs

示例9: GetDetails

 protected override IEnumerable<PropertyData> GetDetails(ContentItem item)
 {
     ContentType definition = definitions.GetContentType(item.GetType());
     foreach (PropertyData detail in item.Details.Values)
         foreach (IContentProperty property in definition.Properties)
             if (detail.Name == property.Name)
             {
                 yield return detail;
                 break;
             }
 }
开发者ID:dpawatts,项目名称:zeus,代码行数:11,代码来源:DefinedPropertyXmlWriter.cs

示例10: WriteDefaultAttributes

 protected virtual void WriteDefaultAttributes(ElementWriter itemElement, ContentItem item)
 {
     itemElement.WriteAttribute("id", item.ID);
     itemElement.WriteAttribute("name", item.Name);
     itemElement.WriteAttribute("parent", item.Parent != null ? item.Parent.ID.ToString() : string.Empty);
     itemElement.WriteAttribute("title", item.Title);
     if (item is WidgetContentItem)
         itemElement.WriteAttribute("zoneName", ((WidgetContentItem) 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("language", item.Language);
     itemElement.WriteAttribute("translationOf", (item.TranslationOf != null) ? item.TranslationOf.ID.ToString() : string.Empty);
     itemElement.WriteAttribute("typeName", item.GetType().GetTypeAndAssemblyName());
     itemElement.WriteAttribute("discriminator", definitions.GetContentType(item.GetType()).Discriminator);
 }
开发者ID:dpawatts,项目名称:zeus,代码行数:21,代码来源:ItemXmlWriter.cs

示例11: GetTemplateUrl

        private string GetTemplateUrl(ContentItem item)
        {
            var templateUrl = String.Empty;
            var pathData = PathDictionary.GetFinders(item.GetType())
                .Where(finder => !(finder is ActionResolver))
                .Select(finder => finder.GetPath(item, null))
                .FirstOrDefault(path => path != null && !path.IsEmpty());

            if (pathData != null)
                templateUrl = pathData.TemplateUrl;
            return templateUrl;
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:12,代码来源:ActionResolver.cs

示例12: IsEnabled

        public override bool IsEnabled(ContentItem contentItem)
        {
            if (!base.IsEnabled(contentItem))
                return false;

            // Check that this content item has allowed children
            IContentTypeManager contentTypeManager = Context.ContentTypes;
            ContentType contentType = contentTypeManager.GetContentType(contentItem.GetType());
            if (!contentTypeManager.GetAllowedChildren(contentType, null, Context.Current.WebContext.User).Any())
                return false;

            return true;
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:13,代码来源:NewItemMenuPlugin.cs

示例13: PlaceHolder

        Control IDisplayable.AddTo(ContentItem item, string detailName, Control container)
        {
            if (!(item is IArticle)) throw new ArgumentException("The supplied item " + item.Path + "#" + item.ID + " of type '" + item.GetType().FullName + "' doesn't implement IArticle.", "item");

            WikiParser parser = Engine.Resolve<WikiParser>();
            WikiRenderer renderer = Engine.Resolve<WikiRenderer>();

            PlaceHolder ph = new PlaceHolder();
            container.Controls.Add(ph);

            renderer.AddTo(parser.Parse((string)item[detailName]), ph, item);

            return ph;
        }
开发者ID:hemonnet,项目名称:hemonnet,代码行数:14,代码来源:WikiTextAttribute.cs

示例14: GetPath

        public PathData GetPath(ContentItem item, string remainingUrl)
        {
            if (string.IsNullOrEmpty(remainingUrl) || string.Equals(remainingUrl, "default", StringComparison.InvariantCultureIgnoreCase))
                remainingUrl = DefaultAction;
            int slashIndex = remainingUrl.IndexOf('/');

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

            var templateUrl = GetTemplateUrl(item);
            var controllerName = _controllerMapper.GetControllerName(item.GetType());

            foreach (string method in _methods)
                if (method.Equals(action, StringComparison.InvariantCultureIgnoreCase))
                    return new MvcPathData(item, templateUrl, action, arguments, controllerName);

            return null;
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:23,代码来源:ActionResolver.cs

示例15: AddToContainer

 protected virtual void AddToContainer(Control container, ItemEditView itemEditor, ContentItem item)
 {
     FieldSet fs = new FieldSet();
     string status = (item.ID != 0) ? "ID #" + item.ID : "(Unsaved)";
     fs.Title = (item.ID != 0) ? Zeus.Context.Current.ContentTypes[item.GetType()].ContentTypeAttribute.Title + " " + status : "New Item " + status;
     container.Controls.Add(fs);
     fs.ContentControls.Add(itemEditor);
 }
开发者ID:dpawatts,项目名称:zeus,代码行数:8,代码来源:ItemEditorList.cs


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