private void CreateAddIns()
		{
			// Create AddIn objects from *.addin files available in this assembly's output directory
			FakeAddInTree _addInTree = new FakeAddInTree();

			using (StreamReader streamReader = new StreamReader(@"TestResources\AddInManager2Test.addin"))
			{
				_addIn1 = AddIn.Load(_addInTree, streamReader);
			}
			
			using (StreamReader streamReader = new StreamReader(@"TestResources\AddInManager2Test_New.addin"))
			{
				_addIn1_new = AddIn.Load(_addInTree, streamReader);
			}
			
			using (StreamReader streamReader = new StreamReader(@"TestResources\AddInManager2Test_2.addin"))
			{
				_addIn2 = AddIn.Load(_addInTree, streamReader);
			}
			
			using (StreamReader streamReader = new StreamReader(@"TestResources\AddInManager2Test_2_New.addin"))
			{
				_addIn2_new = AddIn.Load(_addInTree, streamReader);
			}
			
			using (StreamReader streamReader = new StreamReader(@"TestResources\AddInManager2Test_noVersion.addin"))
			{
				_addIn_noVersion = AddIn.Load(_addInTree, streamReader);
			}
		}
Esempio n. 2
0
		void DoSetUp(XmlReader reader, string endElement, AddIn addIn)
		{
			Stack<ICondition> conditionStack = new Stack<ICondition>();
			List<Codon> innerCodons = new List<Codon>();
			while (reader.Read()) {
				switch (reader.NodeType) {
					case XmlNodeType.EndElement:
						if (reader.LocalName == "Condition" || reader.LocalName == "ComplexCondition") {
							conditionStack.Pop();
						} else if (reader.LocalName == endElement) {
							if (innerCodons.Count > 0)
								this.codons.Add(innerCodons);
							return;
						}
						break;
					case XmlNodeType.Element:
						string elementName = reader.LocalName;
						if (elementName == "Condition") {
							conditionStack.Push(Condition.Read(reader, addIn));
						} else if (elementName == "ComplexCondition") {
							conditionStack.Push(Condition.ReadComplexCondition(reader, addIn));
						} else {
							Codon newCodon = new Codon(this.AddIn, elementName, Properties.ReadFromAttributes(reader), conditionStack.ToArray());
							innerCodons.Add(newCodon);
							if (!reader.IsEmptyElement) {
								ExtensionPath subPath = this.AddIn.GetExtensionPath(this.Name + "/" + newCodon.Id);
								subPath.DoSetUp(reader, elementName, addIn);
							}
						}
						break;
				}
			}
			if (innerCodons.Count > 0)
				this.codons.Add(innerCodons);
		}
Esempio n. 3
0
		public Codon(AddIn addIn, string name, Properties properties, ICondition[] conditions)
		{
			this.addIn      = addIn;
			this.name       = name;
			this.properties = properties;
			this.conditions = conditions;
		}
 public DefaultOptionPanelDescriptor(string id, string label, AddIn addin, object owner, string optionPanelPath)
     : this(id, label)
 {
     this.addin = addin;
     this.owner = owner;
     this.optionPanelPath = optionPanelPath;
 }
Esempio n. 5
0
 public void CancelUpdate(ICSharpCode.Core.AddIn addIn)
 {
     if (CancelUpdateCallback != null)
     {
         CancelUpdateCallback(addIn);
     }
 }
Esempio n. 6
0
 public void CancelUninstallation(ICSharpCode.Core.AddIn addIn)
 {
     if (CancelUninstallationCallback != null)
     {
         CancelUninstallationCallback(addIn);
     }
 }
Esempio n. 7
0
 public void SwitchAddInActivation(ICSharpCode.Core.AddIn addIn)
 {
     if (SwitchAddInActivationCallback != null)
     {
         SwitchAddInActivationCallback(addIn);
     }
 }
Esempio n. 8
0
		public static ICondition ReadComplexCondition(XmlReader reader, AddIn addIn)
		{
			Properties properties = Properties.ReadFromAttributes(reader);
			reader.Read();
			ICondition condition = null;
			while (reader.Read()) {
				switch (reader.NodeType) {
					case XmlNodeType.Element:
						switch (reader.LocalName) {
							case "And":
								condition = AndCondition.Read(reader, addIn);
								goto exit;
							case "Or":
								condition = OrCondition.Read(reader, addIn);
								goto exit;
							case "Not":
								condition = NegatedCondition.Read(reader, addIn);
								goto exit;
							default:
								throw new AddInLoadException("Invalid element name '" + reader.LocalName
								                             + "', the first entry in a ComplexCondition " +
								                             "must be <And>, <Or> or <Not>");
						}
				}
			}
		exit:
			if (condition != null) {
				ConditionFailedAction action = properties.Get("action", ConditionFailedAction.Exclude);
				condition.Action = action;
			}
			return condition;
		}
