Example #1
0
        /// <summary>
        /// Creates a binary aggregate decoder.
        /// </summary>
        /// <param name="path">The path of the member to create an aggregate decoder for.</param>
        /// <param name="source">The encoded data of the aggregate.</param>
        /// <returns>An aggregate encoder capable to decode the given encoded data.</returns>
        public static IAggregateDecoder<IEnumerable<byte>> CreateAggregateDecoder(
            IAggregatePath path,
            IEnumerable<byte> source)
        {
            Debug.Assert(path != null && source != null);

            var sz = path.size();

            return sz != null
                ? (IAggregateDecoder<IEnumerable<byte>>) new FixedSizeDecoder(source, sz.Value)
                : new FlexibleSizeDecoder(source);
        }
Example #2
0
        /// <summary>
        /// Creates a binary aggregate encoder.
        /// </summary>
        /// <param name="path">The path of the member to create an aggregate encoder for.</param>
        /// <param name="instance">The instance of the member that needs to be encoded.</param>
        /// <returns>The binary aggregate encoder for that instance.</returns>
        public static IAggregateEncoder<IEnumerable<byte>> CreateAggregateEncoder(
            IAggregatePath path,
            object instance)
        {
            Debug.Assert(path != null && instance != null);

            var sz = path.size();

            // no size attribute is always treated as a flexible serialization, even though
            // all members may have specified offsets and sizes.

            return sz != null
                ? (IAggregateEncoder<IEnumerable<byte>>) new FixedSizeEncoder(sz.Value)
                : new FlexibleSizeEncoder();
        }
Example #3
0
 public MemberPath(IAggregatePath parent, IMemberInfo member, IEnumerable<Attribute> attributes)
 {
     Parent = parent;
     Member = member;
     Attributes = attributes;
 }