Example #1
0
        /// <summary>
        /// Adds itself as an XML content into the WiX source being generated from the <see cref="WixSharp.Project"/>.
        /// See 'Wix#/samples/Extensions' sample for the details on how to implement this interface correctly.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Process(ProcessingContext context)
        {
            context.Project.IncludeWixExtension(WixExtension.Fire);

            var firewallElement = this.ToXElement(WixExtension.Fire, "FirewallException");

            RemoteAddress.ForEach(address =>
            {
                firewallElement.Add(WixExtension.Fire.XElement("RemoteAddress", (object)address.Trim()));
            });

            var findComponent = context.XParent.FindFirst("Component");

            if (findComponent != null)
            {
                XElement newComponent = this.CreateParentComponent();
                newComponent.Add(firewallElement);
                findComponent.Parent?.Add(newComponent);

                if (ActualFeatures.Any())
                {
                    context.FeatureComponents.Map(ActualFeatures, Id);
                }
                else if (context.FeatureComponents.ContainsKey(context.Project.DefaultFeature))
                {
                    context.FeatureComponents[context.Project.DefaultFeature].Add(Id);
                }
                else
                {
                    context.FeatureComponents[context.Project.DefaultFeature] = new List <string> {
                        Id
                    }
                };
            }
            else
            {
                context.XParent.Add(firewallElement);
            }
        }
Example #2
0
        /// <summary>
        /// Adds itself as an XML content into the WiX source being generated from the <see cref="WixSharp.Project"/>.
        /// See 'Wix#/samples/Extensions' sample for the details on how to implement this interface correctly.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Process(ProcessingContext context)
        {
            XElement component = this.CreateParentComponent();

            component.Add(this.ToXElement("RemoveRegistryKey"));
            context.XParent.FindFirst("Component").Parent?.Add(component);

            if (ActualFeatures.Any())
            {
                context.FeatureComponents.Map(ActualFeatures, Id);
            }
            else if (context.FeatureComponents.ContainsKey(context.Project.DefaultFeature))
            {
                context.FeatureComponents[context.Project.DefaultFeature].Add(Id);
            }
            else
            {
                context.FeatureComponents[context.Project.DefaultFeature] = new List <string> {
                    Id
                }
            };
        }
    }