Esempio n. 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)
                       ));
        }
Esempio n. 2
0
 protected virtual IEnumerable <TResult> TransformQueryResults(
     IEnumerable <TQueryResult> results,
     ClientObjectResolveContext context
     )
 {
     throw Logger.Fatal.NotImplemented();
 }
Esempio n. 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);
        }
Esempio n. 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());
        }
Esempio n. 7
0
 protected virtual IQueryable <TQueryResult>[] CreateQueries(
     ClientObjectResolveContext context
     )
 => new[] { CreateQuery(context) };
Esempio n. 8
0
 protected virtual IQueryable <TQueryResult> CreateQuery(
     ClientObjectResolveContext context
     )
 {
     throw Logger.Fatal.NotImplemented();
 }
Esempio n. 9
0
 protected abstract IEnumerable <TResult> CreateObjects(ClientObjectResolveContext context);
Esempio n. 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;