Beispiel #1
0
        /// <summary>
        /// This method will assume you have used the CompilerCommandAttribute and build the command line
        /// </summary>
        /// <param name="aCommandLineBuilder"></param>
        protected virtual void AddCommandLines(CommandLineBuilder aCommandLineBuilder)
        {
            // get the type for this object
            Type lMyType = this.GetType();

            // get all properties of this object
            PropertyInfo[] lPropertyInfos = lMyType.GetProperties();
            // check each property for the CompilerCommandAttribute
            foreach (PropertyInfo lPropertyInfo in lPropertyInfos)
            {
                if (!lPropertyInfo.CanRead)
                {
                    continue;
                }

                object[] lObjects = lPropertyInfo.GetCustomAttributes(typeof(CompilerCommandAttribute), true);
                if (lObjects != null && lObjects.Length > 0)
                {
                    // if there is a compiler command we will add a switch if need
                    CompilerCommandAttribute lCommand = (CompilerCommandAttribute)lObjects[0];
                    // we need to get the property value of the switch
                    object lValue = lPropertyInfo.GetGetMethod().Invoke(this, null);
                    AddCommand(aCommandLineBuilder, lCommand, lValue);
                }
            }
        }
Beispiel #2
0
        protected virtual void AddCommand(CommandLineBuilder aCommandLineBuilder, CompilerCommandAttribute aCommand, object aValue)
        {
            // if we are not appending values to the switch then we
            // will simply add the switch
            if (!aCommand.AppendValue)
            {
                string lSwitch = aCommand.Switch;

                // get boolean switch value
                BoolCompilerCommandAttribute lBoolCommand = aCommand as BoolCompilerCommandAttribute;
                if (lBoolCommand != null)
                {
                    bool lOption = (bool)aValue;
                    if (!lOption)
                    {
                        lSwitch = lBoolCommand.DisabledSwitch;
                    }
                    // switch is not used in for some compilers
                    if (!UseDefautSwitches && (lOption == (lBoolCommand.SwitchDefault == BoolSwitchDefault.Enabled)))
                    {
                        lSwitch = null;
                    }
                }

                // Add the switch if one exists and is not default when defaults should not be dislpayed
                if (!String.IsNullOrEmpty(lSwitch))
                {
                    aCommandLineBuilder.AppendSwitch(lSwitch);
                }
            }
            else
            {
                // This will append the value of the property to the switch
                if (aValue is ITaskItem[])
                {
                    ITaskItem[] lTaskItems = aValue as ITaskItem[];
                    AppendTaskItemsToSwitch(aCommandLineBuilder, lTaskItems, aCommand);
                }
                else
                {
                    AppendValueToSwitch(aCommandLineBuilder, aValue, aCommand);
                }
            }
        }
Beispiel #3
0
        protected override void AddCommand(CommandLineBuilder aCommandLineBuilder, CompilerCommandAttribute aCommand, object aValue)
        {
            // keep a copy of the current command line
            string lBefore = aCommandLineBuilder.ToString();

            base.AddCommand(aCommandLineBuilder, aCommand, aValue);
            // after adding the command we need t get the appended value out
            // and place it on a line if one exists.
            string lAfter = aCommandLineBuilder.ToString();

            if (lBefore != lAfter)
            {
                lAfter = lAfter.Substring(lBefore.Length, lAfter.Length - lBefore.Length).TrimStart();
                if (lAfter != "")
                {
                    FConfigFileLines.AppendLine(lAfter);
                }
            }
        }
Beispiel #4
0
 private void AppendTaskItemsToSwitch(CommandLineBuilder aCommandLineBuilder, ITaskItem[] aTaskItems, CompilerCommandAttribute aCommand)
 {
     if (aCommand.QuotedValue)
     {
         if (!aCommand.UseSingleItem)
         {
             if (String.IsNullOrEmpty(aCommand.Switch))
             {
                 aCommandLineBuilder.AppendFileNamesIfNotNull(aTaskItems, aCommand.Delimiter);
             }
             else // delphi 7 does not support -Switch"Path Name";"Path Name" so use GetItems method instead
             {
                 aCommandLineBuilder.AppendSwitchIfNotNull(aCommand.Switch, GetItems(aTaskItems, aCommand.Delimiter));
             }
         }
         else
         {
             if (String.IsNullOrEmpty(aCommand.Switch))
             {
                 aCommandLineBuilder.AppendFileNameIfNotNull(aTaskItems[0]);
             }
             else
             {
                 aCommandLineBuilder.AppendSwitchIfNotNull(aCommand.Switch, aTaskItems[0]);
             }
         }
     }
     else
     {
         if (!aCommand.UseSingleItem)
         {
             if (String.IsNullOrEmpty(aCommand.Switch))
             {
                 aCommandLineBuilder.AppendSwitchUnquotedIfNotNull("", aTaskItems, aCommand.Delimiter);
             }
             else
             {
                 aCommandLineBuilder.AppendSwitchUnquotedIfNotNull(aCommand.Switch, aTaskItems, aCommand.Delimiter);
             }
         }
         else
         {
             if (String.IsNullOrEmpty(aCommand.Switch))
             {
                 aCommandLineBuilder.AppendSwitchUnquotedIfNotNull("", aTaskItems[0]);
             }
             else
             {
                 aCommandLineBuilder.AppendSwitchUnquotedIfNotNull(aCommand.Switch, aTaskItems[0]);
             }
         }
     }
 }
Beispiel #5
0
        private void AppendValueToSwitch(CommandLineBuilder aCommandLineBuilder, object aValue, CompilerCommandAttribute aCommand)
        {
            string lValueString = null;

            if (aValue != null)
            {
                lValueString = aValue.ToString();
            }
            if (aCommand.Switch != null)
            {
                if (aCommand.QuotedValue)
                {
                    aCommandLineBuilder.AppendSwitchIfNotNull(aCommand.Switch, lValueString);
                }
                else
                {
                    aCommandLineBuilder.AppendSwitchUnquotedIfNotNull(aCommand.Switch, lValueString);
                }
            }
        }