Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.4.0
public virtual MemoryStream GetStream( string name )
Public Overridable Function GetStream ( name As String ) As MemoryStream
public: virtual MemoryStream^ GetStream( String^ name )
abstract GetStream : name : string -> MemoryStream override GetStream : name : string -> MemoryStream
- Type: SystemString
The name of the resource to retrieve.
Return ValueType: MemoryStream
A MemoryStream object from the specified resource localized for the caller's current UI culture, or if name cannot be found in a resource set.
|ArgumentNullException||name is .|
|ObjectDisposedException||The HybridResourceManager is already disposed.|
|InvalidOperationException||SafeMode is and the type of the resource is neither MemoryStream nor byte.|
|MissingManifestResourceException||No usable set of localized resources has been found, and there are no default culture resources. For information about how to handle this exception, see the notes under Instantiating a ResXResourceManager object section of the description of the ResXResourceManager class.|
Depending on the value of the CloneValues property, the GetObject methods return either a full copy of the specified resource, or always the same instance. For memory streams none of them are ideal because a full copy duplicates the inner buffer of a possibly large array of bytes, whereas returning the same stream instance can cause issues with conflicting positions or disposed state. Therefore the GetStream methods can be used to obtain a new read-only MemoryStream wrapper around the same internal buffer, regardless the current value of the CloneValues property.
GetStream can be used also for byte array resources. However, if the value is returned from compiled resources, then always a new copy of the byte array will be wrapped.
If SafeMode is and name is neither a MemoryStream nor a byte array resource, then instead of throwing an InvalidOperationException the method returns a stream wrapper for the same string value that is returned by the GetString method, which will be the raw XML content for non-string resources.
|The internal buffer is tried to be obtained by reflection in the first place. On platforms, which have possibly unknown non-public member names the public APIs are used, which may copy the content in memory.|