Exemplo n.º 1
0
        public static XmlName GetXmlName(this IXmlObject xmlObject)
        {
            Type    xmlObjectType;
            XmlName xmlName;
            XmlElementMappingAttribute xmlElementMappingAttribute;

            if ((object)xmlObject == null)
            {
                throw new ArgumentNullException(nameof(xmlObject));
            }

            xmlObjectType = xmlObject.GetType();
            xmlElementMappingAttribute = SolderFascadeAccessor.ReflectionFascade.GetOneAttribute <XmlElementMappingAttribute>(xmlObjectType);

            if ((object)xmlElementMappingAttribute == null)
            {
                xmlName = null;
            }
            else
            {
                xmlName = new XmlName()
                {
                    LocalName    = xmlElementMappingAttribute.LocalName,
                    NamespaceUri = xmlElementMappingAttribute.NamespaceUri
                };
            }

            return(xmlName);
        }
Exemplo n.º 2
0
        //============================================================
        // <T>根据对象查找设置。</T>
        //
        // @param xobject 对象
        // @return 类型设置
        //============================================================
        public FXmlObjectConfig FindByType(IXmlObject xobject)
        {
            string           typeName = xobject.GetType().FullName;
            FXmlObjectConfig config   = _types[typeName];

            if (null == config)
            {
                throw new FFatalException("Undefine type({0}).", typeName);
            }
            return(config);
        }
 static void WriteXmlObject(XmlWriter writer, IXmlObject xmlObject)
 {
     foreach (var proprety in xmlObject.GetType().GetProperties())
     {
         if (proprety.IncludeInVXml())
         {
             writer.WriteStartElement(proprety.GetXmlAlias());
             writer.WriteString(proprety.GetValue(xmlObject)?.ToString() ?? "");
             writer.WriteEndElement();
         }
     }
 }