Exemplo n.º 1
0
        public FilePickerFilter([NotNull] FileExtensionPackage extensionPackage)
        {
            if (extensionPackage == null)
            {
                throw new ArgumentNullException(nameof(extensionPackage));
            }

            Filter = ConstructFilter(extensionPackage);
        }
Exemplo n.º 2
0
        private static string ConstructFilter(FileExtensionPackage extensionPackage)
        {
            IEnumerable <string> cache  = extensionPackage.Select(ae => "*" + ae.Extension);
            StringBuilder        filter =
                new StringBuilder(
                    $"{extensionPackage.PackageName} ({string.Join(",", cache)})|{string.Join(";", cache)}");

            foreach (var fileExtension in extensionPackage)
            {
                filter.Append("|");
                filter.Append($"{fileExtension.Name} (*{fileExtension.Extension})|*{fileExtension.Extension}");
            }
            return(filter.ToString());
        }