DataServiceExpressionVisitor.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Client / System / Data / Services / Client / ALinq / DataServiceExpressionVisitor.cs / 1305376 / DataServiceExpressionVisitor.cs

                            //---------------------------------------------------------------------- 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//  
//      Expression Visitors for Linq to URI translator
//  
// 
// @owner  [....]
//--------------------------------------------------------------------- 
namespace System.Data.Services.Client
{
    #region Namespaces.
 
    using System.Diagnostics;
    using System.Linq.Expressions; 
 
    #endregion Namespaces.
 
    /// 
    /// Specific Vistior base class for the DataServiceQueryProvider.
    /// 
    internal abstract class DataServiceALinqExpressionVisitor : ALinqExpressionVisitor 
    {
        ///  
        /// Main visit method. 
        /// 
        /// Expression to visit 
        /// Visited expression
        internal override Expression Visit(Expression exp)
        {
            if (exp == null) 
            {
                return null; 
            } 

            switch ((ResourceExpressionType)exp.NodeType) 
            {
                case ResourceExpressionType.RootResourceSet:
                case ResourceExpressionType.ResourceNavigationProperty:
                    return this.VisitResourceSetExpression((ResourceSetExpression)exp); 
                case ResourceExpressionType.ResourceNavigationPropertySingleton:
                    return this.VisitNavigationPropertySingletonExpression((NavigationPropertySingletonExpression)exp); 
                case ResourceExpressionType.InputReference: 
                    return this.VisitInputReferenceExpression((InputReferenceExpression)exp);
                default: 
                    return base.Visit(exp);
            }
        }
 
        /// 
        /// ResourceSetExpression visit method. 
        ///  
        /// ResourceSetExpression expression to visit
        /// Visited ResourceSetExpression expression 
        internal virtual Expression VisitResourceSetExpression(ResourceSetExpression rse)
        {
            Expression source = this.Visit(rse.Source);
 
            if (source != rse.Source)
            { 
                rse = new ResourceSetExpression(rse.Type, source, rse.MemberExpression, rse.ResourceType, rse.ExpandPaths, rse.CountOption, rse.CustomQueryOptions, rse.Projection); 
            }
 
            return rse;
        }

        ///  
        /// NavigationPropertySingletonExpressionvisit method.
        ///  
        /// NavigationPropertySingletonExpression expression to visit 
        /// Visited NavigationPropertySingletonExpression expression
        internal virtual Expression VisitNavigationPropertySingletonExpression(NavigationPropertySingletonExpression npse) 
        {
            Expression source = this.Visit(npse.Source);

            if (source != npse.Source) 
            {
                npse = new NavigationPropertySingletonExpression(npse.Type, source, npse.MemberExpression, npse.MemberExpression.Type, npse.ExpandPaths, npse.CountOption, npse.CustomQueryOptions, npse.Projection); 
            } 

            return npse; 
        }

        /// 
        /// Visit an , producing a new InputReferenceExpression 
        /// based on the visited form of the  that is referenced by
        /// the InputReferenceExpression argument, . 
        ///  
        /// InputReferenceExpression expression to visit
        /// Visited InputReferenceExpression expression 
        internal virtual Expression VisitInputReferenceExpression(InputReferenceExpression ire)
        {
            Debug.Assert(ire != null, "ire != null -- otherwise caller never should have visited here");
            ResourceExpression re = (ResourceExpression)this.Visit(ire.Target); 
            return re.CreateReference();
        } 
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//---------------------------------------------------------------------- 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//  
//      Expression Visitors for Linq to URI translator
//  
// 
// @owner  [....]
//--------------------------------------------------------------------- 
namespace System.Data.Services.Client
{
    #region Namespaces.
 
    using System.Diagnostics;
    using System.Linq.Expressions; 
 
    #endregion Namespaces.
 
    /// 
    /// Specific Vistior base class for the DataServiceQueryProvider.
    /// 
    internal abstract class DataServiceALinqExpressionVisitor : ALinqExpressionVisitor 
    {
        ///  
        /// Main visit method. 
        /// 
        /// Expression to visit 
        /// Visited expression
        internal override Expression Visit(Expression exp)
        {
            if (exp == null) 
            {
                return null; 
            } 

            switch ((ResourceExpressionType)exp.NodeType) 
            {
                case ResourceExpressionType.RootResourceSet:
                case ResourceExpressionType.ResourceNavigationProperty:
                    return this.VisitResourceSetExpression((ResourceSetExpression)exp); 
                case ResourceExpressionType.ResourceNavigationPropertySingleton:
                    return this.VisitNavigationPropertySingletonExpression((NavigationPropertySingletonExpression)exp); 
                case ResourceExpressionType.InputReference: 
                    return this.VisitInputReferenceExpression((InputReferenceExpression)exp);
                default: 
                    return base.Visit(exp);
            }
        }
 
        /// 
        /// ResourceSetExpression visit method. 
        ///  
        /// ResourceSetExpression expression to visit
        /// Visited ResourceSetExpression expression 
        internal virtual Expression VisitResourceSetExpression(ResourceSetExpression rse)
        {
            Expression source = this.Visit(rse.Source);
 
            if (source != rse.Source)
            { 
                rse = new ResourceSetExpression(rse.Type, source, rse.MemberExpression, rse.ResourceType, rse.ExpandPaths, rse.CountOption, rse.CustomQueryOptions, rse.Projection); 
            }
 
            return rse;
        }

        ///  
        /// NavigationPropertySingletonExpressionvisit method.
        ///  
        /// NavigationPropertySingletonExpression expression to visit 
        /// Visited NavigationPropertySingletonExpression expression
        internal virtual Expression VisitNavigationPropertySingletonExpression(NavigationPropertySingletonExpression npse) 
        {
            Expression source = this.Visit(npse.Source);

            if (source != npse.Source) 
            {
                npse = new NavigationPropertySingletonExpression(npse.Type, source, npse.MemberExpression, npse.MemberExpression.Type, npse.ExpandPaths, npse.CountOption, npse.CustomQueryOptions, npse.Projection); 
            } 

            return npse; 
        }

        /// 
        /// Visit an , producing a new InputReferenceExpression 
        /// based on the visited form of the  that is referenced by
        /// the InputReferenceExpression argument, . 
        ///  
        /// InputReferenceExpression expression to visit
        /// Visited InputReferenceExpression expression 
        internal virtual Expression VisitInputReferenceExpression(InputReferenceExpression ire)
        {
            Debug.Assert(ire != null, "ire != null -- otherwise caller never should have visited here");
            ResourceExpression re = (ResourceExpression)this.Visit(ire.Target); 
            return re.CreateReference();
        } 
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK