コード例 #1
0
        /// <exception cref="System.IO.IOException"/>
        private int ReadNestedPosition(string fieldName, FieldType type)
        {
            var fieldNames = fieldName.Split(NestedFieldPattern);

            if (fieldNames.Length > 1)
            {
                IFieldDefinition fd = null;
                var reader          = this;
                for (var i = 0; i < fieldNames.Length; i++)
                {
                    fd = reader.Cd.GetField(fieldNames[i]);
                    if (fd == null)
                    {
                        break;
                    }
                    if (i == fieldNames.Length - 1)
                    {
                        break;
                    }
                    var pos = reader.ReadPosition(fd);
                    _in.Position(pos);
                    var isNull = _in.ReadBoolean();
                    if (isNull)
                    {
                        throw new ArgumentNullException("Parent field is null: " + fieldNames[i]);
                    }
                    reader = Serializer.CreateReader(_in);
                }
                if (fd == null)
                {
                    throw ThrowUnknownFieldException(fieldName);
                }
                if (fd.GetFieldType() != type)
                {
                    throw new HazelcastSerializationException("Not a '" + type + "' field: " + fieldName);
                }
                return(reader.ReadPosition(fd));
            }
            throw ThrowUnknownFieldException(fieldName);
        }
コード例 #2
0
 /// <exception cref="System.IO.IOException"/>
 private int ReadNestedPosition(string fieldName, FieldType type)
 {
     string[] fieldNames = fieldName.Split(NestedFieldPattern);
     if (fieldNames.Length > 1)
     {
         IFieldDefinition fd = null;
         Hazelcast.IO.Serialization.DefaultPortableReader reader = this;
         for (int i = 0; i < fieldNames.Length; i++)
         {
             fd = reader.cd.GetField(fieldNames[i]);
             if (fd == null)
             {
                 break;
             }
             if (i == fieldNames.Length - 1)
             {
                 break;
             }
             int pos = reader.ReadPosition(fd);
             @in.Position(pos);
             bool isNull = @in.ReadBoolean();
             if (isNull)
             {
                 throw new ArgumentNullException("Parent field is null: " + fieldNames[i]);
             }
             reader = serializer.CreateReader(@in);
         }
         if (fd == null)
         {
             throw ThrowUnknownFieldException(fieldName);
         }
         if (fd.GetFieldType() != type)
         {
             throw new HazelcastSerializationException("Not a '" + type + "' field: " + fieldName);
         }
         return(reader.ReadPosition(fd));
     }
     throw ThrowUnknownFieldException(fieldName);
 }