/// <summary>
        /// Stores the attribute in an extension.
        /// </summary>
        /// <param name="extensible">The object that is being extended.</param>
        /// <param name="attribute">The attribute to store.</param>
        /// <returns>This method always returns true.</returns>
        public bool StoreAttribute(IExtensible extensible, IExtensionAttribute attribute)
        {
            GenericExtension extension;

            extension = extensible.Extensions.FirstOrDefault((e) => e.Name == GenericExtensionHandler.ExtensionName) as GenericExtension;
            if (extension == null)
            {
                extension = new GenericExtension(GenericExtensionHandler.ExtensionName);
                extensible.Extensions.Add(extension);
            }

            extension.AddAttribute(attribute);

            return(true);
        }
        /// <summary>
        /// Stores the attribute in an extension.
        /// </summary>
        /// <param name="extensible">The object that is being extended.</param>
        /// <param name="attribute">The attribute to store.</param>
        /// <returns>This method always returns true.</returns>
        public bool StoreAttribute(IExtensible extensible, IExtensionAttribute attribute)
        {
            GenericExtension extension;

            extension = extensible.Extensions.FirstOrDefault((e) => e.Name == GenericExtensionHandler.ExtensionName) as GenericExtension;
            if (extension == null)
            {
                extension = new GenericExtension(GenericExtensionHandler.ExtensionName);
                extensible.Extensions.Add(extension);
            }

            extension.AddAttribute(attribute);

            return true;
        }
        /// <summary>
        /// Stores the element in an extension.
        /// </summary>
        /// <param name="extensible">The object that is being extended.</param>
        /// <param name="element">The element to store.</param>
        /// <returns>This method always returns true.</returns>
        public bool StoreElement(IExtensible extensible, ElementInfo element)
        {
            GenericExtension extension;

            extension = extensible.Extensions.FirstOrDefault((e) => e.Name == GenericExtensionHandler.ExtensionName) as GenericExtension;
            if (extension == null)
            {
                extension = new GenericExtension(GenericExtensionHandler.ExtensionName);
                extensible.Extensions.Add(extension);
            }

            Utilities.SetParent(element.Element, extensible as XliffElement);
            extension.AddChild(element);

            return(true);
        }
        /// <summary>
        /// Stores the element in an extension.
        /// </summary>
        /// <param name="extensible">The object that is being extended.</param>
        /// <param name="element">The element to store.</param>
        /// <returns>This method always returns true.</returns>
        public bool StoreElement(IExtensible extensible, ElementInfo element)
        {
            GenericExtension extension;

            extension = extensible.Extensions.FirstOrDefault((e) => e.Name == GenericExtensionHandler.ExtensionName) as GenericExtension;
            if (extension == null)
            {
                extension = new GenericExtension(GenericExtensionHandler.ExtensionName);
                extensible.Extensions.Add(extension);
            }

            Utilities.SetParent(element.Element, extensible as XliffElement);
            extension.AddChild(element);

            return true;
        }
        /// <summary>
        /// Demonstrates how to store custom attributes and elements on a <see cref="File"/> element using the built in
        /// generic extension support.
        /// </summary>
        public static void StoreGenericExtension()
        {
            IExtensible extensible;
            GenericExtension extension;
            File file;

            // This namespace will be stored on the document element like: <xliff xmlns:pre1="urn:custom:extension:1.0"
            const string customNamespace = "urn:custom:extension:1.0";
            const string customPrefix = "pre1";

            file = new File("f1");
            extensible = file;
            extension = new GenericExtension("custom");

            // Create custom attributes that look like: <file id="f1" pre1:attr1="value1" pre1:attr2="value2">
            if (extensible.SupportsAttributeExtensions)
            {
                extension.AddAttribute(new GenericExtensionAttribute(customPrefix, customNamespace, "attr1", "value1"));
                extension.AddAttribute(new GenericExtensionAttribute(customPrefix, customNamespace, "attr2", "value2"));
                extensible.Extensions.Add(extension);
            }

            // Create a custom element that looks like: <pre1:element1 pre1:attr1="value1" />
            if (extensible.SupportsElementExtensions)
            {
                ElementInfo info;
                GenericElement element;

                element = new GenericElement();
                element.SetAttribute(customPrefix, customNamespace, "attr1", "value1");
                info = new ElementInfo(new XmlNameInfo(customPrefix, customNamespace, "element1"), element);
                extension.AddChild(info);
            }
        }