本文整理汇总了C#中N2.Persistence.Serialization.ReadingJournal类的典型用法代码示例。如果您正苦于以下问题:C# ReadingJournal类的具体用法?C# ReadingJournal怎么用?C# ReadingJournal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReadingJournal类属于N2.Persistence.Serialization命名空间,在下文中一共展示了ReadingJournal类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: Read
public void Read(XPathNavigator navigator, ContentItem item, ReadingJournal journal)
{
foreach (XPathNavigator detailCollectionElement in EnumerateChildren(navigator))
{
ReadDetailCollection(detailCollectionElement, item, journal);
}
}
开发者ID:Jobu,项目名称:n2cms,代码行数:7,代码来源:DetailCollectionXmlReader.cs
示例3: SetLinkedItem
protected static void SetLinkedItem(string value, ReadingJournal journal, Action<ContentItem> setter, string versionKey = null)
{
int referencedItemID = int.Parse(value);
if (referencedItemID != 0)
{
ContentItem referencedItem = journal.Find(referencedItemID);
if (referencedItem != null)
{
setter(referencedItem);
}
else
{
journal.Register(referencedItemID, setter, relationType: "link");
}
}
else if (!string.IsNullOrEmpty(versionKey))
{
ContentItem referencedItem = journal.Find(versionKey);
if (referencedItem != null)
{
setter(referencedItem);
}
else
{
journal.Register(versionKey, setter);
}
}
}
开发者ID:JohnsonYuan,项目名称:n2cms,代码行数:30,代码来源:XmlReader.cs
示例4: Read
public void Read(System.Xml.XPath.XPathNavigator navigator, ContentItem item, ReadingJournal journal)
{
foreach (XPathNavigator detailElement in EnumerateChildren(navigator))
{
ReadProperty(detailElement, item, journal);
}
}
开发者ID:Jobu,项目名称:n2cms,代码行数:7,代码来源:PersistablePropertyXmlReader.cs
示例5: ReadMultipleValue
internal ContentDetail ReadMultipleValue(XPathNavigator navigator, ContentItem item, ReadingJournal journal, string name)
{
var multiDetail = ContentDetail.Multi(name);
foreach (XPathNavigator valueElement in EnumerateChildren(navigator))
{
switch (valueElement.GetAttribute("key", ""))
{
case ContentDetail.TypeKeys.BoolType:
multiDetail.BoolValue = (bool)Parse(valueElement.Value, typeof(bool));
break;
case ContentDetail.TypeKeys.DateTimeType:
multiDetail.DateTimeValue = (DateTime)Parse(valueElement.Value, typeof(DateTime));
break;
case ContentDetail.TypeKeys.DoubleType:
multiDetail.DoubleValue = (double)Parse(valueElement.Value, typeof(double));
break;
case ContentDetail.TypeKeys.IntType:
multiDetail.IntValue = (int)Parse(valueElement.Value, typeof(int));
break;
case ContentDetail.TypeKeys.LinkType:
SetLinkedItem(valueElement.Value, journal, (referencedItem) => multiDetail.LinkedItem = referencedItem);
break;
case ContentDetail.TypeKeys.MultiType:
journal.Error(new InvalidOperationException("Nested multi types not supported"));
break;
case ContentDetail.TypeKeys.ObjectType:
multiDetail.ObjectValue = Parse(valueElement.Value, typeof(object));
break;
case ContentDetail.TypeKeys.StringType:
multiDetail.StringValue = (string)PrepareStringDetail(item, name, valueElement.Value);
break;
}
}
return multiDetail;
}
开发者ID:amarwadi,项目名称:n2cms,代码行数:35,代码来源:DetailXmlReader.cs
示例6: Read
public void Read(XPathNavigator navigator, ContentItem item, ReadingJournal journal)
{
foreach (XPathNavigator authorizationElement in EnumerateChildren(navigator))
{
string role = authorizationElement.Value;
item.AuthorizedRoles.Add(new AuthorizedRole(item, role));
}
}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:8,代码来源:AuthorizationXmlReader.cs
示例7: Handle
private static void Handle(ContentItem item, ReadingJournal journal, int id)
{
var child = journal.Find(id);
if (child != null)
child.AddTo(item);
else
journal.Register(id, (ci) => ci.AddTo(item), isChild: true);
}
开发者ID:rohancragg,项目名称:n2cms,代码行数:8,代码来源:ChildXmlReader.cs
示例8: 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:Jobu,项目名称:n2cms,代码行数:10,代码来源:DetailCollectionXmlReader.cs
示例9: ReadDetail
protected virtual void ReadDetail(XPathNavigator navigator, DetailCollection collection, ReadingJournal journal)
{
Dictionary<string, string> attributes = GetAttributes(navigator);
Type type = Utility.TypeFromName(attributes["typeName"]);
string meta = attributes.ContainsKey("meta") ? attributes["meta"] : null;
if (type == typeof(ContentItem))
{
int referencedItemID = int.Parse(navigator.Value);
ContentItem referencedItem = journal.Find(referencedItemID);
if (referencedItem != null)
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
referencedItem,
meta));
}
else
{
journal.Register(referencedItemID, (item) =>
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
item,
meta));
}, relationType: "collectionlink");
}
}
else if (type == typeof(Enum))
{
if (meta != null)
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
Parse(navigator.Value, Type.GetType(meta))));
}
}
else if (type == typeof(IMultipleValue))
{
var detail = detailReader.ReadMultipleValue(navigator, collection.EnclosingItem, journal, collection.Name);
detail.Meta = meta;
detail.AddTo(collection);
}
else
{
object value = Parse(navigator.Value, type);
if (value is string)
value = detailReader.PrepareStringDetail(collection.EnclosingItem, collection.Name, value as string, attributes.ContainsKey("encoded") && Convert.ToBoolean(attributes["encoded"]));
collection.Add(ContentDetail.New(collection.EnclosingItem, attributes["name"], value, meta));
}
}
开发者ID:EzyWebwerkstaden,项目名称:n2cms,代码行数:55,代码来源:DetailCollectionXmlReader.cs
示例10: ReadProperty
private void ReadProperty(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);
else
item[name] = Parse(navigator.Value, type);
}
开发者ID:Jobu,项目名称:n2cms,代码行数:11,代码来源:PersistablePropertyXmlReader.cs
示例11: SetLinkedItem
protected static void SetLinkedItem(string value, ReadingJournal journal, Action<ContentItem> setter)
{
int referencedItemID = int.Parse(value);
ContentItem referencedItem = journal.Find(referencedItemID);
if (referencedItem != null)
{
setter(referencedItem);
}
else
{
journal.Register(referencedItemID, setter);
}
}
开发者ID:jupeterson,项目名称:n2cms,代码行数:13,代码来源:XmlReader.cs
示例12: ReadDetail
protected virtual void ReadDetail(XPathNavigator navigator, DetailCollection collection, ReadingJournal journal)
{
Dictionary<string, string> attributes = GetAttributes(navigator);
Type type = Utility.TypeFromName(attributes["typeName"]);
if (type == typeof(ContentItem))
{
int referencedItemID = int.Parse(navigator.Value);
ContentItem referencedItem = journal.Find(referencedItemID);
if (referencedItem != null)
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
referencedItem));
}
else
{
journal.Register(referencedItemID, (item) =>
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
item));
});
}
}
else if (type == typeof(Enum))
{
if (attributes.ContainsKey("meta"))
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
Parse(navigator.Value, Type.GetType(attributes["meta"]))));
}
}
else if (type == typeof(IMultipleValue))
{
detailReader.ReadMultipleValue(navigator, collection.EnclosingItem, journal, collection.Name).AddTo(collection);
}
else
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
Parse(navigator.Value, type)));
}
}
开发者ID:kusl,项目名称:n2cms,代码行数:49,代码来源:DetailCollectionXmlReader.cs
示例13: 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
示例14: ReadSingleItem
public virtual ContentItem ReadSingleItem(XPathNavigator navigator, ReadingJournal journal)
{
if (navigator.LocalName != "item") throw new DeserializationException("Expected element 'item' but was '" + navigator.LocalName + "'");
Dictionary<string, string> attributes = GetAttributes(navigator);
ContentItem item = CreateInstance(attributes);
ReadDefaultAttributes(attributes, item, journal);
foreach(XPathNavigator current in EnumerateChildren(navigator))
{
if(readers.ContainsKey(current.LocalName))
readers[current.LocalName].Read(current, item, journal);
}
return item;
}
开发者ID:GrimaceOfDespair,项目名称:n2cms,代码行数:16,代码来源:ItemXmlReader.cs
示例15: SetLinkedItems
private void SetLinkedItems(XPathNavigator navigator, ReadingJournal journal, ContentItem item, string name)
{
var items = new ItemList();
foreach (XPathNavigator itemElement in EnumerateChildren(navigator))
{
SetLinkedItem(itemElement.Value, journal, (foundItem) =>
{
items.Add(foundItem);
var property = item.GetContentType().GetProperty(name);
if (property != null)
item[name] = items.ConvertTo(property.PropertyType, name);
else
item[name] = items;
}, itemElement.GetAttribute("versionKey", ""));
}
}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:16,代码来源:PersistablePropertyXmlReader.cs
示例16: Read
public void Read(XPathNavigator navigator, ContentItem item, ReadingJournal journal)
{
IDictionary<string, IAttachmentHandler> attachments = _explorer.Map<IAttachmentHandler>(item.GetContentType());
foreach(XPathNavigator attachmentElement in EnumerateChildren(navigator))
{
string name = attachmentElement.GetAttribute("name", string.Empty);
if(attachments.ContainsKey(name))
{
XPathNavigator attachmentContents = navigator.CreateNavigator();
attachmentContents.MoveToFirstChild();
Attachment a = attachments[name].Read(attachmentContents, item);
if(a != null)
journal.Report(a);
}
}
}
开发者ID:nagarjunachallapalli,项目名称:n2cms,代码行数:17,代码来源:AttachmentXmlReader.cs
示例17: Method
private static void Method(ContentItem item, ReadingJournal journal, object id, dynamic child)
{
if (child != null)
child.AddTo(item);
else
{
if (id is string)
{
journal.Register(id.ToString(), (ci) => ci.AddTo(item), isChild: true);
}
else if (id is int)
{
journal.Register(int.Parse(id.ToString()), (ci) => ci.AddTo(item), isChild: true);
}
}
}
开发者ID:nikita239,项目名称:Aspect,代码行数:17,代码来源:Class2.cs
示例18: ReadDefaultAttributes
protected virtual void ReadDefaultAttributes(Dictionary<string, string> attributes, ContentItem item, ReadingJournal journal)
{
item.Created = ToNullableDateTime(attributes["created"]).Value;
item.Expires = ToNullableDateTime(attributes["expires"]);
item.ID = Convert.ToInt32(attributes["id"]);
item.Name = attributes["name"];
if (item.ID.ToString() == item.Name)
item.Name = null;
item.Published = ToNullableDateTime(attributes["published"]);
item.SavedBy = attributes["savedBy"];
item.SortOrder = Convert.ToInt32(attributes["sortOrder"]);
item.Title = attributes["title"];
item.Updated = ToNullableDateTime(attributes["updated"]).Value;
item.Visible = Convert.ToBoolean(attributes["visible"]);
if (!string.IsNullOrEmpty(attributes["zoneName"]))
item.ZoneName = attributes["zoneName"];
if (attributes.ContainsKey("templateKey") && !string.IsNullOrEmpty(attributes["templateKey"]))
item.TemplateKey = attributes["templateKey"];
if (attributes.ContainsKey("translationKey") && !string.IsNullOrEmpty(attributes["translationKey"]))
item.TranslationKey = Convert.ToInt32(attributes["translationKey"]);
if (attributes.ContainsKey("ancestralTrail"))
item.AncestralTrail = attributes["ancestralTrail"];
if (attributes.ContainsKey("alteredPermissions"))
item.AlteredPermissions = (Permission)Convert.ToInt32(attributes["alteredPermissions"]);
if (attributes.ContainsKey("childState"))
item.ChildState = (Collections.CollectionState)Convert.ToInt32(attributes["childState"]);
if (attributes.ContainsKey("versionIndex"))
item.VersionIndex = Convert.ToInt32(attributes["versionIndex"]);
if (attributes.ContainsKey("versionOf"))
{
item.VersionOf.ID = Convert.ToInt32(attributes["versionOf"]);
item.VersionOf.ValueAccessor = repository.Get;
}
if (attributes.ContainsKey("parent"))
{
var parentVersionKey = attributes.ContainsKey("parentVersionKey") ? attributes["parentVersionKey"] : null;
HandleParentRelation(item, attributes["parent"], parentVersionKey, journal);
}
if (attributes.ContainsKey("state") && !string.IsNullOrEmpty(attributes["state"]))
item.State = (ContentState)Convert.ToInt32(attributes["state"]);
else
item.State = SerializationUtility.RecaulculateState(item);
}
开发者ID:meixger,项目名称:n2cms,代码行数:45,代码来源:ItemXmlReader.cs
示例19: ReadDetail
protected virtual void ReadDetail(XPathNavigator navigator, DetailCollection collection, ReadingJournal journal)
{
Dictionary<string, string> attributes = GetAttributes(navigator);
Type type = Utility.TypeFromName(attributes["typeName"]);
if (type == typeof(ContentItem))
{
int referencedItemID = int.Parse(navigator.Value);
ContentItem referencedItem = journal.Find(referencedItemID);
if (referencedItem != null)
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
referencedItem));
}
else
{
journal.ItemAdded += delegate(object sender, ItemEventArgs e)
{
if (e.AffectedItem.ID == referencedItemID)
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
e.AffectedItem));
}
};
}
}
else if (type == typeof(IMultipleValue))
{
detailReader.ReadMultipleValue(navigator, collection.EnclosingItem, journal, collection.Name).AddTo(collection);
}
else
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
Parse(navigator.Value, type)));
}
}
开发者ID:Jobu,项目名称:n2cms,代码行数:42,代码来源:DetailCollectionXmlReader.cs
示例20: Read
public void Read(System.Xml.XPath.XPathNavigator navigator, ContentItem item, ReadingJournal journal)
{
foreach (XPathNavigator childElement in EnumerateChildren(navigator))
{
var attributes = GetAttributes(childElement);
int id;
if (attributes.ContainsKey("id") && int.TryParse(attributes["id"], out id) && id != 0)
{
Handle(item, journal, id);
}
if (attributes.ContainsKey("versionOf") && int.TryParse(attributes["versionOf"], out id) && id != 0)
{
Handle(item, journal, id);
}
else if (attributes.ContainsKey("versionKey"))
{
Handle(item, journal, attributes["versionKey"]);
}
}
}
开发者ID:rohancragg,项目名称:n2cms,代码行数:20,代码来源:ChildXmlReader.cs
注:本文中的N2.Persistence.Serialization.ReadingJournal类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论