Esempio n. 9
0
		public Condition(string name, Properties properties, AddIn addIn)
		{
			this.AddIn = addIn;
			this.name = name;
			this.properties = properties;
			action = properties.Get("action", ConditionFailedAction.Exclude);
		}
 public void AddToTree(ICSharpCode.Core.AddIn addIn)
 {
     if (addIn != null)
     {
         _registeredAddIns.Add(addIn);
     }
 }
Esempio n. 11
0
 public void UninstallAddIn(ICSharpCode.Core.AddIn addIn)
 {
     if (UninstallAddInCallback != null)
     {
         UninstallAddInCallback(addIn);
     }
 }
Esempio n. 12
0
 void GetExtensions(AddIn ai, TreeNode treeNode)
 {
     foreach (ExtensionPath ext in ai.Paths.Values) {
         string[] name = ext.Name.Split('/');
         TreeNode currentNode = treeNode;
         if (name.Length < 1) {
             continue;
         }
         for (int i = 1; i < name.Length; ++i) {
             bool found = false;
             foreach (TreeNode n in currentNode.Nodes) {
                 if (n.Text == name[i]) {
                     currentNode = n;
                     found = true;
                     break;
                 }
             }
             if (found) {
                 if (i == name.Length - 1 && currentNode.Tag == null)
                     currentNode.Tag = ext;
             } else {
                 TreeNode newNode = new TreeNode(name[i]);
                 newNode.ImageIndex = 3;
                 newNode.SelectedImageIndex = 4;
                 if (i == name.Length - 1) {
                     newNode.Tag = ext;
                 }
                 currentNode.Nodes.Add(newNode);
                 currentNode = newNode;
             }
         }
     }
 }
Esempio n. 13
0
		public LazyLoadDoozer(AddIn addIn, Properties properties)
		{
			this.addIn      = addIn;
			this.name       = properties["name"];
			this.className  = properties["class"];
			
		}
Esempio n. 14
0
		public LazyConditionEvaluator(AddIn addIn, Properties properties)
		{
			if (addIn == null)
				throw new ArgumentNullException("addIn");
			this.addIn      = addIn;
			this.name       = properties["name"];
			this.className  = properties["class"];
		}
Esempio n. 15
0
		/// <summary>
		/// Gets the codon with the specified extension path and name.
		/// </summary>
		public static Codon GetCodon(AddIn addin, string extensionPath, string name)
		{
			if (addin.Paths.ContainsKey(extensionPath)) {
				ExtensionPath path = addin.Paths[extensionPath];
				return GetCodon(path.Codons, name);
			}
			return null;
		}
Esempio n. 16
0
		/// <summary>
		/// Creates a new pad descriptor from the AddIn tree.
		/// </summary>
		public PadDescriptor(Codon codon)
		{
			addIn = codon.AddIn;
			shortcut = codon.Properties["shortcut"];
			category = codon.Properties["category"];
			icon = codon.Properties["icon"];
			title = codon.Properties["title"];
			@class = codon.Properties["class"];
		}
Esempio n. 17
0
        public ManagedAddIn(AddIn addIn)
        {
            if (addIn == null)
            {
                throw new ArgumentNullException("addIn");
            }

            _addIn = addIn;
            InstallationSource = AddInInstallationSource.Offline;
        }
Esempio n. 18
0
		public void AddToTree(AddIn addIn)
		{
			if (addIn != null)
			{
				SD.Log.DebugFormatted(
					"[AddInManager2.SD] Added {0} AddIn {1} to tree.", ((addIn.Action == AddInAction.Update) ? "updated" : "new"), addIn.Name);
				
				((AddInTreeImpl)SD.AddInTree).InsertAddIn(addIn);
			}
		}
Esempio n. 19
0
		public Codon(AddIn addIn, string name, Properties properties, IReadOnlyList<ICondition> conditions)
		{
			if (name == null)
				throw new ArgumentNullException("name");
			if (properties == null)
				throw new ArgumentNullException("properties");
			this.addIn      = addIn;
			this.name       = name;
			this.properties = properties;
			this.conditions = conditions;
		}
