/// <summary>
 /// Sets the default event information, if not set already - such as event name, time and instance
 /// </summary>
 internal void SetDefaultValues()
 {
     if (string.IsNullOrEmpty(this.EventName))
     {
         this.EventName           = EventRegistry.GetEventName(this.GetType());
         this.EventTime           = DateTime.Now;
         this.EventOriginInstance = Settings.InstanceName;
     }
 }
        /// <summary>
        /// Raises the custom event on the local Sitecore instance, i.e., on the instance where the event is generated
        /// This does not use the Sitecore EventQueue
        /// </summary>
        /// <param name="evt">Custom event that is routed</param>
        public static void PublishLocally(this SitecoreEvent evt)
        {
            Assert.ArgumentNotNull((object)evt, "evt");

            if (!EventRegistry.IsEventRegistered(evt))
            {
                Log.Error(string.Format("Event '{0}' is not registered on this instance", evt.ToString()), typeof(SitecoreZone.Eventing.EventRouter));
            }

            evt.SetDefaultValues();
            Event.RaiseEvent(evt.EventName, new object[] { evt });
        }
        /// <summary>
        /// Raises the custom event on all Sitecore instances in the cluster (CM, CD, Publishing instance, etc.)
        /// The event is also raised on the local Sitecore instance, i.e., on the instance where the event is generated
        /// </summary>
        /// <param name="evt">Custom event that is routed</param>
        public static void PublishGlobally(this SitecoreEvent evt)
        {
            Assert.ArgumentNotNull((object)evt, "evt");

            if (!EventRegistry.IsEventRegistered(evt))
            {
                Log.Error(string.Format("Event '{0}' is not registered on this instance", evt.ToString()), typeof(SitecoreZone.Eventing.EventRouter));
            }

            evt.SetDefaultValues();
            //Queue events to global and local queues
            WrappedEvent wrappedEvent = new WrappedEvent()
            {
                Event = evt
            };

            EventManager.QueueEvent <WrappedEvent>(wrappedEvent, true, true);
        }
        /// <summary>
        /// Raises the custom event on all remote Sitecore instances in the cluster that uses the target database
        /// The event will not be raised on the local Sitecore instance, i.e., the instance where the event is generated
        /// </summary>
        /// <param name="evt">Custom event that is routed</param>
        /// <param name="remoteTargetDB">Target database where event has to be raised</param>
        public static void PublishToRemoteTargetsOnly(this SitecoreEvent evt, Database remoteTargetDB)
        {
            Assert.ArgumentNotNull((object)evt, "evt");
            Assert.ArgumentNotNull((object)remoteTargetDB, "remoteTargetDB");

            if (!EventRegistry.IsEventRegistered(evt))
            {
                Log.Error(string.Format("Event '{0}' is not registered on this instance", evt.ToString()), typeof(SitecoreZone.Eventing.EventRouter));
            }

            evt.SetDefaultValues();
            //Queue events for remote
            WrappedEvent wrappedEvent = new WrappedEvent()
            {
                Event = evt
            };

            remoteTargetDB.RemoteEvents.Queue.QueueEvent <WrappedEvent>(wrappedEvent);
        }
 /// <summary>
 /// Returns the list of types that have been registsred
 /// </summary>
 /// <returns>List of types that are registered</returns>
 public static Type[] GetKnownTypes()
 {
     return(EventRegistry.GetKnownTypes());
 }