Beispiel #1
0
        /// <summary>
        /// Initializes the specified <see cref="Tuple"/> with default values.
        /// </summary>
        /// <param name="target">Tuple to initialize.</param>
        /// <param name="nullableMap"><see cref="BitArray"/> instance that flags that field should have null value.</param>
        /// <exception cref="ArgumentException">Tuple descriptor field count is not equal to <paramref name="nullableMap"/> count.</exception>
        public static void Initialize(this Tuple target, BitArray nullableMap)
        {
            var descriptor = target.Descriptor;

            if (descriptor.Count != nullableMap.Count)
            {
                throw new ArgumentException(String.Format(Strings.ExInvalidFieldMapSizeExpectedX, descriptor.Count));
            }

            for (int i = 0; i < target.Count; i++)
            {
                if (nullableMap[i])
                {
                    target.SetFieldState(i, TupleFieldState.Available | TupleFieldState.Null);
                }
                else
                {
                    var fieldType = descriptor[i];
                    if (fieldType.IsValueType)
                    {
                        target.SetValue(i, Activator.CreateInstance(fieldType));
                    }
                    else
                    {
                        target.SetFieldState(i, TupleFieldState.Available);
                    }
                }
            }
        }
Beispiel #2
0
 protected internal override void SetFieldState(int fieldIndex, TupleFieldState fieldState)
 {
     InnerTuple.SetFieldState(fieldIndex, fieldState);
 }