Beispiel #1
0
        public static FileAssociations GetAssociations()
        {
            FileAssociations assocs = new FileAssociations();

            ///////////////////////////////////////

            String[] subkeyNames = Registry.ClassesRoot.GetSubKeyNames();

            List <FileExtension> allExtensions = new List <FileExtension>();
            Dictionary <String, List <FileExtension> > progIds = new Dictionary <String, List <FileExtension> >();

            foreach (String keyName in subkeyNames)
            {
                if (!keyName.StartsWith(".", StringComparison.Ordinal))
                {
                    continue;
                }

                RegistryKey key = Registry.ClassesRoot.OpenSubKey(keyName);

                FileExtension ext = new FileExtension(assocs, key);

                allExtensions.Add(ext);

                if (ext.ProgId != null)
                {
                    if (!progIds.ContainsKey(ext.ProgId))
                    {
                        progIds.Add(ext.ProgId, new List <FileExtension>());
                    }

                    progIds[ext.ProgId].Add(ext);
                }
            }

            ///////////////////////////////////////

            List <FileType> allTypes = new List <FileType>();

            foreach (String keyName in progIds.Keys)
            {
                RegistryKey key = Registry.ClassesRoot.OpenSubKey(keyName);
                if (key == null)
                {
                    continue;                             // then the extension uses its progid as its display name and that's it
                }
                FileType type = new FileType(assocs, key);

                type.Extensions.AddRange2(progIds[keyName]);
                foreach (FileExtension ext in type.Extensions)
                {
                    ext.FileType = type;
                }

                allTypes.Add(type);
            }

            assocs._allExts  = allExtensions;
            assocs._allTypes = allTypes;

            assocs.AllExtensions = new ReadOnlyCollection <FileExtension>(assocs._allExts);
            assocs.AllTypes      = new ReadOnlyCollection <FileType>     (assocs._allTypes);

//			Array.Sort( assocs.AllExtensions );
//			Array.Sort( assocs.AllTypes );

            return(assocs);
        }
Beispiel #2
0
 internal FileExtension(FileAssociations assocs, RegistryKey key) : this(assocs) {
     LoadFromKey(key);
 }
Beispiel #3
0
        internal FileExtension(FileAssociations assocs, String extension) : this(assocs) {
            Extension = extension;

            IsDirty = true;
        }
Beispiel #4
0
 private FileExtension(FileAssociations assocs) : base(assocs)
 {
     OpenWithList    = new Collection <String>();
     OpenWithProgIds = new Collection <FileType>();
 }
Beispiel #5
0
        internal FileType(FileAssociations assocs, String progId) : this(assocs) {
            ProgId = progId;

            IsDirty = true;
        }
Beispiel #6
0
 internal FileType(FileAssociations assocs, RegistryKey typeKey) : this(assocs) {
     LoadFromKey(typeKey);
 }
Beispiel #7
0
 private FileType(FileAssociations assocs) : base(assocs)
 {
     Extensions = new Collection <FileExtension>();
     ShellVerbs = new Dictionary <String, String>();
 }
Beispiel #8
0
 protected FileBase(FileAssociations assocs)
 {
     ParentAssocs = assocs;
 }