Пример #1
0
        public static SolutionDescriptor CreateSolutionDescriptor(RuntimeAddin addin, XmlElement xmlElement,
                                                                  FilePath baseDirectory)
        {
            SolutionDescriptor solutionDescriptor = new SolutionDescriptor();

            solutionDescriptor.addin = addin;

            if (xmlElement.Attributes["name"] != null)
            {
                solutionDescriptor.name = xmlElement.Attributes["name"].Value;
            }
            else
            {
                throw new InvalidOperationException("Attribute 'name' not found");
            }

            if (xmlElement.Attributes["type"] != null)
            {
                solutionDescriptor.type = xmlElement.Attributes["type"].Value;
            }

            if (xmlElement.Attributes["directory"] != null)
            {
                solutionDescriptor.directory = xmlElement.Attributes["directory"].Value;
            }

            if (xmlElement["Options"] != null && xmlElement["Options"]["StartupProject"] != null)
            {
                solutionDescriptor.startupProject = xmlElement["Options"]["StartupProject"].InnerText;
            }


            foreach (XmlNode xmlNode in xmlElement.ChildNodes)
            {
                if (xmlNode is XmlElement)
                {
                    XmlElement xmlNodeElement = (XmlElement)xmlNode;
                    switch (xmlNodeElement.Name)
                    {
                    case "Project":
                        solutionDescriptor.entryDescriptors.Add(
                            ProjectDescriptor.CreateProjectDescriptor(xmlNodeElement, baseDirectory));
                        break;

                    case "CombineEntry":
                    case "SolutionItem":
                        solutionDescriptor.entryDescriptors.Add(
                            SolutionItemDescriptor.CreateDescriptor(addin, xmlNodeElement));
                        break;
                    }
                }
            }

            return(solutionDescriptor);
        }
Пример #2
0
		public static ProjectDescriptor CreateProjectDescriptor (XmlElement xmlElement, FilePath baseDirectory)
		{
			ProjectDescriptor projectDescriptor = new ProjectDescriptor ();

			projectDescriptor.name = xmlElement.GetAttribute ("name");
			projectDescriptor.directory = xmlElement.GetAttribute ("directory");
			projectDescriptor.createCondition = xmlElement.GetAttribute ("if");

			projectDescriptor.type = xmlElement.GetAttribute ("type");
			if (String.IsNullOrEmpty (projectDescriptor.type))
				projectDescriptor.type = "DotNet";

			if (xmlElement ["Files"] != null) {
				foreach (XmlNode xmlNode in xmlElement["Files"].ChildNodes)
					if (xmlNode is XmlElement)
						projectDescriptor.files.Add (
							FileDescriptionTemplate.CreateTemplate ((XmlElement)xmlNode, baseDirectory));
			}

			if (xmlElement ["Resources"] != null) {
				foreach (XmlNode xmlNode in xmlElement["Resources"].ChildNodes) {
					if (xmlNode is XmlElement) {
						var fileTemplate = FileDescriptionTemplate.CreateTemplate ((XmlElement)xmlNode, baseDirectory);
						if (fileTemplate is SingleFileDescriptionTemplate)
							projectDescriptor.resources.Add ((SingleFileDescriptionTemplate)fileTemplate);
						else
							MessageService.ShowError (GettextCatalog.GetString ("Only single-file templates allowed to generate resource files"));
					}

				}
			}

			if (xmlElement ["References"] != null) {
				foreach (XmlNode xmlNode in xmlElement["References"].ChildNodes) {
					projectDescriptor.references.Add (new ProjectReferenceDescription ((XmlElement) xmlNode));
				}
			}

			projectDescriptor.projectOptions = xmlElement ["Options"];
			if (projectDescriptor.projectOptions == null)
				projectDescriptor.projectOptions = xmlElement.OwnerDocument.CreateElement ("Options");

			if (xmlElement ["Packages"] != null) {
				foreach (XmlNode xmlNode in xmlElement["Packages"].ChildNodes) {
					if (xmlNode is XmlElement) {
						var packageReference = ProjectTemplatePackageReference.Create ((XmlElement)xmlNode);
						projectDescriptor.packageReferences.Add (packageReference);
					}
				}
			}

			return projectDescriptor;
		}
