Exemple #1
0
 void AddReferenceIfNotExists(string name, string requiredTargetFramework)
 {
     if (!(Project.GetItemsOfType(ItemType.Reference).Any(r => string.Equals(r.Include, name, StringComparison.OrdinalIgnoreCase))))
     {
         ReferenceProjectItem rpi = new ReferenceProjectItem(Project, name);
         if (requiredTargetFramework != null)
         {
             rpi.SetMetadata("RequiredTargetFramework", requiredTargetFramework);
         }
         ProjectService.AddProjectItem(Project, rpi);
     }
 }
Exemple #2
0
        protected internal virtual void AddDotnet35References()
        {
            ReferenceProjectItem rpi = new ReferenceProjectItem(this, "System.Core");

            rpi.SetMetadata("RequiredTargetFramework", "3.5");
            ProjectService.AddProjectItem(this, rpi);

            if (GetItemsOfType(ItemType.Reference).Any(r => r.Include == "System.Data"))
            {
                rpi = new ReferenceProjectItem(this, "System.Data.DataSetExtensions");
                rpi.SetMetadata("RequiredTargetFramework", "3.5");
                ProjectService.AddProjectItem(this, rpi);
            }
            if (GetItemsOfType(ItemType.Reference).Any(r => r.Include == "System.Xml"))
            {
                rpi = new ReferenceProjectItem(this, "System.Xml.Linq");
                rpi.SetMetadata("RequiredTargetFramework", "3.5");
                ProjectService.AddProjectItem(this, rpi);
            }
        }
		ReferenceProjectItem CreateIronPythonReference(IProject project)
		{
			ReferenceProjectItem reference = new ReferenceProjectItem(project, "IronPython");
			reference.SetMetadata("HintPath", @"$(PythonBinPath)\IronPython.dll");
			return reference;
		}
		public FileTemplateImpl(XmlDocument doc, IReadOnlyFileSystem fileSystem)
		{
			author = doc.DocumentElement.GetAttribute("author");
			
			XmlElement config = doc.DocumentElement["Config"];
			name         = config.GetAttribute("name");
			icon         = SD.ResourceService.GetImage(config.GetAttribute("icon"));
			category     = config.GetAttribute("category");
			defaultName  = config.GetAttribute("defaultname");
			languagename = config.GetAttribute("language");
			
			if (config.HasAttribute("subcategory")) {
				subcategory = config.GetAttribute("subcategory");
			}

			string newFileDialogVisibleAttr  = config.GetAttribute("newfiledialogvisible");
			if (newFileDialogVisibleAttr != null && newFileDialogVisibleAttr.Length != 0) {
				if (newFileDialogVisibleAttr.Equals("false", StringComparison.OrdinalIgnoreCase))
					newFileDialogVisible = false;
			}

			if (doc.DocumentElement["Description"] != null) {
				description  = doc.DocumentElement["Description"].InnerText;
			}
			
			if (config["Wizard"] != null) {
				wizardpath = config["Wizard"].Attributes["path"].InnerText;
			}
			
			if (doc.DocumentElement["Properties"] != null) {
				XmlNodeList propertyList = doc.DocumentElement["Properties"].SelectNodes("Property");
				foreach (XmlElement propertyElement in propertyList) {
					properties.Add(new TemplateProperty(propertyElement));
				}
			}
			
			if (doc.DocumentElement["Types"] != null) {
				XmlNodeList typeList = doc.DocumentElement["Types"].SelectNodes("Type");
				foreach (XmlElement typeElement in typeList) {
					customTypes.Add(new TemplateType(typeElement));
				}
			}
			
			if (doc.DocumentElement["References"] != null) {
				XmlNodeList references = doc.DocumentElement["References"].SelectNodes("Reference");
				foreach (XmlElement reference in references) {
					if (!reference.HasAttribute("include"))
						throw new InvalidDataException("Reference without 'include' attribute!");
					ReferenceProjectItem item = new ReferenceProjectItem(null, reference.GetAttribute("include"));
					item.SetMetadata("HintPath", reference.GetAttribute("hintPath"));
					var requiredTargetFramework = reference.GetElementsByTagName("RequiredTargetFramework").OfType<XmlElement>().FirstOrDefault();
					if (requiredTargetFramework != null) {
						item.SetMetadata("RequiredTargetFramework", requiredTargetFramework.Value);
					}
					requiredAssemblyReferences.Add(item);
				}
			}
			
			if (doc.DocumentElement["Actions"] != null) {
				foreach (XmlElement el in doc.DocumentElement["Actions"]) {
					Action<FileTemplateResult> action = ReadAction(el);
					if (action != null)
						actions += action;
				}
			}
			
			fileoptions = doc.DocumentElement["AdditionalOptions"];
			
			// load the files
			XmlElement files  = doc.DocumentElement["Files"];
			XmlNodeList nodes = files.ChildNodes;
			foreach (XmlNode filenode in nodes) {
				if (filenode is XmlElement) {
					this.files.Add(new FileDescriptionTemplate((XmlElement)filenode, fileSystem));
				}
			}
		}
		public void AddReference()
		{
			foreach (ListViewItem item in listView.SelectedItems) {
				string include = chooseSpecificVersionCheckBox.Checked ? item.Tag.ToString() : item.Text;
				ReferenceProjectItem rpi = new ReferenceProjectItem(selectDialog.ConfigureProject, include);
				string requiredFrameworkVersion;
				if (chooseSpecificVersionCheckBox.Checked) {
					if (KnownFrameworkAssemblies.TryGetRequiredFrameworkVersion(item.Tag.ToString(), out requiredFrameworkVersion)) {
						rpi.SetMetadata("RequiredTargetFramework", requiredFrameworkVersion);
					}
				} else {
					// find the lowest version of the assembly and use its RequiredTargetFramework
					ListViewItem lowestVersion = item;
					foreach (ListViewItem item2 in fullItemList) {
						if (item2.Text == item.Text) {
							if (new Version(item2.SubItems[1].Text) < ((DomAssemblyName)lowestVersion.Tag).Version) {
								lowestVersion = item2;
							}
						}
					}
					if (KnownFrameworkAssemblies.TryGetRequiredFrameworkVersion(lowestVersion.Tag.ToString(), out requiredFrameworkVersion)) {
						rpi.SetMetadata("RequiredTargetFramework", requiredFrameworkVersion);
					}
				}
				selectDialog.AddReference(
					item.Text, "Gac", rpi.Include,
					rpi
				);
			}
		}
