EntityIdentifier.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. namespace Abp.Domain.Entities
  3. {
  4. /// <summary>
  5. /// Used to identify an entity.
  6. /// Can be used to store an entity <see cref="Type"/> and <see cref="Id"/>.
  7. /// </summary>
  8. [Serializable]
  9. public class EntityIdentifier
  10. {
  11. /// <summary>
  12. /// Entity Type.
  13. /// </summary>
  14. public Type Type { get; private set; }
  15. /// <summary>
  16. /// Entity's Id.
  17. /// </summary>
  18. public object Id { get; private set; }
  19. /// <summary>
  20. /// Added for serialization purposes.
  21. /// </summary>
  22. private EntityIdentifier()
  23. {
  24. }
  25. /// <summary>
  26. /// Initializes a new instance of the <see cref="EntityIdentifier"/> class.
  27. /// </summary>
  28. /// <param name="type">Entity type.</param>
  29. /// <param name="id">Id of the entity.</param>
  30. public EntityIdentifier(Type type, object id)
  31. {
  32. if (type == null)
  33. {
  34. throw new ArgumentNullException("type");
  35. }
  36. if (id == null)
  37. {
  38. throw new ArgumentNullException("id");
  39. }
  40. Type = type;
  41. Id = id;
  42. }
  43. }
  44. }