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); } }
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; } }
internal static void addPendingFile(NaClFile file) { naclFiles.Add(file); URLLoader_LoadFile(file.FileName, file.ID.ToString()); }
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); }
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; } }