Example #1
0
 private void ViewBase_Unloaded(object sender, RoutedEventArgs e)
 {
     if (_isLeaving == false)
     {
         Unloaded?.Invoke(sender, e);
     }
 }
Example #2
0
        public void Dispose()
        {
            _stopwatch.Stop();

            var entryType = Info.IsRoot ? ContextLogEntryType.ContextEnd : ContextLogEntryType.ChildContextEnd;

            Logger.LogAsType(Settings.ContextEndMessageLevel,
                             $"Context {Info.ContextName} has ended.", entryType);

            _stack.Pop();

            Logger.CompleteIfRoot();
            Logger.TrySetContext(_parent);

            if (_stack.IsEmpty)
            {
                // Logger = null;
                // State = null;

                _namedStacks.Remove(Info.ContextGroupName, out _);

                if (!_namedStacks.Any())
                {
                    _asyncLocalStacks.Value = null;
                }
            }

            OnDispose?.Invoke(this);
            Unloaded?.Invoke(this);
        }
Example #3
0
        public void Dispose()
        {
            State = ScreenState.Finished;

            _uiController?.Dispose();
            Unloaded?.Invoke(this);
        }
Example #4
0
        /// <summary>
        /// Called when the fragment is paused.
        /// </summary>
        public override void OnPause()
        {
            base.OnPause();

            Unloaded?.Invoke(this);

            UninitializeBindingContext();
        }
Example #5
0
        /// <summary>
        /// Called as part of the activity lifecycle when an activity is going into
        ///  the background, but has not (yet) been killed.
        /// </summary>
        protected override void OnPause()
        {
            base.OnPause();

            // Note: call *after* base so NavigationAdapter always gets called
            Unloaded?.Invoke(this);

            UninitializeBindingContext();
        }
Example #6
0
        public override void ViewDidDisappear(bool animated)
        {
            base.ViewDidDisappear(animated);

            // Note: call *after* base so NavigationAdapter always gets called
            Unloaded?.Invoke(this);

            UninitializeBindingContext();
        }
Example #7
0
        public void Unload()
        {
            SoundBuilder.Unload();
            SoundBuilder = null;

            Unloaded?.Invoke(this, EventArgs.Empty);

            GameObject.Destroy(gameObject);
        }
Example #8
0
 /// <summary>
 /// Called when Form's Closing event is raised.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Form_Closing(object sender, FormClosingEventArgs e)
 {
     if (!_closeable)
     {
         e.Cancel = true; // Do not allow to Close
         this.Hide();
     }
     else
     {
         Unloaded?.Invoke(this, null);
     }
 }
Example #9
0
        public void Unload()
        {
            if (Domain != null)
            {
                Unloaded?.Invoke(this, Domain);

                AppDomain.Unload(Domain);
                AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
                Domain = null;
            }

            Unloaded = null;

            Assemblies.Clear();
            Classes = new RemoteClass[0];
        }
Example #10
0
        public async Task UnloadAsync(string id, object asset, IAssetUnloadParameters parameters)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(id));
            }
            if (asset == null)
            {
                throw new ArgumentNullException(nameof(asset));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            Type type = asset.GetType();

            Unloading?.Invoke(id, asset, parameters);

            await OnUnloadAsync(id, asset, parameters);

            Unloaded?.Invoke(id, type, parameters);
        }
Example #11
0
 /// <summary>
 /// Free up the memory in this block, writing out to disk if dirty
 /// </summary>
 public void Unload()
 {
     if (!loaded)
     {
         return;
     }
     if (dirty)
     {
         if (address0 > io.Length)
         {
             io.SetLength(address0);
         }
         if (address0 != io.Position)
         {
             io.Seek(address0, SeekOrigin.Begin);
         }
         io.Write(mem, 0, PAGESIZE);
     }
     mem       = null;
     loaded    = false;
     last_used = 0;
     Unloaded?.Invoke(this, null);
 }
        public async Task UnloadAsync(string id, Scene scene, ISceneUnloadParameters parameters)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(id));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            LogSceneUnload(id, scene, parameters, true);

            Unloading?.Invoke(id, scene, parameters);

            OnRemoveScene(id, scene, parameters);
            await OnUnloadAsync(id, scene, parameters);

            Instances.Remove(scene);

            Unloaded?.Invoke(id, parameters);

            LogSceneUnloaded(id, parameters, true);
        }
Example #13
0
 public void Unload()
 {
     Unloaded?.Invoke();
 }
Example #14
0
 /// <summary>
 /// Called from <see cref="Application.End(Application.RunState)"/> before the <see cref="Toplevel"/> is disposed.
 /// </summary>
 internal virtual void OnUnloaded()
 {
     Unloaded?.Invoke();
 }
