コード例 #1
0
ファイル: ResourcePart.cs プロジェクト: dox0/DotNet471RS3
        protected override Stream GetStreamCore(FileMode mode, FileAccess access)
        {
            Stream stream = null;

            stream = EnsureResourceLocationSet();
            // in order to find the resource we might have to open a stream.
            // rather than waste the stream it is returned here and we can use it.
            if (stream == null)
            {
                // Start looking for resources using the current ui culture.
                // The resource manager will fall back to invariant culture automatically.
                stream = _rmWrapper.Value.GetStream(_name);

                if (stream == null)
                {
                    throw new IOException(SR.Get(SRID.UnableToLocateResource, _name));
                }
            }

            //
            // If this is a Baml stream, it will return BamlStream object, which contains
            // both raw stream and the host assembly.
            //
            ContentType curContent = new ContentType(ContentType);

            if (MimeTypeMapper.BamlMime.AreTypeAndSubTypeEqual(curContent))
            {
                BamlStream bamlStream = new BamlStream(stream, _rmWrapper.Value.Assembly);

                stream = bamlStream;
            }

            return(stream);
        }
コード例 #2
0
        protected override Stream GetStreamCore(FileMode mode, FileAccess access)
        {
            Stream stream = this.EnsureResourceLocationSet();

            if (stream == null)
            {
                stream = this._rmWrapper.Value.GetStream(this._name);
                if (stream == null)
                {
                    throw new IOException(SR.Get("UnableToLocateResource", new object[]
                    {
                        this._name
                    }));
                }
            }
            ContentType contentType = new ContentType(base.ContentType);

            if (MimeTypeMapper.BamlMime.AreTypeAndSubTypeEqual(contentType))
            {
                BamlStream bamlStream = new BamlStream(stream, this._rmWrapper.Value.Assembly);
                stream = bamlStream;
            }
            return(stream);
        }
コード例 #3
0
ファイル: ResourcePart.cs プロジェクト: sjyanxin/WPFSource
        protected override Stream GetStreamCore(FileMode mode, FileAccess access)
        { 
            Stream stream = null; 

            stream = EnsureResourceLocationSet(); 
            // in order to find the resource we might have to open a stream.
            // rather than waste the stream it is returned here and we can use it.
            if (stream == null)
            { 
                // Start looking for resources using the current ui culture.
                // The resource manager will fall back to invariant culture automatically. 
                stream = _rmWrapper.Value.GetStream(_name); 

                if (stream == null) 
                {
                    throw new IOException(SR.Get(SRID.UnableToLocateResource, _name));
                }
            } 

            // 
            // If this is a Baml stream, it will return BamlStream object, which contains 
            // both raw stream and the host assembly.
            // 
            ContentType  curContent = new ContentType(ContentType);

            if (MimeTypeMapper.BamlMime.AreTypeAndSubTypeEqual(curContent))
            { 
                BamlStream bamlStream = new BamlStream(stream, _rmWrapper.Value.Assembly);
 
                stream = bamlStream; 
            }
 
            return stream;
        }