Esempio n. 20
0
 public NuGet.IPackage GetNuGetPackageForAddIn(ICSharpCode.Core.AddIn addIn, bool getLatest)
 {
     if (GetNuGetPackageForAddInCallback != null)
     {
         return(GetNuGetPackageForAddInCallback(addIn, getLatest));
     }
     else
     {
         return(null);
     }
 }
Esempio n. 21
0
        public PlugInProperties(AddIn addIn)
        {
            m_AddIn = addIn;

            InitializeComponent();
            treeView1.Nodes[0].Tag = new PiGeneral(addIn);

            Text = addIn.Name + " Properties";

            if (addIn.Properties["required"] == "true")
                button3.Enabled = false;
        }
Esempio n. 22
0
		void CodonLVSelectedIndexChanged(object sender, EventArgs e)
		{
			if (CodonLV.SelectedItems.Count != 1) {
				return;
			}
			Codon c = CodonLV.SelectedItems[0].Tag as Codon;
			if (c == null) {
				return;
			}
			
			CurrentAddIn = c.AddIn;
		}
Esempio n. 23
0
		private void Initialize(ManagedAddIn addIn)
		{
			_markedAddIn = addIn;
			if (_markedAddIn != null)
			{
				_addIn = addIn.AddIn;
			}
			if (_addIn != null)
			{
				UpdateMembers();
			}
		}
Esempio n. 24
0
 void GetExtensions(AddIn ai, TreeNode treeNode)
 {
     if (!ai.Enabled)
         return;
     foreach (ExtensionPath ext in ai.Paths.Values) {
         TreeNode newNode = new TreeNode(ext.Name);
         newNode.ImageIndex = 3;
         newNode.SelectedImageIndex = 4;
         newNode.Tag = ext;
         treeNode.Nodes.Add(newNode);
     }
 }
Esempio n. 25
0
		public void FixtureSetUp()
		{
			var addInTree = MockRepository.GenerateStub<IAddInTree>();
			addIn = AddIn.Load(addInTree, "CSharpBinding.addin");
			
			registeredIssueProviders = addIn.Paths["/SharpDevelop/ViewContent/TextEditor/C#/IssueProviders"].Codons
				.Select(c => FindType(c.Properties["class"])).Where(t => t != null).ToList();
			NRissueProviders = NRCSharpRefactoring.ExportedTypes.Where(t => t.GetCustomAttribute<IssueDescriptionAttribute>() != null).ToList();
			
			registeredContextActions = addIn.Paths["/SharpDevelop/ViewContent/TextEditor/C#/ContextActions"].Codons
				.Select(c => FindType(c.Properties["class"])).Where(t => t != null).ToList();
			NRcontextActions = NRCSharpRefactoring.ExportedTypes.Where(t => t.GetCustomAttribute<ContextActionAttribute>() != null).ToList();
		}
Esempio n. 26
0
        public IEnumerable <ManagedAddIn> GetDependentAddIns(ICSharpCode.Core.AddIn addIn)
        {
            if ((addIn != null) && (addIn.Manifest != null) && (addIn.Manifest.PrimaryIdentity != null))
            {
                // Get all AddIns which are dependent from given AddIn
                var dependentAddIns = AddInsWithMarkedForInstallation.Where(
                    a => (a.AddIn.Manifest != null) && a.AddIn.Manifest.Dependencies.Any(
                        reference => reference.Name == addIn.Manifest.PrimaryIdentity));
                return(dependentAddIns);
            }

            return(null);
        }
