Exemplo n.º 1
0
		private void ObjectContext_ObjectMaterialized(Object sender, ObjectMaterializedEventArgs e) {
			// TODO: StopWatch!!
			Object entity = e.Entity;

			// Get any DateTime properties!
			PropertyInfo[] props = entity.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Where(p => p.PropertyType == typeof(DateTime)).ToArray();
			foreach (PropertyInfo info in props) {
				Object value = info.GetValue(entity);
				DateTime? dt = value as DateTime?;
				if (value != null) {
					// Let's fix the DateTime properties, it's straight out of the database,
					// so they should all be UTC
					info.SetValue(entity, dt.Value.FixTimeZone());
				}
			}

			// Get any nullable DateTime properties!
			props = entity.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Where(p => p.PropertyType == typeof(DateTime?)).ToArray();
			foreach (PropertyInfo info in props) {
				Object value = info.GetValue(entity);
				DateTime? dt = value as DateTime?;
				if (value != null) {
					// Let's fix the DateTime properties, it's straight out of the database,
					// so they should all be UTC
					info.SetValue(entity, dt.FixTimeZone());
				}
			}
		}
Exemplo n.º 2
0
 private void ObjectContextOnObjectMaterialized(object sender, ObjectMaterializedEventArgs objectMaterializedEventArgs)
 {
     if (objectMaterializedEventArgs.Entity.GetType().Name == "User")
     {
         var user = (User)objectMaterializedEventArgs.Entity;
         Decrypt(user);
     }
 }
Exemplo n.º 3
0
 private void OnObjectContextObjectMaterialized(object sender, ObjectMaterializedEventArgs e)
 {
     var entityChatUser = e.Entity as ChatUser;
     if (entityChatUser != null)
     {
         entityChatUser.LastActivity = DateTime.SpecifyKind(entityChatUser.LastActivity, DateTimeKind.Utc);
     }
 }
Exemplo n.º 4
0
        private void Context_ObjectMaterialized(object sender, System.Data.Entity.Core.Objects.ObjectMaterializedEventArgs e)
        {
            var model = (e.Entity as EntityBase);

            if (model != null)
            {
                model.IsChanged = false;
            }
        }
 private static void ReadAllDateTimeValuesAsUtc(object sender, ObjectMaterializedEventArgs e)
 {
     //Extract all DateTime properties of the object type
     var properties = e.Entity.GetType().GetProperties()
         .Where(property => property.PropertyType == typeof(DateTime) ||
                            property.PropertyType == typeof(DateTime?)).ToList();
     //Set all DaetTimeKinds to Utc
     properties.ForEach(property => SpecifyUtcKind(property, e.Entity));
 }
Exemplo n.º 6
0
		private void ObjectContext_ObjectMaterialized(Object sender, ObjectMaterializedEventArgs e) {
			if(e.Entity is Event) {
				Int32 count = ((Event)e.Entity).Resources.Count;
			}
			else if(e.Entity is Resource) {
				Int32 count = ((Resource)e.Entity).Events.Count;
			}
			else if(e.Entity is Analysis) {
				((Analysis)e.Entity).UpdateDimensionProperties();
			}
		}
Exemplo n.º 7
0
		protected void OnObjectMaterialized(object sender, ObjectMaterializedEventArgs e)
		{
			if (e.Entity is Library)
			{
				var library = ((Library)e.Entity);
				library.Context = this;
				library.Name = LibraryName;
				library.Path = DataSourceFolderPath;
				library.Pages.Sort();
			}
			if (e.Entity is WallbinEntity)
			{
				((WallbinEntity) e.Entity).AllowToHandleChanges = true;
			}
		}
Exemplo n.º 8
0
        protected virtual void OnObjectMaterialized(object sender, System.Data.Entity.Core.Objects.ObjectMaterializedEventArgs e)
        {
            // When materialized, set it's context:
            var entity = e.Entity as IContextualEntity <TContext>;

            if (entity != null)
            {
                entity.Context = (TContext)(object)this;
            }

            // Run OnMaterialized:
            var materialized = e.Entity as IMaterializeInterceptable;

            if (materialized != null)
            {
                materialized.OnMaterialized(this);
            }
        }
        public void OriginalDbContextTracker_ObjectMaterialized(object sender, System.Data.Entity.Core.Objects.ObjectMaterializedEventArgs e)
        {
            try
            {
                //retrieve the tracker with the Guid
                DbContext tempContext = OriginalValuesContext;

                var   clrType    = ObjectContext.GetObjectType(e.Entity.GetType());
                DbSet dbset      = tempContext.Set(clrType);
                var   new_Entity = Activator.CreateInstance(clrType);
                dbset.Add(new_Entity);
                tempContext.Entry(new_Entity).CurrentValues.SetValues(e.Entity);
                tempContext.Entry(new_Entity).State = EntityState.Unchanged;
                //var entry = tempContext.AsObjectContext().ObjectStateManager.GetObjectStateEntry(new_Entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 private void ObjectContextOnObjectMaterialized(object sender, ObjectMaterializedEventArgs objectMaterializedEventArgs)
 {
     ObjectMaterializedInterception.InterceptObjectMaterialized(objectMaterializedEventArgs.Entity);
 }
Exemplo n.º 11
0
		/// <summary>
		/// Called when an entity has been loaded.
		/// </summary>
		/// <param name="sender">The sender</param>
		/// <param name="e">Event arguments</param>
		protected virtual void OnEntityLoad(object sender, ObjectMaterializedEventArgs e) {
			if (e.Entity is Entities.IBaseEntity)
				((Entities.IBaseEntity)e.Entity).OnLoad(this);
		}
Exemplo n.º 12
0
 private void ObjectMaterializedHandler(object sender, ObjectMaterializedEventArgs e)
 {
     EntityLoadedEventHandler handler = EntityLoaded;
     if (handler != null)
         handler(this, new EntityLoadedEventHandlerArgs(e.Entity));
 }
        internal static void ObjectMaterialized(object sender, ObjectMaterializedEventArgs e)
        {
            var entity = e.Entity;

            if (entity == null)
            {
                return;
            }

            if (entity is EventSeries)
            {
                EventSeries.OnMaterialized(entity as EventSeries);
            }
            else if (entity is Event)
            {
                Event.OnMaterialized(entity as Event);
            }
        }
Exemplo n.º 14
0
 static void _context_ObjectMaterialized(object sender, System.Data.Entity.Core.Objects.ObjectMaterializedEventArgs e)
 {
     OnAliceMaterializer(e);
 }
Exemplo n.º 15
0
 protected void ObjectContext_ObjectMaterialized(object sender, ObjectMaterializedEventArgs e)
 {
     if (this.IoCContainer != null)
         this.IoCContainer.BuildUp(e.Entity);
 }
Exemplo n.º 16
0
 private void OnObjectMaterialized(object sender,
                                   System.Data.Entity.Core.Objects.ObjectMaterializedEventArgs e)
 {
 }
Exemplo n.º 17
0
        private void ObjectMaterialized(object sender, ObjectMaterializedEventArgs e)
        {
            var metadata = new HookEntityMetadata(EntityState.Unchanged, this);

            foreach (var postLoadHook in PostLoadHooks)
            {
                postLoadHook.HookObject(e.Entity, metadata);
            }
        }
Exemplo n.º 18
0
		/// <summary>
		/// Processes the loaded entities before returning them.
		/// </summary>
		public static void OnLoad(DbContext context, ObjectMaterializedEventArgs e) {
			if (e.Entity is Models.Model) {
				((Models.Model)e.Entity).OnLoad();
			}
		}