Example #1
0
        /// <summary>
        /// Creates a new instance of the <see cref="SummaryInfo"/> class copying values
        /// from the <see cref="Deployment.WindowsInstaller.SummaryInfo"/> object.
        /// </summary>
        /// <param name="info">The <see cref="Deployment.WindowsInstaller.SummaryInfo"/> from which to copy values.</param>
        /// <exception cref="ArgumentNullException">The parameter <paramref name="info"/> is null.</exception>
        internal SummaryInfo(Deployment.WindowsInstaller.SummaryInfo info)
        {
            if (null == info)
            {
                throw new ArgumentNullException("info");
            }

            this.Author         = info.Author;
            this.CharacterCount = info.CharacterCount;
            this.CodePage       = info.CodePage;
            this.Comments       = info.Comments;
            this.CreateTime     = info.CreateTime;
            this.CreatingApp    = info.CreatingApp;
            this.Keywords       = info.Keywords;
            this.LastPrintTime  = info.LastPrintTime;
            this.LastSavedBy    = info.LastSavedBy;
            this.LastSaveTime   = info.LastSaveTime;
            this.PageCount      = info.PageCount;
            this.RevisionNumber = info.RevisionNumber;
            this.Security       = info.Security;
            this.Subject        = info.Subject;
            this.Template       = info.Template;
            this.Title          = info.Title;
            this.WordCount      = info.WordCount;
        }
Example #2
0
        public void CopySummaryInfo()
        {
            var path = Path.Combine(this.TestContext.DeploymentDirectory, "Example.msi");

            using (var info = new Deployment.WindowsInstaller.SummaryInfo(path, false))
            {
                var copy = new SummaryInfo(info);

                // Verify that the declared properties are the same.
                var infoProperties = info.GetType().GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public).OrderBy(property => property.Name);
                var copyProperties = copy.GetType().GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public).OrderBy(property => property.Name);

                var infoPropertyNames = infoProperties.Select(property => property.Name).ToArray();
                var copyPropertyNames = infoProperties.Select(property => property.Name).ToArray();
                CollectionAssert.AreEqual(infoPropertyNames, copyPropertyNames, "The set of property names are not the same.");

                var infoPropertyTypes = infoProperties.Select(property => property.PropertyType).ToArray();
                var copyPropertyTypes = copyProperties.Select(property => property.PropertyType).ToArray();
                CollectionAssert.AreEqual(infoPropertyTypes, copyPropertyTypes, "The set of property types are not the same.");

                // Verify that the property values are the same.
                for (int i = 0; i < infoProperties.Count(); ++i)
                {
                    var infoProperty = infoProperties.ElementAt(i);
                    var copyProperty = copyProperties.ElementAt(i);

                    var infoPropertyValue = infoProperty.GetValue(info, null);
                    var copyPropertyValue = copyProperty.GetValue(copy, null);
                    Assert.AreEqual(infoPropertyValue, copyPropertyValue, @"The value for property ""{0}"" differs.", infoProperty.Name);
                }
            }
        }
