Beispiel #1
0
        public DefaultRavenContractResolver(ISerializationConventions conventions)
        {
            if (conventions == null)
            {
                throw new ArgumentNullException(nameof(conventions));
            }

            if (conventions is NewtonsoftJsonSerializationConventions == false)
            {
                throw new ArgumentException($"Conventions must be of '{nameof(NewtonsoftJsonSerializationConventions)}' type.", nameof(conventions));
            }

            _conventions = (NewtonsoftJsonSerializationConventions)conventions;

            if (MembersSearchFlag == null)
            {
                return; // use the JSON.Net default, primarily here because it allows user to turn this off if this is a compact issue.
            }

            var field = typeof(DefaultContractResolver).GetField("DefaultMembersSearchFlags", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

            if (field != null)
            {
                field.SetValue(this, MembersSearchFlag);
                return;
            }

            var prop = typeof(DefaultContractResolver).GetProperty("DefaultMembersSearchFlags", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

            if (prop != null)
            {
                prop.SetValue(this, MembersSearchFlag);
                return;
            }

            throw new NotSupportedException("Cannot set DefaultMembersSearchFlags via reflection might have been removed. Set DefaultRavenContractResolver.MembersSearchFlag to null to work around this and please report it along with exact version of JSON.Net, please");
        }
 public BlittableJsonConverter(ISerializationConventions conventions)
     : base(conventions)
 {
 }
Beispiel #3
0
 public NewtonsoftJsonBlittableEntitySerializer(ISerializationConventions conventions)
 {
     _generateEntityIdOnTheClient = new GenerateEntityIdOnTheClient(conventions.Conventions, null);
     _deserializer = new LightWeightThreadLocal <IJsonSerializer>(() => conventions.CreateDeserializer());
     _reader       = new LightWeightThreadLocal <BlittableJsonReader>(() => new BlittableJsonReader());
 }
 protected BlittableJsonConverterBase(ISerializationConventions conventions)
 {
     Conventions = conventions ?? throw new ArgumentNullException(nameof(conventions));
 }
 public GetRevisionsResultCommand(string id, int?start, int?pageSize, ISerializationConventions serialization)
 {
     _serialization = serialization;
     _cmd           = new GetRevisionsCommand(id, start, pageSize);
 }