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


C# ResourceType.SetEpmValue方法代码示例

本文整理汇总了C#中System.Data.Services.Providers.ResourceType.SetEpmValue方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceType.SetEpmValue方法的具体用法?C# ResourceType.SetEpmValue怎么用?C# ResourceType.SetEpmValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.Services.Providers.ResourceType的用法示例。


在下文中一共展示了ResourceType.SetEpmValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeserializeAttributes

 /// <summary>
 /// Deserializes the attributes from the <paramref name="reader"/> and sets values on <paramref name="element"/>
 /// </summary>
 /// <param name="reader">Current content reader.</param>
 /// <param name="currentRoot">Segment which has child attribute segments.</param>
 /// <param name="element">Current object.</param>
 /// <param name="resourceType">Resource type of <paramref name="element"/></param>
 private void DeserializeAttributes(XmlReader reader, EpmTargetPathSegment currentRoot, object element, ResourceType resourceType)
 {
     foreach (var attributeSegment in currentRoot.SubSegments.Where(s => s.IsAttribute))
     {
         String attribValue = WebUtil.GetAttributeEx(reader, attributeSegment.SegmentName.Substring(1), attributeSegment.SegmentNamespaceUri);
         if (attribValue != null)
         {
             if (!EpmContentDeSerializerBase.Match(attributeSegment, this.PropertiesApplied))
             {
                 resourceType.SetEpmValue(attributeSegment, element, attribValue, this);
             }
         }
     }        
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:21,代码来源:EpmCustomContentDeSerializer.cs

示例2: DeSerialize

        /// <summary>Called internally to deserialize each <see cref="SyndicationElementExtension"/></summary>
        /// <param name="reader">XmlReader for current extension</param>
        /// <param name="currentRoot">Node in the target path being processed</param>
        /// <param name="resourceType">ResourceType</param>
        /// <param name="element">object being deserialized</param>
        private void DeSerialize(XmlReader reader, EpmTargetPathSegment currentRoot, ResourceType resourceType, object element)
        {
            EpmValueBuilder currentValue = new EpmValueBuilder();

            do
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (currentRoot.HasContent)
                        {
                            // Throw an exception that we hit mixed-content.
                            // <contentElement>value<someElement /></contentElement>
                            // <contentElement><someElement />value</contentElement>
                            throw DataServiceException.CreateBadRequestError(Strings.EpmDeserialize_MixedContent(resourceType.FullName));
                        }

                        String elementName = reader.LocalName;
                        String namespaceUri = reader.NamespaceURI;
                        EpmTargetPathSegment newRoot = currentRoot.SubSegments
                                                                  .SingleOrDefault(s => s.SegmentNamespaceUri == namespaceUri && s.SegmentName == elementName);
                        if (newRoot == null)
                        {
                            WebUtil.SkipToEnd(reader, elementName, namespaceUri);
                            continue;
                        }

                        currentRoot = newRoot;
                        
                        this.DeserializeAttributes(reader, currentRoot, element, resourceType);
                        
                        if (currentRoot.HasContent)
                        {
                            if (reader.IsEmptyElement)
                            {
                                if (!EpmContentDeSerializerBase.Match(currentRoot, this.PropertiesApplied))
                                {
                                    resourceType.SetEpmValue(currentRoot, element, String.Empty, this);
                                }

                                currentRoot = currentRoot.ParentSegment;
                            }
                        }
                        
                        break;

                    case XmlNodeType.CDATA:
                    case XmlNodeType.Text:
                    case XmlNodeType.SignificantWhitespace:
                        if (!currentRoot.HasContent)
                        {
                            // Throw an exception that we hit mixed-content.
                            // <noContentElement>value<contentElement>value</contentElement></noContentElement>
                            // <noContentElement><contentElement>value</contentElement>value</noContentElement>
                            throw DataServiceException.CreateBadRequestError(Strings.EpmDeserialize_MixedContent(resourceType.FullName));
                        }

                        currentValue.Append(reader.Value);
                        break;
                        
                    case XmlNodeType.EndElement:
                        if (currentRoot.HasContent)
                        {
                            if (!EpmContentDeSerializerBase.Match(currentRoot, this.PropertiesApplied))
                            {
                                resourceType.SetEpmValue(currentRoot, element, currentValue.Value, this);
                            }
                        }

                        currentRoot = currentRoot.ParentSegment;
                        currentValue.Reset();
                        break;

                    case XmlNodeType.Comment:
                    case XmlNodeType.Whitespace:
                        break;

                    case XmlNodeType.None:
                    case XmlNodeType.XmlDeclaration:
                    case XmlNodeType.Attribute:
                    case XmlNodeType.EndEntity:
                    case XmlNodeType.EntityReference:
                    case XmlNodeType.Entity:
                    case XmlNodeType.Document:
                    case XmlNodeType.DocumentType:
                    case XmlNodeType.DocumentFragment:
                    case XmlNodeType.Notation:
                    case XmlNodeType.ProcessingInstruction:
                        throw DataServiceException.CreateBadRequestError(Strings.EpmDeserialize_InvalidXmlEntity);
                }
            }
            while (currentRoot.ParentSegment != null && reader.Read());
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:98,代码来源:EpmCustomContentDeSerializer.cs

