private void InitializeVisitorContent(EpmContentSerializer.EpmNullValuedPropertyTree nullValuedProperties, DataServiceProviderWrapper provider) { this.visitorContent = new Dictionary <EpmTargetPathSegment, EpmCustomContentWriterNodeData>(ReferenceEqualityComparer <EpmTargetPathSegment> .Instance); foreach (EpmTargetPathSegment subSegmentOfRoot in this.Root.SubSegments) { this.visitorContent.Add(subSegmentOfRoot, new EpmCustomContentWriterNodeData(subSegmentOfRoot, this.Element, nullValuedProperties, provider)); this.InitializeSubSegmentVisitorContent(subSegmentOfRoot, nullValuedProperties, provider); } }
private void PopulateData(EpmTargetPathSegment segment, object element, EpmContentSerializer.EpmNullValuedPropertyTree nullValuedProperties, DataServiceProviderWrapper provider) #endif { if (segment.EpmInfo != null) { Object propertyValue; try { #if ASTORIA_CLIENT propertyValue = segment.EpmInfo.ReadPropertyValue(element); #else propertyValue = segment.EpmInfo.ReadPropertyValue(element, provider); #endif } catch #if ASTORIA_CLIENT (System.Reflection.TargetInvocationException) #else (System.Reflection.TargetInvocationException e) #endif { #if !ASTORIA_CLIENT ErrorHandler.HandleTargetInvocationException(e); #endif throw; } #if ASTORIA_CLIENT this.Data = propertyValue == null ? String.Empty : ClientConvert.ToString(propertyValue, false); #else if (propertyValue == null || propertyValue == DBNull.Value) { this.Data = String.Empty; nullValuedProperties.Add(segment.EpmInfo); } else { this.Data = PlainXmlSerializer.PrimitiveToString(propertyValue); } #endif } } }
/// <summary> /// Constructor initializes the base class be identifying itself as a custom content serializer /// </summary> /// <param name="targetTree">Target tree containing mapping information</param> /// <param name="element">Object to be serialized</param> /// <param name="target">SyndicationItem to which content will be added</param> /// <param name="nullValuedProperties">Null valued properties found during serialization</param> /// <param name="provider">Data Service provider used for rights verification.</param> internal EpmCustomContentSerializer(EpmTargetTree targetTree, object element, SyndicationItem target, EpmContentSerializer.EpmNullValuedPropertyTree nullValuedProperties, DataServiceProviderWrapper provider) : base(targetTree, false, element, target) { this.InitializeVisitorContent(nullValuedProperties, provider); }
/// <summary>Initialize the visitor content for all of root's grandchildren and beyond</summary> /// <param name="subSegment">One of root's children</param> /// <param name="nullValuedProperties">Null valued properties found during serialization</param> /// <param name="provider">Data Service provider used for rights verification.</param> private void InitializeSubSegmentVisitorContent(EpmTargetPathSegment subSegment, EpmContentSerializer.EpmNullValuedPropertyTree nullValuedProperties, DataServiceProviderWrapper provider) { foreach (EpmTargetPathSegment segment in subSegment.SubSegments) { this.visitorContent.Add(segment, new EpmCustomContentWriterNodeData(this.visitorContent[subSegment], segment, this.Element, nullValuedProperties, provider)); this.InitializeSubSegmentVisitorContent(segment, nullValuedProperties, provider); } }
/// <summary> /// Constructor initializes the base class be identifying itself as a syndication serializer /// </summary> /// <param name="tree">Target tree containing mapping information</param> /// <param name="element">Object to be serialized</param> /// <param name="target">SyndicationItem to which content will be added</param> /// <param name="nullValuedProperties">Null valued properties found during serialization</param> internal EpmSyndicationContentSerializer(EpmTargetTree tree, object element, SyndicationItem target, EpmContentSerializer.EpmNullValuedPropertyTree nullValuedProperties) : base(tree, true, element, target) { this.nullValuedProperties = nullValuedProperties; }
/// <summary> /// Constructor initializes the base class be identifying itself as a syndication serializer /// </summary> /// <param name="tree">Target tree containing mapping information</param> /// <param name="element">Object to be serialized</param> /// <param name="target">SyndicationItem to which content will be added</param> /// <param name="nullValuedProperties">Null valued properties found during serialization</param> internal EpmSyndicationContentSerializer(EpmTargetTree tree, object element, SyndicationItem target, EpmContentSerializer.EpmNullValuedPropertyTree nullValuedProperties) : base(tree, true, element, target) { this.nullValuedProperties = nullValuedProperties; }
internal EpmCustomContentWriterNodeData(EpmCustomContentWriterNodeData parentData, EpmTargetPathSegment segment, object element, EpmContentSerializer.EpmNullValuedPropertyTree nullValuedProperties, DataServiceProviderWrapper provider) #endif { this.XmlContentStream = parentData.XmlContentStream; this.XmlContentWriter = parentData.XmlContentWriter; #if ASTORIA_CLIENT this.PopulateData(segment, element); #else this.PopulateData(segment, element, nullValuedProperties, provider); #endif }
internal EpmCustomContentWriterNodeData(EpmTargetPathSegment segment, object element, EpmContentSerializer.EpmNullValuedPropertyTree nullValuedProperties, DataServiceProviderWrapper provider) #endif { this.XmlContentStream = new MemoryStream(); XmlWriterSettings customContentWriterSettings = new XmlWriterSettings(); customContentWriterSettings.OmitXmlDeclaration = true; customContentWriterSettings.ConformanceLevel = ConformanceLevel.Fragment; this.XmlContentWriter = XmlWriter.Create(this.XmlContentStream, customContentWriterSettings); #if ASTORIA_CLIENT this.PopulateData(segment, element); #else this.PopulateData(segment, element, nullValuedProperties, provider); #endif }