예제 #1
0
        public TOut GetObject <T, TOut>(IEnumerable <Filter> filters = null, bool loadChild = false, bool getDeleted = false, bool getAll = false) where T : BaseEntity, new() where TOut : BaseEntityObject, new()
        {
            if (!typeof(T).IsSubclassOf(typeof(BaseEntity)))
            {
                throw new ArgumentException("T", "не является наследником " + typeof(BaseEntity).Name);
            }

            if (!typeof(TOut).IsSubclassOf(typeof(BaseEntityObject)))
            {
                throw new ArgumentException("TOut", "не является наследником " + typeof(BaseEntityObject).Name);
            }

            var dto = _provider.GetObject <T>(filters, loadChild, getDeleted, getAll);

            if (dto == null)
            {
                return(null);
            }

            var methodName = GetConverterMethodName(typeof(TOut));
            var method     = GetMethod(typeof(T), methodName);

            return(InvokeConverter <T, TOut>(dto, method));
        }