示例#1
0
        protected EdmFunctionParameterMode?OptionalFunctionParameterMode(string attributeName)
        {
            XmlAttributeInfo attr = this.GetOptionalAttribute(this.currentElement, attributeName);

            if (!attr.IsMissing)
            {
                switch (attr.Value)
                {
                case CsdlConstants.Value_ModeIn:
                    return(EdmFunctionParameterMode.In);

                case CsdlConstants.Value_ModeInOut:
                    return(EdmFunctionParameterMode.InOut);

                case CsdlConstants.Value_ModeOut:
                    return(EdmFunctionParameterMode.Out);

                default:
                    this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidParameterMode, Edm.Strings.CsdlParser_InvalidParameterMode(attr.Value));
                    return(EdmFunctionParameterMode.None);
                }
            }

            return(null);
        }
        protected EdmMultiplicity RequiredMultiplicity(string attributeName)
        {
            XmlAttributeInfo requiredAttribute = this.GetRequiredAttribute(this.currentElement, attributeName);

            if (!requiredAttribute.IsMissing)
            {
                string value = requiredAttribute.Value;
                string str   = value;
                if (value != null)
                {
                    if (str == "1")
                    {
                        return(EdmMultiplicity.One);
                    }
                    else
                    {
                        if (str == "0..1")
                        {
                            return(EdmMultiplicity.ZeroOrOne);
                        }
                        else
                        {
                            if (str == "*")
                            {
                                return(EdmMultiplicity.Many);
                            }
                        }
                    }
                }
                base.ReportError(this.currentElement.Location, EdmErrorCode.InvalidMultiplicity, Strings.CsdlParser_InvalidMultiplicity(requiredAttribute.Value));
            }
            return(EdmMultiplicity.One);
        }
        protected EdmConcurrencyMode?OptionalConcurrencyMode(string attributeName)
        {
            XmlAttributeInfo optionalAttribute = this.GetOptionalAttribute(this.currentElement, attributeName);

            if (!optionalAttribute.IsMissing)
            {
                string value = optionalAttribute.Value;
                string str   = value;
                if (value != null)
                {
                    if (str == "None")
                    {
                        return(new EdmConcurrencyMode?(EdmConcurrencyMode.None));
                    }
                    else
                    {
                        if (str == "Fixed")
                        {
                            return(new EdmConcurrencyMode?(EdmConcurrencyMode.Fixed));
                        }
                    }
                }
                base.ReportError(this.currentElement.Location, EdmErrorCode.InvalidConcurrencyMode, Strings.CsdlParser_InvalidConcurrencyMode(optionalAttribute.Value));
            }
            EdmConcurrencyMode?nullable = null;

            return(nullable);
        }
示例#4
0
        protected EdmMultiplicity RequiredMultiplicity(string attributeName)
        {
            XmlAttributeInfo attr = this.GetRequiredAttribute(this.currentElement, attributeName);

            if (!attr.IsMissing)
            {
                switch (attr.Value)
                {
                case CsdlConstants.Value_EndRequired:
                    return(EdmMultiplicity.One);

                case CsdlConstants.Value_EndOptional:
                    return(EdmMultiplicity.ZeroOrOne);

                case CsdlConstants.Value_EndMany:
                    return(EdmMultiplicity.Many);

                default:
                    this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidMultiplicity, Edm.Strings.CsdlParser_InvalidMultiplicity(attr.Value));
                    break;
                }
            }

            return(EdmMultiplicity.One);
        }
        protected int?OptionalSrid(string attributeName, int defaultSrid)
        {
            int?nullable;
            XmlAttributeInfo optionalAttribute = this.GetOptionalAttribute(this.currentElement, attributeName);

            if (optionalAttribute.IsMissing)
            {
                return(new int?(defaultSrid));
            }
            else
            {
                if (!optionalAttribute.Value.EqualsOrdinalIgnoreCase("Variable"))
                {
                    if (!EdmValueParser.TryParseInt(optionalAttribute.Value, out nullable))
                    {
                        base.ReportError(this.currentElement.Location, EdmErrorCode.InvalidSrid, Strings.ValueParser_InvalidSrid(optionalAttribute.Value));
                    }
                }
                else
                {
                    nullable = null;
                }
                return(nullable);
            }
        }
        protected EdmOnDeleteAction RequiredOnDeleteAction(string attributeName)
        {
            XmlAttributeInfo requiredAttribute = this.GetRequiredAttribute(this.currentElement, attributeName);

            if (!requiredAttribute.IsMissing)
            {
                string value = requiredAttribute.Value;
                string str   = value;
                if (value != null)
                {
                    if (str == "None")
                    {
                        return(EdmOnDeleteAction.None);
                    }
                    else
                    {
                        if (str == "Cascade")
                        {
                            return(EdmOnDeleteAction.Cascade);
                        }
                    }
                }
                base.ReportError(this.currentElement.Location, EdmErrorCode.InvalidOnDelete, Strings.CsdlParser_InvalidDeleteAction(requiredAttribute.Value));
            }
            return(EdmOnDeleteAction.None);
        }
