123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- using System;
- namespace ProtoBuf
- {
-
-
-
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Interface,
- AllowMultiple = false, Inherited = false)]
- public sealed class ProtoContractAttribute : Attribute
- {
-
-
-
- public string Name { get { return name; } set { name = value; } }
- private string name;
-
-
-
-
- public int ImplicitFirstTag
- {
- get { return implicitFirstTag; }
- set
- {
- if (value < 1) throw new ArgumentOutOfRangeException("ImplicitFirstTag");
- implicitFirstTag = value;
- }
- }
- private int implicitFirstTag;
-
-
-
- public bool UseProtoMembersOnly
- {
- get { return HasFlag(OPTIONS_UseProtoMembersOnly); }
- set { SetFlag(OPTIONS_UseProtoMembersOnly, value); }
- }
-
-
-
- public bool IgnoreListHandling
- {
- get { return HasFlag(OPTIONS_IgnoreListHandling); }
- set { SetFlag(OPTIONS_IgnoreListHandling, value); }
- }
-
-
-
-
-
- public ImplicitFields ImplicitFields { get { return implicitFields; } set { implicitFields = value; } }
- private ImplicitFields implicitFields;
-
-
-
-
-
-
-
-
-
- public bool InferTagFromName
- {
- get { return HasFlag(OPTIONS_InferTagFromName); }
- set {
- SetFlag(OPTIONS_InferTagFromName, value);
- SetFlag(OPTIONS_InferTagFromNameHasValue, true);
- }
- }
-
-
-
- internal bool InferTagFromNameHasValue
- {
- get { return HasFlag(OPTIONS_InferTagFromNameHasValue); }
- }
- private int dataMemberOffset;
-
-
-
-
-
-
-
- public int DataMemberOffset
- {
- get { return dataMemberOffset; }
- set { dataMemberOffset = value; }
- }
-
-
-
-
- public bool SkipConstructor
- {
- get { return HasFlag(OPTIONS_SkipConstructor); }
- set { SetFlag(OPTIONS_SkipConstructor, value); }
- }
-
-
-
-
- public bool AsReferenceDefault
- {
- get { return HasFlag(OPTIONS_AsReferenceDefault); }
- set {
- SetFlag(OPTIONS_AsReferenceDefault, value);
- }
- }
- private bool HasFlag(byte flag) { return (flags & flag) == flag; }
- private void SetFlag(byte flag, bool value)
- {
- if (value) flags |= flag;
- else flags = (byte)(flags & ~flag);
- }
- private byte flags;
- private const byte
- OPTIONS_InferTagFromName = 1,
- OPTIONS_InferTagFromNameHasValue = 2,
- OPTIONS_UseProtoMembersOnly = 4,
- OPTIONS_SkipConstructor = 8,
- OPTIONS_IgnoreListHandling = 16,
- OPTIONS_AsReferenceDefault = 32,
- OPTIONS_EnumPassthru = 64,
- OPTIONS_EnumPassthruHasValue = 128;
-
-
-
-
- public bool EnumPassthru
- {
- get { return HasFlag(OPTIONS_EnumPassthru); }
- set {
- SetFlag(OPTIONS_EnumPassthru, value);
- SetFlag(OPTIONS_EnumPassthruHasValue, true);
- }
- }
-
-
-
- internal bool EnumPassthruHasValue
- {
- get { return HasFlag(OPTIONS_EnumPassthruHasValue); }
- }
- }
- }
|