Ejemplo n.º 1
0
 public void RegisterExtension(AddinDescription description, ModuleDescription module, Extension extension)
 {
     if (extension.Path.StartsWith("$"))
     {
         string[] objectTypes = extension.Path.Substring(1).Split(',');
         bool     found       = false;
         foreach (string s in objectTypes)
         {
             ArrayList list = (ArrayList)objectTypeExtensions [s];
             if (list != null)
             {
                 found = true;
                 foreach (ExtensionPoint ep in list)
                 {
                     if (IsAddinCompatible(ep.ParentAddinDescription, description, module))
                     {
                         extension.Path = ep.Path;
                         RegisterExtension(description, module, ep.Path);
                     }
                 }
             }
         }
         if (!found)
         {
             monitor.ReportWarning("The add-in '" + description.AddinId + "' is trying to register the class '" + extension.Path.Substring(1) + "', but there isn't any add-in defining a suitable extension point");
         }
     }
 }
Ejemplo n.º 2
0
 public void RegisterExtension(AddinDescription description, ModuleDescription module, Extension extension)
 {
     if (extension.Path.StartsWith("$"))
     {
         string[] objectTypes = extension.Path.Substring(1).Split(',');
         bool     found       = false;
         foreach (string s in objectTypes)
         {
             List <ExtensionPoint> list;
             if (objectTypeExtensions.TryGetValue(s, out list))
             {
                 found = true;
                 foreach (ExtensionPoint ep in list)
                 {
                     if (IsAddinCompatible(ep.ParentAddinDescription, description, module))
                     {
                         extension.Path = ep.Path;
                         RegisterExtension(description, module, ep.Path);
                     }
                 }
             }
         }
         if (!found)
         {
             monitor.ReportWarning("The add-in '" + description.AddinId + "' is trying to register the class '" + extension.Path.Substring(1) + "', but there isn't any add-in defining a suitable extension point");
         }
     }
     else if (extension.Path.StartsWith("%", StringComparison.Ordinal))
     {
         string[] objectTypes = extension.Path.Substring(1).Split(',');
         bool     found       = false;
         foreach (string s in objectTypes)
         {
             List <ExtensionNodeType> list;
             if (customAttributeTypeExtensions.TryGetValue(s, out list))
             {
                 found = true;
                 foreach (ExtensionNodeType nt in list)
                 {
                     ExtensionPoint ep = (ExtensionPoint)((ExtensionNodeSet)nt.Parent).Parent;
                     if (IsAddinCompatible(ep.ParentAddinDescription, description, module))
                     {
                         extension.Path = ep.Path;
                         foreach (ExtensionNodeDescription node in GetNodesIgnoringConditions(extension))
                         {
                             node.NodeName = nt.NodeName;
                         }
                         RegisterExtension(description, module, ep.Path);
                     }
                 }
             }
         }
         if (!found)
         {
             monitor.ReportWarning("The add-in '" + description.AddinId + "' is trying to register the class '" + extension.Path.Substring(1) + "', but there isn't any add-in defining a suitable extension point");
         }
     }
 }
Ejemplo n.º 3
0
        void ReportReflectionException(IProgressStatus monitor, Exception ex, AddinDescription config, AddinScanResult scanResult)
        {
            scanResult.AddFileToWithFailure(config.AddinFile);
            monitor.ReportWarning("[" + config.AddinId + "] Could not load some add-in assemblies: " + ex.Message);
            if (monitor.LogLevel <= 1)
            {
                return;
            }

            ReflectionTypeLoadException rex = ex as ReflectionTypeLoadException;

            if (rex != null)
            {
                foreach (Exception e in rex.LoaderExceptions)
                {
                    monitor.Log("Load exception: " + e);
                }
            }
        }
Ejemplo n.º 4
0
 public void ReportWarning(string message)
 {
     local.ReportWarning(message);
 }
