예제 #1
0
        private static object GetTypedValue(string typeString, string stringValue)
        {
            Type primitiveType = Type.GetType(typeString);

            if (primitiveType == typeof(bool) || primitiveType == typeof(bool[]))
            {
                return(ConversionUtilities.ConvertStringToBool(stringValue));
            }
            else if (primitiveType == typeof(string) || primitiveType == typeof(string[]))
            {
                return(stringValue);
            }
            else
            {
                return(Convert.ChangeType(stringValue, primitiveType, CultureInfo.InvariantCulture));
            }
        }
예제 #2
0
        private static object GetTypedArrayValue(string typeString, IEnumerable <string> stringValues)
        {
            Type primitiveType = Type.GetType(typeString);

            if (primitiveType == typeof(bool[]))
            {
                return(stringValues.Select(stringValue => ConversionUtilities.ConvertStringToBool(stringValue)).ToArray());
            }
            else if (primitiveType == typeof(string) || primitiveType == typeof(string[]))
            {
                return(stringValues.ToArray());
            }
            else
            {
                return(stringValues.Select(stringValue => Convert.ChangeType(stringValue, primitiveType, CultureInfo.InvariantCulture)).ToArray());
            }
        }
        public override bool Execute()
        {
            BootstrapperBuilder builder = new BootstrapperBuilder {
                Validate = this.Validate,
                Path     = this.Path
            };
            ProductCollection products = builder.Products;
            BuildSettings     settings = new BuildSettings {
                ApplicationFile = this.ApplicationFile,
                ApplicationName = this.ApplicationName,
                ApplicationRequiresElevation = this.ApplicationRequiresElevation,
                ApplicationUrl     = this.ApplicationUrl,
                ComponentsLocation = this.ConvertStringToComponentsLocation(this.ComponentsLocation),
                ComponentsUrl      = this.ComponentsUrl,
                CopyComponents     = this.CopyComponents,
                Culture            = this.culture,
                FallbackCulture    = this.fallbackCulture,
                OutputPath         = this.OutputPath,
                SupportUrl         = this.SupportUrl
            };

            if (this.BootstrapperItems != null)
            {
                Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase);
                foreach (ITaskItem item in this.BootstrapperItems)
                {
                    string metadata = item.GetMetadata("Install");
                    if (string.IsNullOrEmpty(metadata) || ConversionUtilities.ConvertStringToBool(metadata))
                    {
                        if (!hashtable.Contains(item.ItemSpec))
                        {
                            hashtable.Add(item.ItemSpec, item);
                        }
                        else
                        {
                            base.Log.LogWarningWithCodeFromResources("GenerateBootstrapper.DuplicateItems", new object[] { item.ItemSpec });
                        }
                    }
                }
                foreach (Product product in products)
                {
                    if (hashtable.Contains(product.ProductCode))
                    {
                        settings.ProductBuilders.Add(product.ProductBuilder);
                        hashtable.Remove(product.ProductCode);
                    }
                }
                foreach (ITaskItem item2 in hashtable.Values)
                {
                    base.Log.LogWarningWithCodeFromResources("GenerateBootstrapper.ProductNotFound", new object[] { item2.ItemSpec, builder.Path });
                }
            }
            BuildResults results = builder.Build(settings);

            BuildMessage[] messages = results.Messages;
            if (messages != null)
            {
                foreach (BuildMessage message in messages)
                {
                    if (message.Severity == BuildMessageSeverity.Error)
                    {
                        base.Log.LogError(null, message.HelpCode, message.HelpKeyword, null, 0, 0, 0, 0, message.Message, new object[0]);
                    }
                    else if (message.Severity == BuildMessageSeverity.Warning)
                    {
                        base.Log.LogWarning(null, message.HelpCode, message.HelpKeyword, null, 0, 0, 0, 0, message.Message, new object[0]);
                    }
                }
            }
            this.BootstrapperKeyFile        = results.KeyFile;
            this.BootstrapperComponentFiles = results.ComponentFiles;
            return(results.Succeeded);
        }
예제 #4
0
 /// <summary>
 /// Evaluate as boolean
 /// </summary>
 internal override bool BoolEvaluate(ConditionEvaluationState state)
 {
     return(ConversionUtilities.ConvertStringToBool(GetExpandedValue(state)));
 }
예제 #5
0
 static bool MSBuildStringIsTrue(string msbuildString) =>
 ConversionUtilities.ConvertStringToBool(msbuildString, nullOrWhitespaceIsFalse: true);