Ejemplo n.º 1
0
        /// <summary>
        /// Analyzes the transforms included in the patch package to find the ones that
        /// are applicable to an install package.
        /// </summary>
        /// <param name="installPackage">The install package to validate the transforms against</param>
        /// <returns>Array of valid transform names</returns>
        /// <remarks>
        /// The returned list does not include the &quot;patch special transforms&quot; that
        /// are prefixed with &quot;#&quot; If a transform is valid, then its corresponding
        /// special transform is assumed to be valid as well.
        /// </remarks>
        public string[] GetValidTransforms(InstallPackage installPackage)
        {
            ArrayList transformArray = new ArrayList();
            string    transformList  = this.SummaryInfo.LastSavedBy;

            foreach (string transform in transformList.Split(';', ':'))
            {
                if (transform.Length != 0 && !transform.StartsWith("#", StringComparison.Ordinal))
                {
                    this.LogMessage("Checking validity of transform {0}", transform);
                    string tempTransformFile = null;
                    try
                    {
                        tempTransformFile = Path.GetTempFileName();
                        this.ExtractTransform(transform, tempTransformFile);
                        if (installPackage.IsTransformValid(tempTransformFile))
                        {
                            this.LogMessage("Found valid transform: {0}", transform);
                            transformArray.Add(transform);
                        }
                    }
                    finally
                    {
                        if (tempTransformFile != null && File.Exists(tempTransformFile))
                        {
                            try { File.Delete(tempTransformFile); }
                            catch (IOException) { }
                        }
                    }
                }
            }
            return((string[])transformArray.ToArray(typeof(string)));
        }