Beispiel #1
0
        public void Completed <TConverted>(Action <TConverted> action)
        {
            if (setProperty == null)
            {
                LoadData();
            }

            Action <TProperty> convertAndExectueCompleted =
                item =>
            {
                var converted = default(TConverted);

                // ReSharper disable once AccessToStaticMemberViaDerivedType
                // ReSharper disable once RedundantNameQualifier
                if (!Comparer.Equals(item, default(T)))
                {
                    converted = Mapper.Map <TConverted>(item);
                }

                action(converted);
            };

            if (task == null)
            {
                convertAndExectueCompleted(value);
                return;
            }

            task.ContinueWith(t => convertAndExectueCompleted(t.Result), WindowsThreadingFactory.FromCurrentSynchronizationContext());
        }
Beispiel #2
0
        public void Completed(Action <IObservableCollection <TCollectionType> > action)
        {
            if (task == null)
            {
                action(collection);
                return;
            }

            task.ContinueWith(t => action(collection), WindowsThreadingFactory.FromCurrentSynchronizationContext());
        }
Beispiel #3
0
        public void UpdateCollection(IObservableCollection <TParameter> collection)
        {
            if (task == null)
            {
                collection.ReplaceOrAdd(value);
                return;
            }

            task.ContinueWith(t => collection.ReplaceOrAdd(t.Result), WindowsThreadingFactory.FromCurrentSynchronizationContext());
        }
Beispiel #4
0
        public void Completed(Action <IObservableCollection <TCollectionType> > completed)
        {
            if (!loaderParams.UseTaskFactory)
            {
                completed(LoadCollection());
                return;
            }

            Task.Factory.StartNew(() => LoadCollection())
            .ContinueWith(t => completed(t.Result), WindowsThreadingFactory.FromCurrentSynchronizationContext());
        }
Beispiel #5
0
        public void Completed(Action <TProperty> action)
        {
            if (setProperty == null)
            {
                LoadData();
            }

            if (!loaderParams.UseTaskFactory)
            {
                action(value);
                return;
            }

            task.ContinueWith(t => action(t.Result), WindowsThreadingFactory.FromCurrentSynchronizationContext());
        }
Beispiel #6
0
        public void Completed <TConverted>(Action <IObservableCollection <TConverted> > completed)
        {
            if (!loaderParams.UseTaskFactory)
            {
                var collection = LoadCollection();

                var converted = ConvertCollection <TConverted>(collection);

                completed(converted);

                return;
            }

            Task.Factory.StartNew(() => ConvertCollection <TConverted>(LoadCollection()))
            .ContinueWith(t => completed(t.Result), WindowsThreadingFactory.FromCurrentSynchronizationContext());
        }
Beispiel #7
0
        public void Completed <TConverted>(Action <IObservableCollection <TConverted> > action)
        {
            var convertedCollection = (IObservableCollection <TConverted>)null;

            if (collection != null)
            {
                convertedCollection = CollectionFactory.Create(collection.Select(x => Mapper.Map <TConverted>(x)));
            }

            if (task == null)
            {
                action(convertedCollection);
                return;
            }

            task.ContinueWith(t => action(convertedCollection), WindowsThreadingFactory.FromCurrentSynchronizationContext());
        }
        public void TestInitialize()
        {
            WindowsThreadingFactory.SetCurrentThreadScheduler();

            Mapper.Set(() => new AutoMapperMapper());
        }
Beispiel #9
0
 private static void RegisterMultiThreadConfiguration(bool multiThread)
 {
     WindowsThreadingFactory.SetMode(multiThread);
 }