protected RibbonFactory(
            AddInBase addinBase, Assembly[] assemblies, IViewContextProvider contextProvider, IViewLocationStrategy viewLocationStrategy,
            [CanBeNull] string fallbackRibbonType)
        {
            if (assemblies.Length == 0)
                throw new InvalidOperationException("You must specify at least one assembly to scan for viewmodels");

            context = new VstoContribContext(assemblies, addinBase, fallbackRibbonType, viewLocationStrategy);
            ribbonFactoryController = new RibbonFactoryController(contextProvider, context);

            addinBase.Startup += AddinBaseOnStartup;
            addinBase.Shutdown += AddinBaseOnShutdown;
        }
Example #2
0
        protected RibbonFactory(
            AddInBase addinBase, Assembly[] assemblies, IViewContextProvider contextProvider, IViewLocationStrategy viewLocationStrategy,
            [CanBeNull] string fallbackRibbonType)
        {
            if (assemblies.Length == 0)
            {
                throw new InvalidOperationException("You must specify at least one assembly to scan for viewmodels");
            }

            context = new VstoContribContext(assemblies, addinBase, fallbackRibbonType, viewLocationStrategy);
            ribbonFactoryController = new RibbonFactoryController(contextProvider, context);

            addinBase.Startup  += AddinBaseOnStartup;
            addinBase.Shutdown += AddinBaseOnShutdown;
        }
        protected RibbonFactory(
            AddInBase addinBase, Assembly[] assemblies, IViewContextProvider contextProvider,
            [CanBeNull] string fallbackRibbonType)
        {
            if (assemblies.Length == 0)
                throw new InvalidOperationException("You must specify at least one assembly to scan for viewmodels");

            lock (InstanceLock)
            {
                if (Current != null)
                    throw new InvalidOperationException("You can only create a single ribbon factory");
                Current = this;
            }

            context = new VstoContribContext(assemblies, addinBase, fallbackRibbonType);
            ribbonFactoryController = new RibbonFactoryController(contextProvider, context);

            addinBase.Startup += AddinBaseOnStartup;
            addinBase.Shutdown += AddinBaseOnShutdown;
        }
        public RibbonFactoryController(
            IViewContextProvider viewContextProvider,
            VstoContribContext vstoContribContext)
        {
            this.vstoContribContext = vstoContribContext;
            var ribbonTypes = GetTRibbonTypesInAssemblies(vstoContribContext.Assemblies).ToList();

            customTaskPaneRegister  = new CustomTaskPaneRegister(vstoContribContext.AddinBase);
            ribbonViewModelResolver = new ViewModelResolver(
                ribbonTypes, customTaskPaneRegister, viewContextProvider,
                vstoContribContext);

            var ribbonXmlRewriter = new RibbonXmlRewriter(vstoContribContext, ribbonViewModelResolver);

            var    loadExpression = ((Expression <Action <RibbonFactory> >)(r => r.Ribbon_Load(null)));
            string loadMethodName = loadExpression.GetMethodName();

            foreach (Type viewModelType in ribbonTypes)
            {
                ribbonXmlRewriter.LocateAndRegisterViewXml(viewModelType, loadMethodName, vstoContribContext.FallbackRibbonType);
            }
        }
        public RibbonFactoryController(
            IViewContextProvider viewContextProvider,
            VstoContribContext vstoContribContext)
        {
            this.vstoContribContext = vstoContribContext;
            var ribbonTypes = GetTRibbonTypesInAssemblies(vstoContribContext.Assemblies).ToList();

            customTaskPaneRegister = new CustomTaskPaneRegister(vstoContribContext.AddinBase);
            ribbonViewModelResolver = new ViewModelResolver(
                ribbonTypes, customTaskPaneRegister, viewContextProvider, 
                vstoContribContext);

            var ribbonXmlRewriter = new RibbonXmlRewriter(vstoContribContext, ribbonViewModelResolver);

            var loadExpression = ((Expression<Action<RibbonFactory>>)(r => r.Ribbon_Load(null)));
            string loadMethodName = loadExpression.GetMethodName();

            foreach (Type viewModelType in ribbonTypes)
            {
                ribbonXmlRewriter.LocateAndRegisterViewXml(viewModelType, loadMethodName, vstoContribContext.FallbackRibbonType);
            }
        }
Example #6
0
        protected RibbonFactory(
            AddInBase addinBase, Assembly[] assemblies, IViewContextProvider contextProvider,
            [CanBeNull] string fallbackRibbonType)
        {
            if (assemblies.Length == 0)
            {
                throw new InvalidOperationException("You must specify at least one assembly to scan for viewmodels");
            }

            lock (InstanceLock)
            {
                if (Current != null)
                {
                    throw new InvalidOperationException("You can only create a single ribbon factory");
                }
                Current = this;
            }

            context = new VstoContribContext(assemblies, addinBase, fallbackRibbonType);
            ribbonFactoryController = new RibbonFactoryController(contextProvider, context);

            addinBase.Startup  += AddinBaseOnStartup;
            addinBase.Shutdown += AddinBaseOnShutdown;
        }
 public RibbonXmlRewriter(VstoContribContext vstoContribContext, ViewModelResolver ribbonViewModelResolver)
 {
     controlCallbackLookup        = new ControlCallbackLookup();
     this.vstoContribContext      = vstoContribContext;
     this.ribbonViewModelResolver = ribbonViewModelResolver;
 }
 public RibbonXmlRewriter(VstoContribContext vstoContribContext, ViewModelResolver ribbonViewModelResolver)
 {
     controlCallbackLookup = new ControlCallbackLookup();
     this.vstoContribContext = vstoContribContext;
     this.ribbonViewModelResolver = ribbonViewModelResolver;
 }