コード例 #1
0
        public void Save(string path, IProgress <Tuple <string, int> > progress)
        {
            if (progress == null)
            {
                throw new ArgumentNullException("progress");
            }

            XmlWriterSettings settings = new XmlWriterSettings();

            using (XmlTextWriter writer = new XmlTextWriter(path, Encoding.UTF8))
            {
                const int total_count = 10;

                writer.Formatting  = Formatting.Indented;
                writer.Indentation = 4;
                writer.WriteStartElement("comregistry");
                writer.WriteOptionalAttributeString("created", CreatedDate);
                writer.WriteOptionalAttributeString("machine", CreatedMachine);
                writer.WriteBool("sixfour", SixtyFourBit);
                writer.WriteEnum("mode", LoadingMode);
                writer.WriteOptionalAttributeString("user", CreatedUser);
                writer.WriteOptionalAttributeString("access", DefaultAccessPermission);
                writer.WriteOptionalAttributeString("accessr", DefaultAccessRestriction);
                writer.WriteOptionalAttributeString("launch", DefaultLaunchPermission);
                writer.WriteOptionalAttributeString("launchr", DefaultLaunchRestriction);
                Report(progress, "CLSIDs", 1, total_count);
                writer.WriteSerializableObjects("clsids", m_clsids.Values);
                Report(progress, "ProgIDs", 2, total_count);
                writer.WriteSerializableObjects("progids", m_progids.Values);
                Report(progress, "MIME Types", 3, total_count);
                writer.WriteSerializableObjects("mimetypes", m_mimetypes);
                Report(progress, "AppIDs", 4, total_count);
                writer.WriteSerializableObjects("appids", m_appid.Values);
                Report(progress, "Interfaces", 5, total_count);
                writer.WriteSerializableObjects("intfs", m_interfaces.Values);
                Report(progress, "Categories", 6, total_count);
                writer.WriteSerializableObjects("catids", m_categories.Values);
                Report(progress, "LowRights", 7, total_count);
                writer.WriteSerializableObjects("lowies", m_lowrights);
                Report(progress, "TypeLibs", 8, total_count);
                writer.WriteSerializableObjects("typelibs", m_typelibs.Values);
                Report(progress, "PreApproved", 9, total_count);
                writer.WriteStartElement("preapp");
                writer.WriteGuids("clsids", m_preapproved);
                writer.WriteEndElement();
                Report(progress, "Runtime Classes", 10, total_count);
                writer.WriteSerializableObjects("runtime", m_runtime_classes.Values);
                writer.WriteSerializableObjects("rtservers", m_runtime_servers.Values);
                writer.WriteSerializableObjects("rtexts", m_runtime_extensions);
                writer.WriteEndElement();
            }
            FilePath = path;
        }