Ejemplo n.º 5
0
        void ReportReflectionException(IProgressStatus monitor, Exception ex, AddinDescription config, AddinScanResult scanResult)
        {
            scanResult.AddFileToWithFailure (config.AddinFile);
            monitor.ReportWarning ("[" + config.AddinId + "] Could not load some add-in assemblies: " + ex.Message);
            if (monitor.LogLevel <= 1)
                return;

            ReflectionTypeLoadException rex = ex as ReflectionTypeLoadException;
            if (rex != null) {
                foreach (Exception e in rex.LoaderExceptions)
                    monitor.Log ("Load exception: " + e);
            }
        }
Ejemplo n.º 6
0
        void CollectExtensionData(IProgressStatus monitor, AddinIndex addinHash, AddinDescription conf, AddinUpdateData updateData)
        {
            IEnumerable<string> missingDeps = addinHash.GetMissingDependencies (conf, conf.MainModule);
            if (missingDeps.Any ()) {
                string w = "The add-in '" + conf.AddinId + "' could not be updated because some of its dependencies are missing or not compatible:";
                w += BuildMissingAddinsList (addinHash, conf, missingDeps);
                monitor.ReportWarning (w);
                return;
            }

            CollectModuleExtensionData (conf, conf.MainModule, updateData, addinHash);

            foreach (ModuleDescription module in conf.OptionalModules) {
                missingDeps = addinHash.GetMissingDependencies (conf, module);
                if (missingDeps.Any ()) {
                    if (monitor.LogLevel > 1) {
                        string w = "An optional module of the add-in '" + conf.AddinId + "' could not be updated because some of its dependencies are missing or not compatible:";
                        w += BuildMissingAddinsList (addinHash, conf, missingDeps);
                    }
                }
                else
                    CollectModuleExtensionData (conf, module, updateData, addinHash);
            }
        }
Ejemplo n.º 7
0
        void RunScannerProcess(IProgressStatus monitor)
        {
            ISetupHandler setup = GetSetupHandler ();

            IProgressStatus scanMonitor = monitor;
            ArrayList pparams = new ArrayList ();

            bool retry = false;
            do {
                try {
                    if (monitor.LogLevel > 1)
                        monitor.Log ("Looking for addins");
                    setup.Scan (scanMonitor, registry, null, (string[]) pparams.ToArray (typeof(string)));
                    retry = false;
                }
                catch (Exception ex) {
                    ProcessFailedException pex = ex as ProcessFailedException;
                    if (pex != null) {
                        // Get the last logged operation.
                        if (pex.LastLog.StartsWith ("scan:")) {
                            // It crashed while scanning a file. Add the file to the ignore list and try again.
                            string file = pex.LastLog.Substring (5);
                            pparams.Add (file);
                            monitor.ReportWarning ("Could not scan file: " + file);
                            retry = true;
                            continue;
                        }
                    }
                    fatalDatabseError = true;
                    // If the process has crashed, try to do a new scan, this time using verbose log,
                    // to give the user more information about the origin of the crash.
                    if (pex != null && !retry) {
                        monitor.ReportError ("Add-in scan operation failed. The runtime may have encountered an error while trying to load an assembly.", null);
                        if (monitor.LogLevel <= 1) {
                            // Re-scan again using verbose log, to make it easy to find the origin of the error.
                            retry = true;
                            scanMonitor = new ConsoleProgressStatus (true);
                        }
                    } else
                        retry = false;

                    if (!retry) {
                        var pfex = ex as ProcessFailedException;
                        monitor.ReportError ("Add-in scan operation failed", pfex != null? pfex.InnerException : ex);
                        monitor.Cancel ();
                        return;
                    }
                }
            }
            while (retry);
        }
