Exemple #1
0
        public static ProductEndpointResult GetProductSafely(long id)
        {
            var steps = new List <(
                                      Func <ProductEndpointResult, ProductEndpointResult> fn,
                                      ErrorFunctions.ErrorFunction errorFn)>
            {
                (ProductFunctions.GetProductWithError, HandleProductError),
                // additional safe functions...
                (Serialize, e => Console.WriteLine(e))
            };

            return(PipelineFunctions <ProductEndpointResult>
                   .ExecuteSafely(new ProductEndpointResult { id = id }, steps));
        }
Exemple #2
0
        public static ProductEndpointResult GetProduct(long id)
        {
            // here we compose our process pipeline by selection which functions shall be a part of it

            var steps = new List <Func <ProductEndpointResult, ProductEndpointResult> >
            {
                ProductFunctions.GetProduct,
                CommunityFunctions.GetRatings,
                product =>
                {
                    product.ratings = FilterRatings(product.ratings, 3);
                    return(product);
                },
                CommunityFunctions.GetComments,
                Serialize
            };

            return(PipelineFunctions <ProductEndpointResult>
                   .Execute(new ProductEndpointResult { id = id }, steps));
        }