Example #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LogicBase"/> class.
        /// </summary>
        /// <param name="targetView">The target control.</param>
        /// <param name="viewModelType">Type of the view model.</param>
        /// <param name="viewModel">The view model.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="targetView"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="viewModelType"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="viewModelType"/> does not implement interface <see cref="IViewModel"/>.</exception>
        protected LogicBase(IView targetView, Type viewModelType = null, IViewModel viewModel = null)
        {
            if (CatelEnvironment.IsInDesignMode)
            {
                return;
            }

            Argument.IsNotNull("targetView", targetView);

            var targetViewType = targetView.GetType();

            if (viewModelType is null)
            {
                viewModelType = (viewModel != null) ? viewModel.GetType() : _viewModelLocator.ResolveViewModel(targetViewType);
                if (viewModelType is null)
                {
                    throw Log.ErrorAndCreateException <NotSupportedException>($"The view model of the view '{targetViewType.Name}' could not be resolved. Make sure to customize the IViewModelLocator or register the view and view model manually");
                }
            }

            UniqueIdentifier = UniqueIdentifierHelper.GetUniqueIdentifier <LogicBase>();

            Log.Debug($"Constructing behavior '{GetType().Name}' for '{targetView.GetType().Name}' with unique id '{UniqueIdentifier}'");

            TargetView    = targetView;
            ViewModelType = viewModelType;
            ViewModel     = viewModel;

            ViewModelBehavior = (viewModel != null) ? LogicViewModelBehavior.Injected : LogicViewModelBehavior.Dynamic;

            if (ViewModel != null)
            {
                SetDataContext(ViewModel);
            }

            Log.Debug("Subscribing to view events");

            ViewLoadManager.AddView(this);

            if (this.SubscribeToWeakGenericEvent <ViewLoadEventArgs>(ViewLoadManager, nameof(IViewLoadManager.ViewLoading), OnViewLoadedManagerLoadingInternal, false) is null)
            {
                Log.Debug("Failed to use weak events to subscribe to 'ViewLoadManager.ViewLoading', going to subscribe without weak events");

                ViewLoadManager.ViewLoading += OnViewLoadedManagerLoadingInternal;
            }

            if (this.SubscribeToWeakGenericEvent <ViewLoadEventArgs>(ViewLoadManager, nameof(IViewLoadManager.ViewLoaded), OnViewLoadedManagerLoadedInternal, false) is null)
            {
                Log.Debug("Failed to use weak events to subscribe to 'ViewLoadManager.ViewLoaded', going to subscribe without weak events");

                ViewLoadManager.ViewLoaded += OnViewLoadedManagerLoadedInternal;
            }

            if (this.SubscribeToWeakGenericEvent <ViewLoadEventArgs>(ViewLoadManager, nameof(IViewLoadManager.ViewUnloading), OnViewLoadedManagerUnloadingInternal, false) is null)
            {
                Log.Debug("Failed to use weak events to subscribe to 'ViewLoadManager.ViewUnloading', going to subscribe without weak events");

                ViewLoadManager.ViewUnloading += OnViewLoadedManagerUnloadingInternal;
            }

            if (this.SubscribeToWeakGenericEvent <ViewLoadEventArgs>(ViewLoadManager, nameof(IViewLoadManager.ViewUnloaded), OnViewLoadedManagerUnloadedInternal, false) is null)
            {
                Log.Debug("Failed to use weak events to subscribe to 'ViewLoadManager.ViewUnloaded', going to subscribe without weak events");

                ViewLoadManager.ViewUnloaded += OnViewLoadedManagerUnloadedInternal;
            }

            // Required so the ViewLoadManager can handle the rest
            targetView.Loaded   += (sender, e) => Loaded?.Invoke(this, EventArgs.Empty);
            targetView.Unloaded += (sender, e) => Unloaded?.Invoke(this, EventArgs.Empty);

            TargetView.DataContextChanged += OnTargetViewDataContextChanged;

            Log.Debug("Subscribing to view properties");

            // This also subscribes to DataContextChanged, don't double subscribe
            var viewPropertiesToSubscribe = DetermineInterestingViewProperties();

            foreach (var viewPropertyToSubscribe in viewPropertiesToSubscribe)
            {
                TargetView.SubscribeToPropertyChanged(viewPropertyToSubscribe, OnTargetViewPropertyChanged);
            }

            Log.Debug($"Constructed behavior '{GetType().Name}' for '{TargetViewType?.Name}'");
        }
Example #16
0
 /// <summary>
 /// Handle end of unloading.
 /// </summary>
 protected virtual void OnUnloaded()
 {
     _loadProgress = 0;
     Unloaded?.Invoke(this);
 }
 protected virtual void OnUnloaded()
 {
     Unloaded?.Invoke(this, EventArgs.Empty);
 }
Example #18
0
 public static void OnUnloaded(object sender, ScriptUnloadedEventArgs e)
 {
     Unloaded?.Invoke(sender, e);
 }
Example #19
0
 private protected virtual void OnUnloaded()
 {
     Unloaded?.Invoke(this, new RoutedEventArgs(this));
     OnUnloadedPartial();
 }
Example #20
0
        /// <summary>
        /// Unloads the script and returns it back to the manager
        /// that created it.
        /// </summary>
        public void Unload()
        {
            Unloaded?.Invoke(this, EventArgs.Empty);

            Unloaded = null;
        }
Example #21
0
 public void Unload() => Unloaded?.Invoke();
Example #22
0
 protected virtual void OnUnloaded(EventArgs e)
 {
     Unloaded?.Invoke(this, e);
 }
Example #23
0
 private void Form_Unloaded(object sender, EventArgs e)
 {
     Unloaded?.Invoke(this, e);
 }
Example #24
0
 public void RaiseUnloaded(Element element) => Unloaded?.Invoke(element, EventArgs.Empty);
Example #25
0
 protected virtual void OnUnloaded()
 {
     Unloaded?.Invoke(this, new RoutedEventArgs(this));
 }
Example #26
0
 private void Unload()
 {
     Unloaded?.Invoke();
 }
 private void OnUnloaded(object sender, RoutedEventArgs e)
 {
     Unloaded?.Invoke(sender, EventArgs.Empty);
 }
Example #28
0
 public virtual void Unload()
 {
     Unloaded?.Invoke(this, EventArgs.Empty);
 }
Example #29
0
 public virtual void Unload()
 {
     Unloaded?.Invoke(this, new EventArgs());
 }