/// <summary> /// Gets the entity. /// </summary> /// <param name="value">The value.</param> /// <param name="rockContext">The rock context.</param> /// <returns></returns> public IEntity GetEntity(string value, RockContext rockContext) { int?entityId = GetEntityId(value, out EntityTypeCache entityType); if (entityType == null) { return(null); } IService entityService; MethodInfo getMethod; var methodParamTypes = new Type[] { typeof(int) }; // Person is handled differently since it's stored as PersonAlias's EntityType.Guid|PersonAlias.Id // (we need to return the Person tied to the PersonAlias instance) if (entityType.GetEntityType() == typeof(PersonAlias)) { entityService = new PersonAliasService(rockContext); getMethod = entityService.GetType().GetMethod("GetPerson", methodParamTypes); } else { entityService = Reflection.GetServiceForEntityType(entityType.GetEntityType(), rockContext); getMethod = entityService.GetType().GetMethod("Get", methodParamTypes); } return(( IEntity )getMethod.Invoke(entityService, new object[] { entityId })); }