/// <summary> /// Try to update the project data given a project started event. This is useful if the project /// was created (e.g. as a parent) before we saw the started event. /// <remarks>Does nothing if the data has already been set or the new data is null.</remarks> /// </summary> /// <param name="args">The <see cref="ProjectStartedEventArgs"/> instance containing the event data.</param> public void UpdateProject(Project project, ProjectStartedEventArgs args) { if (project.Name == null && args != null) { project.StartTime = args.Timestamp; project.Name = stringTable.Intern(args.Message); project.ProjectFile = stringTable.Intern(args.ProjectFile); if (args.GlobalProperties != null) { AddGlobalProperties(project, args.GlobalProperties); } if (args.Properties != null) { var properties = project.GetOrCreateNodeWithName <Folder>("Properties"); AddProperties(properties, args .Properties .Cast <DictionaryEntry>() .OrderBy(d => d.Key) .Select(d => new KeyValuePair <string, string>( stringTable.Intern(Convert.ToString(d.Key)), stringTable.Intern(Convert.ToString(d.Value))))); } if (args.Items != null) { RetrieveProjectInstance(project, args); var items = project.GetOrCreateNodeWithName <Folder>("Items"); foreach (DictionaryEntry kvp in args.Items) { var itemName = stringTable.Intern(Convert.ToString(kvp.Key)); var itemGroup = items.GetOrCreateNodeWithName <Folder>(itemName); var item = new Item(); var taskItem = kvp.Value as ITaskItem; if (taskItem != null) { item.Text = stringTable.Intern(taskItem.ItemSpec); foreach (DictionaryEntry metadataName in taskItem.CloneCustomMetadata()) { item.AddChild(new Metadata { Name = stringTable.Intern(Convert.ToString(metadataName.Key)), Value = stringTable.Intern(Convert.ToString(metadataName.Value)) }); } itemGroup.AddChild(item); } } } } }
private void AddGlobalProperties(Project project, IEnumerable <KeyValuePair <string, string> > properties) { var propertiesNode = project.GetOrCreateNodeWithName <Folder>("Properties"); if (properties != null && properties.Any()) { var global = propertiesNode.GetOrCreateNodeWithName <Folder>("Global"); AddProperties(global, properties); } }
private void AddGlobalProperties(Project project) { var propertiesNode = project.GetOrCreateNodeWithName <Folder>("Properties"); var properties = project.GlobalProperties; if (properties != null && properties.Any()) { var global = propertiesNode.GetOrCreateNodeWithName <Folder>("Global"); AddProperties(global, properties); } }
private static void AddEntryTargets(Project project) { var targetsNode = project.GetOrCreateNodeWithName <Folder>(Strings.EntryTargets); var entryTargets = project.EntryTargets; if (entryTargets != null) { foreach (var entryTarget in entryTargets) { var property = new EntryTarget { Name = entryTarget, }; targetsNode.AddChild(property); } } }
/// <summary> /// Try to update the project data given a project started event. This is useful if the project /// was created (e.g. as a parent) before we saw the started event. /// <remarks>Does nothing if the data has already been set or the new data is null.</remarks> /// </summary> /// <param name="args">The <see cref="ProjectStartedEventArgs"/> instance containing the event data.</param> public void UpdateProject(Project project, ProjectStartedEventArgs args) { if (project.Name == null && args != null) { project.StartTime = args.Timestamp; project.Name = Intern(args.Message); project.ProjectFile = Intern(args.ProjectFile); project.EntryTargets = string.IsNullOrWhiteSpace(args.TargetNames) ? ImmutableArray <string> .Empty : stringTable.InternList(TextUtilities.SplitSemicolonDelimitedList(args.TargetNames)); var internedGlobalProperties = stringTable.InternStringDictionary(args.GlobalProperties) ?? ImmutableDictionary <string, string> .Empty; project.GlobalProperties = internedGlobalProperties; if (args.GlobalProperties != null) { AddGlobalProperties(project, internedGlobalProperties); } if (args.Properties != null) { var properties = project.GetOrCreateNodeWithName <Folder>(Intern("Properties")); AddProperties(properties, args .Properties .Cast <DictionaryEntry>() .OrderBy(d => d.Key) .Select(d => new KeyValuePair <string, string>( Intern(Convert.ToString(d.Key)), Intern(Convert.ToString(d.Value))))); } if (args.Items != null) { RetrieveProjectInstance(project, args); var items = project.GetOrCreateNodeWithName <Folder>("Items"); foreach (DictionaryEntry kvp in args.Items) { var itemName = Intern(Convert.ToString(kvp.Key)); var itemGroup = items.GetOrCreateNodeWithName <Folder>(itemName); var item = new Item(); var taskItem = kvp.Value as ITaskItem; if (taskItem != null) { item.Text = Intern(taskItem.ItemSpec); foreach (DictionaryEntry metadataName in taskItem.CloneCustomMetadata()) { item.AddChild(new Metadata { Name = Intern(Convert.ToString(metadataName.Key)), Value = Intern(Convert.ToString(metadataName.Value)) }); } itemGroup.AddChild(item); } } } } }