/// <summary>
        /// Function to retrieve the actual plug in based on the name associated with the project metadata item.
        /// </summary>
        /// <param name="metadata">The metadata item to evaluate.</param>
        /// <returns>The plug in, and the <see cref="MetadataPlugInState"/> used to evaluate whether a deep inspection is required.</returns>
        private (ContentPlugIn plugin, MetadataPlugInState state) GetContentPlugIn(ProjectItemMetadata metadata)
        {
            // If the name is null, then we've never assigned the content plugin.  So look it up.
            if (metadata.PlugInName == null)
            {
                return(null, MetadataPlugInState.Unassigned);
            }

            // If we have an empty string
            if (string.IsNullOrWhiteSpace(metadata.PlugInName))
            {
                return(null, MetadataPlugInState.NotFound);
            }

            #pragma warning disable IDE0046 // Convert to conditional expression
            if (!PlugIns.TryGetValue(metadata.PlugInName, out ContentPlugIn plugin))
            {
                return(null, MetadataPlugInState.NotFound);
            }

            return(plugin, MetadataPlugInState.Assigned);

            #pragma warning restore IDE0046 // Convert to conditional expression
        }
Пример #2
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);
		}
Пример #3
0
        /// <summary>
        /// Function to create a file explorer node view model for a file.
        /// </summary>
        /// <param name="project">The project data.</param>
        /// <param name="fileSystemService">The file system service used to manipulate the underlying physical file system.</param>
        /// <param name="parent">The parent for the node.</param>
        /// <param name="file">The file system file to wrap in the view model.</param>
        /// <param name="metaData">[Optional] The metadata for the file.</param>
        /// <returns>The new file explorer node view model.</returns>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="project"/>, <paramref name="metadataManager"/>, <paramref name="fileSystemService"/> or the <paramref name="file"/> parameter is <b>null</b>.</exception>
        public IFileExplorerNodeVm CreateFileExplorerFileNodeVm(IProject project, IFileSystemService fileSystemService, IFileExplorerNodeVm parent, FileInfo file, ProjectItemMetadata metaData = null)
        {
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            if (fileSystemService == null)
            {
                throw new ArgumentNullException(nameof(fileSystemService));
            }

            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            return(DoCreateFileExplorerFileNode(project, fileSystemService, parent, file, metaData, null));
        }
Пример #4
0
        /// <summary>
        /// Function to create a file explorer node view model for a file.
        /// </summary>
        /// <param name="project">The project data.</param>
        /// <param name="fileSystemService">The file system service used to manipulate the underlying physical file system.</param>
        /// <param name="parent">The parent for the node.</param>
        /// <param name="file">The file system file to wrap in the view model.</param>
        /// <param name="metaData">[Optional] The metadata for the file.</param>
        /// <returns>The new file explorer node view model.</returns>
        private IFileExplorerNodeVm DoCreateFileExplorerFileNode(IProject project, IFileSystemService fileSystemService, IFileExplorerNodeVm parent, FileInfo file, ProjectItemMetadata metaData, IReadOnlyList <IFileExplorerNodeVm> openFiles)
        {
            var result = new FileExplorerFileNodeVm();

            // If this node already exists, then don't recreate it and just send it back.
            // This way, we don't need to worry about running around trying to update changed nodes.
            _pathBuilder.Length = 0;
            _pathBuilder.Append(parent.FullPath);
            _pathBuilder.Append(file.Name);
            string newPath = _pathBuilder.ToString();

            IFileExplorerNodeVm openFile = openFiles?.FirstOrDefault(item => string.Equals(item.FullPath, newPath, StringComparison.OrdinalIgnoreCase));

            if (openFile != null)
            {
                if (parent.Children.All(item => !string.Equals(item.FullPath, newPath, StringComparison.OrdinalIgnoreCase)))
                {
                    parent.Children.Add(openFile);
                    openFile.Refresh();
                    (openFile as IContentFile)?.RefreshMetadata();
                }
                return(openFile);
            }

            result.Initialize(new FileExplorerNodeParameters(file.FullName, project, this, fileSystemService)
            {
                Parent   = parent,
                Metadata = metaData
            });

            if (result.Metadata == null)
            {
                if (project.ProjectItems.TryGetValue(result.FullPath, out ProjectItemMetadata existingMetaData))
                {
                    result.Metadata = existingMetaData;
                }
                else
                {
                    result.Metadata = new ProjectItemMetadata();
                }
            }

            parent.Children.Add(result);

            return(result);
        }
		public ProjectOperationContext ()
		{
			GlobalProperties = new ProjectItemMetadata ();
		}
		internal bool Equals (ProjectRunConfiguration other)
		{
			var dict1 = new Dictionary<string, string> ();
			var dict2 = new Dictionary<string, string> ();

			var thisData = new ProjectItemMetadata ();
			Write (thisData);
			GetProps (MainPropertyGroup, dict1);
			GetProps (thisData, dict1);

			var otherData = new ProjectItemMetadata ();
			other.Write (otherData);
			GetProps (other.MainPropertyGroup, dict2);
			GetProps (otherData, dict2);

			if (dict1.Count != dict2.Count)
				return false;
			foreach (var tp in dict1) {
				string v;
				if (!dict2.TryGetValue (tp.Key, out v) || tp.Value != v)
					return false;
			}
			return true;
		}