コード例 #1
0
        /// <summary>
        /// Unregisters all updaters that might have been registered when we checked into Mission Control.
        /// Also cleans up any static variables that might cause issues on re-open.
        /// </summary>
        /// <param name="doc">Revit Document.</param>
        public static void UnregisterUpdaters(Document doc)
        {
            var centralPath = FileInfoUtil.GetCentralFilePath(doc);

            if (MissionControlSetup.Configurations.ContainsKey(centralPath))
            {
                var currentConfig = MissionControlSetup.Configurations[centralPath];
                foreach (var updater in currentConfig.Updaters)
                {
                    if (!updater.IsUpdaterOn)
                    {
                        continue;
                    }

                    if (string.Equals(updater.UpdaterId,
                                      AppCommand.Instance.DoorUpdaterInstance.UpdaterGuid.ToString(), StringComparison.OrdinalIgnoreCase))
                    {
                        AppCommand.Instance.DoorUpdaterInstance.Unregister(doc);
                    }
                    else if (string.Equals(updater.UpdaterId,
                                           AppCommand.Instance.DtmUpdaterInstance.UpdaterGuid.ToString(), StringComparison.OrdinalIgnoreCase))
                    {
                        AppCommand.Instance.DtmUpdaterInstance.Unregister(doc);
                    }
                }
            }

            // (Konrad) Clean up all static classes that would be holding any relevant information.
            // This would cause issues in case that user closes a MissionControl registered project without
            // closing Revit app. These static classes retain their values, and then would trick rest of app
            // to think that it is registered in Mission Control.
            MissionControlSetup.ClearAll();
            AppCommand.ClearAll();
        }