Esempio n. 27
0
 public bool IsAddInPreinstalled(ICSharpCode.Core.AddIn addIn)
 {
     if (addIn != null)
     {
         return
             (String.Equals(addIn.Properties["addInManagerHidden"], "preinstalled", StringComparison.OrdinalIgnoreCase) &&
              FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, addIn.FileName));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 28
0
		/// <summary>
		/// Creates a new pad descriptor from the AddIn tree.
		/// </summary>
		public PadDescriptor(Codon codon)
		{
			if (codon == null)
				throw new ArgumentNullException("codon");
			addIn = codon.AddIn;
			shortcut = codon.Properties["shortcut"];
			category = codon.Properties["category"];
			icon = codon.Properties["icon"];
			title = codon.Properties["title"];
			@class = codon.Properties["class"];
			if (!string.IsNullOrEmpty(codon.Properties["defaultPosition"])) {
				DefaultPosition = (DefaultPadPositions)Enum.Parse(typeof(DefaultPadPositions), codon.Properties["defaultPosition"]);
			}
		}
Esempio n. 29
0
        /// <summary>
        /// Creates a new pad descriptor from the AddIn tree.
        /// </summary>
        public PadDescriptor(Codon codon)
        {
            if(codon == null)
                throw new ArgumentNullException("codon");

            add_in = codon.AddIn;
            shortcut = codon.Properties["shortcut"];
            category = codon.Properties["category"];
            icon = codon.Properties["icon"];
            title = codon.Properties["title"];
            viewmodel_name = codon.Properties["viewModel"];
            template_name = codon.Properties["templateName"];
            if(!string.IsNullOrEmpty(codon.Properties["defaultPosition"]))
                DefaultPosition = (DefaultPadPositions)Enum.Parse(typeof(DefaultPadPositions), codon.Properties["defaultPosition"]);
        }
		public ProjectBindingDescriptor(Codon codon)
		{
			if (codon == null)
				throw new ArgumentNullException("codon");
			this.addIn = codon.AddIn;
			this.language = codon.Id;
			this.className = codon.Properties["class"];
			this.projectFileExtension = codon.Properties["projectfileextension"];
			if (string.IsNullOrEmpty(codon.Properties["supportedextensions"]))
				this.codeFileExtensions = new string[0];
			else
				this.codeFileExtensions = codon.Properties["supportedextensions"].ToLowerInvariant().Split(';');
			if (!string.IsNullOrEmpty(codon.Properties["guid"]))
				this.typeGuid = Guid.Parse(codon.Properties["guid"]);
		}
Esempio n. 31
0
		/// <summary>
		/// Creates a new pad descriptor from the AddIn tree.
		/// </summary>
		public PadDescriptor(Codon codon)
		{
			addIn = codon.AddIn;
			shortcut = codon.Properties["shortcut"];
			category = codon.Properties["category"];
			icon = codon.Properties["icon"];
			title = codon.Properties["title"];
			@class = codon.Properties["class"];
#if ModifiedForAltaxo
      // neccessary in order to load some pads on startup (such pads that are services, like the message output pad)
      string precreate = codon.Properties["precreated"];
      if (precreate != null && precreate.ToLower() == "true")
        CreatePad();
#endif
		}
Esempio n. 32
0
        public static bool IsPreinstalled(AddIn addIn)
        {
            if (addIn == null)
            {
                return false;
            }

            var isMarkedPreinstalled = string.Equals(
                addIn.Properties[LocalConstants.AddInProperties.AddInManagerHidden],
                "preinstalled",
                StringComparison.OrdinalIgnoreCase);

            return isMarkedPreinstalled
                && FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, addIn.FileName);
        }
Esempio n. 33
0
        public AddInControl(AddIn addIn)
        {
            this.addIn = addIn;
            this.BackColor = SystemColors.Window;
            this.ContextMenuStrip = MenuService.CreateContextMenu(this, "/AddIns/AddInManager/ContextMenu");

            isExternal = !FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, addIn.FileName)
                && !FileUtility.IsBaseDirectory(PropertyService.ConfigDirectory, addIn.FileName);

            this.ClientSize = new Size(100, isExternal ? 35 + pathHeight : 35);
            this.SetStyle(ControlStyles.Selectable, true);
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
        }
Esempio n. 34
0
		public AddInTreeSyntaxMode(ICSharpCode.Core.AddIn addin, string resourceName, string name, string[] extensions)
		{
			if (addin == null)
				throw new ArgumentNullException("addin");
			if (resourceName == null)
				throw new ArgumentNullException("resourceName");
			if (name == null)
				throw new ArgumentNullException("name");
			if (extensions == null)
				throw new ArgumentNullException("extensions");
			
			this.addin = addin;
			this.resourceName = resourceName;
			this.Name = name;
			this.Extensions = extensions;
		}