Ejemplo n.º 8
0
        public void ResolveExtensions(IProgressStatus monitor, Hashtable descriptions)
        {
            // Make a copy of the extensions found, sice the hash may change while being scanned
            object[] extensionPointsFound = new object [pathHash.Count];
            pathHash.Values.CopyTo(extensionPointsFound, 0);

            foreach (object ob in extensionPointsFound)
            {
                ExtensionPoint ep = ob as ExtensionPoint;

                if (ep == null)
                {
                    // It is a list of extension from a root add-in
                    ArrayList rootExtensionPoints = (ArrayList)ob;
                    foreach (RootExtensionPoint rep in rootExtensionPoints)
                    {
                        foreach (ExtensionNodeType nt in rep.ExtensionPoint.NodeSet.NodeTypes)
                        {
                            if (nt.ObjectTypeName.Length > 0)
                            {
                                CollectObjectTypeExtensions(rep.Description, rep.ExtensionPoint, nt.ObjectTypeName);
                            }
                        }
                    }
                    continue;
                }

                if (ep.RootAddin == null)
                {
                    // Ignore class extensions
                    if (!ep.Path.StartsWith("$"))
                    {
                        // No add-in has defined this extension point, but some add-in
                        // is trying to extend it. A parent extension may exist. Check it now.
                        ExtensionPoint pep = GetParentExtensionPoint(ep.Path);
                        if (pep != null)
                        {
                            foreach (string a in ep.Addins)
                            {
                                if (!pep.Addins.Contains(a))
                                {
                                    pep.Addins.Add(a);
                                }
                            }
                        }
                        else
                        {
                            foreach (string s in ep.Addins)
                            {
                                monitor.ReportWarning("The add-in '" + s + "' is trying to extend '" + ep.Path + "', but there isn't any add-in defining this extension point");
                            }
                        }
                    }
                    pathHash.Remove(ep.Path);
                }
                else
                {
                    foreach (ExtensionNodeType nt in ep.NodeSet.NodeTypes)
                    {
                        if (nt.ObjectTypeName.Length > 0)
                        {
                            AddinDescription desc = (AddinDescription)descriptions [ep.RootAddin];
                            CollectObjectTypeExtensions(desc, ep, nt.ObjectTypeName);
                        }
                    }
                }
            }

            foreach (ArrayList list in objectTypeExtensions.Values)
            {
                foreach (UnresolvedObjectTypeExtension data in list)
                {
                    if (!data.FoundExtensionPoint)
                    {
                        monitor.ReportWarning("The add-in '" + data.Description.AddinId + "' is trying to register the class '" + data.Extension.Path + "', but there isn't any add-in defining a suitable extension point");
                        // The type extensions may be registered using different base classes.
                        // Make sure the warning is shown only once
                        data.FoundExtensionPoint = true;
                    }
                }
            }
        }
Ejemplo n.º 9
0
		public static void MonitorProcessStatus (IProgressStatus monitor, TextReader reader, StringCollection progessLog)
		{
			string line;
			string exceptionText = null;
			while ((line = reader.ReadLine ()) != null) {
				int i = line.IndexOf (':');
				if (i != -1) {
					string tag = line.Substring (0, i);
					string txt = line.Substring (i+1);
					bool wasTag = true;
					
					switch (tag) {
						case "process-ps-msg":
							monitor.SetMessage (Decode (txt));
							break;
						case "process-ps-progress":
							monitor.SetProgress (double.Parse (txt));
							break;
						case "process-ps-log":
							monitor.Log (Decode (txt));
							break;
						case "process-ps-warning":
							monitor.ReportWarning (Decode (txt));
							break;
						case "process-ps-exception":
							exceptionText = Decode (txt);
							if (exceptionText == string.Empty)
								exceptionText = null;
							break;
						case "process-ps-error":
							string err = Decode (txt);
							if (err == string.Empty) err = null;
							monitor.ReportError (err, exceptionText != null ? new Exception (exceptionText) : null);
							break;
						case "process-ps-cancel":
							monitor.Cancel ();
							break;
						case "process-ps-plog":
							progessLog.Add (Decode (txt));
							break;
						default:
							wasTag = false;
							break;
					}
					if (wasTag)
						continue;
				}
				Console.WriteLine (line);
			}
		}
 public void ReportWarning(string message)
 {
     status.ReportWarning(message);
 }
