HybridResourceManagerGetMetaStream Method

KGy SOFT Core Libraries Help
Returns a MemoryStream instance from the metadata of the specified name and culture.

Namespace:  KGySoft.Resources
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.4.0

public MemoryStream GetMetaStream(
	string name,
	CultureInfo culture = null


Type: SystemString
The name of the metadata to retrieve.
culture (Optional)
Type: System.GlobalizationCultureInfo
An object that represents the culture for which the metadata should be returned. If this value is , the CultureInfo object is obtained by using the CultureInfo.InvariantCulture property. Unlike in case of GetStream methods, no fallback is used if the metadata is not found in the specified culture. This parameter is optional.
Default value: .

Return Value

Type: MemoryStream
A MemoryStream object from the specified metadata, or  if name cannot be found in a resource set.


IExpandoResourceManagerGetMetaStream(String, CultureInfo)

ArgumentNullExceptionname is .
ObjectDisposedExceptionThe HybridResourceManager is already disposed.
InvalidOperationExceptionSafeMode is  and the type of the metadata is neither MemoryStream nor byte[].
MissingManifestResourceExceptionNo 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 GetMetaObject method returns either a full copy of the specified metadata, 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 GetMetaStream method can be used to obtain a new read-only MemoryStream wrapper around the same internal buffer, regardless the current value of the CloneValues property.

GetMetaStream can be used also for byte array metadata.

If SafeMode is  and name is neither a MemoryStream nor a byte array metadata, then instead of throwing an InvalidOperationException the method returns a stream wrapper for the same string value that is returned by the GetString methods, which will be the raw XML content for non-string metadata.

See Also