Exemple #6
0
		void AddReferenceIfNotExists(string name, string requiredTargetFramework)
		{
			if (!(Project.GetItemsOfType(ItemType.Reference).Any(r => string.Equals(r.Include, name, StringComparison.OrdinalIgnoreCase)))) {
				ReferenceProjectItem rpi = new ReferenceProjectItem(Project, name);
				if (requiredTargetFramework != null)
					rpi.SetMetadata("RequiredTargetFramework", requiredTargetFramework);
				ProjectService.AddProjectItem(Project, rpi);
			}
		}
		protected internal virtual void AddDotnet35References()
		{
			ReferenceProjectItem rpi = new ReferenceProjectItem(this, "System.Core");
			rpi.SetMetadata("RequiredTargetFramework", "3.5");
			ProjectService.AddProjectItem(this, rpi);
			
			if (GetItemsOfType(ItemType.Reference).Any(r => r.Include == "System.Data")) {
				rpi = new ReferenceProjectItem(this, "System.Data.DataSetExtensions");
				rpi.SetMetadata("RequiredTargetFramework", "3.5");
				ProjectService.AddProjectItem(this, rpi);
			}
			if (GetItemsOfType(ItemType.Reference).Any(r => r.Include == "System.Xml")) {
				rpi = new ReferenceProjectItem(this, "System.Xml.Linq");
				rpi.SetMetadata("RequiredTargetFramework", "3.5");
				ProjectService.AddProjectItem(this, rpi);
			}
		}
		public FileTemplate(string filename)
		{
			XmlDocument doc = new XmlDocument();
			doc.Load(filename);
			
			author = doc.DocumentElement.GetAttribute("author");
			
			XmlElement config = doc.DocumentElement["Config"];
			name         = config.GetAttribute("name");
			icon         = config.GetAttribute("icon");
			category     = config.GetAttribute("category");
			defaultName  = config.GetAttribute("defaultname");
			languagename = config.GetAttribute("language");
			
			if (config.HasAttribute("subcategory")) {
				subcategory = config.GetAttribute("subcategory");
			}

			string newFileDialogVisibleAttr  = config.GetAttribute("newfiledialogvisible");
			if (newFileDialogVisibleAttr != null && newFileDialogVisibleAttr.Length != 0) {
				if (newFileDialogVisibleAttr.Equals("false", StringComparison.OrdinalIgnoreCase))
					newFileDialogVisible = false;
			}

			if (doc.DocumentElement["Description"] != null) {
				description  = doc.DocumentElement["Description"].InnerText;
			}
			
			if (config["Wizard"] != null) {
				wizardpath = config["Wizard"].Attributes["path"].InnerText;
			}
			
			if (doc.DocumentElement["Properties"] != null) {
				XmlNodeList propertyList = doc.DocumentElement["Properties"].SelectNodes("Property");
				foreach (XmlElement propertyElement in propertyList) {
					properties.Add(new TemplateProperty(propertyElement));
				}
			}
			
			if (doc.DocumentElement["Types"] != null) {
				XmlNodeList typeList = doc.DocumentElement["Types"].SelectNodes("Type");
				foreach (XmlElement typeElement in typeList) {
					customTypes.Add(new TemplateType(typeElement));
				}
			}
			
			if (doc.DocumentElement["References"] != null) {
				XmlNodeList references = doc.DocumentElement["References"].SelectNodes("Reference");
				foreach (XmlElement reference in references) {
					if (!reference.HasAttribute("include"))
						throw new InvalidDataException("Reference without 'include' attribute!");
					ReferenceProjectItem item = new ReferenceProjectItem(null, reference.GetAttribute("include"));
					item.SetMetadata("HintPath", reference.GetAttribute("hintPath"));
					requiredAssemblyReferences.Add(item);
				}
			}
			
			fileoptions = doc.DocumentElement["AdditionalOptions"];
			
			doc.DocumentElement.SetAttribute("fileName", filename); // used for template loading warnings
			
			// load the files
			XmlElement files  = doc.DocumentElement["Files"];
			XmlNodeList nodes = files.ChildNodes;
			foreach (XmlNode filenode in nodes) {
				if (filenode is XmlElement) {
					this.files.Add(new FileDescriptionTemplate((XmlElement)filenode, Path.GetDirectoryName(filename)));
				}
			}
		}