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


C# ContentItem.SetDetail方法代码示例

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


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

示例1: ReadDetail

		protected virtual void ReadDetail(XPathNavigator navigator, ContentItem item, ReadingJournal journal)
		{
			Dictionary<string, string> attributes = GetAttributes(navigator);
			Type type = Utility.TypeFromName(attributes["typeName"]);

			string name = attributes["name"];

			if (type == typeof(ContentItem))
			{
				SetLinkedItem(navigator.Value, journal, (referencedItem) => item[name] = referencedItem, attributes.GetValueOrDefault("versionKey"));
			}
			else if(type == typeof(IMultipleValue))
			{
				var multiDetail = ReadMultipleValue(navigator, item, journal, name);
				multiDetail.AddTo(item);
			}
			else
			{
				object value = Parse(navigator.Value, type);
				if (value is string)
					value = PrepareStringDetail(item, name, value as string, attributes.ContainsKey("encoded") && Convert.ToBoolean(attributes["encoded"]));

				item.SetDetail(name, value, type);
			}
		}
开发者ID:rohancragg,项目名称:n2cms,代码行数:25,代码来源:DetailXmlReader.cs

示例2: ReadDetail

        protected virtual void ReadDetail(XPathNavigator navigator, ContentItem item, ReadingJournal journal)
        {
            Dictionary<string, string> attributes = GetAttributes(navigator);
            Type type = Utility.TypeFromName(attributes["typeName"]);

            string name = attributes["name"];
            string meta = attributes.ContainsKey("meta")
                ? attributes["meta"]
                : null;

            if (type == typeof(System.Enum))
            {
                // we're going to need to do better- we saved a more specific type in 'meta'
                try 
                {
                    type = Utility.TypeFromName(meta); 
                }
                catch (Exception ex)
                {
                    // This is really bad because it means the enum type has gone away. 
                    logger.Warn(ex);
                    
                    // Also, another exception is going to be thrown later because the enum won't be able to be decoded. So we'll just load the value
                    // as a string and hope that someone eventually deals with it. This may automatically happen if the ContentItem used the regular
                    // GetDetail that returns a System.Object. This is the most robust approach because it is the only way the page MIGHT NOT crash
                    // when this exception is encountered. 
                    type = typeof(String);
                }
            }

            if (type == typeof(ContentItem))
            {
                SetLinkedItem(navigator.Value, journal, (referencedItem) => item[name] = referencedItem, attributes.GetValueOrDefault("versionKey"));
            }
            else if(type == typeof(IMultipleValue))
            {
                var multiDetail = ReadMultipleValue(navigator, item, journal, name);
                multiDetail.Meta = meta;
                multiDetail.AddTo(item);
            }
            else
            {
                object value = Parse(navigator.Value, type);
                if (value is string)
                    value = PrepareStringDetail(item, name, value as string, attributes.ContainsKey("encoded") && Convert.ToBoolean(attributes["encoded"]));

                item.SetDetail(name, value, type);
            }
        }
开发者ID:Biswo,项目名称:n2cms,代码行数:49,代码来源:DetailXmlReader.cs

示例3: ReadDetail

        protected virtual void ReadDetail(XPathNavigator navigator, ContentItem item, ReadingJournal journal)
        {
            Dictionary<string, string> attributes = GetAttributes(navigator);
            Type type = Utility.TypeFromName(attributes["typeName"]);

            string name = attributes["name"];

            if (type != typeof(ContentItem))
            {
                object value = Parse(navigator.Value, type);
                if (value is string)
                    value = PrepareStringDetail(item, name, value as string);

                item.SetDetail(name, value, type);
            }
            else
            {
                int referencedItemID = int.Parse(navigator.Value);
                ContentItem referencedItem = journal.Find(referencedItemID);
                if (referencedItem != null)
                {
                    item[name] = referencedItem;
                }
                else
                {
                    EventHandler<ItemEventArgs> handler = null;
                    handler = delegate(object sender, ItemEventArgs e)
                    {
                        if (e.AffectedItem.ID == referencedItemID)
                        {
                            item[name] = e.AffectedItem;
                            journal.ItemAdded -= handler;
                        }
                    };

                    journal.ItemAdded += handler;
                }
            }
        }
开发者ID:spmason,项目名称:n2cms,代码行数:39,代码来源:DetailXmlReader.cs


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