private object Deserialize(StructuredType expectedBaseType, object patchedObject = null) { if (!Request.Body.CanSeek) { var memStream = new MemoryStream(); Request.Body.CopyTo(memStream); memStream.Seek(0, SeekOrigin.Begin); Request.Body = memStream; } if (Request.Body.Position != 0) { Request.Body.Seek(0, SeekOrigin.Begin); } using (var textReader = new StreamReader(Request.Body)) { var deserializer = Session.GetInstance <ITextDeserializer>(); var options = new DeserializeOptions() { Target = patchedObject, ExpectedBaseType = expectedBaseType, TargetNode = Node }; return(deserializer.Deserialize(textReader, options)); } }
public object Deserialize(TextReader textReader, DeserializeOptions options = null) { try { options = options ?? new DeserializeOptions(); var returnTypeSpecified = options.ExpectedBaseType != null; if (returnTypeSpecified && typeof(JToken).IsAssignableFrom(options.ExpectedBaseType)) { // When asking for a JToken, just return the deserialized json object using (var jr = new JsonTextReader(textReader)) { return(JToken.Load(jr)); } } var context = this.contextProvider.GetDeserializationContext(options); var expectedBaseType = returnTypeSpecified ? context.GetClassMapping(options.ExpectedBaseType) : null; return(Deserialize(textReader, expectedBaseType, context, options.Target)); } catch (JsonReaderException exception) { throw new PomonaSerializationException(exception.Message, exception); } catch (JsonSerializationException exception) { throw new PomonaSerializationException(exception.Message, exception); } }
/// <summary> /// Deserializes the specified JSML text into an object of the specified type. /// </summary> public static object Deserialize(XmlReader reader, Type dataContract, DeserializeOptions options) { var xmlDoc = new XmlDocument(); xmlDoc.Load(reader); var deserializer = new Deserializer(options); return(deserializer.Do(dataContract, xmlDoc.DocumentElement)); }
/// <summary> /// Deserializes the specified XML document into an object of the specified type. /// </summary> /// public static object Deserialize(Type dataContract, XmlDocument xmlDoc, DeserializeOptions options) { if (xmlDoc == null) { return(null); } xmlDoc.PreserveWhitespace = true; var deserializer = new Deserializer(options); return(deserializer.Do(dataContract, xmlDoc.DocumentElement)); }
/// <summary> /// Deserializes the specified JSML text into an object of the specified type. /// </summary> public static object Deserialize(Type dataContract, string jsml, DeserializeOptions options) { if (String.IsNullOrEmpty(jsml)) { return(null); } var xmlDoc = new XmlDocument { PreserveWhitespace = true }; xmlDoc.LoadXml(jsml); var deserializer = new Deserializer(options); return(deserializer.Do(dataContract, xmlDoc.DocumentElement)); }
protected void DeserializeGraphicAnnotation(GraphicAnnotationModuleIod module, RectangleF displayedArea, T image) { DicomGraphicsPlane graphic = DicomGraphicsPlane.GetDicomGraphicsPlane(image, true); var sqItems = module.GraphicAnnotationSequence; if (sqItems != null) { var interactiveAnnotations = DeserializeOptions.HasFlag(DicomSoftcopyPresentationStateDeserializeOptions.InteractiveAnnotations); var ignoreImageRelationships = DeserializeIgnoreImageRelationship; foreach (var annotation in sqItems.Select(sqItem => new { LayerId = sqItem.GraphicLayer ?? string.Empty, Graphic = DicomGraphicsFactory.CreateGraphicAnnotation(image.Frame, sqItem, displayedArea, interactiveAnnotations, ignoreImageRelationships) }).Where(g => g.Graphic != null)) { graphic.Layers[annotation.LayerId].Graphics.Add(annotation.Graphic); } } }
public Deserializer(DeserializeOptions options) : base(options) { }
/// <summary> /// Deserializes the specified JSML text into an object of the specified type. /// </summary> public static object Deserialize <T>(XmlReader reader, DeserializeOptions options) { return(Deserialize(reader, typeof(T), options)); }
/// <summary> /// Deserializes the specified JSML text into an object of the specified type. /// </summary> public static T Deserialize <T>(string jsml, DeserializeOptions options) { return((T)Deserialize(typeof(T), jsml, options)); }
/// <summary> /// Deserializes the specified XML Document into an object of the specified type. /// </summary> public static T Deserialize <T>(XmlDocument xmlDoc, DeserializeOptions options) { return((T)Deserialize(typeof(T), xmlDoc, options)); }
public IDeserializationContext GetDeserializationContext(DeserializeOptions options) { options = options ?? new DeserializeOptions(); return(new ServerDeserializationContext(this.typeMapper, this.resourceResolver, options.TargetNode, this.container)); }
public IDeserializationContext GetDeserializationContext(DeserializeOptions options) { return(new ClientDeserializationContext(this.clientTypeMapper, this.client, this.resourceLoader)); }