コード例 #1
0
        private void FindAllReferencesExecute(object obj)
        {
            var cls = ClassesCollectionView.CurrentItem as NdfClassViewModel;

            if (cls == null)
            {
                return;
            }

            var inst = cls.InstancesCollectionView.CurrentItem as NdfObjectViewModel;

            if (inst == null)
            {
                return;
            }

            var result = new List <NdfPropertyValue>();

            Dispatcher      dispatcher = Dispatcher.CurrentDispatcher;
            Action <string> report     = msg => StatusText = msg;

            var s = new Task(() =>
            {
                try
                {
                    //dispatcher.Invoke(() => IsUIBusy = true);
                    dispatcher.Invoke(report, string.Format("Searching for references..."));

                    foreach (var instance in NdfBinary.Instances)
                    {
                        foreach (var propertyValue in instance.PropertyValues)
                        {
                            GetValue(propertyValue, inst, result, propertyValue);
                        }
                    }

                    var resultVm = new ReferenceSearchResultViewModel(result, this);

                    dispatcher.Invoke(() => DialogProvider.ProvideView(resultVm, this));
                    dispatcher.Invoke(report, string.Format("{0} references found", result.Count));
                }
                catch (Exception ex)
                {
                    Trace.TraceError(string.Format("Error while saving Ndfbin file: {0}", ex));
                    dispatcher.Invoke(report, "Error while searching");
                }
            });

            s.Start();
        }
コード例 #2
0
        private void FindAllReferencesExecute(object obj)
        {
            var cls = ClassesCollectionView.CurrentItem as NdfClassViewModel;

            if (cls == null)
                return;

            var inst = cls.InstancesCollectionView.CurrentItem as NdfObjectViewModel;

            if (inst == null)
                return;

            var result = new List<NdfPropertyValue>();

            Dispatcher dispatcher = Dispatcher.CurrentDispatcher;
            Action<string> report = msg => StatusText = msg;

            var s = new Task(() =>
            {
                try
                {
                    //dispatcher.Invoke(() => IsUIBusy = true);
                    dispatcher.Invoke(report, string.Format("Searching for references..."));

                    foreach (var instance in NdfBinary.Instances)
                        foreach (var propertyValue in instance.PropertyValues)
                            GetValue(propertyValue, inst, result, propertyValue);

                    var resultVm = new ReferenceSearchResultViewModel(result, this);

                    dispatcher.Invoke(() => DialogProvider.ProvideView(resultVm, this));
                    dispatcher.Invoke(report, string.Format("{0} references found", result.Count));
                }
                catch (Exception ex)
                {
                    Trace.TraceError(string.Format("Error while saving Ndfbin file: {0}", ex));
                    dispatcher.Invoke(report, "Error while searching");
                }
            });

            s.Start();
        }