Example #1
0
		public bool VisitEnter (IProjectNode project)
		{
			Projects.Add (project);
			// Don't visit child nodes of a project since a 
			// project can't contain further projects.
			return false;
		}
Example #2
0
 public Token(IProjectNode node, TokenType type, string text, int offset, int length, int lineNumber)
 {
     ProjectNode = node;
     m_Type = type;
     m_Text = text;
     m_Offset = offset;
     m_Length = length;
     m_LineNumber = lineNumber;
 }
		readonly Func<IProjectItemNode, bool> filterItem = x => false; // null filter

		public MoveProjectItemsToProjectVisitor(IProjectNode targetProject, Func<IProjectItemNode, bool> filterItem = null)
		{
			stack = new Stack<ISolutionExplorerNode>();
			stack.Push(targetProject);

			if (filterItem != null)
				this.filterItem = filterItem;

			nodesToBeDeleted = new List<ISolutionExplorerNode>();
		}
        /// <summary>
        /// Visists the given visitor with the specified project.
        /// </summary>
        public static bool Accept(IProjectNode project, ISolutionVisitor visitor)
        {
            if (visitor.VisitEnter(project))
            {
                foreach (var node in project.Nodes)
                {
                    if (!node.Accept(visitor))
                        break;
                }
            }

            return visitor.VisitLeave(project);
        }
Example #5
0
      private static bool Equals(IProjectNode lhs, IProjectNode rhs)
      {
         if (object.ReferenceEquals(lhs, rhs))
            return true;

         if (object.ReferenceEquals(lhs, null) || object.ReferenceEquals(rhs, null))
            return false;

         
         if (lhs.GetType().Equals(rhs.GetType()) == false)
            return false;

         return lhs.FullPath.Equals(rhs.FullPath);
      }
Example #6
0
		public void Initialize(IProjectNode baseProject)
		{
			SelectedProject = baseProject;

			BaseProjectName = SelectedProject.Name;

			var projects = solutionExplorer.Solution.FindProjects().ToList();

			// TODO
			// Rather than hardcoding a convention for the shared project name, 
			// is there a way we can instead annotate it with some MSBuild property 
			// that will flag it as "the one" we used before? 
			// This would allow users to rename/move the project freely, 
			// which would make the feature more resilient.
			SharedProjectName = BaseProjectName + "." + Constants.Suffixes.SharedProject;
			SharedProject = GetProjectNode(projects, SharedProjectName);

			NuGetProjectName = BaseProjectName + "." + Constants.Suffixes.NuGetPackage;
			NuGetProject = GetProjectNode(projects, NuGetProjectName);
		}
Example #7
0
		public static void AddReference(this IReferencesNode references, IProjectNode projectReference) =>
			references.AsReferenceContainerNode().AddReference(projectReference);
Example #8
0
 public void OnDocumentChanged(object sender, string newText, IProjectNode project)
 {
     m_textView.Buffer.Text = newText;
 }
Example #9
0
 public virtual void AddReference(IProjectNode referencedProject)
 {
 }
Example #10
0
		/// <summary>
		/// Don't traverse project child elements.
		/// </summary>
		public bool VisitEnter (IProjectNode project)
		{
			if (!done && predicate (project)) {
				Projects.Add (project);
				if (firstOnly)
					done = true;
			}

			return false;
		}
Example #11
0
 void RemoveNode(IProjectNode node)
 {
     node.Parent = null;
     node.Deleted -= HandleNodeDeleted;
 }
 public virtual void Visit(IProjectNode node)
 {
    DefaultVisit(node);
 }
 private void EndWriteNode(IProjectNode node, XmlWriter writer)
 {
     if (node.IsFolder)
     {
         writer.WriteEndElement();
     }
 }
