Inheritance: IDisposable
        public PluginReferenceMapper(Plugin plugin)
        {
            var masters = plugin.MasterFiles.ToList();
            var all = plugin.Context.Plugins.Select(p => p.FileName).ToList();

            allNames = all.ToArray();

            localToContext = new byte[masters.Count + 1];
            for (int i = 0; i < masters.Count; i++)
            {
                localToContext[i] = (byte)all.IndexOf(masters[i]);
            }
            localToContext[masters.Count] = plugin.Context.Plugins.GetPluginNumber(plugin);

            contextToLocal = new byte[all.Count];
            for (int i = 0; i < all.Count; i++)
            {
                if (all[i] == plugin.FileName)
                {
                    contextToLocal[i] = (byte)masters.Count;
                }
                else
                {
                    int index = masters.IndexOf(all[i]);
                    if (index == -1)
                        contextToLocal[i] = byte.MaxValue;
                    else
                        contextToLocal[i] = (byte)index;
                }
            }
        }
Exemple #2
0
        public FormLoader(Plugin plugin, RecordReader stockReader, bool lazyLoading, int backgroundJobs)
        {
            if (backgroundJobs < 0)
                throw new ArgumentException("Number of bakcground jobs must be a positive integer or zero");

            sharedData = new SharedData()
            {
                Plugin = plugin,
                StockReader = stockReader,
                LazyLoading = lazyLoading,
                FormsToLoad = new BlockingCollection<Form>(new ConcurrentQueue<Form>(), 1024),
                WorkerCompleteEvent = new AutoResetEvent(false)
            };

            this.stockReader = stockReader;
            asyncLoading = backgroundJobs > 0;

            bool useStockReader = true;
            while (backgroundJobs-- > 0)
            {
                Worker worker = new Worker(sharedData, useStockReader);
                worker.RunWorkerCompleted += Worker_RunWorkerCompleted;
                worker.RunWorkerAsync();
                workers.Add(new WorkerInfo()
                {
                    Worker = worker
                });

                // Only the first worker can use the stock reader
                useStockReader = false;
            }
        }
Exemple #3
0
            public FindRecordsListener(Plugin plugin, RecordReader reader, Progress progress)
            {
                this.plugin = plugin;
                this.reader = reader;

                // Prefetch plugin number for indexed forms
                pluginNumber = plugin.context.Plugins.GetPluginNumber(plugin);
            }