1 //---------------------------------------------------------------------
2 // <copyright file="FacetDescriptionElement.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
10 using System.Collections.Generic;
12 using System.Data.Metadata.Edm;
14 using System.Diagnostics;
16 namespace System.Data.EntityModel.SchemaObjectModel
18 internal abstract class FacetDescriptionElement : SchemaElement
25 // won't be populated till you call CreateAndValidate
26 FacetDescription _facetDescription;
28 public FacetDescriptionElement(TypeElement type, string name)
33 protected override bool ProhibitAttribute(string namespaceUri, string localName)
35 if (base.ProhibitAttribute(namespaceUri, localName))
40 if (namespaceUri == null && localName == XmlConstants.Name)
48 protected override bool HandleAttribute(XmlReader reader)
50 if (base.HandleAttribute(reader))
54 else if (CanHandleAttribute(reader, XmlConstants.MinimumAttribute))
56 HandleMinimumAttribute(reader);
59 else if (CanHandleAttribute(reader, XmlConstants.MaximumAttribute))
61 HandleMaximumAttribute(reader);
64 else if (CanHandleAttribute(reader, XmlConstants.DefaultValueAttribute))
66 HandleDefaultAttribute(reader);
69 else if (CanHandleAttribute(reader, XmlConstants.ConstantAttribute))
71 HandleConstantAttribute(reader);
78 /////////////////////////////////////////////////////////////////////
82 /// Handler for the Minimum attribute
84 /// <param name="reader">xml reader currently positioned at Minimum attribute</param>
85 protected void HandleMinimumAttribute(XmlReader reader)
88 if (HandleIntAttribute(reader, ref value))
95 /// Handler for the Maximum attribute
97 /// <param name="reader">xml reader currently positioned at Maximum attribute</param>
98 protected void HandleMaximumAttribute(XmlReader reader)
101 if (HandleIntAttribute(reader, ref value))
108 /// Handler for the Default attribute
110 /// <param name="reader">xml reader currently positioned at Default attribute</param>
111 protected abstract void HandleDefaultAttribute(XmlReader reader);
114 /// Handler for the Constant attribute
116 /// <param name="reader">xml reader currently positioned at Constant attribute</param>
117 protected void HandleConstantAttribute(XmlReader reader)
120 if (HandleBoolAttribute(reader, ref value))
126 public abstract EdmType FacetType{ get; }
130 get { return _minValue; }
135 get { return _maxValue; }
138 public object DefaultValue
140 get { return _defaultValue; }
141 set { _defaultValue = value; }
144 public FacetDescription FacetDescription
148 Debug.Assert(_facetDescription != null, "Did you forget to call CreateAndValidate first?");
149 return _facetDescription;
153 internal void CreateAndValidateFacetDescription(string declaringTypeName)
155 _facetDescription = new FacetDescription(Name, FacetType, MinValue, MaxValue, DefaultValue, _isConstant, declaringTypeName);