Ejemplo n.º 1
0
        public static object[] createModel()
        {
            TestModelParser modelParser   = new TestModelParser();
            ModelInstance   modelInstance = modelParser.EmptyModel;

            Animals animals = modelInstance.newInstance(typeof(Animals));

            modelInstance.DocumentElement = animals;

            // add a tns namespace prefix for QName testing
            animals.DomElement.registerNamespace("tns", MODEL_NAMESPACE);

            Bird tweety = createBird(modelInstance, "tweety", Gender.Female);
            Bird hedwig = createBird(modelInstance, "hedwig", Gender.Female);
            Bird timmy  = createBird(modelInstance, "timmy", Gender.Female);
            Egg  egg1   = createEgg(modelInstance, "egg1");

            egg1.Mother = tweety;
            ICollection <Animal> guards = egg1.Guardians;

            guards.Add(hedwig);
            guards.Add(timmy);
            Egg egg2 = createEgg(modelInstance, "egg2");

            egg2.Mother = tweety;
            guards      = egg2.Guardians;
            guards.Add(hedwig);
            guards.Add(timmy);
            Egg egg3 = createEgg(modelInstance, "egg3");

            guards = egg3.Guardians;
            guards.Add(timmy);

            tweety.Spouse = hedwig;
            tweety.Eggs.Add(egg1);
            tweety.Eggs.Add(egg2);
            tweety.Eggs.Add(egg3);

            ICollection <Egg> guardedEggs = hedwig.GuardedEggs;

            guardedEggs.Add(egg1);
            guardedEggs.Add(egg2);

            GuardEgg guardEgg = modelInstance.newInstance(typeof(GuardEgg));

            guardEgg.TextContent = egg1.Id + " " + egg2.Id;
            timmy.GuardedEggRefs.Add(guardEgg);
            timmy.GuardedEggs.Add(egg3);

            return(new object[] { "created", modelInstance, modelParser });
        }
Ejemplo n.º 2
0
        public static object[] createModel()
        {
            TestModelParser modelParser   = new TestModelParser();
            ModelInstance   modelInstance = modelParser.EmptyModel;

            Animals animals = modelInstance.newInstance(typeof(Animals));

            modelInstance.DocumentElement = animals;

            // add a tns namespace prefix for QName testing
            animals.DomElement.registerNamespace("tns", MODEL_NAMESPACE);

            Animal tweety = createBird(modelInstance, "tweety", Gender.Female);
            Animal hedwig = createBird(modelInstance, "hedwig", Gender.Male);
            Animal birdo  = createBird(modelInstance, "birdo", Gender.Female);
            Animal plucky = createBird(modelInstance, "plucky", Gender.Unknown);
            Animal fiffy  = createBird(modelInstance, "fiffy", Gender.Female);

            createBird(modelInstance, "timmy", Gender.Male);
            createBird(modelInstance, "daisy", Gender.Female);

            // create and add some relationships
            RelationshipDefinition hedwigRelationship = createRelationshipDefinition(modelInstance, hedwig, typeof(ChildRelationshipDefinition));

            addRelationshipDefinition(tweety, hedwigRelationship);
            RelationshipDefinition birdoRelationship = createRelationshipDefinition(modelInstance, birdo, typeof(ChildRelationshipDefinition));

            addRelationshipDefinition(tweety, birdoRelationship);
            RelationshipDefinition pluckyRelationship = createRelationshipDefinition(modelInstance, plucky, typeof(FriendRelationshipDefinition));

            addRelationshipDefinition(tweety, pluckyRelationship);
            RelationshipDefinition fiffyRelationship = createRelationshipDefinition(modelInstance, fiffy, typeof(FriendRelationshipDefinition));

            addRelationshipDefinition(tweety, fiffyRelationship);

            tweety.RelationshipDefinitionRefs.Add(hedwigRelationship);
            tweety.RelationshipDefinitionRefs.Add(birdoRelationship);
            tweety.RelationshipDefinitionRefs.Add(pluckyRelationship);
            tweety.RelationshipDefinitionRefs.Add(fiffyRelationship);

            tweety.BestFriends.Add(birdo);
            tweety.BestFriends.Add(plucky);

            return(new object[] { "created", modelInstance, modelParser });
        }