示例3: DeSerialize

        /// <summary>Used for deserializing each of syndication specific content nodes</summary>
        /// <param name="currentRoot">Node in the target path being processed</param>
        /// <param name="resourceType">ResourceType</param>
        /// <param name="element">object being deserialized</param>
        private void DeSerialize(EpmTargetPathSegment currentRoot, ResourceType resourceType, object element)
        {
            foreach (EpmTargetPathSegment newRoot in currentRoot.SubSegments)
            {
                if (newRoot.HasContent)
                {
                    if (!EpmContentDeSerializerBase.Match(newRoot, this.PropertiesApplied))
                    {
                        switch (newRoot.EpmInfo.Attribute.TargetSyndicationItem)
                        {
                            case SyndicationItemProperty.AuthorEmail:
                                if (this.Item.Authors.Count > 0)
                                {
                                    resourceType.SetEpmValue(newRoot, element, this.Item.Authors[0].Email, this);
                                }

                                break;
                            case SyndicationItemProperty.AuthorName:
                                if (this.Item.Authors.Count > 0)
                                {
                                    resourceType.SetEpmValue(newRoot, element, this.Item.Authors[0].Name, this);
                                }

                                break;
                            case SyndicationItemProperty.AuthorUri:
                                if (this.Item.Authors.Count > 0)
                                {
                                    resourceType.SetEpmValue(newRoot, element, this.Item.Authors[0].Uri, this);
                                }

                                break;
                            case SyndicationItemProperty.ContributorEmail:
                                if (this.Item.Contributors.Count > 0)
                                {
                                    resourceType.SetEpmValue(newRoot, element, this.Item.Contributors[0].Email, this);
                                }

                                break;
                            case SyndicationItemProperty.ContributorName:
                                if (this.Item.Contributors.Count > 0)
                                {
                                    resourceType.SetEpmValue(newRoot, element, this.Item.Contributors[0].Name, this);
                                }

                                break;
                            case SyndicationItemProperty.ContributorUri:
                                if (this.Item.Contributors.Count > 0)
                                {
                                    resourceType.SetEpmValue(newRoot, element, this.Item.Contributors[0].Uri, this);
                                }

                                break;
                            case SyndicationItemProperty.Updated:
                                // If this.Item.LastUpdatedTime == DateTimeOffset.MinValue we assume that the date has not been provided 
                                // by the user. This is the same assumption Syndication Api does (see Atom10FeedFormatter.WriteItemContents()).
                                // If the date was not provided by the user we should not touch it - otherwise the response will not be  
                                // compatible with response sent for the same request and the same resource type but having KeepInContent set to true
                                if (this.Item.LastUpdatedTime > DateTimeOffset.MinValue)
                                {
                                    resourceType.SetEpmValue(newRoot, element, XmlConvert.ToString(this.Item.LastUpdatedTime), this);
                                }

                                break;
                            case SyndicationItemProperty.Published:
                                if (this.Item.PublishDate > DateTimeOffset.MinValue)
                                {
                                    resourceType.SetEpmValue(newRoot, element, XmlConvert.ToString(this.Item.PublishDate), this);
                                }

                                break;
                            case SyndicationItemProperty.Rights:
                                if (this.Item.Copyright != null)
                                {
                                    resourceType.SetEpmValue(newRoot, element, this.Item.Copyright.Text, this);
                                }

                                break;
                            case SyndicationItemProperty.Summary:
                                if (this.Item.Summary != null)
                                {
                                    resourceType.SetEpmValue(newRoot, element, this.Item.Summary.Text, this);
                                }

                                break;
                            case SyndicationItemProperty.Title:
                                if (this.Item.Title != null)
                                {
                                    resourceType.SetEpmValue(newRoot, element, this.Item.Title.Text, this);
                                }

                                break;
                            default:
                                Debug.Fail("Unhandled SyndicationItemProperty enum value - should never get here.");
                                break;
                        }
                    }
//.........这里部分代码省略.........
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:101,代码来源:EpmSyndicationContentDeSerializer.cs


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