public override void Clear()
        {
            var removedObjects = new Stack <DomainObject>(); // holds the removed objects in order to raise

            int index = 0;

            foreach (var domainObject in this)
            {
                OnDataChanging(OperationKind.Remove, domainObject, index);
                removedObjects.Push(domainObject);
                ++index;
            }

            Assertion.IsTrue(index == Count);

            WrappedData.Clear();

            foreach (var domainObject in removedObjects)
            {
                --index;
                OnDataChanged(OperationKind.Remove, domainObject, index);
            }

            Assertion.IsTrue(index == 0);
        }
        public override void Insert(int index, DomainObject domainObject)
        {
            ArgumentUtility.CheckNotNull("domainObject", domainObject);

            OnDataChanging(OperationKind.Insert, domainObject, index);
            WrappedData.Insert(index, domainObject);
            OnDataChanged(OperationKind.Insert, domainObject, index);
        }
        public override void Replace(int index, DomainObject value)
        {
            ArgumentUtility.CheckNotNull("value", value);

            var oldDomainObject = GetObject(index);

            if (oldDomainObject != value)
            {
                OnDataChanging(OperationKind.Remove, oldDomainObject, index);
                OnDataChanging(OperationKind.Insert, value, index);
                WrappedData.Replace(index, value);
                OnDataChanged(OperationKind.Remove, oldDomainObject, index);
                OnDataChanged(OperationKind.Insert, value, index);
            }
        }
        public override bool Remove(DomainObject domainObject)
        {
            ArgumentUtility.CheckNotNull("domainObject", domainObject);

            int index = IndexOf(domainObject.ID);

            if (index == -1)
            {
                return(false);
            }

            OnDataChanging(OperationKind.Remove, domainObject, index);
            WrappedData.Remove(domainObject);
            OnDataChanged(OperationKind.Remove, domainObject, index);

            return(true);
        }
        public override bool Remove(ObjectID objectID)
        {
            ArgumentUtility.CheckNotNull("objectID", objectID);

            int index = IndexOf(objectID);

            if (index == -1)
            {
                return(false);
            }

            var domainObject = GetObject(objectID);

            OnDataChanging(OperationKind.Remove, domainObject, index);
            WrappedData.Remove(objectID);
            OnDataChanged(OperationKind.Remove, domainObject, index);

            return(true);
        }
        public async Task <WrappedData> Execute(TestCriteria criteria, DbConnection connection)
        {
            var result = new WrappedData();

            result.FirstClassData  = new List <FirstClass>();
            result.SecondClassData = new List <SecondClass>();

            if (connection.State != System.Data.ConnectionState.Open)
            {
                await connection.OpenAsync();
            }
            using (var command = connection.CreateCommand())
            {
                command.CommandText = "usp_Company_GetById_With_Children";
                command.CommandType = System.Data.CommandType.StoredProcedure;
                var param = command.CreateParameter();
                param.ParameterName = "@CompanyId";
                param.DbType        = System.Data.DbType.Int32;
                param.Value         = criteria.CompanyId;
                if (criteria.CompanyId == null)
                {
                    param.Value = DBNull.Value;
                }
                command.Parameters.Add(param);

                using (DbDataReader reader = await command.ExecuteReaderAsync())
                {
                    while (await reader.ReadAsync())
                    {
                        result.FirstClassData.Add(_firstClassMapper.Map(reader));
                    }
                    await reader.NextResultAsync();

                    while (await reader.ReadAsync())
                    {
                        result.SecondClassData.Add(_secondClassMapper.Map(reader));
                    }
                }
            }
            return(result);
        }
 public void NotifyObservers()
 {
     WrappedData.NotifyObservers();
 }
 public void Detach(IObserver observer)
 {
     WrappedData.Detach(observer);
 }
 public void Attach(IObserver observer)
 {
     WrappedData.Attach(observer);
 }