Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Data.Entity / System / Data / Mapping / ViewGeneration / Structures / ConstantProjectedSlot.cs
1 //---------------------------------------------------------------------
2 // <copyright file="ConstantProjectedSlot.cs" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner Microsoft
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
9
10 using System.Data.Mapping.ViewGeneration.CqlGeneration;
11 using System.Collections.Generic;
12 using System.Text;
13 using System.Diagnostics;
14 using System.Data.Common.CommandTrees;
15 using System.Data.Common.CommandTrees.ExpressionBuilder;
16
17 namespace System.Data.Mapping.ViewGeneration.Structures
18 {
19     /// <summary>
20     /// A constant that can be projected in a cell query.
21     /// </summary>
22     internal sealed class ConstantProjectedSlot : ProjectedSlot
23     {
24         #region Constructors
25         /// <summary>
26         /// Creates a slot with constant value being <paramref name="value"/>.
27         /// </summary>
28         internal ConstantProjectedSlot(Constant value, MemberPath memberPath)
29         {
30             Debug.Assert(value != null);
31             Debug.Assert(value.IsNotNull() == false, "Cannot store NotNull in a slot - NotNull is only for conditions");
32             m_constant = value;
33             m_memberPath = memberPath;
34         }
35         #endregion
36
37         #region Fields
38         /// <summary>
39         /// The actual value.
40         /// </summary>
41         private readonly Constant m_constant;
42         private readonly MemberPath m_memberPath;
43         #endregion
44
45         #region Properties
46         /// <summary>
47         /// Returns the value stored in this constant.
48         /// </summary>
49         internal Constant CellConstant
50         {
51             get { return m_constant; }
52         }
53
54         #endregion
55
56         #region Methods
57         internal override ProjectedSlot DeepQualify(CqlBlock block)
58         {
59             return this; // Nothing to create
60         }
61
62         internal override StringBuilder AsEsql(StringBuilder builder, MemberPath outputMember, string blockAlias, int indentLevel)
63         {
64             return m_constant.AsEsql(builder, outputMember, blockAlias);
65         }
66
67         internal override DbExpression AsCqt(DbExpression row, MemberPath outputMember)
68         {
69             return m_constant.AsCqt(row, outputMember);
70         }
71
72         protected override bool IsEqualTo(ProjectedSlot right)
73         {
74             ConstantProjectedSlot rightSlot = right as ConstantProjectedSlot;
75             if (rightSlot == null)
76             {
77                 return false;
78             }
79             return Constant.EqualityComparer.Equals(m_constant, rightSlot.m_constant);
80         }
81
82         protected override int GetHash()
83         {
84             return Constant.EqualityComparer.GetHashCode(m_constant);
85         }
86
87         internal override void ToCompactString(StringBuilder builder)
88         {
89             m_constant.ToCompactString(builder);
90         }
91         #endregion
92     }
93 }