AvalonPatch.AvalonPatch.readPatchControl C# (CSharp) Method

readPatchControl() public method

public readPatchControl ( ) : void
return void
        void readPatchControl()
        {
            // Extract the control file
            FileInfo outFile = new FileInfo(Path.Combine(tempExtractPath, "PatchControl.xml"));
            FileStream streamOutFile = outFile.OpenWrite();
            extractFile(GetEmbeddedFile("AvalonPatch", "EmbeddedPatches.PatchControl.xml"), streamOutFile);

            // Read the file
            string elementName = "";
            reader = new XmlTextReader(Path.Combine(tempExtractPath, "PatchControl.xml"));
            reader.MoveToContent();
            if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "patches"))
            {
                while (reader.Read())
                {
                    // Get the minium skin version required
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "minskinversion")
                    {
                        reader.Read();
                        minSMPVersion = new Version(reader.Value);

                    }
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "patch")
                    {
                        patchFile thisPatch = new patchFile();
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Element)
                                elementName = reader.Name;
                            else
                            {
                                if ((reader.NodeType == XmlNodeType.Text) && (reader.HasValue))
                                {
                                    switch (elementName)
                                    {
                                        case "name":
                                            thisPatch.patchFileName = reader.Value;
                                            break;
                                        case "action":
                                            thisPatch.patchAction = reader.Value;
                                            break;
                                        case "location":
                                            thisPatch.patchLocation = reader.Value;
                                            break;
                                        case "version":
                                            thisPatch.patchVersion = reader.Value;
                                            break;
                                    }
                                }
                            }
                            if (reader.NodeType == XmlNodeType.EndElement)
                            {
                                if (reader.Name == "patch")
                                {
                                    handlePatch(thisPatch.patchFileName, thisPatch);
                                    break;
                                }
                            }
                        }
                    }
                }
                reader.Close();
            }
        }