Beispiel #1
0
        public void ListPerformance(int n)
        {
            var    list       = new SourceList <int>();
            double runningSum = 0;

            var sw = Stopwatch.StartNew();

            var summation = list.Connect()
                            .Minimum(i => i)
                            .Subscribe(result => runningSum = result);


            //1. this is very slow if there are loads of updates (each updates causes a new summation)
            for (int i = 0; i < n; i++)
            {
                list.Add(i);
            }

            //2. very fast doing this (whole range is 1 update and 1 calculation):
            //list.AddRange(Enumerable.Range(0, n));
            sw.Stop();

            summation.Dispose();
            list.Dispose();

            Console.WriteLine("Total items: {0}. Sum = {1}", n, runningSum);
            Console.WriteLine("List: {0} updates took {1} ms {2:F3} ms each. {3}", n, sw.ElapsedMilliseconds, sw.Elapsed.TotalMilliseconds / n, DateTime.Now.ToShortDateString());
        }
        /// <summary>
        /// Binds the results to the specified <see cref="IObservableList{T}"/>. Unlike
        /// binding to a <see cref="ReadOnlyObservableCollection{T}"/> which loses the
        /// ability to refresh items, binding to an <see cref="IObservableList{T}"/>.
        /// allows for refresh changes to be preserved and keeps the list read-only.
        /// </summary>
        /// <typeparam name="TObject">The type of the object.</typeparam>
        /// <typeparam name="TKey">The type of the key.</typeparam>
        /// <param name="source">The source.</param>
        /// <returns>The <paramref name="source"/> changeset for continued chaining.</returns>
        /// <exception cref="System.ArgumentNullException">source</exception>
        public static IObservable <IChangeSet <TObject, TKey> > BindToObservableList <TObject, TKey>(
            this IObservable <IChangeSet <TObject, TKey> > source,
            out IObservableList <TObject> observableList)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            // Load our source list with the change set.
            // Each changeset we need to convert to remove the key.
            var sourceList = new SourceList <TObject>();

            // Output our readonly observable list, preventing the sourcelist from being editted from anywhere else.
            observableList = sourceList;

            // Return a observable that will connect to the source so we can properly dispose when the pipeline ends.
            return(Observable.Create <IChangeSet <TObject, TKey> >(observer =>
            {
                return source
                .Do(changes => sourceList.Edit(editor => editor.Clone(changes.RemoveKey(editor))))
                .Finally(() => sourceList.Dispose())
                .SubscribeSafe(observer);
            }));
        }
Beispiel #3
0
 protected override void OnNavigatedFrom(bool isInHistory)
 {
     base.OnNavigatedFrom(isInHistory);
     if (!isInHistory)
     {
         _confirmationWordsSourceList.Dispose();
     }
 }
        public void Dispose()
        {
            if (_logItemsSource != null)
            {
                _logItemsSource.Dispose();
            }

            _cleanUp.Dispose();
        }
        /// <inheritdoc/>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _inner?.Dispose();
                _list?.Dispose();
            }

            base.Dispose(disposing);
        }
Beispiel #6
0
        /// <inheritdoc/>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Interlocked.Exchange(ref _inner, Disposable.Empty).Dispose();
                _list?.Dispose();
            }

            base.Dispose(disposing);
        }