Esempio n. 35
0
		public InstallableAddIn(string fileName, bool isPackage)
		{
			this.fileName = fileName;
			this.isPackage = isPackage;
			if (isPackage) {
				ZipFile file = new ZipFile(fileName);
				try {
					LoadAddInFromZip(file);
				} finally {
					file.Close();
				}
			} else {
				addIn = AddIn.Load(fileName);
			}
			if (addIn.Manifest.PrimaryIdentity == null)
				throw new AddInLoadException(ResourceService.GetString("AddInManager.AddInMustHaveIdentity"));
		}
 public InstallableAddIn(string fileName, bool isPackage)
 {
     this.fileName = fileName;
     this.isPackage = isPackage;
     if (isPackage) {
         ZipFile file = new ZipFile(fileName);
         try {
             LoadAddInFromZip(file);
         } finally {
             file.Close();
         }
     } else {
         addIn = AddIn.Load(fileName);
     }
     if (addIn.Manifest.PrimaryIdentity == null)
         throw new AddInLoadException("The AddIn must have an <Identity> for use with the AddIn-Manager.");
 }
		public void ShowAddInDetails(AddIn ai)
		{
			addInLabel.Text = "AddIn : " + ai.Properties["name"];
			
			addInDetailsListView.Items.Clear();
			
			ListViewItem[] items = new ListViewItem[] {
				new ListViewItem(new string[] { "Author", ai.Properties["author"] }),
				new ListViewItem(new string[] { "Copyright", ai.Properties["copyright"]}),
				new ListViewItem(new string[] { "Description", ai.Properties["description"] }),
				new ListViewItem(new string[] { "FileName", ai.FileName}),
				new ListViewItem(new string[] { "Url", ai.Properties["url"]})
			};
			
			// set Filename & Url rows to 'weblink' style
			items[3].Font = items[4].Font = new Font(addInDetailsListView.Font, FontStyle.Underline);
			items[3].ForeColor = items[4].ForeColor = Color.Blue;
			addInDetailsListView.Items.AddRange(items);
			
			if (ai.Version != null)
				addInDetailsListView.Items.Add(new ListViewItem(new string[] { "Version", ai.Version.ToString()}));
			
			foreach (KeyValuePair<string, Version> entry in ai.Manifest.Identities) {
				ListViewItem newListViewItem = new ListViewItem("Identity");
				newListViewItem.SubItems.Add(entry.Key + " = " + entry.Value);
				addInDetailsListView.Items.Add(newListViewItem);
			}
			
			foreach (AddInReference entry in ai.Manifest.Conflicts) {
				ListViewItem newListViewItem = new ListViewItem("Conflict");
				newListViewItem.SubItems.Add(entry.ToString());
				addInDetailsListView.Items.Add(newListViewItem);
			}
			
			foreach (AddInReference entry in ai.Manifest.Dependencies) {
				ListViewItem newListViewItem = new ListViewItem("Dependency");
				newListViewItem.SubItems.Add(entry.ToString());
				addInDetailsListView.Items.Add(newListViewItem);
			}
			
			foreach (Runtime runtime in ai.Runtimes) {
				ListViewItem newListViewItem = new ListViewItem("Runtime Library");
				newListViewItem.SubItems.Add(runtime.Assembly);
				addInDetailsListView.Items.Add(newListViewItem);
			}
		}
Esempio n. 38
0
		static ICommand GetCommandFromStaticProperty(AddIn addIn, string commandName)
		{
			int pos = commandName.LastIndexOf('.');
			if (pos > 0) {
				string className = commandName.Substring(0, pos);
				string propertyName = commandName.Substring(pos + 1);
				Type classType = addIn.FindType(className);
				if (classType != null) {
					PropertyInfo p = classType.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Static);
					if (p != null)
						return (ICommand)p.GetValue(null, null);
					FieldInfo f = classType.GetField(propertyName, BindingFlags.Public | BindingFlags.Static);
					if (f != null)
						return (ICommand)f.GetValue(null);
				}
			}
			return null;
		}
Esempio n. 39
0
        public bool IsAddInInstalled(ICSharpCode.Core.AddIn addIn)
        {
            if (addIn == null)
            {
                // Without a valid AddIn instance we can't do anything...
                return(false);
            }

            string identity = null;

            if (addIn.Manifest != null)
            {
                identity = addIn.Manifest.PrimaryIdentity;
            }
            return(_sdAddInManagement.AddIns
                   .Where(a => (addIn == a) || ((identity != null) && (a.Manifest != null) && a.Manifest.Identities.ContainsKey(identity)))
                   .FirstOrDefault() != null);
        }
Esempio n. 40
0
        public int CompareAddInToPackageVersion(ICSharpCode.Core.AddIn addIn, NuGet.IPackage nuGetPackage)
        {
            if ((addIn == null) || (nuGetPackage == null))
            {
                // Consider this as equal (?)
                return(0);
            }

            // Look if AddIn has a NuGet version tag in manifest
            Version addInVersion = addIn.Version;

            if (addIn.Properties.Contains(ManagedAddIn.NuGetPackageVersionManifestAttribute))
            {
                try
                {
                    addInVersion = new Version(addIn.Properties[ManagedAddIn.NuGetPackageVersionManifestAttribute]);
                }
                catch (Exception)
                {
                    addInVersion = addIn.Version;
                }
            }

            if (addInVersion == null)
            {
                if (nuGetPackage == null)
                {
                    // Both versions are null -> equal
                    return(0);
                }
                else
                {
                    // Non-null version is greater
                    return(-1);
                }
            }

            return(addInVersion.CompareTo(nuGetPackage.Version.Version));
        }