示例#7
0
        protected string RequiredEnumMemberPath(string attributeName)
        {
            XmlAttributeInfo attr = this.GetRequiredAttribute(this.currentElement, attributeName);

            if (!attr.IsMissing)
            {
                return(this.ValidateEnumMemberPath(attr.Value));
            }

            return(null);
        }
示例#8
0
        protected string RequiredQualifiedName(string attributeName)
        {
            XmlAttributeInfo attr = this.GetRequiredAttribute(this.currentElement, attributeName);

            if (!attr.IsMissing)
            {
                return(this.ValidateQualifiedName(attr.Value));
            }

            return(null);
        }
示例#9
0
        protected string OptionalType(string attributeName)
        {
            XmlAttributeInfo attr = this.GetOptionalAttribute(this.currentElement, attributeName);

            if (!attr.IsMissing)
            {
                return(this.ValidateTypeName(attr.Value));
            }

            return(null);
        }
        protected string Required(string attributeName)
        {
            XmlAttributeInfo requiredAttribute = this.GetRequiredAttribute(this.currentElement, attributeName);

            if (!requiredAttribute.IsMissing)
            {
                return(requiredAttribute.Value);
            }
            else
            {
                return(string.Empty);
            }
        }
        protected string OptionalType(string attributeName)
        {
            XmlAttributeInfo optionalAttribute = this.GetOptionalAttribute(this.currentElement, attributeName);

            if (optionalAttribute.IsMissing)
            {
                return(null);
            }
            else
            {
                return(this.ValidateTypeName(optionalAttribute.Value));
            }
        }
        protected string RequiredType(string attributeName)
        {
            XmlAttributeInfo requiredAttribute = this.GetRequiredAttribute(this.currentElement, attributeName);

            if (requiredAttribute.IsMissing)
            {
                return(null);
            }
            else
            {
                return(this.ValidateTypeName(requiredAttribute.Value));
            }
        }
        internal XmlAttributeInfo GetRequiredAttribute(XmlElementInfo element, string attributeName)
        {
            XmlAttributeInfo item = element.Attributes[attributeName];

            if (!item.IsMissing)
            {
                return(item);
            }
            else
            {
                base.ReportError(element.Location, EdmErrorCode.MissingAttribute, Strings.XmlParser_MissingAttribute(attributeName, element.Name));
                return(item);
            }
        }
示例#14
0
        protected int?OptionalMaxLength(string attributeName)
        {
            XmlAttributeInfo attr = this.GetOptionalAttribute(this.currentElement, attributeName);

            if (!attr.IsMissing)
            {
                int?value;
                if (!EdmValueParser.TryParseInt(attr.Value, out value))
                {
                    this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidMaxLength, Edm.Strings.ValueParser_InvalidMaxLength(attr.Value));
                }

                return(value);
            }

            return(null);
        }
示例#15
0
        protected bool?OptionalBoolean(string attributeName)
        {
            XmlAttributeInfo attr = this.GetOptionalAttribute(this.currentElement, attributeName);

            if (!attr.IsMissing)
            {
                bool?value;
                if (!EdmValueParser.TryParseBool(attr.Value, out value))
                {
                    this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidBoolean, Edm.Strings.ValueParser_InvalidBoolean(attr.Value));
                }

                return(value);
            }

            return(null);
        }
        protected int?OptionalMaxLength(string attributeName)
        {
            int?nullable;
            XmlAttributeInfo optionalAttribute = this.GetOptionalAttribute(this.currentElement, attributeName);

            if (optionalAttribute.IsMissing)
            {
                int?nullable1 = null;
                return(nullable1);
            }
            else
            {
                if (!EdmValueParser.TryParseInt(optionalAttribute.Value, out nullable))
                {
                    base.ReportError(this.currentElement.Location, EdmErrorCode.InvalidMaxLength, Strings.ValueParser_InvalidMaxLength(optionalAttribute.Value));
                }
                return(nullable);
            }
        }
