Ejemplo n.º 1
0
        /// <summary>
        /// Deserializes the attributes at the reader's current position and stores them in the
        /// <paramref name="currentElement"/>.
        /// </summary>
        /// <param name="currentElement">The element associated with the reader's current position.</param>
        private void DeserializeAttributes(IXliffDataConsumer currentElement)
        {
            if (this.reader.MoveToFirstAttribute())
            {
                IExtensible extensible;

                extensible = currentElement as IExtensible;
                do
                {
                    SetAttributeResult setResult;
                    XmlNameInfo        name;

                    name      = new XmlNameInfo(this.reader.Prefix, this.reader.NamespaceURI, this.reader.LocalName);
                    setResult = currentElement.TrySetAttributeValue(name, this.reader.Value);
                    if ((setResult == SetAttributeResult.InvalidAttribute) ||
                        ((setResult == SetAttributeResult.PossibleExtension) &&
                         (this.StoreAttributeExtension(extensible) == SetAttributeResult.InvalidAttribute)))
                    {
                        string message;

                        if (string.IsNullOrEmpty(name.Prefix))
                        {
                            message = name.LocalName;
                        }
                        else
                        {
                            message = string.Join(":", name.Prefix, name.LocalName);
                        }

                        message = string.Format(
                            Properties.Resources.XliffReader_InvalidAttributeName_Format,
                            message,
                            currentElement.GetType().Name);
                        throw new NotSupportedException(message);
                    }
                }while (this.reader.MoveToNextAttribute());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deserializes the attributes at the reader's current position and stores them in the
        /// <paramref name="currentElement"/>.
        /// </summary>
        /// <param name="currentElement">The element associated with the reader's current position.</param>
        private void DeserializeAttributes(IXliffDataConsumer currentElement)
        {
            if (this.reader.MoveToFirstAttribute())
            {
                IExtensible extensible;

                extensible = currentElement as IExtensible;
                do
                {
                    SetAttributeResult setResult;
                    XmlNameInfo name;

                    name = new XmlNameInfo(this.reader.Prefix, this.reader.NamespaceURI, this.reader.LocalName);
                    setResult = currentElement.TrySetAttributeValue(name, this.reader.Value);
                    if ((setResult == SetAttributeResult.InvalidAttribute) ||
                        ((setResult == SetAttributeResult.PossibleExtension) &&
                            (this.StoreAttributeExtension(extensible) == SetAttributeResult.InvalidAttribute)))
                    {
                        string message;

                        if (string.IsNullOrEmpty(name.Prefix))
                        {
                            message = name.LocalName;
                        }
                        else
                        {
                            message = string.Join(":", name.Prefix, name.LocalName);
                        }

                        message = string.Format(
                                                Properties.Resources.XliffReader_InvalidAttributeName_Format,
                                                message,
                                                currentElement.GetType().Name);
                        throw new NotSupportedException(message);
                    }
                }
                while (this.reader.MoveToNextAttribute());
            }
        }