예제 #1
0
        /// <summary>
        /// Loads the specified file as assembly. This will throw exception if there are problems. It's possible that the assembly was loaded anyway.
        /// Loading a file with same name again will attempt to return same assembly even if the file versions are different.
        /// </summary>
        /// <param name="file">The file to load from.</param>
        /// <param name="result">The result is set here. Result may be set even when an exception is thrown.</param>
        public static void Load(FileInfo file, ref Assembly result)
        {
            lock (Locker)
            {
                AssemblyLoadResult r = Loaded.FirstOrDefault(q => q.FileName.Equals(file.Name, StringComparison.OrdinalIgnoreCase));
                if (r != null)
                {
                    result = r.Assembly;
                    if (r.Exception != null)
                    {
                        throw r.Exception;
                    }
                    return;
                }

                if (!file.Exists)
                {
                    throw new FileNotFoundException("Specified assembly file was not found!", file.FullName);
                }

                // Must use LoadFile instead of LoadFrom or the load context will not allow types to match up.
                Assembly a = Assembly.LoadFile(file.FullName);

                r           = new AssemblyLoadResult();
                r.Assembly  = a;
                r.FileName  = file.Name;
                r.Exception = null;

                Loaded.Add(r);
                result = a;
            }
        }
예제 #2
0
        public async Task <bool> LoadAsync()
        {
            Log.Debug($"[{Scope}] Loading snapshots");

            var loadingAsync = LoadingAsync;

            if (loadingAsync != null)
            {
                var cancelEventArgs = new CancelEventArgs();
                await loadingAsync(this, cancelEventArgs);

                if (cancelEventArgs.Cancel)
                {
                    Log.Info("Loading canceled by LoadingAsync event");
                    return(false);
                }
            }

            var snapshots = await _snapshotStorageService.LoadSnapshotsAsync();

            lock (_snapshots)
            {
                _snapshots.Clear();
                _snapshots.AddRange(snapshots);
            }

            Loaded.SafeInvoke(this);

            Log.Info($"[{Scope}] Loaded '{snapshots.Count()}' snapshots");

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Loads the view asynchronously.
        /// </summary>
        protected async Task LoadAsyncInternal(bool initiatedLoad, bool parentAwaitAssets)
        {
            if (IsLoaded)
            {
                return;
            }

            if (LoadMode.HasFlag(LoadMode.Manual) && !initiatedLoad)
            {
                return;
            }

            BeforeLoad();

            bool awaitAssets = parentAwaitAssets || LoadMode.HasFlag(LoadMode.AwaitAssets);
            await Task.WhenAll(LayoutChildren.ToList().Select(x => x.LoadAsyncInternal(false, awaitAssets)));

            _isLoaded = true;
            AfterChildrenLoaded();
            Initialize();

            if (awaitAssets)
            {
                await LoadDependencyPropertiesAsync();
            }
            else
            {
                LoadDependencyProperties();
            }
            UpdateBindings();

            AfterLoad();

            Loaded?.Invoke(this);
        }
예제 #4
0
        /// <summary>
        /// Loads the view. Called internally.
        /// </summary>
        protected void LoadInternal(bool initiatedLoad)
        {
            if (IsLoaded)
            {
                return;
            }

            if (LoadMode.HasFlag(LoadMode.Manual) && !initiatedLoad)
            {
                return;
            }

            BeforeLoad();

            foreach (var child in LayoutChildren.ToList())
            {
                child.LoadInternal(false);
            }

            _isLoaded = true;
            AfterChildrenLoaded();
            Initialize();

            LoadDependencyProperties();
            UpdateBindings();

            _initializer?.Invoke(this);

            AfterLoad();

            Loaded?.Invoke(this);
        }
예제 #5
0
        public void Load(string path)
        {
            var fileNameNotValid = false;
            var files            = Directory.GetFiles(SpecialFolder.BlueprintThumbnails.GetPath(), "*.png");

            for (int i = 0; i < files.Length; i++)
            {
                var texture = DirectoryExtensions.LoadPNG(files[i], WIDTH, HEIGHT);
                int hashKey;
                var name  = Path.GetFileNameWithoutExtension(files[i]);
                var valid = int.TryParse(name, out hashKey);

                if (valid)
                {
                    base[hashKey] = Sprite.Create(
                        texture,
                        new Rect(0f, 0f, 800, 800),
                        new Vector2(0.5f, 0.5f));
                }
                else
                {
                    Debug.LogError($"file name not valid");
                }
            }

            if (fileNameNotValid)
            {
                NoticeManager.Instance.Prompt("Incorrect files found in thumbnails folder. Stay the f**k away :)");
            }

            Loaded?.Invoke();
        }
예제 #6
0
        private static void UpdateIsShowing(DependencyObject element)
        {
            if (element == null)
            {
                return;
            }

            if (!Visible.IsVisible(element) ||
                !Loaded.IsLoaded(element))
            {
                element.SetIsShowing(false);
                return;
            }

            var template  = GetTemplate(element);
            var isVisible = GetIsVisible(element);

            if (template != null && isVisible != null)
            {
                element.SetIsShowing(isVisible.Value);
                return;
            }

            element.SetIsShowing(template != null);
        }
예제 #7
0
        public void Load()
        {
            if (File.Exists(_fileName))
            {
                string serialized = File.ReadAllText(_fileName);

                var deserialized = deserialize(serialized);

                lock (_syncModels)
                {
                    _state = deserialized;

                    _deckModels = _state.Decks
                                  .Select(d => new DeckModel(d, _repo, _state.Collection, _transformation))
                                  .ToList();

                    _decksByName = _deckModels.ToMultiDictionary(_ => _.Name, Str.Comparer);

                    _indexByDeck = Enumerable.Range(0, _deckModels.Count)
                                   .ToDictionary(i => _deckModels[i]);
                }
            }

            IsLoaded = true;
            Loaded?.Invoke();
        }
예제 #8
0
파일: TextBase.cs 프로젝트: mumant/Talker
        public bool LoadFile(string file)
        {
            try
            {
                textList.Clear();

                StreamReader stream;
                try
                {
                    stream = new StreamReader(file);
                }
                catch
                {
                    return(false);
                }

                using (stream)
                {
                    string line;
                    while ((line = stream.ReadLine()) != null)
                    {
                        textList.Add(new TextBaseElement(line));
                    }
                }

                return(true);
            }
            finally
            {
                Loaded?.Invoke();
            }
        }
예제 #9
0
 public void Load()
 {
     using (EntityReader <T> curReader = new EntityReader <T>(new MemoryStream(data), DBM))
     {
         for (int i = 1; i <= curReader.TotalRecords; i++)
         {
             //nincs double check, mert kevés az az eset amikor nem kellene lockolni (1. ág)
             lock (this.reader)
             {
                 if (array[i - 1] != null)
                 {
                     curReader.SkipRecord();
                 }
                 else
                 {
                     array[i - 1] = curReader.ReadRecord();
                 }
             }
         }
     }
     lock (this.reader)
     {
         this.reader.Close();
         this.reader = null;
         this.data   = null; //free unused memory
     }
     Loaded.Start();
 }
예제 #10
0
        public int LoadDocData(string moniker)
        {
            try
            {
                var replayer = new BinaryLogReplayEventSource();
                var builder  = new ModelBuilder(replayer);
                replayer.Replay(moniker);
                _filename = moniker;
                Log       = builder.Finish();
            }
            catch (Exception ex)
            {
                if (ex is AggregateException aggregateException)
                {
                    Log = new Log(null, ImmutableList <Evaluation> .Empty, aggregateException.InnerExceptions.ToImmutableList());
                }
                else
                {
                    Log = new Log(null, ImmutableList <Evaluation> .Empty, new[] { ex }.ToImmutableList());
                }
            }

            Loaded?.Invoke(this, new EventArgs());

            return(VSConstants.S_OK);
        }
예제 #11
0
파일: MainMenu.cs 프로젝트: larnin/Spectrum
 static MainMenu()
 {
     Events.MainMenu.Initialized.Subscribe(data =>
     {
         Loaded?.Invoke(default(object), System.EventArgs.Empty);
     });
 }
예제 #12
0
 void Settings_SettingsLoaded(object sender, System.Configuration.SettingsLoadedEventArgs e)
 {
     if (Loaded != null)
     {
         Loaded.Invoke(Assembly.GetExecutingAssembly(), this);
     }
 }
예제 #13
0
 public void RunFullyLoaded()
 {
     Loaded?.Invoke();
     loadingCanvas.gameObject.SetActive(false);
     creditsCanvas.gameObject.SetActive(true);
     loadingDelayText.gameObject.SetActive(false);
 }
예제 #14
0
        /// <summary>
        /// Handles <see cref="QuestInfoMessages.LoadInitialValues"/>.
        /// </summary>
        /// <param name="bs">The <see cref="BitStream"/> to read from.</param>
        void ReadLoadInitialValues(BitStream bs)
        {
            _completedQuests.Clear();
            _activeQuests.Clear();

            // Read completed quests
            var count = bs.ReadByte();

            for (var i = 0; i < count; i++)
            {
                _completedQuests.Add(bs.ReadQuestID());
            }

            // Read Active quests
            count = bs.ReadByte();
            for (var i = 0; i < count; i++)
            {
                _activeQuests.Add(bs.ReadQuestID());
            }

            // Raise events
            OnLoaded();

            if (Loaded != null)
            {
                Loaded.Raise(this, EventArgs.Empty);
            }
        }
        /// <summary>
        ///     Write the save file.
        /// </summary>
        public static void WriteSave()
        {
            if (Loaded == null)
            {
                Loaded = new EnhancedGUISave();
            }
            foreach (var renderer in EnhancedGUIRenderer.Renderers)
            {
                foreach (var window in renderer.Windows)
                {
                    var data = Loaded.GetWindowData(window.Name);
                    if (data == null)
                    {
                        data = new SerializableWindow();
                        Loaded.Windows.Add(data);
                    }

                    data.Name            = window.Name;
                    data.Ready           = true;
                    data.X               = window.Rect.x;
                    data.Y               = window.Rect.y;
                    data.Height          = window.Rect.height;
                    data.Width           = window.Rect.width;
                    data.IsContentActive = window.IsContentActive;
                }
            }

            File.WriteAllText(SaveFileName, JsonUtility.ToJson(Loaded, true));
        }
예제 #16
0
        public void Load(IEnumerable <IPlaylist> playlists)
        {
            if (IsLoaded || playlists == null)
            {
                return;
            }

            string           currentSongPath     = CurrentPlaylist?.CurrentSong?.Path;
            double           currentSongPosition = CurrentPlaylist?.CurrentSongPosition ?? 0;
            List <IPlaylist> remainingPlaylists  = Playlists.ToList();
            List <IPlaylist> addPlaylists        = new List <IPlaylist>();

            foreach (IPlaylist setPlaylist in playlists)
            {
                IPlaylist existingPlaylist = remainingPlaylists.FirstOrDefault(p => p.AbsolutePath == setPlaylist.AbsolutePath);

                if (existingPlaylist == null)
                {
                    addPlaylists.Add(setPlaylist);
                }
                else
                {
                    existingPlaylist.Songs = setPlaylist.Songs;
                    remainingPlaylists.Remove(existingPlaylist);
                }
            }

            Playlists.Change(remainingPlaylists, addPlaylists);

            SetCurrentPlaylistAndCurrentSong(currentSongPath, currentSongPosition);

            //AutoSaveLoad.CheckLibrary(this, "LoadedComplete");
            IsLoaded = true;
            Loaded?.Invoke(this, System.EventArgs.Empty);
        }
예제 #17
0
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        internal XbrlFragment(XbrlDocument ParentDocument, INamespaceManager namespaceManager, INode XbrlRootNode)
        {
            this.Document         = ParentDocument;
            this.NamespaceManager = namespaceManager;
            this.XbrlRootNode     = XbrlRootNode;
            this.Schemas          = new XbrlSchemaCollection();
            this.ValidationErrors = new List <ValidationError>();
            CreateNamespaceManager();
            //---------------------------------------------------------------------------
            // Load.
            //---------------------------------------------------------------------------
            ReadSchemaLocationAttributes();
            ReadLinkbaseReferences();
            ReadTaxonomySchemaReferences();
            ReadRoleReferences();
            ReadArcroleReferences();
            ReadContexts();
            ReadUnits();
            ReadFacts();
            ReadFootnoteLinks();
            Loaded?.Invoke(this, null);
            //---------------------------------------------------------------------------
            // Validate.
            //---------------------------------------------------------------------------
            var validator = new Xbrl2Dot1Validator();

            validator.Validate(this);
            Validated?.Invoke(this, null);
        }
예제 #18
0
        public void Load()
        {
            if (IsLoaded || IsLoading)
            {
                return;
            }

            IsLoading = true;

            if (_version.IsUpToDate)
            {
                _index = new RAMDirectory(FSDirectory.Open(_version.Directory), IOContext.READ_ONCE);
            }
            else
            {
                _index = new RAMDirectory(createKeywordsFrom(_repo), IOContext.READ_ONCE);
            }

            _indexReader = DirectoryReader.Open(_index);
            _searcher    = new IndexSearcher(_indexReader);

            IsLoaded  = true;
            IsLoading = false;
            Loaded?.Invoke();
        }
예제 #19
0
        public void Load(string path)
        {
            try
            {
                var json = File.ReadAllText(path);

                var unverifiedBlueprints = JsonConvert.DeserializeObject <List <BlueprintModel> >(json);
                var validBlueprints      = unverifiedBlueprints.Distinct().Where(x => x.IsValid);

                // Return a list of blueprints that are valid and unique
                AddRange(validBlueprints);
                Loaded?.Invoke();
                HasLoaded = true;
            }
            catch (FileNotFoundException)
            {
                File.Create(path);
                Loaded?.Invoke();
                HasLoaded = true;
            }
            catch (Exception e)
            {
                Debug.LogWarning("Error on blueprint collection load:" + e);
            }
        }
예제 #20
0
        protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
        {
            base.OnElementPropertyChanged(args);

            /*
             * Console.WriteLine("Container: " + this.Container);
             * Console.WriteLine("Control: " + this.Control);
             * Console.WriteLine("Element: " + this.Element);
             */
            //Console.WriteLine("OnElementPropertyChanged set LoadedControl to " + LoadedControl + " from Control " + Control + " Element: " + Element);

            /* special implementation neccessary beacuse the native Control is not being ready at start/in mainpage contructor */

            if (Control != null && LoadedControl == null)
            {
                LoadedControl = Control;
                // Console.WriteLine("OnElementPropertyChanged set LoadedControl to " + LoadedControl + " from Control " + Control);
                Loaded.Invoke();
            }

            // handling case with Xamarin.Forms.Layout // https://forums.xamarin.com/discussion/comment/386827#Comment_386827
            if (Container != null && LoadedControl == null)
            {
                LoadedControl = Container;
                // Console.WriteLine("OnElementPropertyChanged set LoadedControl to " + LoadedControl + " from Container " + Container);
                Loaded.Invoke();
            }

            // no page equivalent in native
        }
예제 #21
0
        public void LoadHistory(string file)
        {
            string directory = Path.GetDirectoryName(file);

            if (string.IsNullOrEmpty(directory))
            {
                throw new ArgumentException($"parent directory not found for path: {file}", nameof(file));
            }

            Directory.CreateDirectory(directory);

            if (File.Exists(file))
            {
                HistoryState state;

                using (var fileReader = File.OpenText(file))
                    using (var jsonReader = new JsonTextReader(fileReader))
                        state = _serializer.Deserialize <HistoryState>(jsonReader);

                _settingsHistory = state.SettingsHistory;
                _settingsIndex   = state.SettingsIndex;
            }
            else
            {
                _settingsHistory = new List <GuiSettings>();
                var defaultSettings = new GuiSettings();
                Add(defaultSettings);
            }

            IsLoaded = true;
            Loaded?.Invoke();
        }
예제 #22
0
        public override void OnFrameworkInitializationCompleted()
        {
            if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime lifetime)
            {
                try
                {
                    Loaded?.Invoke(this, EventArgs.Empty);
                    lifetime.Exit += OnExit;

                    var mainViewModel = new MainWindowViewModel();
                    var mainView      = View.CreateAndAttach(mainViewModel);
                    lifetime.MainWindow = mainView;

                    Log.Verbose("GUI framework successfully initialized");
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Unable to initialize GUI framework");
                }
            }
            else
            {
                Log.Error("Unable to initialize GUI framework: expected desktop lifetime but found {0}", ApplicationLifetime);
            }

            base.OnFrameworkInitializationCompleted();
        }
