Exemple #1
0
 /// <summary>
 /// Helper function to parse the ParameterEntryElement
 /// </summary>
 /// <param name="element"></param>
 /// <param name="parentItem"></param>
 /// <returns></returns>
 private Utilities.TaskItem ReadParameterEntryElement(Xml.XmlElement element, Utilities.TaskItem parentItem)
 {
     Debug.Assert(element != null && parentItem != null);
     Utilities.TaskItem taskItem = null;
     if (string.Compare(element.Name, "parameterEntry", System.StringComparison.OrdinalIgnoreCase) == 0)
     {
         taskItem = new Microsoft.Build.Utilities.TaskItem(parentItem);
         taskItem.RemoveMetadata("OriginalItemSpec");
         foreach (Xml.XmlNode attribute in element.Attributes)
         {
             if (attribute != null && attribute.Name != null && attribute.Value != null)
             {
                 string value = DisableEscapeMSBuildVariable ? attribute.Value : Utility.EscapeTextForMSBuildVariable(attribute.Value);
                 taskItem.SetMetadata(attribute.Name, value);
             }
         }
     }
     else if (string.Compare(element.Name, "parameterValidation", System.StringComparison.OrdinalIgnoreCase) == 0)
     {
         taskItem = new Microsoft.Build.Utilities.TaskItem(parentItem);
         taskItem.RemoveMetadata("OriginalItemSpec");
         taskItem.SetMetadata("Element", "parameterValidation");
         foreach (Xml.XmlNode attribute in element.Attributes)
         {
             if (attribute != null && attribute.Name != null && attribute.Value != null)
             {
                 string value = DisableEscapeMSBuildVariable ? attribute.Value : Utility.EscapeTextForMSBuildVariable(attribute.Value);
                 taskItem.SetMetadata(attribute.Name, value);
             }
         }
     }
     return(taskItem);
 }
Exemple #2
0
        /// <summary>
        /// Parse the Parameter element
        /// </summary>
        /// <param name="element"></param>
        private void ReadParameterElement(Xml.XmlElement element)
        {
            Debug.Assert(element != null);
            if (string.Compare(element.Name, "parameter", System.StringComparison.OrdinalIgnoreCase) == 0)
            {
                Xml.XmlAttribute nameAttribute = element.Attributes.GetNamedItem("name") as Xml.XmlAttribute;
                if (nameAttribute != null)
                {
                    Utilities.TaskItem taskItem = new Microsoft.Build.Utilities.TaskItem(nameAttribute.Value);
                    foreach (Xml.XmlNode attribute in element.Attributes)
                    {
                        string attributeName = attribute.Name.ToLower(System.Globalization.CultureInfo.InvariantCulture);
                        if (string.CompareOrdinal(attributeName, "xmlns") == 0 ||
                            attribute.Name.StartsWith("xmlns:", System.StringComparison.Ordinal) ||
                            string.CompareOrdinal(attributeName, "name") == 0
                            )
                        {
                            continue;
                        }
                        string value = DisableEscapeMSBuildVariable ? attribute.Value : Utility.EscapeTextForMSBuildVariable(attribute.Value);
                        taskItem.SetMetadata(attribute.Name, value);
                    }
                    // work around the MSDeploy.exe limition of the Parameter must have the ParameterEntry.
                    // m_parametersList.Add(taskItem);
                    bool fAddNoParameterEntryParameter = true;

                    foreach (Xml.XmlNode childNode in element.ChildNodes)
                    {
                        Xml.XmlElement childElement = childNode as Xml.XmlElement;
                        if (childElement != null)
                        {
                            Utilities.TaskItem childEntry = ReadParameterEntryElement(childElement, taskItem);
                            if (childEntry != null)
                            {
                                fAddNoParameterEntryParameter = false; // we have Parameter entry, supress adding the Parameter with no entry
                                m_parametersList.Add(childEntry);
                            }
                        }
                    }

                    if (fAddNoParameterEntryParameter)
                    {
                        // finally add a parameter without any entry
                        m_parametersList.Add(taskItem);
                    }
                }
            }
        }