Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the OrderedQueryableProxy class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="underlyingImplementation">The underlying implementation of the proxy.</param>
 public OrderedQueryableProxy(IWrapperScope wrapperScope, System.Linq.IOrderedQueryable underlyingImplementation)
 {
     ExceptionUtilities.CheckArgumentNotNull(wrapperScope, "wrapperScope");
     ExceptionUtilities.CheckArgumentNotNull(underlyingImplementation, "underlyingImplementation");
     
     this.Scope = wrapperScope;
     this.underlyingImplementation = underlyingImplementation;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the OrderedQueryableProxy class.
        /// </summary>
        /// <param name="wrapperScope">The wrapper scope.</param>
        /// <param name="underlyingImplementation">The underlying implementation of the proxy.</param>
        public OrderedQueryableProxy(IWrapperScope wrapperScope, System.Linq.IOrderedQueryable <T> underlyingImplementation)
        {
            ExceptionUtilities.CheckArgumentNotNull(wrapperScope, "wrapperScope");
            ExceptionUtilities.CheckArgumentNotNull(underlyingImplementation, "underlyingImplementation");

            this.Scope = wrapperScope;
            this.underlyingImplementation = underlyingImplementation;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Converts the Linq data to a commaseperated string including header.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="delimiter">The delimiter.</param>
        /// <param name="nullvalue">The nullvalue.</param>
        /// <returns></returns>
        public static string ToCSVString(this System.Linq.IOrderedQueryable data, string delimiter, string nullvalue)
        {
            StringBuilder csvdata          = new StringBuilder();
            string        replaceFrom      = delimiter.Trim();
            string        replaceDelimiter = ";";

            System.Reflection.PropertyInfo[] headers = data.ElementType.GetProperties();
            switch (replaceFrom)
            {
            case ";":
                replaceDelimiter = ":";
                break;

            case ",":
                replaceDelimiter = "¸";
                break;

            case "\t":
                replaceDelimiter = "    ";
                break;

            default:
                break;
            }
            if (headers.Length > 0)
            {
                foreach (var head in headers)
                {
                    csvdata.Append(head.Name.Replace("_", " ") + delimiter);
                }
                csvdata.Append("\n");
            }
            foreach (var row in data)
            {
                var fields = row.GetType().GetProperties();
                for (int i = 0; i < fields.Length; i++)
                {
                    object value = null;
                    try
                    {
                        value = fields[i].GetValue(row, null);
                    }
                    catch { }
                    if (value != null)
                    {
                        csvdata.Append(value.ToString().Replace("\r", "\f").Replace("\n", " \f").Replace("_", " ").Replace(replaceFrom, replaceDelimiter) + delimiter);
                    }
                    else
                    {
                        csvdata.Append(nullvalue);
                        csvdata.Append(delimiter);
                    }
                }
                csvdata.Append("\n");
            }
            return(csvdata.ToString());
        }
Exemplo n.º 4
0
 /// <summary>
 /// Disposes the wrapped instance if it implements IDisposable.
 /// </summary>
 /// <param name="disposing">Whether or not to dispose managed resources</param>
 protected virtual void Dispose(bool disposing)
 {
     CallOrderUtilities.TryWrapArbitraryMethodCall(
         () => this.Dispose(),
         () =>
     {
         var d = this.underlyingImplementation as IDisposable;
         if (d != null)
         {
             d.Dispose();
             this.underlyingImplementation = null;
         }
     });
 }
Exemplo n.º 5
0
        public void CanObtainFromCovariantIOrderedQueryable()
        {
            // If an ordered queryable is cast covariantly and then has ThenBy() called on it,
            // it depends on IOrderedEnumerable<TElement> also being covariant to allow for
            // that ThenBy() to be processed within Linq-to-objects, as otherwise there is no
            // equivalent ThenBy() overload to translate the call to.

            System.Linq.IOrderedQueryable <IComparable> ordered =
                System.Linq.Queryable.OrderBy(
                    System.Linq.Queryable.Select(
                        System.Linq.Queryable.AsQueryable(
                            Enumerable.Range(0, 100)
                            ),
                        i => i.ToString()),
                    i => i.Length);
            ordered = System.Linq.Queryable.ThenBy(ordered, i => i);
            string[] expected =
                Enumerable.Range(0, 100).Select(i => i.ToString()).OrderBy(i => i.Length).ThenBy(i => i).ToArray();
            Assert.Equal(expected, ordered);
        }
Exemplo n.º 6
0
 public static System.Linq.IOrderedQueryable <TSource> ThenByDescending <TSource, TKey>(this System.Linq.IOrderedQueryable <TSource> source, System.Linq.Expressions.Expression <System.Func <TSource, TKey> > keySelector, System.Collections.Generic.IComparer <TKey> comparer)
 {
     return(default(System.Linq.IOrderedQueryable <TSource>));
 }
Exemplo n.º 7
0
 public static System.Linq.IOrderedQueryable <TSource> ThenBy <TSource, TKey>(this System.Linq.IOrderedQueryable <TSource> source, System.Linq.Expressions.Expression <System.Func <TSource, TKey> > keySelector)
 {
     return(default(System.Linq.IOrderedQueryable <TSource>));
 }
Exemplo n.º 8
0
 public static System.Linq.IOrderedQueryable <TSource> ThenBy <TSource, TKey>(this System.Linq.IOrderedQueryable <TSource> source, System.Linq.Expressions.Expression <System.Func <TSource, TKey> > keySelector, System.Collections.Generic.IComparer <TKey> comparer)
 {
     throw null;
 }
Exemplo n.º 9
0
 public static System.Linq.IOrderedQueryable <TSource> ThenBy <TSource, TKey>(this System.Linq.IOrderedQueryable <TSource> source, System.Linq.Expressions.Expression <System.Func <TSource, TKey> > keySelector)
 {
     throw null;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Converts the Linq data to a commaseperated string including header.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <param name="delimiter">The delimiter.</param>
 /// <returns></returns>
 public static string ToCSVString(this System.Linq.IOrderedQueryable data, string delimiter)
 {
     return(ToCSVString(data, "; ", null));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Converts the Linq data to a commaseperated string including header.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <returns></returns>
 public static string ToCSVString(this System.Linq.IOrderedQueryable data)
 {
     return(ToCSVString(data, "; "));
 }
Exemplo n.º 12
0
 /// <summary>
 /// Disposes the wrapped instance if it implements IDisposable.
 /// </summary>
 /// <param name="disposing">Whether or not to dispose managed resources</param>
 protected virtual void Dispose(bool disposing)
 {
     CallOrderUtilities.TryWrapArbitraryMethodCall(
         () => this.Dispose(),
         () =>
             {
                 var d = this.underlyingImplementation as IDisposable;
                 if (d != null)
                 {
                     d.Dispose();
                     this.underlyingImplementation = null;
                 }
             });
 }