Пример #3
0
		public static ProjectDescriptor CreateProjectDescriptor (XmlElement xmlElement, FilePath baseDirectory)
		{
			ProjectDescriptor projectDescriptor = new ProjectDescriptor ();

			projectDescriptor.name = xmlElement.GetAttribute ("name");
			projectDescriptor.directory = xmlElement.GetAttribute ("directory");

			projectDescriptor.type = xmlElement.GetAttribute ("type");
			if (String.IsNullOrEmpty (projectDescriptor.type))
				projectDescriptor.type = "DotNet";

			if (xmlElement ["Files"] != null) {
				foreach (XmlNode xmlNode in xmlElement["Files"].ChildNodes)
					if (xmlNode is XmlElement)
						projectDescriptor.files.Add (
							FileDescriptionTemplate.CreateTemplate ((XmlElement)xmlNode, baseDirectory));
			}

			if (xmlElement ["Resources"] != null) {
				foreach (XmlNode xmlNode in xmlElement["Resources"].ChildNodes) {
					if (xmlNode is XmlElement) {
						var fileTemplate = FileDescriptionTemplate.CreateTemplate ((XmlElement)xmlNode, baseDirectory);
						if (fileTemplate is SingleFileDescriptionTemplate)
							projectDescriptor.resources.Add ((SingleFileDescriptionTemplate)fileTemplate);
						else
							MessageService.ShowError (GettextCatalog.GetString ("Only single-file templates allowed to generate resource files"));
					}

				}
			}

			if (xmlElement ["References"] != null) {
				foreach (XmlNode xmlNode in xmlElement["References"].ChildNodes) {
					XmlElement elem = (XmlElement)xmlNode;
					var refType = elem.GetAttribute ("type");
					ProjectReference projectReference = new ProjectReference ((ReferenceType)Enum.Parse (typeof(ReferenceType), refType), elem.GetAttribute ("refto"));
					string specificVersion = elem.GetAttribute ("SpecificVersion");
					if (!string.IsNullOrEmpty (specificVersion))
						projectReference.SpecificVersion = bool.Parse (specificVersion);
					string localCopy = elem.GetAttribute ("LocalCopy");
					if (!string.IsNullOrEmpty (localCopy) && projectReference.CanSetLocalCopy)
						projectReference.LocalCopy = bool.Parse (localCopy);
					projectDescriptor.references.Add (projectReference);
				}
			}

			projectDescriptor.projectOptions = xmlElement ["Options"];
			if (projectDescriptor.projectOptions == null)
				projectDescriptor.projectOptions = xmlElement.OwnerDocument.CreateElement ("Options");

			return projectDescriptor;
		}
Пример #4
0
        public static ProjectDescriptor CreateProjectDescriptor(XmlElement xmlElement, FilePath baseDirectory)
        {
            ProjectDescriptor projectDescriptor = new ProjectDescriptor();

            projectDescriptor.name            = xmlElement.GetAttribute("name");
            projectDescriptor.directory       = xmlElement.GetAttribute("directory");
            projectDescriptor.createCondition = xmlElement.GetAttribute("if");

            projectDescriptor.type = xmlElement.GetAttribute("type");

            if (xmlElement ["Files"] != null)
            {
                foreach (XmlNode xmlNode in xmlElement["Files"].ChildNodes)
                {
                    if (xmlNode is XmlElement)
                    {
                        projectDescriptor.files.Add(
                            FileDescriptionTemplate.CreateTemplate((XmlElement)xmlNode, baseDirectory));
                    }
                }
            }

            if (xmlElement ["Resources"] != null)
            {
                foreach (XmlNode xmlNode in xmlElement["Resources"].ChildNodes)
                {
                    if (xmlNode is XmlElement)
                    {
                        var fileTemplate = FileDescriptionTemplate.CreateTemplate((XmlElement)xmlNode, baseDirectory);
                        if (fileTemplate is SingleFileDescriptionTemplate)
                        {
                            projectDescriptor.resources.Add((SingleFileDescriptionTemplate)fileTemplate);
                        }
                        else
                        {
                            MessageService.ShowError(GettextCatalog.GetString("Only single-file templates allowed to generate resource files"));
                        }
                    }
                }
            }

            if (xmlElement ["References"] != null)
            {
                foreach (XmlNode xmlNode in xmlElement["References"].ChildNodes)
                {
                    projectDescriptor.references.Add(new ProjectReferenceDescription((XmlElement)xmlNode));
                }
            }

            projectDescriptor.projectOptions = xmlElement ["Options"];
            if (projectDescriptor.projectOptions == null)
            {
                projectDescriptor.projectOptions = xmlElement.OwnerDocument.CreateElement("Options");
            }

            if (xmlElement ["Packages"] != null)
            {
                foreach (XmlNode xmlNode in xmlElement["Packages"].ChildNodes)
                {
                    if (xmlNode is XmlElement)
                    {
                        var packageReference = ProjectTemplatePackageReference.Create((XmlElement)xmlNode, baseDirectory);
                        projectDescriptor.packageReferences.Add(packageReference);
                    }
                }
            }

            return(projectDescriptor);
        }
