コード例 #1
0
 protected AddinResolver(IndexManager indexManager, BodyRepository bodyRepo, ConvertionManager convertionManager)
 {
     _indexManager      = indexManager;
     _bodyRepo          = bodyRepo;
     _convertionManager = convertionManager;
     _addinParsers      = new List <AddinParser> {
         new XmlAddinParser()
     };
 }
コード例 #2
0
        /// <summary>
        /// Initializes the specified should refresh.
        /// </summary>
        /// <param name="shouldRefresh">
        /// if set to <c>true</c>, scan the addin probe directories for new and updated addins every time the application starts up.
        /// otherwise, initialize the addin framework directly.
        /// </param>
        public void Initialize(bool shouldRefresh)
        {
            if (_initialized)
            {
                return;
            }

            var storage = CreateStorage(_adnConfig.FileConfiguration);

            _indexManager = new IndexManager {
                Storage = storage
            };
            _bodyRepo = new BodyRepository {
                Storage = storage
            };
            var hasExistingAddins = _indexManager.Read();

            // remove addins waiting for delete.
            ProcessPendingAddins();

            if (shouldRefresh || !hasExistingAddins)
            {
                // get addin file packs.
                // excluding: those files that have been scanned last time, if they are unchanged
                var filePackResult = GetFilePackResult();
                if (filePackResult != null)
                {
                    //storage.Close(); // close the persistence file first
                    if (BuildDatabase(filePackResult))
                    {
                        storage = StorageHelper.CreateStorage
                                      (_adnConfig.FileConfiguration.PersistentFile, _adnConfig.FileConfiguration.TransactionFile);
                        _indexManager.Storage = storage;
                        _bodyRepo.Storage     = storage;
                        hasExistingAddins     = _indexManager.Read();
                        if (hasExistingAddins)
                        {
                            _indexManager.Build();
                        }
                        _bodyRepo.ResetCache();
                    }
                }
                else if (hasExistingAddins)
                {
                    _indexManager.Build();
                }
            }
            else
            {
                _indexManager.Build();
            }

            _initialized = true;
        }
コード例 #3
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);
        }
コード例 #4
0
 internal DefaultAddinResolver(IndexManager indexManager, BodyRepository bodyRepo, ConvertionManager convertionManager)
     : base(indexManager, bodyRepo, convertionManager)
 {
 }