Example #14
0
 bool BelongsToThisFolder(IProjectNode node)
 {
     if (IsRootNode) {
         return node.Path.Split(System.IO.Path.DirectorySeparatorChar).Length == 1 || node.Path.StartsWith(".\\");
     }
     return System.IO.Path.GetDirectoryName(node.Path) == _dirpath;
 }
        private void Save(IProjectNode node, XmlTextWriter writer)
        {
            BeginWriteNode(node, writer);

            foreach (IProjectNode childNode in node.Children)
            {
                Save(childNode, writer);
            }

            EndWriteNode(node, writer);
        }
        private void BeginWriteNode(IProjectNode node, XmlTextWriter writer)
        {
            if (node.IsFolder)
            {
                writer.WriteStartElement("Folder");
                writer.WriteAttributeString("Name", node.Name);
            }
            else
            {
                writer.WriteStartElement("RecordedTemplate");
                writer.WriteAttributeString("Name", node.Name);

                writer.WriteStartElement("Template");
                writer.WriteAttributeString("Name", node.Template.Header.Title);
                writer.WriteAttributeString("Path", node.Template.Header.FullFileName.Replace(userSettings.TemplatePath, "{fixup}"));
                writer.WriteAttributeString("Version", node.Template.Header.Version);
                writer.WriteEndElement();

                writer.WriteStartElement("Input");
                if (node.Input.Count > 0)
                {
                    foreach (string key in node.Input.Keys)
                    {
                        object value = node.Input[key];

                        if (key == "OutputPath")
                        {
                            value = this.CreateFixup(this.projectFilePath, (string)value);
                        }

                        if (value == null)
                        {
                            writer.WriteStartElement("Item");
                            writer.WriteAttributeString("Type", "(null)");
                            writer.WriteAttributeString("Key", key);
                            writer.WriteEndElement();
                            continue;
                        }

                        string typeName = value.GetType().FullName;

                        writer.WriteStartElement("Item");
                        writer.WriteAttributeString("Type", typeName);
                        writer.WriteAttributeString("Key", key);

                        switch (typeName)
                        {
                            case "System.Collections.ArrayList":

                                ArrayList list = value as ArrayList;

                                string values = "";
                                string comma = "";

                                foreach (string s in list)
                                {
                                    values += comma;
                                    values += s;
                                    comma = ",";
                                }

                                writer.WriteAttributeString("Value", values);
                                break;

                            default:

                                writer.WriteAttributeString("Value", value.ToString());
                                break;
                        }

                        writer.WriteEndElement();
                    }
                }
                writer.WriteEndElement();

                writer.WriteStartElement("Settings");

                // Save these off so we can restore them
                string bakTemplatePath = node.Settings.TemplatePath;
                string bakOutputPath = node.Settings.OutputPath;
                string bakUIAssemblyPath = node.Settings.UIAssemblyPath;
                string bakCompilerAssemblyPath = node.Settings.CompilerAssemblyPath;
                string bakLanguageMappingFile = node.Settings.LanguageMappingFile;
                string bakUserMetadataFile = node.Settings.UserMetadataFile;

                // Remove Hard coded Paths
                node.Settings.TemplatePath = "{fixup}";
                node.Settings.OutputPath = "{fixup}";
                node.Settings.UIAssemblyPath = "{fixup}";
                node.Settings.CompilerAssemblyPath = "{fixup}";
                node.Settings.LanguageMappingFile = "{fixup}";
                node.Settings.UserMetadataFile = "{fixup}";

                // Now write it
                node.Settings.Save(writer);
                writer.WriteEndElement();

                // Restore the original values
                node.Settings.TemplatePath = bakTemplatePath;
                node.Settings.OutputPath = bakOutputPath;
                node.Settings.UIAssemblyPath = bakUIAssemblyPath;
                node.Settings.CompilerAssemblyPath = bakCompilerAssemblyPath;
                node.Settings.LanguageMappingFile = bakLanguageMappingFile;
                node.Settings.UserMetadataFile = bakUserMetadataFile;

                writer.WriteEndElement();
            }
        }
Example #17
0
		public bool VisitLeave (IProjectNode project) => true;
Example #18
0
		/// <summary>
		/// Begins visiting a project.
		/// </summary>
		/// <param name="project">The project being visited.</param>
		/// <returns>
		///   <see langword="true" /> if the project children should be visited; <see langword="false" /> otherwise.
		/// </returns>
		public virtual bool VisitEnter (IProjectNode project) => true;
Example #19
0
		public bool VisitLeave (IProjectNode project) => !done;
