/// <param name="type">
        ///          type of event </param>
        /// <param name="entity">
        ///          the entity this event targets </param>
        /// <returns> an <seealso cref="IActivitiEntityEvent"/>. In case an <seealso cref="ExecutionContext"/> is active, the execution related event fields will be populated. If not, execution details will be retrieved from the
        ///         <seealso cref="Object"/> if possible. </returns>
        public static IActivitiEntityEvent CreateEntityEvent(ActivitiEventType type, object entity)
        {
            ActivitiEntityEventImpl newEvent = new ActivitiEntityEventImpl(entity, type);

            // In case an execution-context is active, populate the event fields
            // related to the execution
            PopulateEventWithCurrentContext(newEvent);
            return(newEvent);
        }
        /// <param name="type">
        ///          type of event </param>
        /// <param name="entity">
        ///          the entity this event targets </param>
        /// <returns> an <seealso cref="IActivitiEntityEvent"/> </returns>
        public static IActivitiEntityEvent CreateEntityEvent(ActivitiEventType type, object entity, string executionId, string processInstanceId, string processDefinitionId)
        {
            ActivitiEntityEventImpl newEvent = new ActivitiEntityEventImpl(entity, type)
            {
                ExecutionId         = executionId,
                ProcessInstanceId   = processInstanceId,
                ProcessDefinitionId = processDefinitionId
            };

            return(newEvent);
        }