public override object Serialize(object clrObject, int depth) { object obj; if (clrObject != null) { DSResource dSResource = new DSResource(base.ResourceType, true); if (this.referencePropertyType != PSEntityMetadata.ReferenceSetCmdlets.ReferencePropertyType.KeyOnly) { EntityTypeSerializer entityTypeSerializer = new EntityTypeSerializer(base.ResourceType, true); dSResource = entityTypeSerializer.Serialize(clrObject, depth + 1) as DSResource; } else { IEnumerator <ResourceProperty> enumerator = base.ResourceType.Properties.GetEnumerator(); using (enumerator) { while (enumerator.MoveNext()) { ResourceProperty current = enumerator.Current; if ((current.Kind & ResourcePropertyKind.Key) != ResourcePropertyKind.Key) { continue; } if (clrObject != current.GetCustomState().DefaultValue) { object obj1 = clrObject; dSResource.SetValue(current.Name, SerializerBase.SerializeResourceProperty(obj1, base.ResourceType, current, depth + 1)); } else { obj = null; return(obj); } } return(dSResource); } return(obj); } return(dSResource); } else { return(null); } }
public override object Serialize(object clrObject, int depth) { object obj; if (clrObject != null) { DSResource dSResource = new DSResource(base.ResourceType, true); if (this.referencePropertyType != PSEntityMetadata.ReferenceSetCmdlets.ReferencePropertyType.KeyOnly) { EntityTypeSerializer entityTypeSerializer = new EntityTypeSerializer(base.ResourceType, true); dSResource = entityTypeSerializer.Serialize(clrObject, depth + 1) as DSResource; } else { IEnumerator<ResourceProperty> enumerator = base.ResourceType.Properties.GetEnumerator(); using (enumerator) { while (enumerator.MoveNext()) { ResourceProperty current = enumerator.Current; if ((current.Kind & ResourcePropertyKind.Key) != ResourcePropertyKind.Key) { continue; } if (clrObject != current.GetCustomState().DefaultValue) { object obj1 = clrObject; dSResource.SetValue(current.Name, SerializerBase.SerializeResourceProperty(obj1, base.ResourceType, current, depth + 1)); } else { obj = null; return obj; } } return dSResource; } return obj; } return dSResource; } else { return null; } }