Example #1
0
        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;
        }
Example #2
0
        public void Initialize(ContentEntitySerializationFormat format)
        {
            PrettyName = format.PrettyName ?? "";
            UniqueId   = format.UniqueId;

            foreach (DataInstance data in format.Data)
            {
                _data[DataAccessorFactory.GetId(data.CurrentData)] = data;
            }
        }
Example #3
0
        /// <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;
            }
        }
Example #4
0
 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 });
 }
Example #5
0
        /// <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);
        }
Example #6
0
        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...");
            }
        }
Example #7
0
        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>();
        }
Example #8
0
 public static IIncomeStatementServices GetIncomeStatementServices()
 {
     return(new IncomeStatementServices(DataAccessorFactory.GetIncomeStatementDataAccessor()));
 }
Example #9
0
 public static IVoucherServices GetVoucherServices()
 {
     return(new VoucherServices(DataAccessorFactory.GetVoucherDataAccessor()));
 }
Example #10
0
 public static IJournalServices GetJournalServices()
 {
     return(new JournalServices(DataAccessorFactory.GetJournalDataAccessor()));
 }
Example #11
0
 /// <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);
 }
Example #12
0
 public static IAccountTypeServices GetAccountTypeServices()
 {
     return(new AccountTypeServices(DataAccessorFactory.GetAccountTypeAccessor()));
 }
Example #13
0
 public static IUserServices GetUserServices()
 {
     return(new UserServices(DataAccessorFactory.GetUserAccessor()));
 }
Example #14
0
 public static ICompanyServices GetCompanyServices()
 {
     return(new CompanyServices(DataAccessorFactory.GetCompanyAccessor()));
 }
Example #15
0
        /// <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;
            }
        }
Example #16
0
 public static ITransactionDetailServices GetTransactionDetailServices()
 {
     return(new TransactionDetailServices(DataAccessorFactory.GetTransactionDetailAccessor()));
 }
Example #17
0
 public static ILedgerServices GetLedgerServices()
 {
     return(new LedgerServices(DataAccessorFactory.GetLedgerDataAccessor()));
 }
 public AccessorResolver(DataAccessorFactory dataAccessorFactory)
 {
     Accessor = dataAccessorFactory.Create <T>();
 }
Example #19
0
 /// <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;
 }