Example #20
0
		public static void AddReference(this IProjectNode project, IProjectNode projectReference) =>
			project.AsReferenceContainerNode().AddReference(projectReference);
        public void Load(string fileNameAndFilePath, esSettings mainSettings)
        {
            userSettings = mainSettings;

            RootNode = null;

            Dictionary<int, IProjectNode> parents = new Dictionary<int, IProjectNode>();

            using (XmlTextReader reader = new XmlTextReader(fileNameAndFilePath))
            {
                projectFilePath = fileNameAndFilePath;
                reader.WhitespaceHandling = WhitespaceHandling.None;

                IProjectNode currentNode = null;

                reader.Read();
                reader.Read();

                if (reader.Name != "EntitySpacesProject")
                {
                    throw new Exception("Invalid Project File: '" + fileNameAndFilePath + "'");
                }

                reader.Read();

                currentNode = new esProjectNode2010();
                currentNode.Name = reader.GetAttribute("Name");
                RootNode = currentNode;

                parents[reader.Depth] = currentNode;

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        switch (reader.LocalName)
                        {
                            case "Folder":

                                currentNode = new esProjectNode();
                                currentNode.Name = reader.GetAttribute("Name");

                                parents[reader.Depth - 1].Children.Add(currentNode);
                                parents[reader.Depth] = currentNode;
                                break;

                            case "RecordedTemplate":

                                currentNode = new esProjectNode();
                                currentNode.Name = reader.GetAttribute("Name");
                                currentNode.IsFolder = false;

                                int depth = reader.Depth;

                                // <Template>
                                reader.Read();
                                currentNode.Template = new Template();

                                // Path fixup to the template
                                string path = reader.GetAttribute("Path");
                                path = path.Replace("{fixup}", userSettings.TemplatePath);
                                path = path.Replace("\\\\", "\\");

                                currentNode.Template.Parse(path);

                                // <Input>
                                reader.Read();
                                XmlReader input = reader.ReadSubtree();
                                input.Read();

                                currentNode.Input = new Hashtable();

                                while (input.Read())
                                {
                                    string type = input.GetAttribute("Type");
                                    string key = input.GetAttribute("Key");
                                    string value = input.GetAttribute("Value");

                                    if (key == "OutputPath")
                                    {
                                        value = FixupTheFixup(this.projectFilePath, value);
                                    }

                                    switch (type)
                                    {
                                        case "(null)":
                                            currentNode.Input[key] = null;
                                            break;

                                        case "System.String":
                                            currentNode.Input[key] = value;
                                            break;

                                        case "System.Char":
                                            currentNode.Input[key] = Convert.ToChar(value);
                                            break;

                                        case "System.DateTime":
                                            currentNode.Input[key] = Convert.ToDateTime(value);
                                            break;

                                        case "System.Decimal":
                                            currentNode.Input[key] = Convert.ToDecimal(value);
                                            break;

                                        case "System.Double":
                                            currentNode.Input[key] = Convert.ToDouble(value);
                                            break;

                                        case "System.Boolean":
                                            currentNode.Input[key] = Convert.ToBoolean(value);
                                            break;

                                        case "System.Int16":
                                            currentNode.Input[key] = Convert.ToInt16(value);
                                            break;

                                        case "System.Int32":
                                            currentNode.Input[key] = Convert.ToInt32(value);
                                            break;

                                        case "System.Int64":
                                            currentNode.Input[key] = Convert.ToInt64(value);
                                            break;

                                        case "System.Collections.ArrayList":

                                            ArrayList list = new ArrayList();
                                            string[] items = value.Split(',');

                                            foreach (string item in items)
                                            {
                                                list.Add(item);
                                            }

                                            currentNode.Input[key] = list;
                                            break;
                                    }
                                }

                                // <Settings>
                                reader.Read();
                                XmlReader settings = reader.ReadSubtree();

                                esSettings2010 theSettings = new esSettings2010();
                                theSettings.Load(settings);
                                currentNode.Settings = theSettings;

                                // Fixup Settings ...
                                currentNode.Settings.TemplatePath = userSettings.TemplatePath;
                                currentNode.Settings.OutputPath = userSettings.OutputPath;
                                currentNode.Settings.UIAssemblyPath = userSettings.UIAssemblyPath;
                                currentNode.Settings.CompilerAssemblyPath = userSettings.CompilerAssemblyPath;
                                currentNode.Settings.LanguageMappingFile = userSettings.LanguageMappingFile;
                                currentNode.Settings.UserMetadataFile = userSettings.UserMetadataFile;

                                parents[depth - 1].Children.Add(currentNode);
                                break;
                        }
                    }
                }
            }
        }
