Exemplo n.º 1
0
        static void Write(VisualDProject prj, XmlWriter x)
        {
            x.WriteStartDocument();

            x.WriteStartElement("DProject");

            x.WriteElementString("ProjectGuid", prj.ItemId);

            foreach (VisualDPrjConfig config in prj.Configurations)
            {
                x.WriteStartElement("Config");
                x.WriteAttributeString("name", config.Name);
                x.WriteAttributeString("platform", config.Platform);

                foreach (var kv in config.Properties)
                {
                    x.WriteElementString(kv.Key, kv.Value);
                }

                x.WriteEndElement();
            }

            //TODO: Files

            x.WriteEndDocument();
            x.Close();
        }
Exemplo n.º 2
0
        public static VisualDProject Read(FilePath file, XmlReader x)
        {
            var prj = new VisualDProject();

            prj.FileName = file;
            var    folderStack = new Stack <string>();
            string path;

            while (x.Read())
            {
                if (x.NodeType == XmlNodeType.Element)
                {
                    switch (x.LocalName)
                    {
                    case "ProjectGuid":
                        prj.ItemIdToAssign = x.ReadString();
                        break;

                    case "Config":
                        VisualDPrjConfig.ReadAndAdd(prj, x.GetAttribute("name"), x.GetAttribute("platform"), x.ReadSubtree());
                        break;

                    case "Folder":
                        if (folderStack.Count == 0)
                        {
                            // Somehow, the very root Folder node gets merely ignored..somehow
                            folderStack.Push(string.Empty);
                            break;
                        }

                        folderStack.Push(Building.ProjectBuilder.EnsureCorrectPathSeparators(x.GetAttribute("name") ?? string.Empty));
                        path = GetPath(folderStack);
                        if (!string.IsNullOrWhiteSpace(path))
                        {
                            prj.AddDirectory(path);
                        }
                        break;

                    case "File":
                        var filePath = Building.ProjectBuilder.EnsureCorrectPathSeparators(x.GetAttribute("path"));
                        //TODO: Custom tools that are executed right before building..gosh!
                        if (!string.IsNullOrWhiteSpace(filePath) && !string.IsNullOrWhiteSpace(path = GetPath(folderStack, filePath)))
                        {
                            prj.AddFile(Path.IsPathRooted(path) ? path : prj.BaseDirectory.Combine(path).ToString(), BuildAction.Compile);
                        }
                        break;
                    }
                }
                if (x.NodeType == XmlNodeType.EndElement && x.LocalName == "Folder")
                {
                    folderStack.Pop();
                }
            }

            return(prj);
        }
Exemplo n.º 3
0
		public static VisualDPrjConfig ReadAndAdd(VisualDProject prj, string name, string platform, XmlReader x)
		{
			var c = prj.AddNewConfiguration (name ?? "Unknown") as VisualDPrjConfig;
			c.Platform = platform;

			while (x.Read ()) {
				var n = x.LocalName;
				if (string.IsNullOrWhiteSpace (n) || n == "Config")
					continue;
				var content = x.ReadElementContentAsString();

				if (!string.IsNullOrWhiteSpace (content))
					c.Properties [n] = content;
			}
				
			return c;
		}
Exemplo n.º 4
0
        public object ReadFile(FilePath file, Type expectedType, IProgressMonitor monitor)
        {
            VisualDProject prj = null;

            using (var s = File.OpenText(file))
                using (var r = new XmlTextReader(s))
                    prj = Read(file, r);

            if (typeof(Project).IsSubclassOf(expectedType))
            {
                return(prj);
            }

            if (typeof(Solution).IsSubclassOf(expectedType))
            {
                var sln = new Solution();
                sln.Name = prj.Name;
                sln.RootFolder.AddItem(prj);
                return(sln);
            }

            return(prj);
        }
Exemplo n.º 5
0
        public static VisualDPrjConfig ReadAndAdd(VisualDProject prj, string name, string platform, XmlReader x)
        {
            var c = prj.AddNewConfiguration(name ?? "Unknown") as VisualDPrjConfig;

            c.Platform = platform;

            while (x.Read())
            {
                var n = x.LocalName;
                if (string.IsNullOrWhiteSpace(n) || n == "Config")
                {
                    continue;
                }
                var content = x.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(content))
                {
                    c.Properties [n] = content;
                }
            }

            return(c);
        }
 public VisualDProjectReferenceCollection(VisualDProject prj) : base(prj)
 {
 }
Exemplo n.º 7
0
		static void Write(VisualDProject prj, XmlWriter x)
		{
			x.WriteStartDocument();

			x.WriteStartElement("DProject");

			x.WriteElementString("ProjectGuid", prj.ItemId);

			foreach (VisualDPrjConfig config in prj.Configurations)
			{
				x.WriteStartElement("Config");
				x.WriteAttributeString("name", config.Name);
				x.WriteAttributeString("platform", config.Platform);

				foreach (var kv in config.Properties)
					x.WriteElementString(kv.Key, kv.Value);

				x.WriteEndElement();
			}

			//TODO: Files

			x.WriteEndDocument();
			x.Close();
		}
Exemplo n.º 8
0
		public static VisualDProject Read(FilePath file, XmlReader x)
		{
			var prj = new VisualDProject ();
			prj.FileName = file;
			var folderStack = new Stack<string>();
			string path;

			while (x.Read())
			{
				if (x.NodeType == XmlNodeType.Element)
					switch (x.LocalName)
					{
						case "ProjectGuid":
							prj.ItemIdToAssign = x.ReadString();
							break;
						case "Config":
							VisualDPrjConfig.ReadAndAdd(prj, x.GetAttribute("name"), x.GetAttribute("platform"), x.ReadSubtree());
							break;
						case "Folder":
							if (folderStack.Count == 0)
							{
								// Somehow, the very root Folder node gets merely ignored..somehow
								folderStack.Push(string.Empty);
								break;
							}

							folderStack.Push(Building.ProjectBuilder.EnsureCorrectPathSeparators(x.GetAttribute("name") ?? string.Empty));
							path = GetPath(folderStack);
							if(!string.IsNullOrWhiteSpace(path))
								prj.AddDirectory(path);
							break;
						case "File":
							var filePath = Building.ProjectBuilder.EnsureCorrectPathSeparators(x.GetAttribute("path"));
							//TODO: Custom tools that are executed right before building..gosh!
							if (!string.IsNullOrWhiteSpace(filePath) && !string.IsNullOrWhiteSpace(path = GetPath(folderStack, filePath)))
								prj.AddFile(Path.IsPathRooted(path) ? path : prj.BaseDirectory.Combine(path).ToString(), BuildAction.Compile);
							break;
					}
				if (x.NodeType == XmlNodeType.EndElement && x.LocalName == "Folder")
					folderStack.Pop();
			}

			return prj;
		}
		public VisualDProjectReferenceCollection (VisualDProject prj) : base(prj)
		{
		}