當前位置: 首頁>>代碼示例>>C#>>正文


C# ReadingJournal.Find方法代碼示例

本文整理匯總了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);
                }
            }
        }
開發者ID:JohnsonYuan,項目名稱:n2cms,代碼行數:30,代碼來源:XmlReader.cs

示例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);
		}
開發者ID:rohancragg,項目名稱:n2cms,代碼行數:8,代碼來源:ChildXmlReader.cs

示例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));
            }
        }
開發者ID:EzyWebwerkstaden,項目名稱:n2cms,代碼行數:55,代碼來源:DetailCollectionXmlReader.cs

示例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);
			}
		}
開發者ID:jupeterson,項目名稱:n2cms,代碼行數:13,代碼來源:XmlReader.cs

示例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)));
			}
		}
開發者ID:kusl,項目名稱:n2cms,代碼行數:49,代碼來源:DetailCollectionXmlReader.cs

示例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)));
            }
        }
開發者ID:Jobu,項目名稱:n2cms,代碼行數:42,代碼來源:DetailCollectionXmlReader.cs

示例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;
                }
            }
        }
開發者ID:AnonymousRetard,項目名稱:n2cms,代碼行數:40,代碼來源:DetailXmlReader.cs

示例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;
            }
        }
開發者ID:Jobu,項目名稱:n2cms,代碼行數:23,代碼來源:XmlReader.cs

示例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);
     }
 }
開發者ID:GrimaceOfDespair,項目名稱:n2cms,代碼行數:9,代碼來源:ItemXmlReader.cs

示例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);
     }
 }
開發者ID:brianmatic,項目名稱:n2cms,代碼行數:20,代碼來源:ItemXmlReader.cs

示例11: Handle

 public static void Handle(ContentItem item, ReadingJournal journal, string id)
 {
     var child = journal.Find(id);
     Method(item, journal, id, child);
 }
開發者ID:nikita239,項目名稱:Aspect,代碼行數:5,代碼來源:Class2.cs


注:本文中的N2.Persistence.Serialization.ReadingJournal.Find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。