当前位置: 首页>>代码示例>>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;未经允许,请勿转载。