Esempio n. 1
0
 public void FillContext(WorksheetContext ctx)
 {
     ctx.Context.Entites.ForEach((e) =>
     {
         Attribute attribute = e.Attributes.FirstOrDefault(a => a.IsTypeOf <Table>());
         if (attribute.IsNotNull())
         {
             Table table = attribute.CastToType <Table>();
             if (_dataSet.Tables.Contains(table.TableName))
             {
                 IEntityCollection collection = e.Entities as IEntityCollection;
                 if (collection.IsNotNull())
                 {
                     foreach (DataRow row in _dataSet.Tables[table.TableName].Rows)
                     {
                         Entity entity = collection.CreateInstance(e.EntityType, true, new object[] { row }) as Entity;
                         if (entity.IsNotNull())
                         {
                             collection.Add(entity);
                         }
                     }
                 }
             }
         }
     });
     ctx.AcceptChanges();
 }
Esempio n. 2
0
 internal void SetValue(string name, object value, Type propertyType)
 {
     if (EntityCtx.DynamicProperties.IsNotNull())
     {
         IEnumerable <Entity> entities = this[EntityCtx.DynamicProperties.Property.Name] as IEnumerable <Entity>;
         if (entities.IsNotNull())
         {
             Entity entity = entities.FirstOrDefault(e => e[EntityCtx.DynamicProperties.CodeProperty].IsNotNull() && e[EntityCtx.DynamicProperties.CodeProperty].Equals(name));
             if (entity.IsNotNull())
             {
                 if (EntityCtx.DynamicProperties.ValuesProperties.ContainsKey(propertyType))
                 {
                     entity[EntityCtx.DynamicProperties.ValuesProperties[propertyType]] = value;
                 }
             }
             else
             {
                 IEntityCollection collection = entities as IEntityCollection;
                 if (collection.IsNotNull())
                 {
                     entity = collection.CreateInstance(EntityCtx.DynamicProperties.Property.ReletedEntity.RelatedEntity.EntityType, true, null) as Entity;
                     if (entity.IsNotNull())
                     {
                         if (EntityCtx.DynamicProperties.ValuesProperties.ContainsKey(propertyType))
                         {
                             entity[EntityCtx.DynamicProperties.ValuesProperties[propertyType]] = value;
                         }
                         entity[EntityCtx.DynamicProperties.CodeProperty] = name;
                         collection.Add(entity);
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
0
 internal Context InitailizeRows(EntitiesContext mctx, Dictionary <string, Func <object, object> > ini)
 {
     Entites.ForEach((e) =>
     {
         e.Entities = ini[e.Name](mctx).CastToType <IEnumerable <Entity> >();
         IEntityCollection collection = e.Entities as IEntityCollection;
         if (collection.IsNotNull())
         {
             collection.Context = this;
         }
     });
     return(this);
 }
Esempio n. 4
0
 private void AllowEditCollection(Entity e, bool value)
 {
     if (e.EntityCtx.IsNotNull())
     {
         e.EntityCtx.Properties.Where(p => p.ReletedEntity.IsNotNull() && p.ReletedEntity.Related == Releted.List).
         ToList().ForEach((p) =>
         {
             IEntityCollection collection = e[p.Name] as IEntityCollection;
             if (collection.IsNotNull())
             {
                 collection.AllowEdit = value;
             }
         });
     }
 }