Esempio n. 1
0
        /// <summary>
        /// Deserializes a fixed object and returns the object. The default implementation uses CreateFixed()
        /// and GetFixedBuffer() and returns what CreateFixed() returned.
        /// </summary>
        /// <param name="reuse">If appropriate, uses this object instead of creating a new one.</param>
        /// <param name="writerSchema">The FixedSchema the writer used during serialization.</param>
        /// <param name="readerSchema">The schema that the readr uses. Must be a FixedSchema with the same
        /// size as the writerSchema.</param>
        /// <param name="d">The decoder for deserialization.</param>
        /// <returns>The deserilized object.</returns>
        protected override object ReadFixed(object reuse, FixedSchema writerSchema, Schema readerSchema, Decoder d)
        {
            FixedSchema rs = readerSchema as FixedSchema;

            if (rs.Size != writerSchema.Size)
            {
                throw new AvroException("Size mismatch between reader and writer fixed schemas. Writer: " + writerSchema +
                                        ", reader: " + readerSchema);
            }

            SpecificFixed fixedrec = (reuse != null ? reuse : ObjectCreator.Instance.New(rs.Fullname, Schema.Type.Fixed)) as SpecificFixed;

            d.ReadFixed(fixedrec.Value);
            return(fixedrec);
        }
Esempio n. 2
0
 protected bool Equals(SpecificFixed obj)
 {
     if (this == obj)
     {
         return(true);
     }
     if (obj != null && obj is SpecificFixed)
     {
         SpecificFixed that = obj as SpecificFixed;
         if (that.Schema.Equals(this.Schema))
         {
             for (int i = 0; i < value.Length; i++)
             {
                 if (this.value[i] != that.Value[i])
                 {
                     return(false);
                 }
             }
             return(true);
         }
     }
     return(false);
 }