コード例 #1
0
 internal static DataServiceQueryContinuation Create(Uri nextLinkUri, ProjectionPlan plan)
 {
     if (nextLinkUri == null)
     {
         return(null);
     }
     return((DataServiceQueryContinuation)Util.ConstructorInvoke(typeof(DataServiceQueryContinuation <>).MakeGenericType(new Type[] { plan.ProjectedType }).GetInstanceConstructors(false).Single <ConstructorInfo>(), new object[] { nextLinkUri, plan }));
 }
コード例 #2
0
        public IQueryable CreateQuery(Expression expression)
        {
            Util.CheckArgumentNull <Expression>(expression, "expression");
            Type elementType = TypeSystem.GetElementType(expression.Type);
            Type type        = typeof(DataServiceQuery <> .DataServiceOrderedQuery).MakeGenericType(new Type[] { elementType });

            object[] arguments = new object[] { expression, this };
            return((IQueryable)Util.ConstructorInvoke(type.GetInstanceConstructor(false, new Type[] { typeof(Expression), typeof(DataServiceQueryProvider) }), arguments));
        }
コード例 #3
0
        /// <summary>Factory method for creating DataServiceOrderedQuery based on expression </summary>
        /// <param name="expression">The expression for the new query</param>
        /// <returns>new DataServiceQuery</returns>
        public IQueryable CreateQuery(Expression expression)
        {
            Util.CheckArgumentNull(expression, "expression");
            Type et = TypeSystem.GetElementType(expression.Type);
            Type qt = typeof(DataServiceQuery <> .DataServiceOrderedQuery).MakeGenericType(et);

            object[] args = new object[] { expression, this };

            ConstructorInfo ci = qt.GetInstanceConstructor(
                false /*isPublic*/,
                new Type[] { typeof(Expression), typeof(DataServiceQueryProvider) });

            return((IQueryable)Util.ConstructorInvoke(ci, args));
        }
コード例 #4
0
        /// <summary>Creates a new <see cref="DataServiceQueryContinuation"/> instance.</summary>
        /// <param name="nextLinkUri">Link to next page of data (possibly null).</param>
        /// <param name="plan">Plan to materialize the data (only null if nextLinkUri is null).</param>
        /// <returns>A new continuation object; null if nextLinkUri is null.</returns>
        internal static DataServiceQueryContinuation Create(Uri nextLinkUri, ProjectionPlan plan)
        {
            Debug.Assert(plan != null || nextLinkUri == null, "plan != null || nextLinkUri == null");

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

            var    constructors = typeof(DataServiceQueryContinuation <>).MakeGenericType(plan.ProjectedType).GetInstanceConstructors(false /*isPublic*/);
            object result       = Util.ConstructorInvoke(constructors.Single(), new object[] { nextLinkUri, plan });

            return((DataServiceQueryContinuation)result);
        }
コード例 #5
0
        /// <summary>Creates a new <see cref="DataServiceQueryContinuation"/> instance.</summary>
        /// <param name="nextLinkUri">Link to next page of data (possibly null).</param>
        /// <param name="plan">Plan to materialize the data (only null if nextLinkUri is null).</param>
        /// <returns>A new continuation object; null if nextLinkUri is null.</returns>
        internal static DataServiceQueryContinuation Create(Uri nextLinkUri, ProjectionPlan plan)
        {
            Debug.Assert(plan != null || nextLinkUri == null, "plan != null || nextLinkUri == null");

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

            var constructors = typeof(DataServiceQueryContinuation <>).MakeGenericType(plan.ProjectedType).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance);

            Debug.Assert(constructors.Length == 1, "constructors.Length == 1");
            object result = Util.ConstructorInvoke(constructors[0], new object[] { nextLinkUri, plan });

            return((DataServiceQueryContinuation)result);
        }
コード例 #6
0
        internal static QueryOperationResponse GetInstance(Type elementType, HeaderCollection headers, DataServiceRequest query, MaterializeAtom results)
        {
            Type genericType = typeof(QueryOperationResponse <>).MakeGenericType(elementType);

#if !ASTORIA_LIGHT && !PORTABLELIB
            return((QueryOperationResponse)Activator.CreateInstance(
                       genericType,
                       BindingFlags.CreateInstance | BindingFlags.NonPublic | BindingFlags.Instance,
                       null,
                       new object[] { headers, query, results },
                       System.Globalization.CultureInfo.InvariantCulture));
#else
            ConstructorInfo info = genericType.GetInstanceConstructors(false /*isPublic*/).Single();
            return((QueryOperationResponse)Util.ConstructorInvoke(info, new object[] { headers, query, results }));
#endif
        }
コード例 #7
0
        internal static QueryOperationResponse GetInstance(Type elementType, Dictionary <string, string> headers, DataServiceRequest query, MaterializeAtom results)
        {
            Type genericType = typeof(QueryOperationResponse <>).MakeGenericType(elementType);

#if !ASTORIA_LIGHT
            return((QueryOperationResponse)Activator.CreateInstance(
                       genericType,
                       BindingFlags.CreateInstance | BindingFlags.NonPublic | BindingFlags.Instance,
                       null,
                       new object[] { headers, query, results },
                       System.Globalization.CultureInfo.InvariantCulture));
#else
            System.Reflection.ConstructorInfo[] info = genericType.GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance);
            System.Diagnostics.Debug.Assert(1 == info.Length, "only expected 1 ctor");
            return((QueryOperationResponse)Util.ConstructorInvoke(info[0], new object[] { headers, query, results }));
#endif
        }