AddLoadableException() public static method

public static AddLoadableException ( Exception e ) : void
e System.Exception
return void
Ejemplo n.º 1
0
        private void init(string filename, Stream stream, Loader.LoadedCallbackMethod loadedCallback)
                #endif
        {
            try
            {
                if (filename != null)
                {
                    fromFile = true;
                                        #if WINRT || WP8
                    LoadedStream = await Streams.OpenFile(filename);
                                        #elif NaCl
                    this.loadedCallback = loadedCallback;

                    filename = filename.Replace('\\', '/');
                    file     = new NaClFile(filename);
                    Streams.NaClFileLoadedCallback += fileLoaded;
                    Streams.addPendingFile(file);
                    Loader.AddLoadable(this);

                    return;
                                        #else
                    LoadedStream = Streams.OpenFile(filename);
                                        #endif
                }
                else
                {
                    fromFile     = false;
                    LoadedStream = stream;
                }
            }
            catch (Exception e)
            {
                FailedToLoad = true;
                Loader.AddLoadableException(e);
                Dispose();
                if (loadedCallback != null)
                {
                    loadedCallback(this, false);
                }
                return;
            }

            Loaded = true;
            if (loadedCallback != null)
            {
                loadedCallback(this, true);
            }
        }
Ejemplo n.º 2
0
        private void fileLoaded(NaClFile file)
        {
            if (file.ID == this.file.ID)
            {
                Streams.NaClFileLoadedCallback -= fileLoaded;

                if (file.FailedToLoad)
                {
                    FailedToLoad = true;
                    if (loadedCallback != null)
                    {
                        loadedCallback(this, false);
                    }
                    loadedCallback = null;
                    Dispose();
                    return;
                }

                try
                {
                    LoadedStream          = new MemoryStream(file.Data);
                    LoadedStream.Position = 0;
                }
                catch (Exception e)
                {
                    FailedToLoad = true;
                    Loader.AddLoadableException(e);
                    if (loadedCallback != null)
                    {
                        loadedCallback(this, false);
                    }
                    loadedCallback = null;
                    Dispose();
                    return;
                }

                Loaded = true;
                if (loadedCallback != null)
                {
                    loadedCallback(this, true);
                }
                loadedCallback = null;
            }
        }