ProtoIgnoreAttribute.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. namespace ProtoBuf
  3. {
  4. /// <summary>
  5. /// Indicates that a member should be excluded from serialization; this
  6. /// is only normally used when using implict fields.
  7. /// </summary>
  8. [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field,
  9. AllowMultiple = false, Inherited = true)]
  10. public class ProtoIgnoreAttribute : Attribute {}
  11. /// <summary>
  12. /// Indicates that a member should be excluded from serialization; this
  13. /// is only normally used when using implict fields. This allows
  14. /// ProtoIgnoreAttribute usage
  15. /// even for partial classes where the individual members are not
  16. /// under direct control.
  17. /// </summary>
  18. [AttributeUsage(AttributeTargets.Class,
  19. AllowMultiple = true, Inherited = false)]
  20. public sealed class ProtoPartialIgnoreAttribute : ProtoIgnoreAttribute
  21. {
  22. /// <summary>
  23. /// Creates a new ProtoPartialIgnoreAttribute instance.
  24. /// </summary>
  25. /// <param name="memberName">Specifies the member to be ignored.</param>
  26. public ProtoPartialIgnoreAttribute(string memberName)
  27. : base()
  28. {
  29. if (Helpers.IsNullOrEmpty(memberName)) throw new ArgumentNullException("memberName");
  30. this.memberName = memberName;
  31. }
  32. /// <summary>
  33. /// The name of the member to be ignored.
  34. /// </summary>
  35. public string MemberName { get { return memberName; } }
  36. private readonly string memberName;
  37. }
  38. }