Пример #1
0
        public ComponentSpecification DeserialiseComponentSpecification(XmlNode specNode, EntitySet entitySet)
        {
            NodeProcessor proc = new NodeProcessor(specNode);

            string name = proc.Attributes.GetString("name");

            ComponentSpecification spec = new ComponentSpecificationImpl(name);

            entitySet.AddComponentSpecification(spec);

            var propertyNodes = specNode.SelectNodes("Property");

            if (propertyNodes != null)
            {
                foreach (XmlNode node in propertyNodes)
                {
                    var property = DeserialiseComponentProperty(node, spec);
                    spec.AddProperty(property);
                }
            }

            var componentNodes = specNode.SelectNodes("Component");

            if (componentNodes != null)
            {
                foreach (XmlNode node in componentNodes)
                {
                    // This adds the component as well as creating it.
                    DeserialiseComponent(node, spec);
                }
            }

            return(spec);
        }
        public void Setup()
        {
            // Setup Database
            database = new Database("DB1");
            var table = new Table("User");

            table.AddColumn(new Column("Name"));
            table.AddColumn(new Column("AddressStreet"));
            table.AddColumn(new Column("AddressCity"));
            table.AddColumn(new Column("AddressCountry"));
            database.AddTable(table);

            // Setup Entities
            entitySet = new EntitySetImpl();
            Entity userEntity = new EntityImpl("User");

            userEntity.AddProperty(new PropertyImpl("Name"));

            // Create the Address type
            spec = new ComponentSpecificationImpl("Address");

            spec.AddProperty(new ComponentPropertyImpl("Street"));
            spec.AddProperty(new ComponentPropertyImpl("City"));
            spec.AddProperty(new ComponentPropertyImpl("Country"));

            // Create the Address component for the User entity.
            component = spec.CreateImplementedComponentFor(userEntity, "HomeAddress");

            entitySet.AddEntity(userEntity);
            entitySet.AddComponentSpecification(spec);

            // Setup the Mappings
            mappingSet       = new MappingSetImpl(database, entitySet);
            componentMapping = new ComponentMappingImpl();
            mappingSet.AddMapping(componentMapping);

            componentMapping.AddPropertyAndColumn(component.Properties[0], table.Columns[1]);
            componentMapping.AddPropertyAndColumn(component.Properties[1], table.Columns[2]);
            componentMapping.AddPropertyAndColumn(component.Properties[2], table.Columns[3]);

            // Add the mapping between the Name property and the Name column in the database table.
            mappingSet.ChangeMappedColumnFor(userEntity.ConcreteProperties[0]).To(table.Columns[0]);
        }
        public void Setup()
        {
            database  = new Database("Db1");
            entitySet = new EntitySetImpl();

            table = new Table("Table1");
            table.AddColumn(new Column("AddressStreet"));

            var entity1 = new EntityImpl("Entity1");

            componentSpec = new ComponentSpecificationImpl("Address");
            entitySet.AddComponentSpecification(componentSpec);
            componentSpec.AddProperty(new ComponentPropertyImpl("Street"));

            component1 = componentSpec.CreateImplementedComponentFor(entity1, "HomeAddress");
            component2 = componentSpec.CreateImplementedComponentFor(entity1, "WorkAddress");

            database.AddTable(table);
            entitySet.AddEntity(entity1);
        }
Пример #4
0
        public void Setup()
        {
            // Setup Database
            database = new Database("DB1");
            var table = new Table("User");
            table.AddColumn(new Column("Name"));
            table.AddColumn(new Column("AddressStreet"));
            table.AddColumn(new Column("AddressCity"));
            table.AddColumn(new Column("AddressCountry"));
            database.AddTable(table);

            // Setup Entities
            entitySet = new EntitySetImpl();
            Entity userEntity = new EntityImpl("User");
            userEntity.AddProperty(new PropertyImpl("Name"));

            // Create the Address type
            spec = new ComponentSpecificationImpl("Address");

            spec.AddProperty(new ComponentPropertyImpl("Street"));
            spec.AddProperty(new ComponentPropertyImpl("City"));
            spec.AddProperty(new ComponentPropertyImpl("Country"));

            // Create the Address component for the User entity.
            component = spec.CreateImplementedComponentFor(userEntity, "HomeAddress");

            entitySet.AddEntity(userEntity);
            entitySet.AddComponentSpecification(spec);

            // Setup the Mappings
            mappingSet = new MappingSetImpl(database, entitySet);
            componentMapping = new ComponentMappingImpl();
            mappingSet.AddMapping(componentMapping);

            componentMapping.AddPropertyAndColumn(component.Properties[0], table.Columns[1]);
            componentMapping.AddPropertyAndColumn(component.Properties[1], table.Columns[2]);
            componentMapping.AddPropertyAndColumn(component.Properties[2], table.Columns[3]);

            // Add the mapping between the Name property and the Name column in the database table.
            mappingSet.ChangeMappedColumnFor(userEntity.ConcreteProperties[0]).To(table.Columns[0]);
        }