Пример #1
0
 public DatumInfo(DatumFlags flags, int size = 0, int precision = 0, int scale = 0)
 {
     this.size = size;
     this.precision = precision;
     this.scale = scale;
     this.flags = flags;
 }
Пример #2
0
        public MemberDescriptor(PropertyInfo property, int order = 0, bool versioned = false)
            : this(property.Name.ToMemberName(), property.PropertyType, property, order)
        {
            if (versioned)
            {
                if (IsUnique || IsIndexed)
                {
                    flags &= ~DatumFlags.Indexed;
                    flags &= ~DatumFlags.Unique; // We need to move these up to a compound index
                }

                if (IsIdentity)
                {
                    flags &= ~DatumFlags.Identity;
                }

                if (IsVersion)
                {
                    flags |= DatumFlags.Key;
                }
            }

            _get = property.GetValue;
            _set = property.SetValue;
        }
Пример #3
0
        public static DatumInfo AsciiString(int length, bool isFixedSize = false)
        {
            var flags = DatumFlags.String | Ascii;

            if (isFixedSize) flags |= FixedSize;

            return new DatumInfo(flags, length);
        }
Пример #4
0
        // Range

        public static DatumInfo Binary(int length, bool isFixedSize = false)
        {
            var flags = DatumFlags.Binary;

            if (isFixedSize) flags |= FixedSize;

            return new DatumInfo(flags, length);
        }
Пример #5
0
        private MemberDescriptor(string name, Type _type, MemberInfo _member, int order)
        {
            #region Preconditions

            if (_type == null) throw new ArgumentNullException(nameof(_type));
            if (_member == null) throw new ArgumentNullException(nameof(_member));

            #endregion

            typeDetails = TypeDetails.Get(_type);

            Order = order;

            if (typeDetails.IsNullable || !typeDetails.IsValueType)
            {
                flags |= DatumFlags.Optional;
            }

            Name         = name;
            PropertyName = _member.Name;

            foreach (var a in _member.GetCustomAttributes())
            {
                if (a is ColumnAttribute)
                {
                    var columnAttribute = (ColumnAttribute)a;

                    if (columnAttribute.Name != null)
                    {
                        Name = columnAttribute.Name;
                    }

                    if (columnAttribute.Order != 0)
                    {
                        Order = columnAttribute.Order;
                    }
                }
                else if (a is MutableAttribute)
                {
                    flags |= DatumFlags.Mutable;
                }
                else if (a is AsciiAttribute)
                {
                    flags |= DatumFlags.Ascii;
                }
                else if (a is IdentityAttribute)
                {
                    var identity = (IdentityAttribute)a;

                    flags |= (DatumFlags.Identity | DatumFlags.Key);

                    flags &= ~DatumFlags.Mutable; // An identity may not be changed
                    flags &= ~DatumFlags.Optional;

                    Identity = identity;
                }
                else if (a is KeyAttribute || a is cm::KeyAttribute)
                {
                    flags |= DatumFlags.Key;

                    flags &= ~DatumFlags.Mutable; // An identity may not be changed
                }
                else if (a is TimestampAttribute)
                {
                    flags |= DatumFlags.Timestamp | DatumFlags.Computed;

                    flags &= ~DatumFlags.Mutable; // An identity may not be changed
                }
                else if (a is cm::RequiredAttribute)
                {
                    flags &= ~DatumFlags.Optional;
                }
                else if (a is FixedSizeAttribute)
                {
                    flags &= ~DatumFlags.FixedSize;
                }
                else if (a is cm::MaxLengthAttribute)
                {
                    var m = (cm::MaxLengthAttribute)a;

                    Size = m.Length;
                }
                else if (a is cm::StringLengthAttribute)
                {
                    var m = (cm::StringLengthAttribute)a;

                    Size = m.MaximumLength;
                }
                else if (a is VersionAttribute)
                {
                    flags |= DatumFlags.Version;
                    flags &= ~DatumFlags.Optional;
                }
                else if (a is PrecisionAttribute)
                {
                    var p = a as PrecisionAttribute;

                    Precision = p.Precision;
                    Scale = p.Scale;
                }
                else if (a is UniqueAttribute)
                {
                    flags |= DatumFlags.Unique | DatumFlags.Indexed;
                }
                else if (a is IndexedAttribute)
                {
                    flags |= DatumFlags.Indexed;
                }
            }

            if (Size == null)
            {
                Size = GetSize(_type);
            }
        }
Пример #6
0
        public MemberDescriptor(string name, Type type, bool isKey = false)
        {
            Name = name;
            PropertyName = name;

            if (isKey)
            {
                flags |= DatumFlags.Key;
            }

            this.typeDetails = TypeDetails.Get(type);
        }