Esempio n. 41
0
        public AddInTreeSyntaxMode(ICSharpCode.Core.AddIn addin, string resourceName, string name, string[] extensions)
        {
            if (addin == null)
            {
                throw new ArgumentNullException("addin");
            }
            if (resourceName == null)
            {
                throw new ArgumentNullException("resourceName");
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (extensions == null)
            {
                throw new ArgumentNullException("extensions");
            }

            this.addin        = addin;
            this.resourceName = resourceName;
            this.Name         = name;
            this.Extensions   = extensions;
        }
Esempio n. 42
0
 public static AddIn Load(System.IO.TextReader textReader)
 {
     return(AddIn.Load(textReader, null));
 }
Esempio n. 43
0
        private static void SetupAddIn(XmlReader reader, AddIn addIn, string hintPath)
        {
            while (reader.Read())
            {
                if ((reader.NodeType != XmlNodeType.Element) || !reader.IsStartElement())
                {
                    continue;
                }
                switch (reader.LocalName)
                {
                case "StringResources":
                case "BitmapResources":
                    if (reader.AttributeCount != 1)
                    {
                        throw new NotSupportedException("BitmapResources requires ONE attribute.");
                    }
                    break;

                case "Runtime":
                {
                    if (!reader.IsEmptyElement)
                    {
                        Runtime.ReadSection(reader, addIn, hintPath);
                    }
                    continue;
                }

                case "Include":
                    if (reader.AttributeCount != 1)
                    {
                        throw new NotSupportedException("Include requires ONE attribute.");
                    }
                    goto Label_0146;

                case "Path":
                    goto Label_01A3;

                case "Manifest":
                {
                    addIn.Manifest.ReadManifestSection(reader, hintPath);
                    continue;
                }

                default:
                    throw new NotSupportedException("Unknown root path node:" + reader.LocalName);
                }
                string item = StringParser.Parse(reader.GetAttribute("file"));
                if (reader.LocalName == "BitmapResources")
                {
                    addIn.BitmapResources.Add(item);
                }
                else
                {
                    addIn.StringResources.Add(item);
                }
                continue;
Label_0146:
                if (!reader.IsEmptyElement)
                {
                    throw new NotSupportedException("Include nodes must be empty!");
                }
                if (hintPath == null)
                {
                    throw new NotSupportedException("Cannot use include nodes when hintPath was not specified (e.g. when AddInManager reads a .addin file)!");
                }
                string            inputUri = Path.Combine(hintPath, reader.GetAttribute(0));
                XmlReaderSettings settings = new XmlReaderSettings
                {
                    ConformanceLevel = ConformanceLevel.Fragment
                };
                using (XmlReader reader2 = XmlReader.Create(inputUri, settings))
                {
                    SetupAddIn(reader2, addIn, Path.GetDirectoryName(inputUri));
                    continue;
                }
Label_01A3:
                if (reader.AttributeCount != 1)
                {
                    throw new NotSupportedException("Import node requires ONE attribute.");
                }
                string        attribute     = reader.GetAttribute(0);
                ExtensionPath extensionPath = addIn.GetExtensionPath(attribute);
                if (!reader.IsEmptyElement)
                {
                    ExtensionPath.SetUp(extensionPath, reader, "Path");
                }
            }
        }
Esempio n. 44
0
 public LazyConditionEvaluator(AddIn addIn, Properties properties)
 {
     this.addIn     = addIn;
     this.name      = properties["name"];
     this.className = properties["class"];
 }
Esempio n. 45
0
        static void SetupAddIn(XmlReader reader, AddIn addIn, string hintPath)
        {
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && reader.IsStartElement())
                {
                    switch (reader.LocalName)
                    {
                    case "StringResources":
                    case "BitmapResources":
                        if (reader.AttributeCount != 1)
                        {
                            throw new AddInLoadException("BitmapResources requires ONE attribute.");
                        }

                        string filename = StringParser.Parse(reader.GetAttribute("file"));

                        if (reader.LocalName == "BitmapResources")
                        {
                            addIn.BitmapResources.Add(filename);
                        }
                        else
                        {
                            addIn.StringResources.Add(filename);
                        }
                        break;

                    case "Runtime":
                        if (!reader.IsEmptyElement)
                        {
                            Runtime.ReadSection(reader, addIn, hintPath);
                        }
                        break;

                    case "Include":
                        if (reader.AttributeCount != 1)
                        {
                            throw new AddInLoadException("Include requires ONE attribute.");
                        }
                        if (!reader.IsEmptyElement)
                        {
                            throw new AddInLoadException("Include nodes must be empty!");
                        }
                        if (hintPath == null)
                        {
                            throw new AddInLoadException("Cannot use include nodes when hintPath was not specified (e.g. when AddInManager reads a .addin file)!");
                        }
                        string            fileName = Path.Combine(hintPath, reader.GetAttribute(0));
                        XmlReaderSettings xrs      = new XmlReaderSettings();
                        xrs.ConformanceLevel = ConformanceLevel.Fragment;
                        using (XmlReader includeReader = XmlTextReader.Create(fileName, xrs))
                        {
                            SetupAddIn(includeReader, addIn, Path.GetDirectoryName(fileName));
                        }
                        break;

                    case "Path":
                        if (reader.AttributeCount != 1)
                        {
                            throw new AddInLoadException("Import node requires ONE attribute.");
                        }
                        string        pathName      = reader.GetAttribute(0);
                        ExtensionPath extensionPath = addIn.GetExtensionPath(pathName);
                        if (!reader.IsEmptyElement)
                        {
                            ExtensionPath.SetUp(extensionPath, reader, "Path");
                        }
                        break;

                    case "Manifest":
                        addIn.Manifest.ReadManifestSection(reader, hintPath);
                        break;

                    default:
                        throw new AddInLoadException("Unknown root path node:" + reader.LocalName);
                    }
                }
            }
        }
 public LazyLoadDoozer(AddIn addIn, Properties properties)
 {
     this.addIn     = addIn;
     this.name      = properties["name"];
     this.className = properties["class"];
 }
