Esempio n. 1
0
        private IList <TokenRowData> InternalSelect(int startRowIndex, int maximumRows, out int resultCount)
        {
            Array tokenRowData      = null;
            Array tokenRowDataRange = Array.CreateInstance(typeof(TokenRowData), maximumRows);

            resultCount = 0;

            if (maximumRows == 0)
            {
                return(new List <TokenRowData>());
            }

            using (AuthorityManagement service = new AuthorityManagement())
            {
                IList <AuthorityTokenSummary> tokens    = service.ListAuthorityTokens();
                List <TokenRowData>           tokenRows = CollectionUtils.Map <AuthorityTokenSummary, TokenRowData>(
                    tokens, delegate(AuthorityTokenSummary token)
                {
                    TokenRowData row = new TokenRowData(token);
                    return(row);
                });

                tokenRowData = CollectionUtils.ToArray(tokenRows);

                int copyLength = adjustCopyLength(startRowIndex, maximumRows, tokenRowData.Length);

                Array.Copy(tokenRowData, startRowIndex, tokenRowDataRange, 0, copyLength);

                if (copyLength < tokenRowDataRange.Length)
                {
                    tokenRowDataRange = resizeArray(tokenRowDataRange, copyLength);
                }
            };

            if (tokenRowData != null)
            {
                resultCount = tokenRowData.Length;
            }

            return(CollectionUtils.Cast <TokenRowData>(tokenRowDataRange));
        }
Esempio n. 2
0
        private IList<TokenRowData> InternalSelect(int startRowIndex, int maximumRows, out int resultCount)
        {
            Array tokenRowData = null;
            Array tokenRowDataRange = Array.CreateInstance(typeof(TokenRowData), maximumRows);

            resultCount = 0;

            if (maximumRows == 0) return new List<TokenRowData>();

            using(AuthorityManagement service = new AuthorityManagement())
            {
                IList<AuthorityTokenSummary> tokens = service.ListAuthorityTokens();
                List<TokenRowData> tokenRows = CollectionUtils.Map<AuthorityTokenSummary, TokenRowData>(
                    tokens, delegate(AuthorityTokenSummary token)
                           {
                               TokenRowData row = new TokenRowData(token);
                               return row;
                           });

                tokenRowData = CollectionUtils.ToArray(tokenRows);

                int copyLength = adjustCopyLength(startRowIndex, maximumRows, tokenRowData.Length);

                Array.Copy(tokenRowData, startRowIndex, tokenRowDataRange, 0, copyLength);

                if(copyLength < tokenRowDataRange.Length)
                {
                    tokenRowDataRange = resizeArray(tokenRowDataRange, copyLength);
                }
            };

            if (tokenRowData != null)
            {
                resultCount = tokenRowData.Length;
            }

            return CollectionUtils.Cast<TokenRowData>(tokenRowDataRange);
        }