public void ParseAddin (IProgressStatus progressStatus, string file, string outFile, bool inProcess)
		{
			if (!inProcess) {
				SetupProcess.ExecuteCommand (progressStatus, registry.RegistryPath, AddinManager.StartupDirectory, "get-desc", Path.GetFullPath (file), outFile);
				return;
			}
			
			using (fileDatabase.LockRead ())
			{
				// First of all, check if the file belongs to a registered add-in
				AddinScanFolderInfo finfo;
				if (GetFolderInfoForPath (progressStatus, Path.GetDirectoryName (file), out finfo) && finfo != null) {
					AddinFileInfo afi = finfo.GetAddinFileInfo (file);
					if (afi != null && afi.AddinId != null) {
						AddinDescription adesc;
						if (afi.IsRoot)
							GetHostDescription (progressStatus, afi.AddinId, file, out adesc);
						else
							GetAddinDescription (progressStatus, afi.AddinId, out adesc);
						if (adesc != null)
							adesc.Save (outFile);
						return;
					}
				}
				
				
				AddinScanner scanner = new AddinScanner (this);
				
				SingleFileAssemblyResolver res = new SingleFileAssemblyResolver (progressStatus, registry, scanner);
				ResolveEventHandler resolver = new ResolveEventHandler (res.Resolve);

				EventInfo einfo = typeof(AppDomain).GetEvent ("ReflectionOnlyAssemblyResolve");
				
				try {
					AppDomain.CurrentDomain.AssemblyResolve += resolver;
					if (einfo != null) einfo.AddEventHandler (AppDomain.CurrentDomain, resolver);
				
					AddinDescription desc = scanner.ScanSingleFile (progressStatus, file, new AddinScanResult ());
					if (desc != null)
						desc.Save (outFile);
				}
				finally {
					AppDomain.CurrentDomain.AssemblyResolve -= resolver;
					if (einfo != null) einfo.RemoveEventHandler (AppDomain.CurrentDomain, resolver);
				}
			}
		}
Пример #2
0
        public void ParseAddin(IProgressStatus progressStatus, string domain, string file, string outFile, bool inProcess)
        {
            if (!inProcess) {
                ISetupHandler setup = GetSetupHandler ();
                setup.GetAddinDescription (progressStatus, registry, Path.GetFullPath (file), outFile);
                return;
            }

            using (fileDatabase.LockRead ())
            {
                // First of all, check if the file belongs to a registered add-in
                AddinScanFolderInfo finfo;
                if (GetFolderInfoForPath (progressStatus, Path.GetDirectoryName (file), out finfo) && finfo != null) {
                    AddinFileInfo afi = finfo.GetAddinFileInfo (file);
                    if (afi != null && afi.IsAddin) {
                        AddinDescription adesc;
                        GetAddinDescription (progressStatus, afi.Domain, afi.AddinId, file, out adesc);
                        if (adesc != null)
                            adesc.Save (outFile);
                        return;
                    }
                }

                AddinScanResult sr = new AddinScanResult ();
                sr.Domain = domain;
                AddinScanner scanner = new AddinScanner (this, sr, progressStatus);

                SingleFileAssemblyResolver res = new SingleFileAssemblyResolver (progressStatus, registry, scanner);
                ResolveEventHandler resolver = new ResolveEventHandler (res.Resolve);

                EventInfo einfo = typeof(AppDomain).GetEvent ("ReflectionOnlyAssemblyResolve");

                try {
                    AppDomain.CurrentDomain.AssemblyResolve += resolver;
                    if (einfo != null) einfo.AddEventHandler (AppDomain.CurrentDomain, resolver);

                    AddinDescription desc = scanner.ScanSingleFile (progressStatus, file, sr);
                    if (desc != null) {
                        // Reset the xml doc so that it is not reused when saving. We want a brand new document
                        desc.ResetXmlDoc ();
                        desc.Save (outFile);
                    }
                }
                finally {
                    AppDomain.CurrentDomain.AssemblyResolve -= resolver;
                    if (einfo != null) einfo.RemoveEventHandler (AppDomain.CurrentDomain, resolver);
                }
            }
        }