Esempio n. 47
0
        public static void Load(System.Collections.Generic.List <string> addInFiles, List <string> disabledAddIns)
        {
            System.Collections.Generic.List <AddIn> list = new System.Collections.Generic.List <AddIn>();
            System.Collections.Generic.Dictionary <string, System.Version> dictionary  = new System.Collections.Generic.Dictionary <string, System.Version>();
            System.Collections.Generic.Dictionary <string, AddIn>          dictionary2 = new System.Collections.Generic.Dictionary <string, AddIn>();
            foreach (string current in addInFiles)
            {
                AddIn addIn;
                try
                {
                    addIn = AddIn.Load(current);
                }
                catch (System.Exception ex)
                {
                    addIn = new AddIn();
                    addIn.addInFileName      = current;
                    addIn.CustomErrorMessage = ex.Message;
                }
                if (addIn.Action == AddInAction.CustomError)
                {
                    list.Add(addIn);
                }
                else
                {
                    addIn.Enabled = true;
                    if (disabledAddIns != null && disabledAddIns.Count > 0)
                    {
                        foreach (string current2 in addIn.Manifest.Identities.Keys)
                        {
                            if (disabledAddIns.Contains(current2))
                            {
                                addIn.Enabled = false;
                                break;
                            }
                        }
                    }
                    if (addIn.Enabled)
                    {
                        foreach (System.Collections.Generic.KeyValuePair <string, System.Version> current3 in addIn.Manifest.Identities)
                        {
                            if (dictionary.ContainsKey(current3.Key))
                            {
                                addIn.Enabled = false;
                                addIn.Action  = AddInAction.InstalledTwice;
                                break;
                            }
                            dictionary.Add(current3.Key, current3.Value);
                            dictionary2.Add(current3.Key, addIn);
                        }
                    }
                    list.Add(addIn);
                }
            }
            while (true)
            {
IL_175:
                for (int i = 0; i < list.Count; i++)
                {
                    AddIn addIn2 = list[i];
                    if (addIn2.Enabled)
                    {
                        foreach (AddInReference current4 in addIn2.Manifest.Conflicts)
                        {
                            System.Version version;
                            if (current4.Check(dictionary, out version))
                            {
                                AddInTree.DisableAddin(addIn2, dictionary, dictionary2);
                                goto IL_175;
                            }
                        }
                        foreach (AddInReference current5 in addIn2.Manifest.Dependencies)
                        {
                            System.Version version;
                            if (!current5.Check(dictionary, out version))
                            {
                                AddInTree.DisableAddin(addIn2, dictionary, dictionary2);
                                goto IL_175;
                            }
                        }
                    }
                }
                break;
            }
            foreach (AddIn current6 in list)
            {
                try
                {
                    AddInTree.InsertAddIn(current6);
                }
                catch (System.Exception ex2)
                {
                    MessageBox.Show(ex2.Message);
                }
            }
        }
