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