Ejemplo n.º 1
0
        /// <summary>
        ///     Deseriliazes the specified XML element to its corresponding
        ///     <seealso cref="EntityMetadata"/> representation.
        /// </summary>
        /// <param name="entity">The `entity` element to be deserialized.</param>
        private static EntityMetadata ParseEntity(XElement entity)
        {
            var name            = entity.Attribute(XmlMetadataSchema.EntityAttributeName).Value;
            var idAttributeName = entity.Attribute(XmlMetadataSchema.EntityAttributeIdAttribute).Value;
            var whereClause     = entity.Attribute(XmlMetadataSchema.EntityAttributeWhereClause).ValueOrDefault((string)null);
            var parentEntity    = entity.Attribute(XmlMetadataSchema.EntityAttributeParentEntity).ValueOrDefault((string)null);
            var associations    = XmlAssociationsParser.Parse(entity);

            return(new EntityMetadata(name,
                                      XmlSchemaParser.Parse(name, entity, idAttributeName, associations.Item2, whereClause, parentEntity),
                                      associations.Item1,
                                      XmlConnectorParametersParser.Parse(entity)
                                      ));
        }
        public void should_not_add_object_to_collection_when_no_properties()
        {
            const string emptySchema = "<xsd:schema targetNamespace=\"http://www.example.com/IPO\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:ipo=\"http://www.example.com/IPO\"></xsd:schema>";
            var          apiObjects  = new Dictionary <string, ApiObject>();
            var          obj         = parser.Parse("key", emptySchema, apiObjects, "Generated");

            Assert.AreEqual(null, obj);
            Assert.AreEqual(0, apiObjects.Count);
        }
Ejemplo n.º 3
0
        private ApiObject ParseXmlSchema(string key, string schema, IDictionary <string, ApiObject> objects, string targetNamespace, IDictionary <string, ApiObject> otherObjects, IDictionary <string, ApiObject> schemaObjects)
        {
            if (objects.ContainsKey(key))
            {
                return(null);
            }

            var xmlSchemaParser = new XmlSchemaParser();
            var obj             = xmlSchemaParser.Parse(key, schema, objects, targetNamespace);

            if (obj != null && !objects.ContainsKey(key) && !UniquenessHelper.HasSameProperties(obj, objects, otherObjects, schemaObjects))
            {
                objects.Add(key, obj);         // to associate that key with the main XML Schema object
            }
            return(obj);
        }