Beispiel #7
0
        void ReleaseDesignerOutlets()
        {
            if (SourceList != null)
            {
                SourceList.Dispose();
                SourceList = null;
            }

            if (ViewContainer != null)
            {
                ViewContainer.Dispose();
                ViewContainer = null;
            }
        }
        /// <summary>
        /// Binds the results to the specified <see cref="IObservableList{T}"/>. Unlike
        /// binding to a <see cref="ReadOnlyObservableCollection{T}"/> which loses the
        /// ability to refresh items, binding to an <see cref="IObservableList{T}"/>.
        /// allows for refresh changes to be preserved and keeps the list read-only.
        /// </summary>
        /// <typeparam name="TObject">The type of the object.</typeparam>
        /// <typeparam name="TKey">The type of the key.</typeparam>
        /// <param name="source">The source.</param>
        /// <returns>The <paramref name="source"/> changeset for continued chaining.</returns>
        /// <exception cref="System.ArgumentNullException">source</exception>
        public static IObservable <ISortedChangeSet <TObject, TKey> > BindToObservableList <TObject, TKey>(
            this IObservable <ISortedChangeSet <TObject, TKey> > source,
            out IObservableList <TObject> observableList)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            // Load our source list with the change set.
            // Each changeset we need to convert to remove the key.
            var sourceList = new SourceList <TObject>();

            // Output our readonly observable list, preventing the sourcelist from being editted from anywhere else.
            observableList = sourceList;

            // Return a observable that will connect to the source so we can properly dispose when the pipeline ends.
            return(Observable.Create <ISortedChangeSet <TObject, TKey> >(observer =>
            {
                return source
                .Do(changes =>
                {
                    switch (changes.SortedItems.SortReason)
                    {
                    case SortReason.InitialLoad:
                        sourceList.AddRange(changes.SortedItems.Select(kv => kv.Value));
                        break;

                    case SortReason.ComparerChanged:
                    case SortReason.DataChanged:
                    case SortReason.Reorder:
                        sourceList.Edit(editor => editor.Clone(changes.RemoveKey(editor)));
                        break;

                    case SortReason.Reset:
                        sourceList.Edit(editor =>
                        {
                            editor.Clear();
                            editor.AddRange(changes.SortedItems.Select(kv => kv.Value));
                        });
                        break;
                    }
                })
                .Finally(() => sourceList.Dispose())
                .SubscribeSafe(observer);
            }));
        }
Beispiel #9
0
        void ReleaseDesignerOutlets()
        {
            if (AddButton != null)
            {
                AddButton.Dispose();
                AddButton = null;
            }

            if (EditButton != null)
            {
                EditButton.Dispose();
                EditButton = null;
            }

            if (Search != null)
            {
                Search.Dispose();
                Search = null;
            }

            if (DeleteButton != null)
            {
                DeleteButton.Dispose();
                DeleteButton = null;
            }

            if (SourceList != null)
            {
                SourceList.Dispose();
                SourceList = null;
            }

            if (ViewContainer != null)
            {
                ViewContainer.Dispose();
                ViewContainer = null;
            }
        }
Beispiel #10
0
        public ISourceList <TType> GetList <TType>(int key = 0)
            where TType : IEntity
        {
            CheckDisposed();

            var listKey = new ListKey(key, typeof(TType));

            while (true)
            {
                if (_lists.TryGetValue(listKey, out var target))
                {
                    return((ISourceList <TType>)target);
                }

                var list = new SourceList <TType>();

                if (_lists.TryAdd(listKey, list))
                {
                    return(list);
                }

                list.Dispose();
            }
        }
        public void ListPerformance(int n)
        {
            var list = new SourceList<int>();
            double runningSum = 0;

            var sw = Stopwatch.StartNew();

            var summation = list.Connect()
                .Avg(i => i)
                .Subscribe(result => runningSum = result);


            //1. this is very slow if there are loads of updates (each updates causes a new summation)
            for (int i = 0; i < n; i++)
                list.Add(i);

            //2. very fast doing this (whole range is 1 update and 1 calculation):
            //list.AddRange(Enumerable.Range(0, n));
            sw.Stop();

            summation.Dispose();
            list.Dispose();

            Console.WriteLine("Total items: {0}. Sum = {1}", n, runningSum);
            Console.WriteLine("List: {0} updates took {1} ms {2:F3} ms each. {3}", n, sw.ElapsedMilliseconds, sw.Elapsed.TotalMilliseconds / n, DateTime.Now.ToShortDateString());

        }