Example #3
0
        public void CopySummaryInfo()
        {
            var path = Path.Combine(this.TestContext.DeploymentDirectory, "Example.msi");
            using (var info = new Deployment.WindowsInstaller.SummaryInfo(path, false))
            {
                var copy = new SummaryInfo(info);

                // Verify that the declared properties are the same.
                var infoProperties = info.GetType().GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public).OrderBy(property => property.Name);
                var copyProperties = copy.GetType().GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public).OrderBy(property => property.Name);

                var infoPropertyNames = infoProperties.Select(property => property.Name).ToArray();
                var copyPropertyNames = infoProperties.Select(property => property.Name).ToArray();
                CollectionAssert.AreEqual(infoPropertyNames, copyPropertyNames, "The set of property names are not the same.");

                var infoPropertyTypes = infoProperties.Select(property => property.PropertyType).ToArray();
                var copyPropertyTypes = copyProperties.Select(property => property.PropertyType).ToArray();
                CollectionAssert.AreEqual(infoPropertyTypes, copyPropertyTypes, "The set of property types are not the same.");

                // Verify that the property values are the same.
                for (int i = 0; i < infoProperties.Count(); ++i)
                {
                    var infoProperty = infoProperties.ElementAt(i);
                    var copyProperty = copyProperties.ElementAt(i);

                    var infoPropertyValue = infoProperty.GetValue(info, null);
                    var copyPropertyValue = copyProperty.GetValue(copy, null);
                    Assert.AreEqual(infoPropertyValue, copyPropertyValue, @"The value for property ""{0}"" differs.", infoProperty.Name);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Writes a <see cref="SummaryInfo"/> object for each supported file type to the pipeline.
        /// </summary>
        /// <param name="item">A <see cref="PSObject"/> representing the file system object to process.</param>
        protected override void ProcessItem(PSObject item)
        {
            var path         = item.GetPropertyValue <string>("PSPath");
            var providerPath = this.SessionState.Path.GetUnresolvedProviderPathFromPSPath(path);

            // Make sure the file exists and is a patch.
            var type = FileInfo.GetFileTypeInternal(providerPath);

            if (FileType.Package == type || FileType.Patch == type || FileType.Transform == type)
            {
                using (var info = new Deployment.WindowsInstaller.SummaryInfo(providerPath, false))
                {
                    var copy = new SummaryInfo(info);
                    var obj  = PSObject.AsPSObject(copy);

                    // Add the class type as the first type name.
                    var name = typeof(SummaryInfo).FullName + "#" + type;
                    obj.TypeNames.Insert(0, name);

                    // Attach the original PSPath and write to the pipeline.
                    obj.SetPropertyValue("PSPath", path);
                    this.WriteObject(obj);
                }
            }

            // Enumerate transforms in the patch.
            if (FileType.Patch == type && this.IncludeTransforms)
            {
                using (var patch = new PatchPackage(providerPath))
                {
                    foreach (var transform in patch.GetTransformsInfo(true))
                    {
                        var obj = PSObject.AsPSObject(transform);

                        // Attach the original patch path and write to the pipeline.
                        obj.SetPropertyValue("Patch", providerPath);
                        this.WriteObject(obj);
                    }
                }
            }
        }
Example #5
0
        /// <summary>
        /// Writes a <see cref="SummaryInfo"/> object for each supported file type to the pipeline.
        /// </summary>
        /// <param name="item">A <see cref="PSObject"/> representing the file system object to process.</param>
        protected override void ProcessItem(PSObject item)
        {
            var path = item.GetPropertyValue<string>("PSPath");
            var providerPath = this.SessionState.Path.GetUnresolvedProviderPathFromPSPath(path);

            // Make sure the file exists and is a patch.
            var type = FileInfo.GetFileTypeInternal(providerPath);
            if (FileType.Package == type || FileType.Patch == type || FileType.Transform == type)
            {
                using (var info = new Deployment.WindowsInstaller.SummaryInfo(providerPath, false))
                {
                    var copy = new SummaryInfo(info);
                    var obj = PSObject.AsPSObject(copy);

                    // Add the class type as the first type name.
                    var name = typeof(SummaryInfo).FullName + "#" + type;
                    obj.TypeNames.Insert(0, name);

                    // Attach the original PSPath and write to the pipeline.
                    obj.SetPropertyValue("PSPath", path);
                    this.WriteObject(obj);
                }
            }

            // Enumerate transforms in the patch.
            if (FileType.Patch == type && this.IncludeTransforms)
            {
                using (var patch = new PatchPackage(providerPath))
                {
                    foreach (var transform in patch.GetTransformsInfo(true))
                    {
                        var obj = PSObject.AsPSObject(transform);

                        // Attach the original patch path and write to the pipeline.
                        obj.SetPropertyValue("Patch", providerPath);
                        this.WriteObject(obj);
                    }
                }
            }
        }
Example #6
0
 public void SummaryInfoThrows()
 {
     // Casting alone should throw.
     Deployment.WindowsInstaller.SummaryInfo info = null;
     var copy = new SummaryInfo(info);
 }