예제 #1
0
        private void HandleMemberElement(XmlReader reader)
        {
            SchemaEnumMember schemaEnumMember = new SchemaEnumMember((SchemaElement)this);

            schemaEnumMember.Parse(reader);
            if (!schemaEnumMember.Value.HasValue)
            {
                if (this._enumMembers.Count == 0)
                {
                    schemaEnumMember.Value = new long?(0L);
                }
                else
                {
                    long num = this._enumMembers[this._enumMembers.Count - 1].Value.Value;
                    if (num < long.MaxValue)
                    {
                        schemaEnumMember.Value = new long?(num + 1L);
                    }
                    else
                    {
                        this.AddError(ErrorCode.CalculatedEnumValueOutOfRange, EdmSchemaErrorSeverity.Error, (object)Strings.CalculatedEnumValueOutOfRange);
                        schemaEnumMember.Value = new long?(num);
                    }
                }
            }
            this._enumMembers.Add(schemaEnumMember);
        }
예제 #2
0
        // <summary>
        // Handler for the Member element.
        // </summary>
        // <param name="reader"> XmlReader positioned on the Member element. </param>
        private void HandleMemberElement(XmlReader reader)
        {
            DebugCheck.NotNull(reader);

            var enumMember = new SchemaEnumMember(this);

            enumMember.Parse(reader);

            // if the value has not been specified we need to fix it up.
            if (!enumMember.Value.HasValue)
            {
                if (_enumMembers.Count == 0)
                {
                    enumMember.Value = 0;
                }
                else
                {
                    var previousValue = (long)_enumMembers[_enumMembers.Count - 1].Value;
                    if (previousValue < long.MaxValue)
                    {
                        enumMember.Value = previousValue + 1;
                    }
                    else
                    {
                        AddError(
                            ErrorCode.CalculatedEnumValueOutOfRange,
                            EdmSchemaErrorSeverity.Error,
                            Strings.CalculatedEnumValueOutOfRange);

                        // the error has been reported. Assigning previous + 1 would cause an overflow. Null is not really
                        // expected later on so just assign the previous value.
                        enumMember.Value = previousValue;
                    }
                }
            }

            _enumMembers.Add(enumMember);
        }
예제 #3
0
        // <summary>
        // Handler for the Member element.
        // </summary>
        // <param name="reader"> XmlReader positioned on the Member element. </param>
        private void HandleMemberElement(XmlReader reader)
        {
            DebugCheck.NotNull(reader);

            var enumMember = new SchemaEnumMember(this);
            enumMember.Parse(reader);

            // if the value has not been specified we need to fix it up.
            if (!enumMember.Value.HasValue)
            {
                if (_enumMembers.Count == 0)
                {
                    enumMember.Value = 0;
                }
                else
                {
                    var previousValue = (long)_enumMembers[_enumMembers.Count - 1].Value;
                    if (previousValue < long.MaxValue)
                    {
                        enumMember.Value = previousValue + 1;
                    }
                    else
                    {
                        AddError(
                            ErrorCode.CalculatedEnumValueOutOfRange,
                            EdmSchemaErrorSeverity.Error,
                            Strings.CalculatedEnumValueOutOfRange);

                        // the error has been reported. Assigning previous + 1 would cause an overflow. Null is not really 
                        // expected later on so just assign the previous value. 
                        enumMember.Value = previousValue;
                    }
                }
            }

            _enumMembers.Add(enumMember);
        }