Microsoft.Xna.Framework.ContentExtensions.OpenStream C# (CSharp) Méthode

OpenStream() static private méthode

static private OpenStream ( this Content, string name ) : Stream
Content this
name string
Résultat Stream
        internal static Stream OpenStream(this ContentManager Content, string name)
        {
            // This code taken from MonoGames' ContentManager.OpenStream
            // That method is protected, so we can't access it here
            Stream stream;
            try
            {
                string assetPath = name;
                stream = TitleContainer.OpenStream(assetPath);
            #if ANDROID
                // Read the asset into memory in one go. This results in a ~50% reduction
                // in load times on Android due to slow Android asset streams.
                MemoryStream memStream = new MemoryStream();
                stream.CopyTo(memStream);
                memStream.Seek(0, SeekOrigin.Begin);
                stream.Close();
                stream = memStream;
            #endif
            }
            catch (FileNotFoundException fileNotFound)
            {
                throw new ContentLoadException("The content file was not found.", fileNotFound);
            }
            #if !WINRT
            catch (DirectoryNotFoundException directoryNotFound)
            {
                throw new ContentLoadException("The directory was not found.", directoryNotFound);
            }
            #endif
            catch (Exception exception)
            {
                throw new ContentLoadException("Error opening stream.", exception);
            }
            return stream;
        }