예제 #1
0
        protected sealed override IEnumerable ToEnumerable(Object state, ClientObjectResolveContext context)
        {
            if (state == null)
            {
                throw Logger.Fatal.ArgumentNull(nameof(state));
            }

            if (context == null)
            {
                throw Logger.Fatal.ArgumentNull(nameof(context));
            }

            var enumerables = (state as IEnumerable <TQueryResult>[]);

            if (enumerables == null)
            {
                throw Logger.Fatal.ArgumentNotAssignableTo(
                          nameof(state),
                          state,
                          typeof(IEnumerable <TQueryResult>[])
                          );
            }

            return(enumerables.SelectMany(
                       enumerable => TransformQueryResults(enumerable, context)
                       ));
        }
예제 #2
0
 protected virtual IEnumerable <TResult> TransformQueryResults(
     IEnumerable <TQueryResult> results,
     ClientObjectResolveContext context
     )
 {
     throw Logger.Fatal.NotImplemented();
 }
예제 #3
0
        protected sealed override Object Initialize(ClientObjectResolveContext context)
        {
            var queries = CreateQueries(context);

            if (queries == null)
            {
                return(Enumerable.Empty <TQueryResult>());
            }

            var collections = queries
                              .OfType <ClientObjectCollection>()
                              .ToArray();

            if (collections.Any())
            {
                throw Logger.Fatal.InvalidOperationFormat(
                          SR.ClientObjectQueryResolveBuilder_CollectionQuery,
                          GetType(),
                          nameof(CreateQueries),
                          typeof(ClientObjectCollection)
                          );
            }

            return(queries
                   .Select(context.LoadQuery)
                   .ToArray());
        }
        protected override IEnumerable <T> CreateObjects(ClientObjectResolveContext context)
        {
            if (context == null)
            {
                throw Logger.Fatal.ArgumentNull(nameof(context));
            }


            return(context.ProvisionerContext.GetState <T>());
        }
        protected sealed override void InitializeContextBeforeParent(ClientObjectResolveContext context)
        {
            if (context == null)
            {
                throw Logger.Fatal.ArgumentNull(nameof(context));
            }

            context.Include(ChildrenExpression);

            base.InitializeContextBeforeParent(context);
        }
예제 #6
0
        protected sealed override Object Initialize(ClientObjectResolveContext context)
        {
            if (context == null)
            {
                throw Logger.Fatal.ArgumentNull(nameof(context));
            }

            var objects = CreateObjects(context) ?? new TResult[0];

            if (objects != null)
            {
                foreach (var clientObj in objects)
                {
                    context.Load(clientObj);
                }
            }

            return(objects.ToImmutableArray());
        }
예제 #7
0
 protected virtual IQueryable <TQueryResult>[] CreateQueries(
     ClientObjectResolveContext context
     )
 => new[] { CreateQuery(context) };
예제 #8
0
 protected virtual IQueryable <TQueryResult> CreateQuery(
     ClientObjectResolveContext context
     )
 {
     throw Logger.Fatal.NotImplemented();
 }
예제 #9
0
 protected abstract IEnumerable <TResult> CreateObjects(ClientObjectResolveContext context);
예제 #10
0
 protected sealed override IEnumerable ToEnumerable(Object state, ClientObjectResolveContext context)
 => (IEnumerable)(state);
 protected sealed override IEnumerable <TResult> TransformQueryResults(IEnumerable <TResult> results, ClientObjectResolveContext context)
 => results;