コード例 #1
0
 /// <summary>
 /// Recupera o enumerador das entidade com base no resultado preparado.
 /// </summary>
 /// <param name="prepareResult"></param>
 /// <param name="sourceContext"></param>
 /// <returns></returns>
 private IEnumerator <IEntity> GetEnumerator(PrepareNestedQueriesResult prepareResult, Colosoft.Query.ISourceContext sourceContext)
 {
     if (prepareResult.Exceptions.Count > 0)
     {
         throw new AggregateException(prepareResult.Exceptions.FirstOrDefault().Message, prepareResult.Exceptions);
     }
     foreach (var i in prepareResult.ParentResult)
     {
         IEntity       entity        = null;
         LazyDataState lazyDataState = new LazyDataState();
         prepareResult.EntityLoader.GetLazyData(i, lazyDataState, sourceContext, prepareResult.UiContext, prepareResult.EntityTypeManager, prepareResult.Exceptions);
         using (var args = new EntityLoaderCreatorArgs <Model>((Model)i.DataModel, i.RecordKey, i.Children, i.Links, i.References, prepareResult.UiContext, prepareResult.EntityTypeManager))
         {
             entity = ((EntityLoader <TEntity1, Model>)prepareResult.EntityLoader).EntityCreator(args);
             lazyDataState.Entity = entity;
             if (entity is IConnectedEntity)
             {
                 ((IConnectedEntity)entity).Connect(sourceContext);
             }
             if (entity is IEntityRecordObserver)
             {
                 ((IEntityRecordObserver)entity).RegisterObserver(i.RecordKey);
             }
             if (entity is ILoadableEntity)
             {
                 ((ILoadableEntity)entity).NotifyLoaded();
             }
         }
         i.Dispose();
         yield return(entity);
     }
 }
コード例 #2
0
            /// <summary>
            /// Processo o resultado da consulta.
            /// </summary>
            /// <param name="prepareResult"></param>
            /// <param name="queryableResult"></param>
            private static void ProcessQueryResult(PrepareNestedQueriesResult prepareResult, Query.IQueryResult queryableResult)
            {
                var bindStrategy      = prepareResult.EntityLoader.GetBindStrategy();
                var objectCreator     = prepareResult.EntityLoader.GetObjectCreator();
                var recordKeyFactory  = prepareResult.EntityLoader.GetRecordKeyFactory();
                var dataModelTypeName = Colosoft.Reflection.TypeName.Get(prepareResult.EntityLoader.DataModelType);

                Colosoft.Query.IQueryResultBindStrategySession bindStrategySession = null;
                foreach (var record in queryableResult)
                {
                    var data = objectCreator.Create();
                    if (bindStrategySession == null)
                    {
                        bindStrategySession = bindStrategy.CreateSession(record.Descriptor);
                    }
                    var bindResult = bindStrategySession.Bind(record, Query.BindStrategyMode.All, ref data);
                    if (!bindResult.Any())
                    {
                        throw new Exception(string.Format("Not found scheme for bind record data to type '{0}'", data.GetType().FullName));
                    }
                    var recordKey = recordKeyFactory.Create(dataModelTypeName, record);
                    EntityLoaderCreatorArgs creatorArgs = null;
                    creatorArgs = new EntityLoaderCreatorArgs((Model)data, recordKey, new EntityLoaderChildContainer(), new EntityLoaderLinksContainer(), new EntityLoaderReferenceContainer(), prepareResult.UiContext, prepareResult.EntityTypeManager);
                    prepareResult.ParentResult.Add(creatorArgs);
                }
            }
コード例 #3
0
 /// <summary>
 /// Cria uma nova instancia da entidade associada.
 /// </summary>
 /// <param name="uiContext">Contexto de interface com o usuário.</param>
 /// <param name="entityTypeManager">Gerenciador do tipo da entidade.</param>
 /// <param name="creatorArgs">Argumentos que serão usadaos na crição da entidade.</param>
 /// <param name="sourceContext">Contexto de origem dos dados.</param>
 /// <returns></returns>
 public abstract IEntity Create(string uiContext, IEntityTypeManager entityTypeManager, EntityLoaderCreatorArgs creatorArgs, Colosoft.Query.ISourceContext sourceContext);
コード例 #4
0
 /// <summary>
 /// Recupera os dados de carga tardia .
 /// </summary>
 /// <param name="creatorArgs">Argumentos para a criação da entidade.</param>
 /// <param name="state">Estado dos dados de carga tardia.</param>
 /// <param name="sourceContext">Contexto de origem dos dados.</param>
 /// <param name="uiContext">Contexto da interface com o usuário.</param>
 /// <param name="entityTypeManager">Gerenciador dos tipos de entidades.</param>
 /// <param name="exceptions">Fila dos erros ocorridos.</param>
 public abstract void GetLazyData(EntityLoaderCreatorArgs creatorArgs, LazyDataState state, Colosoft.Query.ISourceContext sourceContext, string uiContext, IEntityTypeManager entityTypeManager, Queue <Exception> exceptions);