示例#1
0
文件: Program.cs 项目: alcexhim/Mocha
        public static void Main(string[] args)
        {
            Oms oms = new MemoryOms();

            oms.InitializeTenants("System/Tenants");

            oms.Load("System/Snapshots");

            oms.DefaultTenant = oms.GetTenant("archalos1");

            TestExisting(oms);
            oms.BeginTransaction();

            InstanceHandle ihInventoryItem = oms.CreateClass(LocalInstanceGuids.Classes.InventoryItem, "InventoryItem", "Inventory Item");
            InstanceHandle ihCharacter     = oms.CreateClass(LocalInstanceGuids.Classes.Character, "Character", "Character");
            InstanceHandle ihGender        = oms.CreateClass(LocalInstanceGuids.Classes.Character, "Gender", "Gender");

            oms.CommitTransaction();

            oms.BeginTransaction();

            InstanceHandle ikCharacter__has__Gender = oms.CreateRelationshipInstance(ihCharacter, "has", ihGender, LocalRelationshipGuids.Character__has__Gender);
            InstanceHandle ihGender1 = oms.CreateInstance(ihGender);

            oms.CommitTransaction();
            oms.BeginTransaction();

            InstanceHandle ikCharacter__Ashlyn = oms.CreateInstance(LocalInstanceGuids.Characters.Ashlyn, LocalInstanceGuids.Classes.Character);

            oms.CreateRelationship(ikCharacter__Ashlyn, ikCharacter__has__Gender, ihGender1);

            oms.CommitTransaction();

            InstanceHandle ihClass = oms.GetInstance(InstanceKey.Parse("1$1"));

            ihClass = oms.GetInstance(KnownInstanceGuids.Classes.Class);

            Guid id = Guid.Empty;


            bool verified = oms.Transactions.Verify();

            InstanceHandle ihGndr = oms.GetRelatedInstance(ikCharacter__Ashlyn, ikCharacter__has__Gender);

            // InstanceKey key = oms.GetInstanceKey(ihGndr);

            InstanceHandle ihGnd2 = oms.GetRelatedInstance(ikCharacter__Ashlyn, ikCharacter__has__Gender);

            oms.Save("System/Snapshots");

            Console.WriteLine(ikCharacter__Ashlyn.ToString());
        }