示例#1
0
        public void StartScanAndUpdateDB(IList <LibraryItemEntity> list, Action callback)
        {
            Func <IDictionary <LibraryItemEntity, IList <DirectoryInfo> > > function = () =>
            {
                var removeList = LibraryItems.Where(item => list.FirstOrDefault(i => 0 == string.Compare(i.Path, item.Path, true)).IsNull());
                var addList    = list.Where(item => !LibraryItems.Any(i => 0 == string.Compare(i.Path, item.Path, true)));
                DeleteLibraryItems(removeList.ToList());


                AddLibraryItems(addList.ToList());
                HistoryScanner scanner = new HistoryScanner(addList.ToList());
                scanner.StartScan();
                WriteToDBByScannedResult(scanner.Results);

                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                {
                    RefreshDBData();
                    if (!callback.IsNull())
                    {
                        callback();
                    }
                }));

                return(scanner.Results);
            };

            function.BeginInvoke(ar =>
            {
                IEnumerable <DirectoryInfo> results = ThreadHelper.EndInvokeFunc <IEnumerable <DirectoryInfo> >(ar);
            }, function);
        }
示例#2
0
 public void PocoTypeCheckedChange(LibraryItemViewModel pocoTypeInfo, bool isChecked)
 {
     LibraryItems.Where(t => t.PocoProperty != null && t.PocoProperty.ReflectedType == pocoTypeInfo.PocoType).ToList()
     .ForEach(t => t.GenerateThis = pocoTypeInfo.GenerateThis);
 }
        public void GenerateWPF()
        {
            IEnumerable <IGrouping <Type, LibraryItemViewModel> > groupedPropsByType = LibraryItems.Where(item => item.PocoProperty != null && item.GenerateThis).GroupBy(item => item.PocoProperty.DeclaringType);

            SelectedGenerator.Init(base.TargetAssemblyInfo);
            SelectedGenerator.GenerateGUIProject(OutputFolder, groupedPropsByType.Select(g => g.Key).ToList(), OutputNamespace, 4);

            Process.Start(OutputFolder);
        }