예제 #1
0
        public void RemoveMetadata(string metadataName)
        {
            if (metadataName == null)
            {
                throw new ArgumentNullException("metadataName");
            }

            if (ReservedNameUtils.IsReservedMetadataName(metadataName))
            {
                throw new ArgumentException(String.Format("\"{0}\" is a reserved item meta-data, and cannot be modified or deleted.",
                                                          metadataName));
            }

            if (FromXml)
            {
                if (unevaluatedMetadata.Contains(metadataName))
                {
                    XmlNode node = itemElement [metadataName];
                    itemElement.RemoveChild(node);
                }
            }
            else if (HasParentItem)
            {
                if (parent_item.child_items.Count > 1)
                {
                    SplitParentItem();
                }
                parent_item.RemoveMetadata(metadataName);
            }

            DeleteMetadata(metadataName);
        }
예제 #2
0
        void SetMetadata(string metadataName,
                         string metadataValue,
                         bool treatMetadataValueAsLiteral,
                         bool fromDynamicItem)
        {
            if (metadataName == null)
            {
                throw new ArgumentNullException("metadataName");
            }

            if (metadataValue == null)
            {
                throw new ArgumentNullException("metadataValue");
            }

            if (ReservedNameUtils.IsReservedMetadataName(metadataName))
            {
                throw new ArgumentException(String.Format("\"{0}\" is a reserved item meta-data, and cannot be modified or deleted.",
                                                          metadataName));
            }

            if (treatMetadataValueAsLiteral && !HasParentItem)
            {
                metadataValue = MSBuildUtils.Escape(metadataValue);
            }

            if (FromXml)
            {
                XmlElement element = itemElement [metadataName];
                if (element == null)
                {
                    element           = itemElement.OwnerDocument.CreateElement(metadataName, Project.XmlNamespace);
                    element.InnerText = metadataValue;
                    itemElement.AppendChild(element);
                }
                else
                {
                    element.InnerText = metadataValue;
                }
            }
            else if (HasParentItem)
            {
                if (parent_item.child_items.Count > 1)
                {
                    SplitParentItem();
                }
                parent_item.SetMetadata(metadataName, metadataValue, treatMetadataValueAsLiteral, fromDynamicItem);
            }

            // We don't want to reevalute the project for dynamic items
            if (!fromDynamicItem && !IsDynamic && (FromXml || HasParentItem))
            {
                parent_item_group.ParentProject.MarkProjectAsDirty();
                parent_item_group.ParentProject.NeedToReevaluate();
            }

            DeleteMetadata(metadataName);
            AddMetadata(metadataName, metadataValue);
        }
예제 #3
0
 string GetMetadataValue(string metadataName)
 {
     if (ReservedNameUtils.IsReservedMetadataName(metadataName))
     {
         return(ReservedNameUtils.GetReservedMetadata(ItemSpec, metadataName, escapedMetadata));
     }
     return(((string)escapedMetadata [metadataName]) ?? String.Empty);
 }
예제 #4
0
 public bool HasMetadata(string metadataName)
 {
     if (ReservedNameUtils.IsReservedMetadataName(metadataName))
     {
         return(true);
     }
     else
     {
         return(evaluatedMetadata.Contains(metadataName));
     }
 }
예제 #5
0
 public void RemoveMetadata(string metadataName)
 {
     if (metadataName == null)
     {
         throw new ArgumentNullException("metadataName");
     }
     if (ReservedNameUtils.IsReservedMetadataName(metadataName))
     {
         throw new ArgumentException("Can't remove reserved metadata");
     }
     escapedMetadata.Remove(metadataName);
 }
예제 #6
0
 public string GetMetadata(string metadataName)
 {
     if (ReservedNameUtils.IsReservedMetadataName(metadataName))
     {
         return(ReservedNameUtils.GetReservedMetadata(ItemSpec, metadataName, metadata));
     }
     else if (metadata.Contains(metadataName))
     {
         return((string)metadata [metadataName]);
     }
     else
     {
         return(String.Empty);
     }
 }
예제 #7
0
 public string GetMetadata(string metadataName)
 {
     if (ReservedNameUtils.IsReservedMetadataName(metadataName))
     {
         string metadata = ReservedNameUtils.GetReservedMetadata(FinalItemSpec, metadataName, unevaluatedMetadata);
         return((metadataName.ToLower() == "fullpath") ? MSBuildUtils.Escape(metadata) : metadata);
     }
     else if (unevaluatedMetadata.Contains(metadataName))
     {
         return((string)unevaluatedMetadata [metadataName]);
     }
     else
     {
         return(String.Empty);
     }
 }
예제 #8
0
        public string GetEvaluatedMetadata(string metadataName)
        {
            if (ReservedNameUtils.IsReservedMetadataName(metadataName))
            {
                string metadata = ReservedNameUtils.GetReservedMetadata(FinalItemSpec, metadataName, evaluatedMetadata);
                return(MSBuildUtils.Unescape(metadata));
            }

            if (evaluatedMetadata.Contains(metadataName))
            {
                return((string)evaluatedMetadata [metadataName]);
            }
            else
            {
                return(String.Empty);
            }
        }
예제 #9
0
 public string GetMetadata(string metadataName)
 {
     if (ReservedNameUtils.IsReservedMetadataName(metadataName))
     {
         string metadata = ReservedNameUtils.GetReservedMetadata(FinalItemSpec, metadataName, unevaluatedMetadata);
         return(string.Equals(metadataName, "fullpath", StringComparison.OrdinalIgnoreCase)
                                 ? MSBuildUtils.Escape(metadata)
                                 : metadata);
     }
     else if (unevaluatedMetadata.Contains(metadataName))
     {
         return((string)unevaluatedMetadata [metadataName]);
     }
     else
     {
         return(String.Empty);
     }
 }
예제 #10
0
        public void SetMetadata(string metadataName, string metadataValue)
        {
            if (metadataName == null)
            {
                throw new ArgumentNullException("metadataName");
            }
            if (metadataValue == null)
            {
                throw new ArgumentNullException("metadataValue");
            }

            // allow RecursiveDir to be set, it gets set by DirectoryScanner
            if (String.Compare(metadataName, "RecursiveDir", StringComparison.InvariantCultureIgnoreCase) != 0 &&
                ReservedNameUtils.IsReservedMetadataName(metadataName))
            {
                throw new ArgumentException("Can't modify reserved metadata");
            }

            escapedMetadata [metadataName] = metadataValue;
        }
예제 #11
0
        public void SetMetadata(string metadataName, string metadataValue)
        {
            if (metadataName == null)
            {
                throw new ArgumentNullException("metadataName");
            }
            if (metadataValue == null)
            {
                throw new ArgumentNullException("metadataValue");
            }
            if (ReservedNameUtils.IsReservedMetadataName(metadataName))
            {
                throw new ArgumentException("Can't modify reserved metadata");
            }

            if (metadata.Contains(metadataName))
            {
                metadata.Remove(metadataName);
            }
            metadata.Add(metadataName, metadataValue);
        }