Пример #5
0
        public static ProjectDescriptor CreateProjectDescriptor(XmlElement xmlElement, FilePath baseDirectory)
        {
            ProjectDescriptor projectDescriptor = new ProjectDescriptor();

            projectDescriptor.name = xmlElement.GetAttribute("name");

            projectDescriptor.type = xmlElement.GetAttribute("type");
            if (String.IsNullOrEmpty(projectDescriptor.type))
            {
                projectDescriptor.type = "DotNet";
            }

            if (xmlElement["Files"] != null)
            {
                foreach (XmlNode xmlNode in xmlElement["Files"].ChildNodes)
                {
                    if (xmlNode is XmlElement)
                    {
                        projectDescriptor.files.Add(
                            FileDescriptionTemplate.CreateTemplate((XmlElement)xmlNode, baseDirectory));
                    }
                }
            }

            if (xmlElement["Resources"] != null)
            {
                foreach (XmlNode xmlNode in xmlElement["Resources"].ChildNodes)
                {
                    if (xmlNode is XmlElement)
                    {
                        var fileTemplate = FileDescriptionTemplate.CreateTemplate((XmlElement)xmlNode, baseDirectory);
                        if (fileTemplate is SingleFileDescriptionTemplate)
                        {
                            projectDescriptor.resources.Add((SingleFileDescriptionTemplate)fileTemplate);
                        }
                        else
                        {
                            MessageService.ShowError(GettextCatalog.GetString("Only single-file templates allowed to generate resource files"));
                        }
                    }
                }
            }

            if (xmlElement["References"] != null)
            {
                foreach (XmlNode xmlNode in xmlElement["References"].ChildNodes)
                {
                    XmlElement       elem             = (XmlElement)xmlNode;
                    var              refType          = elem.GetAttribute("type");
                    ProjectReference projectReference = new ProjectReference((ReferenceType)Enum.Parse(typeof(ReferenceType), refType), elem.GetAttribute("refto"));
                    string           specificVersion  = elem.GetAttribute("SpecificVersion");
                    if (!string.IsNullOrEmpty(specificVersion))
                    {
                        projectReference.SpecificVersion = bool.Parse(specificVersion);
                    }
                    projectDescriptor.references.Add(projectReference);
                }
            }

            projectDescriptor.projectOptions = xmlElement["Options"];
            if (projectDescriptor.projectOptions == null)
            {
                projectDescriptor.projectOptions = xmlElement.OwnerDocument.CreateElement("Options");
            }

            return(projectDescriptor);
        }
Пример #6
0
        public void AddPackageReferenceForCreatedProject(Project project, ProjectDescriptor projectDescriptor)
        {
            var packageReference = new PackageReferencesForCreatedProject(project.Name, projectDescriptor.GetPackageReferences());

            packageReferencesForCreatedProjects.Add(packageReference);
        }
 public void AddPackageReferenceForCreatedProject(Project project, ProjectDescriptor projectDescriptor)
 {
     var packageReference = new PackageReferencesForCreatedProject (project.Name, projectDescriptor.GetPackageReferences ());
     packageReferencesForCreatedProjects.Add (packageReference);
 }