当前位置: 首页>>代码示例>>C#>>正文


C# Serialization.ReadingJournal类代码示例

本文整理汇总了C#中N2.Persistence.Serialization.ReadingJournal的典型用法代码示例。如果您正苦于以下问题:C# ReadingJournal类的具体用法?C# ReadingJournal怎么用?C# ReadingJournal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ReadingJournal类属于N2.Persistence.Serialization命名空间,在下文中一共展示了ReadingJournal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的N2.Persistence.Serialization.ReadingJournal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。