Exemplo n.º 1
0
        internal protected virtual void Read(Project project, IMSBuildItemEvaluated buildItem)
        {
            ItemName           = buildItem.Name;
            Include            = buildItem.Include;
            UnevaluatedInclude = buildItem.UnevaluatedInclude;
            Condition          = buildItem.Condition;
            metadata           = null;

            if (buildItem.SourceItem != null)
            {
                HashSet <string> knownProps = GetKnownMetadata();
                foreach (var prop in buildItem.SourceItem.Metadata.GetProperties())
                {
                    if (!knownProps.Contains(prop.Name))
                    {
                        if (metadata == null)
                        {
                            metadata = new ProjectItemMetadata(project.MSBuildProject);
                        }
                        // Get the evaluated value for the original metadata property
                        var p = new ItemMetadataProperty(prop.Name, buildItem.Metadata.GetValue(prop.Name), prop.UnevaluatedValue);
                        p.ParentProject = project.MSBuildProject;
                        metadata.AddProperty(p);
                    }
                }
                if (metadata != null)
                {
                    metadata.OnLoaded();
                }
            }
            buildItem.Metadata.ReadObjectProperties(this, GetType(), true);
        }
Exemplo n.º 2
0
 internal void AddProperty(ItemMetadataProperty prop)
 {
     if (properties == null)
     {
         properties   = new Dictionary <string, MSBuildProperty> (StringComparer.OrdinalIgnoreCase);
         propertyList = new List <MSBuildProperty> ();
     }
     prop.ParentProject     = project;
     properties [prop.Name] = prop;
     propertyList.Add(prop);
 }
Exemplo n.º 3
0
        MSBuildProperty AddProperty(string name, string condition = null)
        {
            if (properties == null)
            {
                properties   = new Dictionary <string, MSBuildProperty> (StringComparer.OrdinalIgnoreCase);
                propertyList = new List <MSBuildProperty> ();
            }
            int i = propertyOrder != null?propertyOrder.IndexOf(name) : -1;

            int insertIndex = -1;

            if (i != -1)
            {
                var foundProp = FindExistingProperty(i - 1, -1);
                if (foundProp != null)
                {
                    insertIndex = propertyList.IndexOf(foundProp) + 1;
                }
                else
                {
                    foundProp = FindExistingProperty(i + 1, 1);
                    if (foundProp != null)
                    {
                        insertIndex = propertyList.IndexOf(foundProp) - 1;
                    }
                }
            }

            var prop = new ItemMetadataProperty(name);

            prop.ParentProject = project;
            properties [name]  = prop;

            if (insertIndex != -1)
            {
                propertyList.Insert(insertIndex, prop);
            }
            else
            {
                propertyList.Add(prop);
            }
            return(prop);
        }