Ejemplo n.º 1
0
        /// <summary>
        /// Supports the save infrastructure and creates the XElement based on current object's data.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="xe"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        private static void CreateXElement <T>(XElement xe, DcmesElement value)
        {
            if (value == null)
            {
                return;
            }
            var elementName = typeof(T).GetCustomAttributes(typeof(EPubElement), true).OfType <EPubElement>().Single();

            if (elementName == null)
            {
                return;
            }
            var se = new XElement(DcNamespace + elementName.Name,
                                  value.Text);

            if (value.Identifier != null)
            {
                se.Add(new XAttribute("id", value.Identifier));
            }
            if (value.Lang != null)
            {
                se.Add(new XAttribute("lang", value.Lang));
            }
            if (value.Dir != ProgressionDirection.Default)
            {
                //se.Add(new XAttribute("dir", value.Dir));
            }
            xe.Add(se);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Supports the save infrastructure and creates the XElement based on current object's data.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value"></param>
        /// <returns></returns>
        private static void CreateXElement <T>(XElement xe, DcmesElement value)
        {
            if (value == null)
            {
                return;
            }
            var      elementName = typeof(T).GetCustomAttributes(typeof(EPubElement), true).FirstOrDefault() as EPubElement;
            XElement se          = new XElement(DcNamespace + elementName.Name,
                                                value.Text,
                                                new XAttribute("id", value.Identifier ?? String.Empty),
                                                new XAttribute("lang", value.Lang ?? String.Empty),
                                                new XAttribute("dir", value.Dir.ToString())
                                                );

            xe.Add(se);
        }