Exemple #1
0
        private void RebuildDefaultPayload()
        {
            var payload = new Dictionary <string, byte[]>
            {
                { PayloadKey.Language, GraphOptions.ToUtf8Buffer(_language) },
                { PayloadKey.Source, GraphOptions.ToUtf8Buffer(_source) }
            };

            if (_name != null)
            {
                payload.Add(PayloadKey.Name, GraphOptions.ToUtf8Buffer(_name));
            }
            var readConsistencyLevel = ReadConsistencyLevel;

            if (readConsistencyLevel != null)
            {
                payload.Add(PayloadKey.ReadConsistencyLevel, GraphOptions.ToUtf8Buffer(
                                GraphOptions.GetConsistencyName(readConsistencyLevel.Value)));
            }
            var writeConsistencyLevel = WriteConsistencyLevel;

            if (writeConsistencyLevel != null)
            {
                payload.Add(PayloadKey.WriteConsitencyLevel, GraphOptions.ToUtf8Buffer(
                                GraphOptions.GetConsistencyName(writeConsistencyLevel.Value)));
            }
            if (ReadTimeoutMillis > 0)
            {
                payload.Add(PayloadKey.RequestTimeout, GraphOptions.ToBuffer(ReadTimeoutMillis));
            }
            _defaultPayload = payload;
        }
Exemple #2
0
 private void Add <T>(IDictionary <string, byte[]> payload, string key, T value, T empty, Func <T, byte[]> converter = null)
 {
     if (converter == null)
     {
         converter = v => GraphOptions.ToUtf8Buffer((string)(object)v);
     }
     byte[] payloadValue;
     if (value != null && !value.Equals(empty))
     {
         payloadValue = converter(value);
     }
     else
     {
         _defaultPayload.TryGetValue(key, out payloadValue);
     }
     if (payloadValue == null)
     {
         return;
     }
     payload.Add(key, payloadValue);
 }