Beispiel #1
0
        // @return value: whether new or updated addins found
        bool BuildDatabase(FilePackResult filePackResult)
        {
            var domainName = "addin";
            var dmManager  = new DomainManager();
            var proxy      = dmManager.CreateMarshalObject <AddinResolverProxy>(domainName);
            var result     = proxy.Resolve(_adnConfig.MessageDialog, filePackResult,
                                           _adnConfig.FileConfiguration.PersistentFile, _adnConfig.FileConfiguration.TransactionFile);

            dmManager.UnloadDomain(domainName);
            return(result);
        }
Beispiel #2
0
        // @return value: whether the persistence file (AddinIndexManager/AddinBodyRepository) has been updated.
        public bool Resolve(IMessageDialog dialog, FilePackResult filePackResult, string persistentFile, string transactionFile)
        {
            var storage      = StorageHelper.CreateStorage(persistentFile, transactionFile);
            var indexManager = new IndexManager {
                Storage = storage
            };

            if (indexManager.Read())
            {
                indexManager.Build();
            }
            var bodyRepo = new BodyRepository {
                Storage = storage
            };
            var convertionManager = new ConvertionManager();

            InitializeConvertion(convertionManager);

            var resolver    = new DefaultAddinResolver(indexManager, bodyRepo, convertionManager);
            var hasNewAddin = resolver.Resolve(dialog, filePackResult);

            //storage.Close();
            return(hasNewAddin);
        }
 internal abstract bool Resolve(IMessageDialog dialog, FilePackResult filePackResult);
Beispiel #4
0
        internal override bool Resolve(IMessageDialog dialog, FilePackResult filePackResult)
        {
            // try parsing the new (or updated) addin manifests (configuration)
            var adnResolutions = TryParseAddins(dialog, filePackResult.AddinFilePacks);

            if (adnResolutions == null)
            {
                return(false);
            }

            var ctx            = new ResolutionContext();
            var addinCollision = new AddinCollision();

            // try to register id of new addins at first, so that we can tell whether there are
            // any updated addins when registering that of the existing addins.
            foreach (var adnResolution in adnResolutions)
            {
                TryRegisterAddin(dialog, ctx, adnResolution, addinCollision);
            }

            // register all assets of existing addins to the context (skipping updated addins)
            List <AddinResolution> resolableAddins = null;

            if (_indexManager.AddinCount > 0)
            {
                resolableAddins = RegisterExistingAssets(dialog, ctx, addinCollision, adnResolutions);
            }

            // try to register assets of new and updated addins to the context
            foreach (var adnResolution in adnResolutions)
            {
                TryRegisterAssets(dialog, ctx, adnResolution, addinCollision);
            }

            if (resolableAddins != null)
            {
                adnResolutions.AddRange(resolableAddins);
            }

            // tries to resolve all addin, and make sure:
            // 1. there is no cirular dependencies between the resolved addins.
            // 2. the resolved addin list is sorted by the dependency.
            adnResolutions = TryResolveAddins(dialog, _convertionManager, ctx, adnResolutions);
            if (ResolutionFailed(dialog, ctx, adnResolutions))
            {
                return(false);
            }

            // if there is any conflicting addins, trim them and all addins that depends on them.
            if (addinCollision.Count > 0)
            {
                TrimConflictingAddins(addinCollision, adnResolutions);
                if (ResolutionFailed(dialog, ctx, adnResolutions))
                {
                    return(false);
                }
            }

            // save all new and/or updated addin records to persistent file.
            PersistAddinRecords(ctx, adnResolutions);

            ctx.Dispose();
            return(true);
        }