Beispiel #1
0
        public IFormat Open(FileItem f)
        {
            // check extensions
            if (f.Extension != null)
            {
                if (ExtensionToType.ContainsKey(f.Extension))
                {
                    foreach (var type in ExtensionToType[f.Extension])
                    {
                        IFormat format = Activator.CreateInstance(type) as IFormat;
                        if (format.Verify(f) && format.CanOpen)
                        {
                            format.Open(f);
                            return(format);
                        }
                    }
                }
            }

            // check verify
            foreach (var type in AllTypes)
            {
                IFormat format = Activator.CreateInstance(type) as IFormat;

                if (format.Verify(f) && format.CanOpen)
                {
                    format.Open(f);
                    return(format);
                }
            }

            // not supported
            return(null);
        }