Пример #1
0
        /// <summary>
        /// Helper method for writing the XML attribute.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="property">The property.</param>
        /// <param name="flow">The flow.</param>
        private void WriteXmlAttribute(XmlWriter writer, PropertyDescriptor property, object flow)
        {
            IEnumerable <System.Xml.Serialization.XmlAttributeAttribute> attribs = property.Attributes.OfType <System.Xml.Serialization.XmlAttributeAttribute>();

            System.Xml.Serialization.XmlAttributeAttribute xmlAttrib = attribs.ElementAtOrDefault(0);
            if (xmlAttrib != null)
            {
                object prop = property.GetValue(flow);
                if (prop != null)
                {
                    writer.WriteStartAttribute(xmlAttrib.AttributeName);
                    writer.WriteValue(prop.ToString());
                    writer.WriteEndAttribute();
                }
            }
        }
Пример #2
0
 private static void LoadColorsFromFields(Dictionary <string, PDFColor> hash)
 {
     System.Reflection.FieldInfo[] fields = typeof(PDFColors).GetFields(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
     foreach (System.Reflection.FieldInfo fi in fields)
     {
         object[] attrs = fi.GetCustomAttributes(typeof(System.Xml.Serialization.XmlAttributeAttribute), false);
         if (null != attrs && attrs.Length > 0)
         {
             System.Xml.Serialization.XmlAttributeAttribute attr = (System.Xml.Serialization.XmlAttributeAttribute)attrs[0];
             string name = attr.AttributeName;
             if (string.IsNullOrEmpty(name))
             {
                 name = fi.Name;
             }
             object color = fi.GetValue(null);
             if (null != color && color is PDFColor)
             {
                 hash.Add(name, (PDFColor)color);
             }
         }
     }
 }