Esempio n. 1
0
 public ExportRepositoryHandler(RepositoryType repositoryType, object[] elements, Catalogue catalogue, IWin32Window parent)
 {
     _repositoryType = repositoryType;
     _elements       = elements;
     _catalogue      = catalogue;
     _parent         = parent;
 }
Esempio n. 2
0
        private static Catalogue GetCatalogue(IUnityContainer container)
        {
            const string method = "GetCatalogue";

            IRepositoryReader repositoryReader = null;
            Catalogue         catalogue        = null;

            try
            {
                // Access the current catalogue.

                repositoryReader = container.Resolve <IRepositoryReader>();
                catalogue        = repositoryReader.Read();

                _errorGettingCatalogue = null;
            }
            catch (Exception ex)
            {
                _errorGettingCatalogue = ex;
                _internalMessageHandler.HandleEventMessage(new EventMessage(null, Event.Error, typeof(InstrumentationManager), method,
                                                                            string.Format("Failed to initialise the current catalogue for the Instrumentation module: {0}{1}", Environment.NewLine, ex)));
            }

            try
            {
                if (catalogue != null)
                {
                    // Register for callbacks.

                    var repositoryUpdate = repositoryReader as IRepositoryUpdate;
                    if (repositoryUpdate != null)
                    {
                        repositoryUpdate.RegisterCallback(RepositoryCallback);
                    }
                }
            }
            catch (Exception ex)
            {
                _internalMessageHandler.HandleEventMessage(new EventMessage(null, Event.Warning, typeof(InstrumentationManager), method,
                                                                            string.Format("Failed to register an Instrumentation repository callback for repository"
                                                                                          + " in process {0}, running as user '{1}\\{2}'. Instrumentation will still be initialised,"
                                                                                          + " but configuration changes will have no effect until the process is restarted.{3}{4}",
                                                                                          Process.GetCurrentProcess().Id, Environment.UserDomainName, Environment.UserName,
                                                                                          Environment.NewLine, ex)));
            }

            return(catalogue);
        }
Esempio n. 3
0
        protected void AddExportMenuItems(object[] elements, Catalogue catalogue)
        {
            ContextSubMenuItem subMenuItem = new ContextSubMenuItem("Export To");

            AddTaskMenuItem(subMenuItem);

            // Look for RepositoryWriters in the environment.

            Module module = ConfigurationManager.GetCatalogue(catalogue.EnvironmentContext).Modules[Constants.Module.Name];

            if (module != null)
            {
                foreach (RepositoryType repositoryType in module.RepositoryTypes)
                {
                    if (Node.IsWriter(repositoryType))
                    {
                        AddMenuItem(subMenuItem, new ContextMenuItem(repositoryType.RepositoryDisplayName, string.Empty, new MenuCommandHandler((new ExportRepositoryHandler(repositoryType, elements, catalogue, Snapin.GetMainWindow())).Export)));
                    }
                }
            }
        }
Esempio n. 4
0
        private static void InitialiseEvents(Catalogue catalogue)
        {
            const string method = "InitialiseEvents";

            try
            {
                // Grab all the events giving them an appropriate index.

                int index = 0;
                foreach (EventType eventType in catalogue.EventTypes)
                {
                    var eventInfo = (EventInfo)Events[eventType.Name];
                    if (eventInfo == null)
                    {
                        eventInfo = new EventInfo(eventType.Name, eventType.IsEnabled, ++index);
                        Events[eventType.Name] = eventInfo;
                    }
                    else
                    {
                        eventInfo.IsEnabled = eventType.IsEnabled;
                        eventInfo.Index     = ++index;
                    }
                }

                // Initialise the default status.

                _defaultEventStatus = new BitArray(Events.Count + 1, false);

                // Index 0 is for unknown events and its status is always false.

                int eventIndex = 0;
                _defaultEventStatus[0] = false;
                _allEvents             = new string[Events.Count];
                foreach (EventInfo eventInfo in Events.Values)
                {
                    _allEvents[eventIndex++] = eventInfo.Name;

                    if (eventInfo.IsEnabled)
                    {
                        _defaultEventStatus[eventInfo.Index] = true;
                    }
                }
            }
            catch (Exception ex)
            {
                _internalMessageHandler.HandleEventMessage(new EventMessage(null, Event.Error, typeof(InstrumentationManager), method,
                                                                            "Failed to initialise Instrumentation events: "
                                                                            + Environment.NewLine + ex));
            }
            finally
            {
                // Ensure that there are defaults.

                if (_defaultEventStatus == null)
                {
                    _defaultEventStatus = new BitArray(Events.Count + 1, false);
                }
                if (_allEvents == null)
                {
                    _allEvents = new string[Events.Count];
                    for (int index = 0; index < _allEvents.Length; ++index)
                    {
                        _allEvents[index] = string.Empty;
                    }
                }
            }
        }
Esempio n. 5
0
 protected void AddExportMenuItems(object element, Catalogue catalogue)
 {
     AddExportMenuItems(new object[] { element }, catalogue);
 }
Esempio n. 6
0
 internal EventType(Catalogue catalogue, string name)
     :       this(catalogue, name, false)
 {
 }
Esempio n. 7
0
        protected void ApplyManageTypes(Catalogue catalogue, Catalogue newCatalogue)
        {
            // Copy all repository and store types.

            catalogue.Commit();
        }
Esempio n. 8
0
 public EventType CreateEventType(Catalogue catalogue, string name)
 {
     return(new EventType(catalogue, _interner.Intern(name)));
 }
Esempio n. 9
0
        // EventType

        public EventType CreateEventType(Catalogue catalogue, string name, bool isEnabled)
        {
            return(new EventType(catalogue, _interner.Intern(name), isEnabled));
        }
Esempio n. 10
0
 private bool EqualChildren(Catalogue other)
 {
     return(EventTypes.Equals(other.EventTypes) &&
            Namespaces.Equals(other.Namespaces));
 }
Esempio n. 11
0
 private static bool EqualDetails(Catalogue other)
 {
     return(true);
 }
Esempio n. 12
0
 public static bool Equals(Catalogue c1, Catalogue c2)
 {
     return(object.Equals(c1, c2));
 }