Exemple #1
0
        public DefaultDocumentList[] Find()
        {
            var lists = new List <DefaultDocumentList>();

            var finder = new ReferenceFileFinder(cancellationToken);

            finder.Find();

            var xmlFiles = new List <Tuple <DefaultDocumentList, bool> >();

            foreach (var dir in FilesDirs)
            {
                cancellationToken.ThrowIfCancellationRequested();
                if (!Directory.Exists(dir))
                {
                    continue;
                }

                var files = GetFiles(dir);
                foreach (var f in files)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    var d = ReadDefaultFileList(f);
                    if (d != null)
                    {
                        xmlFiles.Add(d);
                    }
                }
            }

            var dict = new Dictionary <string, DefaultDocumentList>(StringComparer.OrdinalIgnoreCase);

            foreach (var t in xmlFiles)
            {
                if (t.Item2)                    // if non-user file
                {
                    dict[t.Item1.Name] = t.Item1;
                }
            }

            foreach (var f in finder.AllFiles)
            {
                dict[f.Name] = f;
            }

            foreach (var t in xmlFiles)
            {
                if (!t.Item2)                   // if user file
                {
                    dict[t.Item1.Name] = t.Item1;
                }
            }

            lists.AddRange(dict.Values);
            lists.Sort((a, b) => StringComparer.OrdinalIgnoreCase.Compare(a.Name, b.Name));
            return(lists.ToArray());
        }
		public DefaultDocumentList[] Find() {
			var lists = new List<DefaultDocumentList>();

			var finder = new ReferenceFileFinder(cancellationToken);
			finder.Find();

			var xmlFiles = new List<Tuple<DefaultDocumentList, bool>>();
			foreach (var dir in FilesDirs) {
				cancellationToken.ThrowIfCancellationRequested();
				if (!Directory.Exists(dir))
					continue;

				var files = GetFiles(dir);
				foreach (var f in files) {
					cancellationToken.ThrowIfCancellationRequested();
					var d = ReadDefaultFileList(f);
					if (d != null)
						xmlFiles.Add(d);
				}
			}

			var dict = new Dictionary<string, DefaultDocumentList>(StringComparer.OrdinalIgnoreCase);

			foreach (var t in xmlFiles) {
				if (t.Item2)	// if non-user file
					dict[t.Item1.Name] = t.Item1;
			}

			foreach (var f in finder.AllFiles)
				dict[f.Name] = f;

			foreach (var t in xmlFiles) {
				if (!t.Item2)	// if user file
					dict[t.Item1.Name] = t.Item1;
			}

			lists.AddRange(dict.Values);
			lists.Sort((a, b) => StringComparer.OrdinalIgnoreCase.Compare(a.Name, b.Name));
			return lists.ToArray();
		}