Пример #1
0
        private void Init()
        {
            var xmlTypeAtt = XType.GetCustomAttribute <XmlTypeAttribute>();

            Description = xmlTypeAtt.Description;

            KeyProperty = XType.GetProperty(xmlTypeAtt.KeyPropertyName);
            if (KeyProperty == null)
            {
                throw new TestLibsException($"Couldn't find KeyProperty with name: {xmlTypeAtt.KeyPropertyName} for type: {XType}");
            }

            Location = new XmlLocation(XType);
            var propertyInfos = XType.GetProperties();

            foreach (var propertyInfo in propertyInfos)
            {
                var xmlPropertyAtt = propertyInfo.GetCustomAttribute <XmlPropertyAttribute>(true);
                if (xmlPropertyAtt != null)
                {
                    var xmlProperty = new XmlProperty(this, propertyInfo);
                    XmlProperties.Add(xmlProperty);
                }
            }
        }
Пример #2
0
        public static List <string> XmlSerializationXmlPropCtxt(XmlProperties xmlProperty)
        {
            List <string> combinedXmlDeclarations = new List <string>();

            if (!string.IsNullOrEmpty(xmlProperty.Name))
            {
                combinedXmlDeclarations.Add("'name': '" + xmlProperty.Name + "'");
            }
            if (xmlProperty.Attribute)
            {
                combinedXmlDeclarations.Add("'attr': True");
            }
            if (!string.IsNullOrEmpty(xmlProperty.Prefix))
            {
                combinedXmlDeclarations.Add("'prefix': '" + xmlProperty.Prefix + "'");
            }
            if (!string.IsNullOrEmpty(xmlProperty.Namespace))
            {
                combinedXmlDeclarations.Add("'ns': '" + xmlProperty.Namespace + "'");
            }
            return(combinedXmlDeclarations);
        }