示例#1
0
        static async Task Main(string[] args)
        {
            //var report = await Surf.Wave(args?.FirstOrDefault() ?? "https://private-ac89c-surfdude.apiary-mock.com/")
            //       .FromRoot()
            //       .ThenSubmit("registration-finder", new { status = "active", email = "*****@*****.**" })
            //       .GoAsync();

            var context = new SurfContext(args?.FirstOrDefault() ?? "https://private-ac89c-surfdude.apiary-mock.com/", loggerFactory);

            var report = await Surf.Wave(context)
                         .FromRoot()
                         .Then("registrations")
                         .ThenItem(0)
                         .ThenSubmit("update-contact-details", new { email = "*****@*****.**" })
                         .ThenRead(out Func <ResourceModel> getContactDetails)
                         .Then("registration")
                         //.ThenSubmit("add-processing-instruction", new { message = "Put NO-SPAM in the email subject." })
                         .GoAsync();

            Console.WriteLine(String.Join(Environment.NewLine, loggerFactory.Messages));

            Console.WriteLine(getContactDetails()?.Email);

            foreach (var line in report.Lines)
            {
                Console.WriteLine(line.Message);
            }

            report.EnsureSuccess();
        }
示例#2
0
        public static IWaveStart Wave(SurfContext journeyContext)
        {
            if (journeyContext == null)
            {
                throw new ArgumentNullException(nameof(journeyContext));
            }

            return(new Surf(journeyContext));
        }
示例#3
0
 public Surf(SurfContext journeyContext)
     : base(journeyContext, new SimpleJsonResourceReaderWriter(journeyContext))
 {
 }
示例#4
0
 internal ReadStep <TModel> GetReadStep <TModel>(SurfContext context, TModel[] models) where TModel : class
 {
     return(new ReadStep <TModel>(this.CreateStepContext(context), models));
 }
示例#5
0
 private HttpStepContext CreateStepContext(SurfContext context)
 {
     return(new HttpStepContext(this.HttpClient, context, this.ResourceFormatter));
 }
示例#6
0
 protected internal virtual IStep GetToItemStep(int index, SurfContext context)
 {
     return(new ToItemStep(this.CreateStepContext(context), index));
 }
示例#7
0
 protected internal virtual IStep GetSubmitStep(string rel, object transferObject, SurfContext context)
 {
     return(new SubmitStep(this.CreateStepContext(context), rel, transferObject));
 }
示例#8
0
 protected internal virtual IStep GetToStep(string rel, SurfContext context)
 {
     return(new ToStep(this.CreateStepContext(context), rel));
 }
示例#9
0
        //

        protected internal virtual IStep GetFromStep(string uri, SurfContext context)
        {
            return(new FromStep(this.CreateStepContext(context), uri ?? context.RootUri.ToString()));
        }
示例#10
0
 public StepFactory(SurfContext context, IHypertextResourceFormatter resourceFormatter)
 {
     this.SurfContext       = context ?? throw new ArgumentNullException(nameof(context));
     this.ResourceFormatter = resourceFormatter ?? throw new ArgumentNullException(nameof(resourceFormatter));
 }
示例#11
0
 protected WaveBuilder(SurfContext context, StepFactory stepFactory)
 {
     this.SurfContext = context ?? throw new ArgumentNullException(nameof(context));
     this.StepFactory = stepFactory ?? throw new ArgumentNullException(nameof(stepFactory));
 }
示例#12
0
 protected WaveBuilder(SurfContext context, IHypertextResourceFormatter resourceFormatter)
 {
     this.SurfContext = context ?? throw new ArgumentNullException(nameof(context));
     this.StepFactory = new StepFactory(context, resourceFormatter);
 }