internal static Oms GetTestingOms() { Oms _oms = (Oms)TYPE_OMS.Assembly.CreateInstance(TYPE_OMS.FullName); _oms.DefaultTenant = _oms.CreateTenant("default"); _oms.Initialize(new MemoryAccessor(Properties.Resources.Mocha_Core_v1_0_mcl)); return(_oms); }
public static void InitializeTenants(this Oms oms, string path) { TenantHandle defaultTenant = oms.DefaultTenant; string[] files = { path }; if (System.IO.Directory.Exists(path)) { files = System.IO.Directory.GetFiles(path, "tenant.xml", System.IO.SearchOption.AllDirectories); } foreach (string file in files) { MochaTenantDefinitionObjectModel mcl1 = new MochaTenantDefinitionObjectModel(); Document.Load(mcl1, tenantdf, new FileAccessor(file, false, false, true)); foreach (Tenant tenant in mcl1.Tenants) { oms.DefaultTenant = oms.CreateTenant(tenant.Name); string[] libraryPathList = new string[tenant.LibraryReferences.Count]; for (int i = 0; i < tenant.LibraryReferences.Count; i++) { string libraryPath = tenant.LibraryReferences[i].Path.ReplaceVariables(new KeyValuePair <string, object>[] { new KeyValuePair <string, object>("MochaRoot", System.IO.Path.Combine(new string[] { System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "System" })) }); libraryPathList[i] = libraryPath; } oms.Initialize(libraryPathList); Console.WriteLine("[mocha debug]: initialized tenant `{0}`", tenant.Name); } } oms.DefaultTenant = defaultTenant; oms.PendingTransactions.Clear(); }