Пример #1
0
        internal void SaveBuildResultToFile(string preservationFile,
                                            BuildResult result, long hashCode)
        {
            _writer = new XmlTextWriter(preservationFile, Encoding.UTF8);

            try {
                _writer.Formatting  = Formatting.Indented;
                _writer.Indentation = 4;
                _writer.WriteStartDocument();

                // <preserve assem="assemblyFile">
                _writer.WriteStartElement("preserve");

                // Save the type of BuildResult we're dealing with
                Debug.Assert(result.GetCode() != BuildResultTypeCode.Invalid);
                SetAttribute("resultType", ((int)result.GetCode()).ToString(CultureInfo.InvariantCulture));

                // Save the virtual path for this BuildResult
                if (result.VirtualPath != null)
                {
                    SetAttribute("virtualPath", result.VirtualPath.VirtualPathString);
                }

                // Get the hash code of the BuildResult
                long hash = result.ComputeHashCode(hashCode);

                // The hash should always be valid if we got here.
                Debug.Assert(hash != 0, "hash != 0");

                // Save it to the preservation file
                SetAttribute("hash", hash.ToString("x", CultureInfo.InvariantCulture));

                // Can be null if that's what the VirtualPathProvider returns
                string fileHash = result.VirtualPathDependenciesHash;
                if (fileHash != null)
                {
                    SetAttribute("filehash", fileHash);
                }

                result.SetPreservedAttributes(this);

                SaveDependencies(result.VirtualPathDependencies);

                // </preserve>
                _writer.WriteEndElement();
                _writer.WriteEndDocument();

                _writer.Close();
            }
            catch {
                // If an exception occurs during the writing of the xml file, clean it up
                _writer.Close();
                File.Delete(preservationFile);

                throw;
            }
        }
    internal void SaveBuildResultToFile(string preservationFile,
        BuildResult result, long hashCode) {

        _writer = new XmlTextWriter(preservationFile, Encoding.UTF8);

        try {
            _writer.Formatting = Formatting.Indented;
            _writer.Indentation = 4;
            _writer.WriteStartDocument();

            // <preserve assem="assemblyFile">
            _writer.WriteStartElement("preserve");

            // Save the type of BuildResult we're dealing with
            Debug.Assert(result.GetCode() != BuildResultTypeCode.Invalid); 
            SetAttribute("resultType", ((int)result.GetCode()).ToString(CultureInfo.InvariantCulture));

            // Save the virtual path for this BuildResult
            if (result.VirtualPath != null)
                SetAttribute("virtualPath", result.VirtualPath.VirtualPathString);

            // Get the hash code of the BuildResult
            long hash = result.ComputeHashCode(hashCode);

            // The hash should always be valid if we got here.
            Debug.Assert(hash != 0, "hash != 0"); 

            // Save it to the preservation file
            SetAttribute("hash", hash.ToString("x", CultureInfo.InvariantCulture));

            // Can be null if that's what the VirtualPathProvider returns
            string fileHash = result.VirtualPathDependenciesHash;
            if (fileHash != null)
                SetAttribute("filehash", fileHash);

            result.SetPreservedAttributes(this);

            SaveDependencies(result.VirtualPathDependencies);

            // </preserve>
            _writer.WriteEndElement();
            _writer.WriteEndDocument();

            _writer.Close();
        }
        catch {

            // If an exception occurs during the writing of the xml file, clean it up
            _writer.Close();
            File.Delete(preservationFile);

            throw;
        }
    }
Пример #3
0
 internal void SaveBuildResultToFile(string preservationFile, BuildResult result, long hashCode)
 {
     this._writer = new XmlTextWriter(preservationFile, Encoding.UTF8);
     try
     {
         this._writer.Formatting = Formatting.Indented;
         this._writer.Indentation = 4;
         this._writer.WriteStartDocument();
         this._writer.WriteStartElement("preserve");
         this.SetAttribute("resultType", ((int) result.GetCode()).ToString(CultureInfo.InvariantCulture));
         if (result.VirtualPath != null)
         {
             this.SetAttribute("virtualPath", result.VirtualPath.VirtualPathString);
         }
         this.SetAttribute("hash", result.ComputeHashCode(hashCode).ToString("x", CultureInfo.InvariantCulture));
         string virtualPathDependenciesHash = result.VirtualPathDependenciesHash;
         if (virtualPathDependenciesHash != null)
         {
             this.SetAttribute("filehash", virtualPathDependenciesHash);
         }
         result.SetPreservedAttributes(this);
         this.SaveDependencies(result.VirtualPathDependencies);
         this._writer.WriteEndElement();
         this._writer.WriteEndDocument();
         this._writer.Close();
     }
     catch
     {
         this._writer.Close();
         File.Delete(preservationFile);
         throw;
     }
 }