Esempio n. 1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        internal EntityMemberName(EntityMember member)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member");
            }

            // set...
            if (member.EntityType == null)
            {
                throw new InvalidOperationException("member.EntityType is null.");
            }
            _entityTypeName = member.EntityType.EntityTypeName;
            _name           = member.Name;

            // check...
            if (member is EntityField)
            {
                _memberType = EntityMemberType.Field;
            }
            else
            {
                throw new NotSupportedException(string.Format("Cannot handle '{0}'.", member));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a view property for the given expression.
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="expression"></param>
        /// <returns></returns>
        public static EntityViewProperty GetViewProperty(EntityType entityType, string expression)
        {
            if (entityType == null)
            {
                throw new ArgumentNullException("entityType");
            }
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }
            if (expression.Length == 0)
            {
                throw ExceptionHelper.CreateZeroLengthArgumentException("expression");
            }

            // is it a member?
            EntityMember member = entityType.GetMember(expression, OnNotFound.ReturnNull);

            if (member != null)
            {
                return(member.GetViewProperty());
            }

            // is it a property?
            PropertyInfo property = entityType.Type.GetProperty(expression, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);

            if (property != null)
            {
                return(new EntityBindViewProperty(entityType, property));
            }

            // throw...
            throw new InvalidOperationException(string.Format(Cultures.Exceptions, "Cannot create expression for '{0}' on '{1}'.", expression, entityType));
        }
Esempio n. 3
0
        public void Initializing(EntityMemberBox box, BootFX.Common.Entities.EntityMember member)
        {
            if (box == null)
            {
                throw new ArgumentNullException("box");
            }
            if (member == null)
            {
                throw new ArgumentNullException("member");
            }

            // set...
            if (member is EntityField)
            {
                EntityField field = (EntityField)member;
                if (field.EnumerationType != null)
                {
                    this.EnumType = field.EnumerationType;
                }
                else
                {
                    throw new InvalidOperationException(string.Format("Field '{0}' does not have an enumeration mapping.", member));
                }
            }
            else
            {
                throw new NotSupportedException(string.Format("Cannot handle '{0}'.", member));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Sorts the list using the given comparer.
        /// </summary>
        /// <param name="comparer"></param>
        public void Sort(string memberName, CultureInfo culture, SortDirection direction)
        {
            if (memberName == null)
            {
                throw new ArgumentNullException("memberName");
            }
            if (memberName.Length == 0)
            {
                throw new ArgumentOutOfRangeException("'memberName' is zero-length.");
            }

            // check...
            this.AssertIsStrongCollection();

            // get...
            EntityMember member = this.EntityType.GetMember(memberName, OnNotFound.ThrowException);

            if (member == null)
            {
                throw new InvalidOperationException("member is null.");
            }
            if (member is EntityField)
            {
                this.Sort((EntityField)member, culture, direction);
            }
            else
            {
                throw new NotSupportedException(string.Format("Cannot handle '{0}'.", member));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="member"></param>
        public EntityMemberViewProperty(EntityMember member) : base(member.EntityType)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member");
            }

            _member = member;
        }
Esempio n. 6
0
        /// <summary>
        /// Gets the key for the given field.
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        private object GetKey(EntityMember member)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member");
            }

            // just return it...
            return(member);
        }
Esempio n. 7
0
        /// <summary>
        /// Gets the value for the given field.
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public void SetValue(EntityMember member, object value)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member");
            }

            // set...
            object key = this.GetKey(member);

            this.Values[key] = value;
        }
Esempio n. 8
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="field"></param>
        internal EntityMemberComparer(IComparer innerComparer, EntityMember member)
        {
            if (innerComparer == null)
            {
                throw new ArgumentNullException("innerComparer");
            }
            if (member == null)
            {
                throw new ArgumentNullException("member");
            }

            // set...
            _innerComparer = innerComparer;
            _member        = member;
        }
Esempio n. 9
0
        /// <summary>
        /// Pulls the value from the entity.
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        private object PullValue(EntityMember member)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member");
            }

            if (member is EntityField)
            {
                return(this.PullValue((EntityField)member));
            }
            if (member is ChildToParentEntityLink)
            {
                return(this.PullValue((ChildToParentEntityLink)member));
            }
            else
            {
                throw new NotSupportedException(string.Format(Cultures.Exceptions, "Cannot handle '{0}'.", member.GetType()));
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Gets the value for the given field.
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public object GetValue(EntityMember member)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member");
            }

            // in the cache?
            object key   = this.GetKey(member);
            object value = null;

            if (this.Values.Contains(key) == false)
            {
                value            = this.PullValue(member);
                this.Values[key] = value;
            }
            else
            {
                value = this.Values[key];
            }

            // return...
            return(value);
        }