DeploymentStager.DependencyResource.Stage C# (CSharp) Method

Stage() public method

public Stage ( DeploymentStager stager, System.Xml.Linq.XElement xmlElement ) : void
stager DeploymentStager
xmlElement System.Xml.Linq.XElement
return void
        public void Stage(DeploymentStager stager, XElement xmlElement)
        {
            FileInfo file = new FileInfo(path);

            // Get the pre-compress data.
            hash = FileVerification.GetSHA1Hash(path);
            size = file.Length;

            // Compress.
            if (!Directory.Exists("staging")) Directory.CreateDirectory("staging");
            string compressPath = "staging\\" + file.Name + ".lzma";
            SevenzipCompresser compresser = new SevenzipCompresser(path);
            int ExitCode = compresser.compress(compressPath);

            // Get the data for the compressed file.
            FileInfo archive = new FileInfo(compressPath);
            downloadHash = FileVerification.GetSHA1Hash(compressPath);
            downloadSize = archive.Length;

            // Update the XML.
            xmlElement.SetAttributeValue("hash", hash);
            xmlElement.SetAttributeValue("downloadHash", downloadHash);
            xmlElement.SetAttributeValue("size", size);
            xmlElement.SetAttributeValue("downloadSize", downloadSize);
        }

Usage Example

        public void Run()
        {
            // Load the imput file.
            XDocument       InputDoc  = XDocument.Load(InputFilename);
            XDocument       PatchDoc  = XDocument.Load(PatchFilename);
            List <XElement> resources = PatchDoc.Root.Element("files").Elements().ToList();

            for (int i = 0; i < resources.Count; i++)
            {
                string             filepath = "";
                DependencyResource resource = new DependencyResource(resources[i], filepath);

                // Find the record in the patch.
                XElement        patchElement = null;
                List <XElement> patchFiles   = PatchDoc.Root.Element("files").Elements().ToList();
                for (int j = 0; j < patchFiles.Count; j++)
                {
                    if (patchFiles[j].Name.ToString().Equals(resource.name))
                    {
                        patchElement = patchFiles[i];
                        break;
                    }
                }

                // Stage the differences.
                resource.Stage(this, patchElement);
            }

            // Save the patch.
            PatchDoc.Save(PatchFilename);
        }
All Usage Examples Of DeploymentStager.DependencyResource::Stage
DependencyResource