Esempio n. 48
0
        /// <summary>
        /// Loads a list of .addin files, ensuring that dependencies are satisfied.
        /// This method is normally called by <see cref="CoreStartup.RunInitialization"/>.
        /// </summary>
        /// <param name="addInFiles">
        /// The list of .addin file names to load.
        /// </param>
        /// <param name="disabledAddIns">
        /// The list of disabled AddIn identity names.
        /// </param>
        public static void Load(List <string> addInFiles, List <string> disabledAddIns)
        {
            List <AddIn> list = new List <AddIn>();
            Dictionary <string, Version> dict      = new Dictionary <string, Version>();
            Dictionary <string, AddIn>   addInDict = new Dictionary <string, AddIn>();
            var nameTable = new System.Xml.NameTable();

            foreach (string fileName in addInFiles)
            {
                AddIn addIn;
                try {
                    addIn = AddIn.Load(fileName, nameTable);
                } catch (AddInLoadException ex) {
                    LoggingService.Error(ex);
                    if (ex.InnerException != null)
                    {
                        MessageService.ShowError("Error loading AddIn " + fileName + ":\n"
                                                 + ex.InnerException.Message);
                    }
                    else
                    {
                        MessageService.ShowError("Error loading AddIn " + fileName + ":\n"
                                                 + ex.Message);
                    }
                    addIn = new AddIn();
                    addIn.addInFileName      = fileName;
                    addIn.CustomErrorMessage = ex.Message;
                }
                if (addIn.Action == AddInAction.CustomError)
                {
                    list.Add(addIn);
                    continue;
                }
                addIn.Enabled = true;
                if (disabledAddIns != null && disabledAddIns.Count > 0)
                {
                    foreach (string name in addIn.Manifest.Identities.Keys)
                    {
                        if (disabledAddIns.Contains(name))
                        {
                            addIn.Enabled = false;
                            break;
                        }
                    }
                }
                if (addIn.Enabled)
                {
                    foreach (KeyValuePair <string, Version> pair in addIn.Manifest.Identities)
                    {
                        if (dict.ContainsKey(pair.Key))
                        {
                            MessageService.ShowError("Name '" + pair.Key + "' is used by " +
                                                     "'" + addInDict[pair.Key].FileName + "' and '" + fileName + "'");
                            addIn.Enabled = false;
                            addIn.Action  = AddInAction.InstalledTwice;
                            break;
                        }
                        else
                        {
                            dict.Add(pair.Key, pair.Value);
                            addInDict.Add(pair.Key, addIn);
                        }
                    }
                }
                list.Add(addIn);
            }
checkDependencies:
            for (int i = 0; i < list.Count; i++)
            {
                AddIn addIn = list[i];
                if (!addIn.Enabled)
                {
                    continue;
                }

                Version versionFound;

                foreach (AddInReference reference in addIn.Manifest.Conflicts)
                {
                    if (reference.Check(dict, out versionFound))
                    {
                        MessageService.ShowError(addIn.Name + " conflicts with " + reference.ToString()
                                                 + " and has been disabled.");
                        DisableAddin(addIn, dict, addInDict);
                        goto checkDependencies;                         // after removing one addin, others could break
                    }
                }
                foreach (AddInReference reference in addIn.Manifest.Dependencies)
                {
                    if (!reference.Check(dict, out versionFound))
                    {
                        if (versionFound != null)
                        {
                            MessageService.ShowError(addIn.Name + " has not been loaded because it requires "
                                                     + reference.ToString() + ", but version "
                                                     + versionFound.ToString() + " is installed.");
                        }
                        else
                        {
                            MessageService.ShowError(addIn.Name + " has not been loaded because it requires "
                                                     + reference.ToString() + ".");
                        }
                        DisableAddin(addIn, dict, addInDict);
                        goto checkDependencies;                         // after removing one addin, others could break
                    }
                }
            }
            foreach (AddIn addIn in list)
            {
                try {
                    InsertAddIn(addIn);
                } catch (AddInLoadException ex) {
                    LoggingService.Error(ex);
                    MessageService.ShowError("Error loading AddIn " + addIn.FileName + ":\n"
                                             + ex.Message);
                }
            }
        }