Ejemplo n.º 11
0
        public static void MonitorProcessStatus(IProgressStatus monitor, TextReader reader, StringCollection progessLog)
        {
            string line;
            string exceptionText = null;

            while ((line = reader.ReadLine()) != null)
            {
                int i = line.IndexOf(':');
                if (i != -1)
                {
                    string tag    = line.Substring(0, i);
                    string txt    = line.Substring(i + 1);
                    bool   wasTag = true;

                    switch (tag)
                    {
                    case "process-ps-msg":
                        monitor.SetMessage(Decode(txt));
                        break;

                    case "process-ps-progress":
                        monitor.SetProgress(double.Parse(txt));
                        break;

                    case "process-ps-log":
                        monitor.Log(Decode(txt));
                        break;

                    case "process-ps-warning":
                        monitor.ReportWarning(Decode(txt));
                        break;

                    case "process-ps-exception":
                        exceptionText = Decode(txt);
                        if (exceptionText == string.Empty)
                        {
                            exceptionText = null;
                        }
                        break;

                    case "process-ps-error":
                        string err = Decode(txt);
                        if (err == string.Empty)
                        {
                            err = null;
                        }
                        monitor.ReportError(err, exceptionText != null ? new Exception(exceptionText) : null);
                        break;

                    case "process-ps-cancel":
                        monitor.Cancel();
                        break;

                    case "process-ps-plog":
                        progessLog.Add(Decode(txt));
                        break;

                    default:
                        wasTag = false;
                        break;
                    }
                    if (wasTag)
                    {
                        continue;
                    }
                }
                Console.WriteLine(line);
            }
        }
		public void ResolveExtensions (IProgressStatus monitor, Hashtable descriptions)
		{
			// Make a copy of the extensions found, sice the hash may change while being scanned
			object[] extensionPointsFound = new object [pathHash.Count];
			pathHash.Values.CopyTo (extensionPointsFound, 0);

			foreach (object ob in extensionPointsFound) {
				ExtensionPoint ep = ob as ExtensionPoint;
				
				if (ep == null) {
					// It is a list of extension from a root add-in
					ArrayList rootExtensionPoints = (ArrayList) ob;
					foreach (RootExtensionPoint rep in rootExtensionPoints) {
						foreach (ExtensionNodeType nt in rep.ExtensionPoint.NodeSet.NodeTypes) {
							if (nt.ObjectTypeName.Length > 0)
								CollectObjectTypeExtensions (rep.Description, rep.ExtensionPoint, nt.ObjectTypeName);
						}
					}
					continue;
				}
				
				if (ep.RootAddin == null) {
					// Ignore class extensions
					if (!ep.Path.StartsWith ("$")) {
						// No add-in has defined this extension point, but some add-in
						// is trying to extend it. A parent extension may exist. Check it now.
						ExtensionPoint pep = GetParentExtensionPoint (ep.Path);
						if (pep != null) {
							foreach (string a in ep.Addins)
								if (!pep.Addins.Contains (a))
									pep.Addins.Add (a);
						} else {
							foreach (string s in ep.Addins)
								monitor.ReportWarning ("The add-in '" + s + "' is trying to extend '" + ep.Path + "', but there isn't any add-in defining this extension point");
						}
					}
					pathHash.Remove (ep.Path);
				}
				else {
					foreach (ExtensionNodeType nt in ep.NodeSet.NodeTypes) {
						if (nt.ObjectTypeName.Length > 0) {
							AddinDescription desc = (AddinDescription) descriptions [ep.RootAddin];
							CollectObjectTypeExtensions (desc, ep, nt.ObjectTypeName);
						}
					}
				}
			}
			
			foreach (ArrayList list in objectTypeExtensions.Values) {
				foreach (UnresolvedObjectTypeExtension data in list) {
					if (!data.FoundExtensionPoint) {
						monitor.ReportWarning ("The add-in '" + data.Description.AddinId + "' is trying to register the class '" + data.Extension.Path + "', but there isn't any add-in defining a suitable extension point");
						// The type extensions may be registered using different base classes.
						// Make sure the warning is shown only once
						data.FoundExtensionPoint = true;
					}
				}
			}
		}
Ejemplo n.º 13
0
 public void ReportWarning(string message)
 {
     FlushLog();
     status.ReportWarning(message);
 }