예제 #23
0
 public virtual void OnLoad()
 {
     if (Loaded != null)
     {
         Loaded.Invoke();
     }
 }
예제 #24
0
 public void Dispose()
 {
     Instance = null;
     Loaded.Dispose();
     Thread.Abort();
     return;
 }
예제 #25
0
 /// <summary>
 /// </summary>
 /// <param name="assemblyPath"></param>
 private void VerifyPlugin(string assemblyPath)
 {
     try
     {
         var bytes     = File.ReadAllBytes(assemblyPath);
         var pAssembly = Assembly.Load(bytes);
         var pType     = pAssembly.GetType(pAssembly.GetName()
                                           .Name + ".Plugin");
         var implementsIPlugin = typeof(IPlugin).IsAssignableFrom(pType);
         if (!implementsIPlugin)
         {
             Logging.Log(Logger, String.Format("*IPlugin Not Implemented* :: {0}", pAssembly.GetName()
                                               .Name));
             return;
         }
         var plugin = new PluginInstance
         {
             Instance     = (IPlugin)Activator.CreateInstance(pType),
             AssemblyPath = assemblyPath
         };
         plugin.Instance.Initialize(Instance);
         Loaded.Add(plugin);
     }
     catch (Exception ex)
     {
     }
 }
예제 #26
0
        internal void LoadIndex(LuceneSearcherState <TId, TDoc> state)
        {
            BeginLoad?.Invoke();

            bool stateExisted = State != null;

            if (!stateExisted)
            {
                State = state;
            }

            var index = CreateIndex(state);

            if (index == null)
            {
                return;
            }

            state.Load(index);

            if (stateExisted)
            {
                State.Dispose();
                State = state;
            }

            Loaded?.Invoke();
        }
예제 #27
0
 protected ViewModelBase()
 {
     if (!Loaded.Contains(this))
     {
         Loaded.Add(this);
     }
 }
예제 #28
0
        public void SetAnimationStream(Stream inputStream)
        {
            if (inputStream == null)
            {
                _gifMovie    = null;
                _movieWidth  = 0;
                _movieHeight = 0;
            }
            else
            {
                _gifMovie = Movie.DecodeStream(inputStream);
                if (_gifMovie != null)
                {
                    _movieWidth  = _gifMovie.Width();
                    _movieHeight = _gifMovie.Height();
                }
                else
                {
                    _movieWidth  = 0;
                    _movieHeight = 0;
                }

                Loaded?.Invoke(this, EventArgs.Empty);
            }
        }
예제 #29
0
 private async void ViewBase_Loaded(object sender, RoutedEventArgs e)
 {
     if (_isLeaving == false)
     {
         Loaded?.Invoke(sender, e);
         await PlayEnterAnimationAsync();
     }
 }
예제 #30
0
 private void ObjectExplorerForm_VisibleChanged(object sender, EventArgs e)
 {
     if (!_isLoaded)
     {
         Loaded?.Invoke(sender, e);
         _isLoaded = true;
     }
 }