本文整理汇总了C#中N2.Persistence.Serialization.ReadingJournal.Find方法的典型用法代码示例。如果您正苦于以下问题:C# ReadingJournal.Find方法的具体用法?C# ReadingJournal.Find怎么用?C# ReadingJournal.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类N2.Persistence.Serialization.ReadingJournal
的用法示例。
在下文中一共展示了ReadingJournal.Find方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
}
示例2: Handle
private void Handle(ContentItem item, ReadingJournal journal, string versionKey)
{
var child = journal.Find(versionKey);
if (child != null)
child.AddTo(item);
else
journal.Register(versionKey, (ci) => ci.AddTo(item), isChild: true);
}
示例3: 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));
}
}
示例4: 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);
}
}
示例5: 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)));
}
}
示例6: 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)));
}
}
示例7: 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[name] = value;
//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;
}
}
}
示例8: 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
{
EventHandler<ItemEventArgs> handler = null;
handler = delegate(object sender, ItemEventArgs e)
{
if (e.AffectedItem.ID == referencedItemID)
{
setter(e.AffectedItem);
journal.ItemAdded -= handler;
}
};
journal.ItemAdded += handler;
}
}
示例9: HandleParentRelation
protected virtual void HandleParentRelation(ContentItem item, string parent, ReadingJournal journal)
{
if (!string.IsNullOrEmpty(parent))
{
int parentID = int.Parse(parent);
ContentItem parentItem = journal.Find(parentID);
item.AddTo(parentItem);
}
}
示例10: HandleParentRelation
protected virtual void HandleParentRelation(ContentItem item, string parent, string parentVersionKey, ReadingJournal journal)
{
int parentID = 0;
if (int.TryParse(parent, out parentID) && parentID != 0)
{
ContentItem parentItem = journal.Find(parentID);
if (parentItem != null)
item.AddTo(parentItem);
else
journal.Register(parentID, (laterParent) => item.AddTo(laterParent), isChild: true);
}
if (!string.IsNullOrEmpty(parentVersionKey))
{
ContentItem parentItem = journal.Find(parentVersionKey);
if (parentItem != null)
item.AddTo(parentItem);
else
journal.Register(parentVersionKey, (laterParent) => item.AddTo(laterParent), isChild: true);
}
}
示例11: Handle
public static void Handle(ContentItem item, ReadingJournal journal, string id)
{
var child = journal.Find(id);
Method(item, journal, id, child);
}