Example #22
0
 void AddNode(IProjectNode node)
 {
     TakeOwnership(node);
     node.Parent = this;
     node.Deleted += HandleNodeDeleted;
 }
		public bool VisitEnter(IProjectNode project) => true;
Example #24
0
 void MoveToThisFolder(IProjectNode node)
 {
     node.Move(_dirpath);
 }
Example #25
0
 /// <summary>
 /// Adapts the specified project to supported target types.
 /// </summary>
 /// <param name="project">The project to adapt.</param>
 /// <returns>The entry point that exposes supported target types.</returns>
 public static IAdaptable <IProjectNode> Adapt(this IProjectNode project)
 {
     return(new TreeNodeAdaptable <IProjectNode>(project));
 }
Example #26
0
 void TakeOwnership(IProjectNode node)
 {
     if (!BelongsToThisFolder(node)) {
         MoveToThisFolder(node);
     }
 }
Example #27
0
 /// <summary>
 /// Begins visiting a project.
 /// </summary>
 /// <param name="project">The project being visited.</param>
 /// <returns>
 ///   <see langword="true" /> if the project children should be visited; <see langword="false" /> otherwise.
 /// </returns>
 public virtual bool VisitEnter(IProjectNode project)
 {
     return true;
 }
Example #28
0
 public bool Equals(IProjectNode other)
 {
     return Equals(this, other);
 }
Example #29
0
 /// <summary>
 /// Ends visiting a project.
 /// </summary>
 /// <param name="project">The project being visited.</param>
 /// <returns>
 ///   <see langword="true" /> if the project siblings should be visited; <see langword="false" /> otherwise.
 /// </returns>
 public virtual bool VisitLeave(IProjectNode project)
 {
     return true;
 }
        private void ConvertProjectNodeSettings(IProjectNode node)
        {
            foreach (IProjectNode childNode in node.Children)
            {
                if (childNode.Settings != null)
                {
                    childNode.Settings = ((esSettings2010)childNode.Settings).To2011();

                    try
                    {
                        esSettings.AdjustPathsBasedOnPriorVersions(childNode.Settings as esSettings, @"Software\EntitySpaces 2009", "ES2009", false);
                        esSettings.AdjustPathsBasedOnPriorVersions(childNode.Settings as esSettings, @"Software\EntitySpaces 2010", "ES2010", false);
                        esSettings.AdjustPathsBasedOnPriorVersions(childNode.Settings as esSettings, @"Software\EntitySpaces 2011", "ES2011", false);
                        esSettings.AdjustPathsBasedOnPriorVersions(childNode.Settings as esSettings, @"Software\EntitySpaces 2012", "ES2012", true);
                    }
                    catch { }
                }

                ConvertProjectNodeSettings(childNode);
            }
        }
Example #31
0
		/// <summary>
		/// Ends visiting a project.
		/// </summary>
		/// <param name="project">The project being visited.</param>
		/// <returns>
		///   <see langword="true" /> if the project siblings should be visited; <see langword="false" /> otherwise.
		/// </returns>
		public virtual bool VisitLeave (IProjectNode project) => true;
		public bool VisitLeave(IProjectNode project)
		{
			// Once the project has been processed, delete all nodes
			// in order to avoid CollectionModified exception
			foreach (var node in nodesToBeDeleted)
			{
				var deletableNode = node.As<IDeletableNode>();
				if (deletableNode != null)
				{
					try
					{
						deletableNode.Delete();
					}
					catch
					{
						// Ignore? 
					}
				}
			}

			return false;
		}
Example #33
0
 public bool VisitLeave(IProjectNode project) => !done;