Adding Publish and UnPublish EventArgs

This commit is contained in:
Morten Christensen
2012-12-28 14:15:12 -01:00
parent 3ae5aa7195
commit 194d241b02
5 changed files with 150 additions and 2 deletions

View File

@@ -0,0 +1,53 @@
using System.Collections.Generic;
namespace Umbraco.Core.Events
{
public class PublishEventArgs<TEntity> : CancellableObjectEventArgs<IEnumerable<TEntity>>
{
/// <summary>
/// Constructor accepting multiple entities that are used in the publish operation
/// </summary>
/// <param name="eventObject"></param>
/// <param name="canCancel"></param>
public PublishEventArgs(IEnumerable<TEntity> eventObject, bool canCancel)
: base(eventObject, canCancel)
{
}
/// <summary>
/// Constructor accepting multiple entities that are used in the publish operation
/// </summary>
/// <param name="eventObject"></param>
public PublishEventArgs(IEnumerable<TEntity> eventObject)
: base(eventObject)
{
}
/// <summary>
/// Constructor accepting a single entity instance
/// </summary>
/// <param name="eventObject"></param>
public PublishEventArgs(TEntity eventObject)
: base(new List<TEntity> { eventObject })
{
}
/// <summary>
/// Constructor accepting a single entity instance
/// </summary>
/// <param name="eventObject"></param>
/// <param name="canCancel"></param>
public PublishEventArgs(TEntity eventObject, bool canCancel)
: base(new List<TEntity> { eventObject }, canCancel)
{
}
/// <summary>
/// Returns all entities that were published during the operation
/// </summary>
public IEnumerable<TEntity> PublishedEntities
{
get { return EventObject; }
}
}
}

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Events
{
@@ -44,7 +43,7 @@ namespace Umbraco.Core.Events
}
/// <summary>
/// Returns all entities that were deleted during the operation
/// Returns all entities that were saved during the operation
/// </summary>
public IEnumerable<TEntity> SavedEntities
{

View File

@@ -0,0 +1,53 @@
using System.Collections.Generic;
namespace Umbraco.Core.Events
{
public class UnPublishEventArgs<TEntity> : CancellableObjectEventArgs<IEnumerable<TEntity>>
{
/// <summary>
/// Constructor accepting multiple entities that are used in the unpublish operation
/// </summary>
/// <param name="eventObject"></param>
/// <param name="canCancel"></param>
public UnPublishEventArgs(IEnumerable<TEntity> eventObject, bool canCancel)
: base(eventObject, canCancel)
{
}
/// <summary>
/// Constructor accepting multiple entities that are used in the unpublish operation
/// </summary>
/// <param name="eventObject"></param>
public UnPublishEventArgs(IEnumerable<TEntity> eventObject)
: base(eventObject)
{
}
/// <summary>
/// Constructor accepting a single entity instance
/// </summary>
/// <param name="eventObject"></param>
public UnPublishEventArgs(TEntity eventObject)
: base(new List<TEntity> { eventObject })
{
}
/// <summary>
/// Constructor accepting a single entity instance
/// </summary>
/// <param name="eventObject"></param>
/// <param name="canCancel"></param>
public UnPublishEventArgs(TEntity eventObject, bool canCancel)
: base(new List<TEntity> { eventObject }, canCancel)
{
}
/// <summary>
/// Returns all entities that were unpublished during the operation
/// </summary>
public IEnumerable<TEntity> UnPublishedEntities
{
get { return EventObject; }
}
}
}

View File

@@ -0,0 +1,40 @@
namespace Umbraco.Core.Models.EntityBase
{
internal interface IUmbracoEntity : IEntity
{
/// <summary>
/// Gets or sets the Id of the Parent entity
/// </summary>
int ParentId { get; set; }
/// <summary>
/// Gets or sets the sort order of the Entity
/// </summary>
int SortOrder { get; set; }
/// <summary>
/// Gets or sets the level of the Entity
/// </summary>
int Level { get; set; }
/// <summary>
/// Gets or sets the path to the Entity
/// </summary>
string Path { get; set; }
/// <summary>
/// Profile of the user who created this Entity
/// </summary>
int CreatorId { get; set; }
/// <summary>
/// Boolean indicating whether this Entity is Trashed or not.
/// If an Entity is Trashed it will be located in the Recyclebin.
/// </summary>
/// <remarks>
/// When content is trashed it should be unpublished.
/// Not all entities support being trashed, they'll always return false.
/// </remarks>
bool Trashed { get; }
}
}

View File

@@ -125,6 +125,7 @@
<Compile Include="Events\CancellableObjectEventArgs.cs" />
<Compile Include="Events\DeleteRevisionsEventArgs.cs" />
<Compile Include="Events\EventExtensions.cs" />
<Compile Include="Events\PublishEventArgs.cs" />
<Compile Include="Events\TypedEventHandler.cs" />
<Compile Include="Events\PublishingEventArgs.cs" />
<Compile Include="Events\MoveEventArgs.cs" />
@@ -133,6 +134,7 @@
<Compile Include="Events\RollbackEventArgs.cs" />
<Compile Include="Events\SaveEventArgs.cs" />
<Compile Include="Events\SendToPublishEventArgs.cs" />
<Compile Include="Events\UnPublishEventArgs.cs" />
<Compile Include="MacroPropertyTypeResolver.cs" />
<Compile Include="Models\ContentBase.cs" />
<Compile Include="Models\ContentExtensions.cs" />
@@ -153,6 +155,7 @@
<Compile Include="Models\Css\TrieNode.cs" />
<Compile Include="Models\DictionaryItem.cs" />
<Compile Include="Models\DictionaryTranslation.cs" />
<Compile Include="Models\EntityBase\IUmbracoEntity.cs" />
<Compile Include="Models\File.cs" />
<Compile Include="Models\IDataTypeDefinition.cs" />
<Compile Include="Models\IDictionaryItem.cs" />