/// <summary> /// Creates a new instance of Core /// </summary> /// <param name="Settings"></param> /// <param name="metadata"></param> /// <param name="SecurityRoles"></param> /// <param name="Workflows"></param> public Core(XrmMockupSettings Settings, MetadataSkeleton metadata, List <Entity> Workflows, List <SecurityRole> SecurityRoles) { this.TimeOffset = new TimeSpan(); this.settings = Settings; this.metadata = metadata; baseCurrency = metadata.BaseOrganization.GetAttributeValue <EntityReference>("basecurrencyid"); baseCurrencyPrecision = metadata.BaseOrganization.GetAttributeValue <int>("pricingdecimalprecision"); this.db = new XrmDb(metadata.EntityMetadata, GetOnlineProxy()); this.snapshots = new Dictionary <string, Snapshot>(); this.security = new Security(this, metadata, SecurityRoles, this.db); this.ServiceFactory = new MockupServiceProviderAndFactory(this); //add the additional plugin settings to the meta data if (settings.IPluginMetadata != null) { metadata.Plugins.AddRange(Settings.IPluginMetadata); } this.pluginManager = new PluginManager(Settings.BasePluginTypes, metadata.EntityMetadata, metadata.Plugins); this.workflowManager = new WorkflowManager(Settings.CodeActivityInstanceTypes, Settings.IncludeAllWorkflows, Workflows, metadata.EntityMetadata); this.systemAttributeNames = new List <string>() { "createdon", "createdby", "modifiedon", "modifiedby" }; this.RequestHandlers = GetRequestHandlers(db); InitializeDB(); this.security.InitializeSecurityRoles(db); //persist the access team templates as they livein the db as records. if (metadata.AccessTeamTemplates != null) { foreach (var att in metadata.AccessTeamTemplates) { if (!db.HasRow(att.ToEntityReference())) { var create = new CreateRequest(); create.Target = att; this.Execute(create, AdminUserRef); } } } }
internal bool EntityExists(EntityReference entityReference) { return(db.HasRow(entityReference)); }