ParameterRetriever.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 / DataEntity / System / Data / Common / CommandTrees / Internal / ParameterRetriever.cs / 1305376 / ParameterRetriever.cs

                            //---------------------------------------------------------------------- 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// 
// @owner  [....]
// @backupOwner [....] 
//--------------------------------------------------------------------- 

using System; 
using System.Collections.Generic;
using System.Globalization;

using System.Data.Common; 
using System.Data.Metadata.Edm;
using System.Linq; 
using System.Diagnostics; 

namespace System.Data.Common.CommandTrees.Internal 
{
    internal sealed class ParameterRetriever : BasicCommandTreeVisitor
    {
        private readonly Dictionary paramMappings = new Dictionary(); 

        private ParameterRetriever() 
        { 
        }
 
        internal static System.Collections.ObjectModel.ReadOnlyCollection GetParameters(DbCommandTree tree)
        {
            Debug.Assert(tree != null, "Ensure command tree is non-null before calling ParamterRetriever.GetParameters");
 
            ParameterRetriever retriever = new ParameterRetriever();
            retriever.VisitCommandTree(tree); 
            return retriever.paramMappings.Values.ToList().AsReadOnly(); 
        }
 
        public override void Visit(DbParameterReferenceExpression expression)
        {
            Debug.Assert(expression != null, "Command tree subexpressions should never be null");
 
            this.paramMappings[expression.ParameterName] = expression;
        } 
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//---------------------------------------------------------------------- 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// 
// @owner  [....]
// @backupOwner [....] 
//--------------------------------------------------------------------- 

using System; 
using System.Collections.Generic;
using System.Globalization;

using System.Data.Common; 
using System.Data.Metadata.Edm;
using System.Linq; 
using System.Diagnostics; 

namespace System.Data.Common.CommandTrees.Internal 
{
    internal sealed class ParameterRetriever : BasicCommandTreeVisitor
    {
        private readonly Dictionary paramMappings = new Dictionary(); 

        private ParameterRetriever() 
        { 
        }
 
        internal static System.Collections.ObjectModel.ReadOnlyCollection GetParameters(DbCommandTree tree)
        {
            Debug.Assert(tree != null, "Ensure command tree is non-null before calling ParamterRetriever.GetParameters");
 
            ParameterRetriever retriever = new ParameterRetriever();
            retriever.VisitCommandTree(tree); 
            return retriever.paramMappings.Values.ToList().AsReadOnly(); 
        }
 
        public override void Visit(DbParameterReferenceExpression expression)
        {
            Debug.Assert(expression != null, "Command tree subexpressions should never be null");
 
            this.paramMappings[expression.ParameterName] = expression;
        } 
    } 
}

// 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