public static object FromStreamContext(Type componentType, StreamContext streamContext, Encoding encoding = null) { if (componentType == null) { throw new ArgumentNullException("componentType"); } if (streamContext == null) { throw new ArgumentNullException("streamContext"); } StreamingSource ss = StreamingSource.Create( componentType, streamContext.ContentType, streamContext.Extension ); if (ss == null) { throw RuntimeFailure.NoAcceptableStreamingSource(componentType); } if (ss is TextSource text) { text.Encoding = encoding; } return(ss.Load(streamContext, componentType)); }
static ITextConversion GetStreamingSource(Type type) { if (StreamingSource.Create(type) == null) { return(null); } return(StreamingSourceConversion.Instance); }
public bool TryConvertFromText(string text, Type componentType, IServiceProvider sp, CultureInfo culture, out object result) { StreamingSource ss = StreamingSource.Create(componentType); if (ss == null) { result = null; return(false); } result = ss.LoadFromText(text, componentType); return(true); }
public void WriteValue(Type componentType, object value) { if (componentType == null) { throw new ArgumentNullException("componentType"); } if (value == null) { throw new ArgumentNullException("value"); } StreamingSource ss = StreamingSource.Create( componentType, ContentType, null, ServiceProvider.Null ); ss.Save(this, value); }
static StreamingSource() { Text = new TextStreamingSource(); XmlFormatter = new XmlFormatterStreamingSource(); Properties = new PropertiesStreamingSource(); }
public StreamingSourceAttribute(KnownStreamingSource knownStreamingSource) : base(StreamingSource.GetStreamingSourceType(knownStreamingSource)) { }