当前位置: 首页>>代码示例>>C#>>正文


C# AddinScanResult.AddAddinToUpdate方法代码示例

本文整理汇总了C#中Mono.Addins.Database.AddinScanResult.AddAddinToUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# AddinScanResult.AddAddinToUpdate方法的具体用法?C# AddinScanResult.AddAddinToUpdate怎么用?C# AddinScanResult.AddAddinToUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.Addins.Database.AddinScanResult的用法示例。


在下文中一共展示了AddinScanResult.AddAddinToUpdate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ScanFile


//.........这里部分代码省略.........

                    if (database.IsGlobalRegistry && config.AddinId.IndexOf ('.') == -1) {
                        errors.Add ("Add-ins registered in the global registry must have a namespace.");
                    }

                    if (errors.Count > 0) {
                        scanSuccessful = false;
                        monitor.ReportError ("Errors found in add-in '" + file + ":", null);
                        foreach (string err in errors)
                            monitor.ReportError (err, null);
                    }

                    // Make sure all extensions sets are initialized with the correct add-in id

                    config.SetExtensionsAddinId (config.AddinId);

                    scanResult.ChangesFound = true;

                    // If the add-in already existed, try to reuse the relation data it had.
                    // Also, the dependencies of the old add-in need to be re-analized

                    AddinDescription existingDescription = null;
                    bool res = database.GetAddinDescription (monitor, folderInfo.Domain, config.AddinId, config.AddinFile, out existingDescription);

                    // If we can't get information about the old assembly, just regenerate all relation data
                    if (!res)
                        scanResult.RegenerateRelationData = true;

                    string replaceFileName = null;

                    if (existingDescription != null) {
                        // Reuse old relation data
                        config.MergeExternalData (existingDescription);
                        Util.AddDependencies (existingDescription, scanResult);
                        replaceFileName = existingDescription.FileName;
                    }

                    // If the scanned file results in an add-in version different from the one obtained from
                    // previous scans, the old add-in needs to be uninstalled.
                    if (fi != null && fi.IsAddin && fi.AddinId != config.AddinId) {
                        database.UninstallAddin (monitor, folderInfo.Domain, fi.AddinId, fi.File, scanResult);

                        // If the add-in version has changed, regenerate everything again since old data can't be reused
                        if (Addin.GetIdName (fi.AddinId) == Addin.GetIdName (config.AddinId))
                            scanResult.RegenerateRelationData = true;
                    }

                    // If a description could be generated, save it now (if the scan was successful)
                    if (scanSuccessful) {

                        // Assign the domain
                        if (config.IsRoot) {
                            if (folderInfo.RootsDomain == null) {
                                if (scanResult.Domain != null && scanResult.Domain != AddinDatabase.UnknownDomain && scanResult.Domain != AddinDatabase.GlobalDomain)
                                    folderInfo.RootsDomain = scanResult.Domain;
                                else
                                    folderInfo.RootsDomain = database.GetUniqueDomainId ();
                            }
                            config.Domain = folderInfo.RootsDomain;
                        } else
                            config.Domain = folderInfo.Domain;

                        if (config.IsRoot && scanResult.HostIndex != null) {
                            // If the add-in is a root, register its assemblies
                            foreach (string f in config.MainModule.Assemblies) {
                                string asmFile = Path.Combine (config.BasePath, f);
                                scanResult.HostIndex.RegisterAssembly (asmFile, config.AddinId, config.AddinFile, config.Domain);
                            }
                        }

                        // Finally save

                        if (database.SaveDescription (monitor, config, replaceFileName)) {
                            // The new dependencies also have to be updated
                            Util.AddDependencies (config, scanResult);
                            scanResult.AddAddinToUpdate (config.AddinId);
                            scannedAddinId = config.AddinId;
                            scannedIsRoot = config.IsRoot;
                            return;
                        }
                    }
                }
            }
            catch (Exception ex) {
                monitor.ReportError ("Unexpected error while scanning file: " + file, ex);
            }
            finally {
                AddinFileInfo ainfo = folderInfo.SetLastScanTime (file, scannedAddinId, scannedIsRoot, fs.GetLastWriteTime (file), !scanSuccessful);

                if (scanSuccessful && config != null) {
                    // Update the ignore list in the folder info object. To be used in the next scan
                    foreach (string df in config.AllIgnorePaths) {
                        string path = Path.Combine (config.BasePath, df);
                        ainfo.AddPathToIgnore (Path.GetFullPath (path));
                    }
                }

                monitor.Log ("plog:endscan");
            }
        }
开发者ID:JamesChan,项目名称:mono-addins,代码行数:101,代码来源:AddinScanner.cs


注:本文中的Mono.Addins.Database.AddinScanResult.AddAddinToUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。