示例#17
0
        protected EdmOnDeleteAction RequiredOnDeleteAction(string attributeName)
        {
            XmlAttributeInfo attr = this.GetRequiredAttribute(this.currentElement, attributeName);

            if (!attr.IsMissing)
            {
                switch (attr.Value)
                {
                case CsdlConstants.Value_None:
                    return(EdmOnDeleteAction.None);

                case CsdlConstants.Value_Cascade:
                    return(EdmOnDeleteAction.Cascade);

                default:
                    this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidOnDelete, Edm.Strings.CsdlParser_InvalidDeleteAction(attr.Value));
                    break;
                }
            }

            return(EdmOnDeleteAction.None);
        }
示例#18
0
        protected EdmConcurrencyMode?OptionalConcurrencyMode(string attributeName)
        {
            XmlAttributeInfo attr = this.GetOptionalAttribute(this.currentElement, attributeName);

            if (!attr.IsMissing)
            {
                switch (attr.Value)
                {
                case CsdlConstants.Value_None:
                    return(EdmConcurrencyMode.None);

                case CsdlConstants.Value_Fixed:
                    return(EdmConcurrencyMode.Fixed);

                default:
                    this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidConcurrencyMode, Edm.Strings.CsdlParser_InvalidConcurrencyMode(attr.Value));
                    break;
                }
            }

            return(null);
        }
        protected EdmFunctionParameterMode?OptionalFunctionParameterMode(string attributeName)
        {
            XmlAttributeInfo optionalAttribute = this.GetOptionalAttribute(this.currentElement, attributeName);

            if (optionalAttribute.IsMissing)
            {
                EdmFunctionParameterMode?nullable = null;
                return(nullable);
            }
            else
            {
                string value = optionalAttribute.Value;
                string str   = value;
                if (value != null)
                {
                    if (str == "In")
                    {
                        return(new EdmFunctionParameterMode?(EdmFunctionParameterMode.In));
                    }
                    else
                    {
                        if (str == "InOut")
                        {
                            return(new EdmFunctionParameterMode?(EdmFunctionParameterMode.InOut));
                        }
                        else
                        {
                            if (str == "Out")
                            {
                                return(new EdmFunctionParameterMode?(EdmFunctionParameterMode.Out));
                            }
                        }
                    }
                }
                base.ReportError(this.currentElement.Location, EdmErrorCode.InvalidParameterMode, Strings.CsdlParser_InvalidParameterMode(optionalAttribute.Value));
                return(new EdmFunctionParameterMode?(EdmFunctionParameterMode.None));
            }
        }
示例#20
0
        protected int?OptionalSrid(string attributeName, int defaultSrid)
        {
            XmlAttributeInfo attr = this.GetOptionalAttribute(this.currentElement, attributeName);

            if (!attr.IsMissing)
            {
                int?srid;
                if (attr.Value.EqualsOrdinalIgnoreCase(CsdlConstants.Value_SridVariable))
                {
                    srid = null;
                }
                else
                {
                    if (!EdmValueParser.TryParseInt(attr.Value, out srid))
                    {
                        this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidSrid, Edm.Strings.ValueParser_InvalidSrid(attr.Value));
                    }
                }

                return(srid);
            }

            return(defaultSrid);
        }
示例#21
0
 static XmlAttributeInfo()
 {
     XmlAttributeInfo.Missing = new XmlAttributeInfo();
 }
示例#22
0
        protected string Optional(string attributeName)
        {
            XmlAttributeInfo attr = this.GetOptionalAttribute(this.currentElement, attributeName);

            return(!attr.IsMissing ? attr.Value : null);
        }
示例#23
0
		static XmlAttributeInfo()
		{
			XmlAttributeInfo.Missing = new XmlAttributeInfo();
		}
示例#24
0
        protected string Required(string attributeName)
        {
            XmlAttributeInfo attr = this.GetRequiredAttribute(this.currentElement, attributeName);

            return(!attr.IsMissing ? attr.Value : string.Empty);
        }