internal MultithreadedSystem(MultithreadedSystemSharedContext sharedData, ISystem system) { System = system; _shared = sharedData; PerformanceData = new PerformanceInformation(system); ITriggerFilterProvider trigger = system as ITriggerFilterProvider; if (trigger != null) { _filter = new Filter(DataAccessorFactory.MapTypesToDataAccessors(trigger.RequiredDataTypes)); _entityCache = new EntityCache(_filter); // all of these triggers require a filter _triggerAdded = trigger as Trigger.Added; _triggerRemoved = trigger as Trigger.Removed; _triggerModified = trigger as Trigger.Modified; _triggerUpdate = trigger as Trigger.Update; _triggerInput = trigger as Trigger.Input; } // these triggers don't require a filter _triggerGlobalPreUpdate = system as Trigger.GlobalPreUpdate; _triggerGlobalPostUpdate = system as Trigger.GlobalPostUpdate; _triggerGlobalInput = system as Trigger.GlobalInput; }
public void Initialize(ContentEntitySerializationFormat format) { PrettyName = format.PrettyName ?? ""; UniqueId = format.UniqueId; foreach (DataInstance data in format.Data) { _data[DataAccessorFactory.GetId(data.CurrentData)] = data; } }
/// <summary> /// Initializes the RuntimeTemplate with data from the given ContentTemplate. /// </summary> public void Initialize(ContentTemplateSerializationFormat template) { TemplateId = template.TemplateId; PrettyName = template.PrettyName; foreach (Data.IData data in template.DefaultDataInstances) { _defaultDataInstances[DataAccessorFactory.GetId(data)] = data; } }
public void TestGetData() { string cxx = "SELECT * FROM [Products] where ProductID=@ProductID"; var paras = new SqlParameter { DbType = DbType.Int32, Direction = ParameterDirection.Input, Value = 1, Size = 4, ParameterName = "ProductID" }; int flag = DataAccessorFactory.Create("TestDB").ExecuteNonQuery(cxx, new DbParameter[] { paras }); }
/// <summary> /// Attempts to retrieve a data instance with the given DataAccessor from the list of added /// data. /// </summary> /// <param name="accessor">The DataAccessor to lookup</param> /// <returns>A data instance, or null if it cannot be found</returns> private Data.IData GetAddedData_unlocked(DataAccessor accessor) { int id = accessor.Id; // TODO: optimize this so we don't have to search through all added data... though // this should actually be pretty quick for (int i = 0; i < _toAddStage1.Count; ++i) { int addedId = DataAccessorFactory.GetId(_toAddStage1[i].GetType()); if (addedId == id) { return(_toAddStage1[i]); } } return(null); }
public async Task TestDataAccessorFactory() { var mEntity = await DatabaseInitializeHelper.CreateSimpleMEntity(); try { var dataAccessorFactory = new DataAccessorFactory<DataAccessorContextFactory>(new DataAccessorContextFactory()); using (var dataAccessor = dataAccessorFactory.Create()) { Assert.AreEqual(mEntity.Id, (await dataAccessor.GetSingleOrDefaultAsync<MEntity>(mE => mE.Name.Equals(mEntity.Name))).Id); } } catch (Exception) { Assert.Fail("Something went wrong with this DataAccessorFactory thing..."); } }
public void Setup() { mockQueryFirst2A = CreateA(2); mockQueryFirst2B = CreateB(2); mockQueryFirst4A = CreateA(4); mockQueryFirst4B = CreateB(4); mockQueryFirst8A = CreateA(8); mockQueryFirst8B = CreateB(8); mockQueryFirst16A = CreateA(16); mockQueryFirst16B = CreateB(16); mockQueryFirst32A = CreateA(32); mockQueryFirst32B = CreateB(32); // DAO dapperExecuteAccessor = new DapperAccessor(); var engine = new ExecuteEngineConfig() .ToEngine(); var factory = new DataAccessorFactory(engine); smartExecuteAccessor = factory.Create <IBenchmarkAccessor>(); }
public static IIncomeStatementServices GetIncomeStatementServices() { return(new IncomeStatementServices(DataAccessorFactory.GetIncomeStatementDataAccessor())); }
public static IVoucherServices GetVoucherServices() { return(new VoucherServices(DataAccessorFactory.GetVoucherDataAccessor())); }
public static IJournalServices GetJournalServices() { return(new JournalServices(DataAccessorFactory.GetJournalDataAccessor())); }
/// <summary> /// Creates a new DataAccessor that accesses the specified Data type. /// </summary> /// <param name="dataType">The type of Data to retrieve; note that this parameter must be a /// subtype of Data</param> public DataAccessor(Type dataType) : this() { Id = DataAccessorFactory.GetId(dataType); }
public static IAccountTypeServices GetAccountTypeServices() { return(new AccountTypeServices(DataAccessorFactory.GetAccountTypeAccessor())); }
public static IUserServices GetUserServices() { return(new UserServices(DataAccessorFactory.GetUserAccessor())); }
public static ICompanyServices GetCompanyServices() { return(new CompanyServices(DataAccessorFactory.GetCompanyAccessor())); }
/// <summary> /// Applies data state changes to the entity. /// </summary> /// <remarks> /// This function is not thread-safe; no other API calls can be made to the Entity while /// this function is being executed. /// </remarks> /// <returns>If more data state change updates are needed</returns> public void DataStateChangeUpdate() { // do removals { for (int i = 0; i < _toRemoveStage1.Count; ++i) { int id = _toRemoveStage1[i].Id; _removedLastFrame[id] = _toRemoveStage1[i]; // _removedLastFrame[id] is removed in stage2 _eventDispatcher.Submit(RemovedDataEvent.Create(this, DataAccessorFactory.GetTypeFromId(id))); } for (int i = 0; i < _toRemoveStage2.Count; ++i) { int id = _toRemoveStage2[i].Id; _removedLastFrame.Remove(id); _data.Remove(id); } _toRemoveStage2.Clear(); Utils.Swap(ref _toRemoveStage1, ref _toRemoveStage2); } // We don't throw an exception immediately. If we are throwing an exception, that means // that the Entity is in an invalid state (adding a bad data instance). However, the // only way to recover from that invalid state is by having this method terminate. // Hence, we only throw an exception at the end of the method. Exception exceptionToThrow = null; // do additions for (int i = 0; i < _toAddStage1.Count; ++i) { Data.IData added = _toAddStage1[i]; int id = DataAccessorFactory.GetId(added.GetType()); // make sure we do not readd the same data instance twice if (_data.ContainsKey(id)) { exceptionToThrow = new AlreadyAddedDataException(this, new DataAccessor(added)); continue; } _addedLastFrame[id] = added; if (added is Data.IVersioned) { Data.IVersioned versioned = (Data.IVersioned)added; _data[id] = new VersionedDataContainer(versioned.Duplicate(), versioned.Duplicate(), versioned.Duplicate()); } else { Data.NonVersioned nonVersioned = (Data.NonVersioned)added; _data[id] = new NonVersionedDataContainer(nonVersioned); } // visualize the initial data _eventDispatcher.Submit(AddedDataEvent.Create(this, added.GetType())); } for (int i = 0; i < _toAddStage2.Count; ++i) { _addedLastFrame.Remove(new DataAccessor(_toAddStage2[i]).Id); } _toAddStage2.Clear(); Utils.Swap(ref _toAddStage1, ref _toAddStage2); if (exceptionToThrow != null) { throw exceptionToThrow; } }
public static ITransactionDetailServices GetTransactionDetailServices() { return(new TransactionDetailServices(DataAccessorFactory.GetTransactionDetailAccessor())); }
public static ILedgerServices GetLedgerServices() { return(new LedgerServices(DataAccessorFactory.GetLedgerDataAccessor())); }
public AccessorResolver(DataAccessorFactory dataAccessorFactory) { Accessor = dataAccessorFactory.Create <T>(); }
/// <summary> /// Adds a default data instance to the template. The template "owns" the passed data /// instance; a copy is not made of it. /// </summary> /// <remarks> /// If the ITemplate is currently being backed by an IGameEngine, this will throw an /// InvalidOperationException. /// </remarks> /// <param name="data">The data instance to copy from.</param> public void AddDefaultData(Data.IData data) { _defaultDataInstances[DataAccessorFactory.GetId(data)] = data; }