Exemplo n.º 1
0
        public void AddRow(DataView view, Type recType, MappedRecord model)
        {
            DataRow row = NewRow(view, recType, model);

            view.Table.Rows.Add(row);
            AddRecordToCollection(model);
        }
Exemplo n.º 2
0
        protected void AppendRow(DataView view, Type recType, MappedRecord record)
        {
            modelTables[recType].ForEach(mt => mt.BeginProgrammaticUpdate());
            DataRow row = NewRow(view, recType, record);

            view.Table.Rows.Add(row);
            AddRecordToCollection(record);
            modelTables[recType].ForEach(mt => mt.EndProgrammaticUpdate());
        }
Exemplo n.º 3
0
        protected void AppendRow(DataView view, Type recType, MappedRecord model)
        {
            modelTables.Single(kvp => kvp.Key == model.GetType()).Value.ForEach(mt => mt.BeginProgrammaticUpdate());
            DataRow row = NewRow(view, recType, model);

            view.Table.Rows.Add(row);
            AddRecordToCollection(model);
            modelTables.Single(kvp => kvp.Key == recType).Value.ForEach(mt => mt.EndProgrammaticUpdate());
        }
Exemplo n.º 4
0
        protected DataRow NewRow(DataView view, Type modelType, MappedRecord model)
        {
            List <Field> fields = GetFields(modelType);
            DataRow      row    = view.Table.NewRow();

            foreach (Field field in fields.Where(f => f.IsTableField))
            {
                object val = modelType.GetProperty(field.Name).GetValue(model);
                row[field.Name] = val ?? DBNull.Value;
            }

            model.Row = row;

            return(row);
        }
Exemplo n.º 5
0
        public void Replace(MappedRecord oldEntity, MappedRecord withEntity)
        {
            var oldEntityType  = oldEntity.GetType();
            var mappedEntities = mappedRecords[oldEntityType];
            int idx            = mappedEntities.Cast <MappedRecord>().IndexOf(e => e.Row == oldEntity.Row);

            if (idx != -1)
            {
                mappedEntities[idx] = (IEntity)withEntity;
            }

            var tables = modelTables[oldEntityType];

            tables.ForEach(mt => mt.Replace((IEntity)oldEntity, (IEntity)withEntity));
        }
Exemplo n.º 6
0
        protected void AddRecordToCollection(MappedRecord record)
        {
            Assert.That(mappedRecords.ContainsKey(record.GetType()), "Model Manager does not know about " + record.GetType().Name + ".\r\nCreate an instance of ModuleMgr with this record collection.");

            mappedRecords[record.GetType()].Add((IEntity)record);
        }
Exemplo n.º 7
0
        protected void AppendDecoupledRow(DataView view, Type recType, MappedRecord record)
        {
            DataRow row = NewRow(view, recType, record);

            view.Table.Rows.Add(row);
        }