Ejemplo n.º 1
0
        private void LoadReader(string pluginDir)
        {
            var categ = new DirectoryCatalog(pluginDir);
            var cname = AttributedModelServices.GetContractName(typeof(IEMailReader));
            Expression <Func <ExportDefinition, bool> > exp = a => a.ContractName == cname;
            var id = new ImportDefinition(exp, cname, ImportCardinality.ExactlyOne, true, true);
            var l  = categ.GetExports(id).ToList();

            if (l.Count == 1)
            {
                var cc = new CompositionContainer(categ);
                cc.ComposeParts(this);
                creader.Content    = Reader;
                Reader.QueryThread = OnQueryThread;
            }
            else if (l.Count == 0)
            {
                creader.Visibility = Visibility.Collapsed;
                MessageBox.Show("Failed to find any plugin!");
            }
        }
Ejemplo n.º 2
0
        public EMailAttachments()
        {
            InitializeComponent();
            GBB.Header = Properties.Resources.AttachmentsWordQ;
            GBC.Header = Properties.Resources.PreviewWord;
            (LstAttach.View as GridView).Columns[0].Header = Properties.Resources.NameWord;
            var dir = Assembly.GetExecutingAssembly().CodeBase.Substring("file:///".Length).Replace('/', '\\');

            dir = dir.Substring(0, dir.LastIndexOf('\\'));
            var categ = new DirectoryCatalog(dir);
            var cname = AttributedModelServices.GetContractName(typeof(IImageViewer));
            Expression <Func <ExportDefinition, bool> > exp = a => a.ContractName == cname;
            var id = new ImportDefinition(exp, cname, ImportCardinality.ExactlyOne, true, true);
            var l  = categ.GetExports(id).ToList();

            if (l.Count == 1)
            {
                var cc = new CompositionContainer(categ);
                cc.ComposeParts(this);
                cviewer.Content = ImageViewer;
            }
        }