Exemplo n.º 1
0
        /// <summary>
        /// Implement this method to execute some tasks when Autodesk Revit starts.
        /// </summary>
        public Result OnStartup(UIControlledApplication application)
        {
            var containerGuid = ContainerProviderReflector.GetContainerGuid(this);

            var container = new TContainer();

            this.InjectContainerToItself(container);

            this.HookUpContainer(container, containerGuid);
            this.HookupRevitContext(application, container);

            this.AddRevitUI(container, application);

            try
            {
                // Calls the client's Startup
                var result = OnStartup(container, application);
                if (result != Result.Succeeded)
                {
                    return(result);
                }

                // Calls the client's CreateRibbon
                var imageManager  = new ImageManager();
                var ribbonManager = new RibbonManager(application, imageManager);
                OnCreateRibbon(ribbonManager);

                return(result);
            }
            catch
            {
                // If an exception the client's code, throw the exception to the stack
                throw;
            }
        }
Exemplo n.º 2
0
        private static IContainer GetContainer()
        {
            var type          = typeof(TApplication);
            var containerGuid = ContainerProviderReflector.GetContainerGuid(type);
            var container     = RevitContainerProviderBase.GetContainer(containerGuid);

            return(container);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Implement this method to execute some tasks when Autodesk Revit shuts down.
        /// </summary>
        public Result OnShutdown(UIControlledApplication application)
        {
            var containerGuid = ContainerProviderReflector.GetContainerGuid(this);
            var container     = containers[containerGuid];

            try
            {
                // Unhooks the events
                UnhookRevitContext(application, containerGuid);
                // Calls the client's Shotdown
                return(OnShutdown(container, application));
            }
            catch
            {
                // If anything goes wrong with the client's code, throw the exception to the stack
                throw;
            }
            finally
            {
                // Unhooks and cleans the container even if an exception is thrown
                UnhookContainer(containerGuid, container);
            }
        }