Exemplo n.º 1
0
        public List <T> GetList <T>(string id, SubjectRelatedListFilterData filterData = null) where T : class
        {
            if (_client == null)
            {
                return(default(List <T>));
            }

            object[] obj  = null;
            List <T> list = new List <T>();


            try
            {
                if (filterData == null)
                {
                    filterData = new SubjectRelatedListFilterData {
                    }
                }
                ;

                if (typeof(T) == typeof(XmlListItemData))
                {
                    XElement element = _client.GetListXml(id, filterData);

                    list = XmlListItemData.GetListOf(element) as List <T>;
                }
                else
                {
                    obj = _client.GetList(id, filterData);

                    if (obj != null && obj.Length > 0)
                    {
                        list = obj.OfType <T>().ToList();
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error("GetList<" + typeof(T).Name + ">", e);
                throw;
            }

            return(list);
        }
Exemplo n.º 2
0
        public List <T> GetList <T>(string id, SubjectRelatedListFilterData filterData = null) where T : class
        {
            object[] obj  = null;
            List <T> list = new List <T>();

            CoreService().Using(client =>
            {
                try
                {
                    if (filterData == null)
                    {
                        filterData = new SubjectRelatedListFilterData {
                        }
                    }
                    ;

                    if (typeof(T) == typeof(XmlListItemData))
                    {
                        XElement element = client.GetListXml(id, filterData);

                        list = XmlListItemData.GetListOf(element) as List <T>;
                    }
                    else
                    {
                        obj = client.GetList(id, filterData);

                        if (obj != null && obj.Length > 0)
                        {
                            list = obj.OfType <T>().ToList();
                        }
                    }
                }
                catch (Exception e)
                {
                    throw;
                }
            });

            return(list);
        }