Beispiel #12
0
        void ReleaseDesignerOutlets()
        {
            if (PointInspector != null)
            {
                PointInspector.Dispose();
                PointInspector = null;
            }

            if (ArrowInspector != null)
            {
                ArrowInspector.Dispose();
                ArrowInspector = null;
            }

            if (AttachedStyleInspector != null)
            {
                AttachedStyleInspector.Dispose();
                AttachedStyleInspector = null;
            }

            if (BackButton != null)
            {
                BackButton.Dispose();
                BackButton = null;
            }

            if (BooleanPropertyInspector != null)
            {
                BooleanPropertyInspector.Dispose();
                BooleanPropertyInspector = null;
            }

            if (BorderInspectorsButton != null)
            {
                BorderInspectorsButton.Dispose();
                BorderInspectorsButton = null;
            }

            if (ColorPaletteInspector != null)
            {
                ColorPaletteInspector.Dispose();
                ColorPaletteInspector = null;
            }

            if (ConnectionInspectorsButton != null)
            {
                ConnectionInspectorsButton.Dispose();
                ConnectionInspectorsButton = null;
            }

            if (ConnectionsInspector != null)
            {
                ConnectionsInspector.Dispose();
                ConnectionsInspector = null;
            }

            if (DesignSurface != null)
            {
                DesignSurface.Dispose();
                DesignSurface = null;
            }

            if (DetailsInspectorButton != null)
            {
                DetailsInspectorButton.Dispose();
                DetailsInspectorButton = null;
            }

            if (DocumentScrollView != null)
            {
                DocumentScrollView.Dispose();
                DocumentScrollView = null;
            }

            if (DocumentView != null)
            {
                DocumentView.Dispose();
                DocumentView = null;
            }

            if (DocumentViewHeight != null)
            {
                DocumentViewHeight.Dispose();
                DocumentViewHeight = null;
            }

            if (DocumentViewWidth != null)
            {
                DocumentViewWidth.Dispose();
                DocumentViewWidth = null;
            }

            if (ExportButton != null)
            {
                ExportButton.Dispose();
                ExportButton = null;
            }

            if (FillInspector != null)
            {
                FillInspector.Dispose();
                FillInspector = null;
            }

            if (FillInspectorsButton != null)
            {
                FillInspectorsButton.Dispose();
                FillInspectorsButton = null;
            }

            if (FontInspector != null)
            {
                FontInspector.Dispose();
                FontInspector = null;
            }

            if (FrameInspector != null)
            {
                FrameInspector.Dispose();
                FrameInspector = null;
            }

            if (GeneralInfoInspector != null)
            {
                GeneralInfoInspector.Dispose();
                GeneralInfoInspector = null;
            }

            if (GradientInspector != null)
            {
                GradientInspector.Dispose();
                GradientInspector = null;
            }

            if (GroupInspector != null)
            {
                GroupInspector.Dispose();
                GroupInspector = null;
            }

            if (InspectorScrollView != null)
            {
                InspectorScrollView.Dispose();
                InspectorScrollView = null;
            }

            if (InspectorView != null)
            {
                InspectorView.Dispose();
                InspectorView = null;
            }

            if (LanguageSelector != null)
            {
                LanguageSelector.Dispose();
                LanguageSelector = null;
            }

            if (LibrarySelector != null)
            {
                LibrarySelector.Dispose();
                LibrarySelector = null;
            }

            if (NumberPropertyInspector != null)
            {
                NumberPropertyInspector.Dispose();
                NumberPropertyInspector = null;
            }

            if (OSSelector != null)
            {
                OSSelector.Dispose();
                OSSelector = null;
            }

            if (PolygonInspector != null)
            {
                PolygonInspector.Dispose();
                PolygonInspector = null;
            }

            if (PortfolioInspector != null)
            {
                PortfolioInspector.Dispose();
                PortfolioInspector = null;
            }

            if (PropertyInspector != null)
            {
                PropertyInspector.Dispose();
                PropertyInspector = null;
            }

            if (RectPropertyInspector != null)
            {
                RectPropertyInspector.Dispose();
                RectPropertyInspector = null;
            }

            if (RoundRectInspector != null)
            {
                RoundRectInspector.Dispose();
                RoundRectInspector = null;
            }

            if (ScriptDebuggerInspector != null)
            {
                ScriptDebuggerInspector.Dispose();
                ScriptDebuggerInspector = null;
            }

            if (SketchInspector != null)
            {
                SketchInspector.Dispose();
                SketchInspector = null;
            }

            if (SketchPath != null)
            {
                SketchPath.Dispose();
                SketchPath = null;
            }

            if (SourceList != null)
            {
                SourceList.Dispose();
                SourceList = null;
            }

            if (StarInspector != null)
            {
                StarInspector.Dispose();
                StarInspector = null;
            }

            if (StyleInspector != null)
            {
                StyleInspector.Dispose();
                StyleInspector = null;
            }

            if (TextEditor != null)
            {
                TextEditor.Dispose();
                TextEditor = null;
            }

            if (TextEditorMode != null)
            {
                TextEditorMode.Dispose();
                TextEditorMode = null;
            }

            if (TextEditorTitle != null)
            {
                TextEditorTitle.Dispose();
                TextEditorTitle = null;
            }

            if (TextInspector != null)
            {
                TextInspector.Dispose();
                TextInspector = null;
            }

            if (TextPropertyInspector != null)
            {
                TextPropertyInspector.Dispose();
                TextPropertyInspector = null;
            }

            if (ToolArrow != null)
            {
                ToolArrow.Dispose();
                ToolArrow = null;
            }

            if (ToolBezier != null)
            {
                ToolBezier.Dispose();
                ToolBezier = null;
            }

            if (ToolCursor != null)
            {
                ToolCursor.Dispose();
                ToolCursor = null;
            }

            if (ToolLine != null)
            {
                ToolLine.Dispose();
                ToolLine = null;
            }

            if (ToolOval != null)
            {
                ToolOval.Dispose();
                ToolOval = null;
            }

            if (ToolPolygon != null)
            {
                ToolPolygon.Dispose();
                ToolPolygon = null;
            }

            if (ToolRect != null)
            {
                ToolRect.Dispose();
                ToolRect = null;
            }

            if (ToolRoundRect != null)
            {
                ToolRoundRect.Dispose();
                ToolRoundRect = null;
            }

            if (ToolStar != null)
            {
                ToolStar.Dispose();
                ToolStar = null;
            }

            if (ToolText != null)
            {
                ToolText.Dispose();
                ToolText = null;
            }

            if (ToolTriangle != null)
            {
                ToolTriangle.Dispose();
                ToolTriangle = null;
            }

            if (ToolVector != null)
            {
                ToolVector.Dispose();
                ToolVector = null;
            }
        }
Beispiel #13
0
 public void Dispose()
 {
     _sourceList.Dispose();
 }
 public void OnTestCompleted()
 {
     _cache.Dispose();
     _result.Dispose();
 }
Beispiel #15
0
 public void Dispose()
 {
     SourceList.Dispose();
     AudioList.Dispose();
 }
Beispiel #16
0
 public void CleanUp()
 {
     _binder.Dispose();
     _source.Dispose();
 }
 public void Dispose()
 {
     _favouriteQuotes?.Dispose();
 }
 public void Dispose()
 {
     _cache.Dispose();
     _result.Dispose();
 }
Beispiel #19
0
 public void Dispose()
 {
     _binder.Dispose();
     _source.Dispose();
 }
Beispiel #20
0
 public void Dispose()
 {
     _sourceListNotifications.Dispose();
     _observableListNotifications.Dispose();
     _source.Dispose();
 }