/// <summary> /// Initializes a new instance of the <see cref="Project"/> class. /// </summary> /// <param name="name">The name of the project. Typically it is the name of the product to be installed.</param> /// <param name="items">The project installable items (e.g. directories, files, registry keys, Custom Actions).</param> public Project(string name, params WixObject[] items) { if (!Compiler.AutoGeneration.LegacyDefaultIdAlgorithm) { this.CustomIdAlgorithm = this.HashedTargetPathIdAlgorithm; } Name = name; OutFileName = name; var dirs = new List <Dir>(); var actions = new List <Action>(); var regs = new List <RegValue>(); var props = new List <Property>(); var bins = new List <Binary>(); var genericItems = new List <IGenericEntity>(); var urlreservation = new List <UrlReservation>(); if (items.OfType <Media>().Any()) { this.Media.Clear(); } foreach (WixObject obj in items) { var rawItems = new List <WixObject>(); if (obj is WixItems) { rawItems.AddRange((obj as WixItems).Items); } else { rawItems.Add(obj); } foreach (WixObject item in rawItems) { if (item is LaunchCondition) { LaunchConditions.Add(item as LaunchCondition); } else if (item is Dir) { dirs.Add(item as Dir); } else if (item is Action) { actions.Add(item as Action); } else if (item is RegValue) { regs.Add(item as RegValue); } else if (item is UrlReservation) { urlreservation.Add(item as UrlReservation); } else if (item is RegFile) { var file = item as RegFile; var values = Tasks.ImportRegFile(file.Path); if (file.Feature != null) { values.ForEach(x => { x.Feature = file.Feature; x.Features = file.Features; }); } regs.AddRange(values); } else if (item is Property || item is PropertyRef) { props.Add(item as Property); } else if (item is Binary) { bins.Add(item as Binary); } else if (item is WixGuid) { GUID = (item as WixGuid).Value; } else if (item is Media) { Media.Add(item as Media); } else if (item is IGenericEntity) { genericItems.Add(item as IGenericEntity); } else { throw new Exception("Unexpected object type is among Project constructor arguments: " + item.GetType().Name); } } } Dirs = dirs.ToArray(); Actions = actions.ToArray(); RegValues = regs.ToArray(); Properties = props.ToArray(); Binaries = bins.ToArray(); UrlReservations = urlreservation.ToArray(); GenericItems = genericItems.ToArray(); }
/// <summary> /// Initializes a new instance of the <see cref="Project"/> class. /// </summary> /// <param name="name">The name of the project. Typically it is the name of the product to be installed.</param> /// <param name="items">The project installable items (e.g. directories, files, registry keys, Custom Actions).</param> public Project(string name, params WixObject[] items) { Name = name; OutFileName = name; var dirs = new List <Dir>(); var actions = new List <Action>(); var regs = new List <RegValue>(); var envvars = new List <EnvironmentVariable>(); var props = new List <Property>(); var bins = new List <Binary>(); var users = new List <User>(); var sqls = new List <SqlDatabase>(); var certs = new List <Certificate>(); var genericItems = new List <IGenericEntity>(); var fwexceptions = new List <FirewallException>(); if (items.OfType <Media>().Any()) { this.Media.Clear(); } foreach (WixObject obj in items) { var rawItems = new List <WixObject>(); if (obj is WixItems) { rawItems.AddRange((obj as WixItems).Items); } else { rawItems.Add(obj); } foreach (WixObject item in rawItems) { if (item is LaunchCondition) { LaunchConditions.Add(item as LaunchCondition); } else if (item is Dir) { dirs.Add(item as Dir); } else if (item is Action) { actions.Add(item as Action); } else if (item is RegValue) { regs.Add(item as RegValue); } else if (item is EnvironmentVariable) { envvars.Add(item as EnvironmentVariable); } else if (item is FirewallException) { fwexceptions.Add(item as FirewallException); } else if (item is RegFile) { var file = item as RegFile; var values = Tasks.ImportRegFile(file.Path); if (file.Feature != null) { values.ForEach(x => x.Feature = file.Feature); } regs.AddRange(values); } else if (item is Property || item is PropertyRef) { props.Add(item as Property); } else if (item is Binary) { bins.Add(item as Binary); } else if (item is WixGuid) { GUID = (item as WixGuid).Value; } else if (item is Media) { Media.Add(item as Media); } else if (item is User) { users.Add(item as User); } else if (item is SqlDatabase) { sqls.Add(item as SqlDatabase); } else if (item is Certificate) { certs.Add(item as Certificate); } else if (item is IGenericEntity) { genericItems.Add(item as IGenericEntity); } else { throw new Exception("Unexpected object type is among Project constructor arguments: " + item.GetType().Name); } } } Dirs = dirs.ToArray(); Actions = actions.ToArray(); RegValues = regs.ToArray(); Properties = props.ToArray(); Binaries = bins.ToArray(); EnvironmentVariables = envvars.ToArray(); Users = users.ToArray(); SqlDatabases = sqls.ToArray(); Certificates = certs.ToArray(); FirewallExceptions = fwexceptions.ToArray(); GenericItems = genericItems.ToArray(); }