예제 #1
0
        public Entity(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            Type = type;
            Name = Type.Name;
            SetTableName(Name.Pluralize());
            Verbose = new Verbose(Type);

            Properties = type.GetProperties()
                         .Select(x => new Property(this, x))
                         .ToList();

            if (IsChangeEntity)
            {
                AllowAdd = AllowEdit = AllowDelete = false;
            }

            // check if has ToString() method
            HasToStringMethod =
                Type.GetMethod("ToString")
                .DeclaringType.Name != "Object";
        }
예제 #2
0
        public Entity(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            Type    = type;
            Name    = Type.Name;
            Verbose = new Verbose(type);

            Properties = type.GetProperties()
                         .Select(x => new Property(this, x))
                         .ToList();

            Links = new Links(Attributes);
            SetTableName(Attributes);
            SetLinkKey();

            SetSearchProperties(Attributes);

            CanAdd = true;
            if (IsChangeEntity)
            {
                CanAdd = Links.HasDelete = Links.HasEdit = false;
            }

            // check if has ToString() method
            HasToStringMethod =
                Type.GetMethod("ToString")
                .DeclaringType.Name != "Object";

            var recordDisplay = Attributes.OfType <RecordDisplayAttribute>().FirstOrDefault();

            if (recordDisplay != null)
            {
                RecordDisplayFormat = recordDisplay.DisplayFormat;
            }
        }
예제 #3
0
        public Entity(Type type)
        {
            if (type == null)
                throw new ArgumentNullException(nameof(type));

            Type = type;
            Name = Type.Name;
            SetTableName(Name.Pluralize());
            Verbose = new Verbose(Type);

            Properties = type.GetProperties()
                .Select(x => new Property(this, x))
                .ToList();

            if (IsChangeEntity)
            {
                AllowAdd = AllowEdit = AllowDelete = false;
            }

            // check if has ToString() method
            HasToStringMethod =
                Type.GetMethod("ToString")
                .DeclaringType.Name != "Object";
        }
예제 #4
0
        public Entity(Type type)
        {
            if (type == null)
                throw new ArgumentNullException("type");

            Type = type;
            Name = Type.Name;
            Verbose = new Verbose(type);

            Properties = type.GetProperties()
                .Select(x => new Property(this, x))
                .ToList();

            Links = new Links(Attributes);
            SetTableName(Attributes);
            SetLinkKey();

            SetSearchProperties(Attributes);

            CanAdd = true;
            if (IsChangeEntity)
            {
                CanAdd = Links.HasDelete = Links.HasEdit = false;
            }

            // check if has ToString() method
            HasToStringMethod =
                Type.GetMethod("ToString")
                .DeclaringType.Name != "Object";

            var recordDisplay = Attributes.OfType<RecordDisplayAttribute>().FirstOrDefault();
            if (recordDisplay != null)
            {
                RecordDisplayFormat = recordDisplay.DisplayFormat;
            }
        }