Exemple #1
0
 private static ParseResult Match_QuotedChar(InputStream input)
 {
     return(WithAction(
                Sequence(Match_Backslash, Any),
                result =>
     {
         string ch = new SequenceResult(result)[1].MatchedString;
         return new ParseResult(ch);
     })(input));
 }
        public InventoryItem(NancyContext context, InventoryItemDto item)
            : base(context.Request.Url.ToString(), new [] { "item", "detail" })
        {
            Properties = new Dictionary <string, object>
            {
                { "Name", item.Name },
                { "Quantity", item.Quantity }
            };

            Links = new LinksFactory(context)
                    .With(new GetInventoryLink(), WithLink <GetInventoryLink> .Property(x => x.Title = "Back to inventory"))
                    .Build();

            Actions = new ActionsFactory(context)
                      .With(new AddInventoryItemQuantityAction(item.Id, item.Version),
                            WithAction <AddInventoryItemQuantityAction>
                            .Field(x => x.Version)
                            .Having(x => x.Type = "hidden"))
                      .With(new RemoveInventoryItemQuantityAction(item.Id, item.Version),
                            WithAction <RemoveInventoryItemQuantityAction>
                            .Field(x => x.Version)
                            .Having(x => x.Type = "hidden"))
                      .With(new RenameInventoryItemAction(item.Id, item.Version, item.Name),
                            WithAction <RenameInventoryItemAction>
                            .Field(x => x.Version)
                            .Having(x => x.Type = "hidden"))
                      .Build();
        }
 protected UnauthorisedResponse(NancyContext context, IList <string> @class) : base(context.Request.Url.ToString(), @class)
 {
     Actions = new ActionsFactory(context)
               .With(new PostLogin(), WithAction <PostLogin> .Field(x => x.Password).Having(x => x.Type = "password"))
               .With(new PostRegister(),
                     WithAction <PostRegister> .Field(x => x.Password).Having(x => x.Type        = "password"),
                     WithAction <PostRegister> .Field(x => x.ConfirmPassword).Having(x => x.Type = "password"))
               .With(new PostResetPassword())
               .Build();
 }
        public InventoryCollectionItem(NancyContext context, InventoryListItemDto item)
            : base($"{context.Request.Url.SiteBase}{context.Request.Url.BasePath}{context.Request.Url.Path}/{item.Id}", "inventory-item")
        {
            Properties = new Dictionary <string, object> {
                { "Name", item.Name }
            };
            Links = new LinksFactory(context).With(new GetInventoryItemLink(item.Id)).Build();

            Actions = new ActionsFactory(context)
                      .With(new RemoveInventoryItemAction(item.Id, item.Version),
                            WithAction <RemoveInventoryItemAction> .Field(x => x.Version)
                            .Having(x => x.Type = "hidden"))
                      .Build();
        }
Exemple #5
0
        public User(NancyContext context, Domain.User user) : base(context.Request.Url.ToString(), "user")
        {
            Properties = new Dictionary <string, object>
            {
                { "Username", user.Username },
                { "Claims", string.Join(", ", user.Claims.Select(x => x.ToString()).ToList()) }
            };

            Links = new LinksFactory(context).With(new GetUsers(), WithLink <GetUsers> .Property(x => x.Title = "Back to all users")).Build();

            Actions = new ActionsFactory(context).With(new PutClaims(user),
                                                       WithAction <PutClaims> .Field(x => x.Claims)
                                                       .Having(x => x.Type    = "select")
                                                       .Having(x => x.Options = GetClaimsOptions())).Build();
        }
Exemple #6
0
 private static ParseResult Match_Int(InputStream input)
 {
     return(WithAction(Sequence(Match_Digit, ZeroOrMore(Match_Digit)),
                       r => new ParseResult(r.MatchedString, int.Parse(r.MatchedString, CultureInfo.InvariantCulture)))(input));
 }
 /// <summary>
 /// Maps each variable name to a matching property then calls the
 /// provided delegate with the parameters. This method IS case-sensitive
 /// </summary>
 public void With <T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(WithAction <T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> with)
 {
     this._Invoke(with);
 }
 /// <summary>
 /// Maps each variable name to a matching property then calls the
 /// provided delegate with the parameters. This method IS case-sensitive
 /// </summary>
 public void With <T0, T1, T2, T3, T4, T5>(WithAction <T0, T1, T2, T3, T4, T5> with)
 {
     this._Invoke(with);
 }
 /// <summary>
 /// Maps each variable name to a matching property then calls the
 /// provided delegate with the parameters. This method IS case-sensitive
 /// </summary>
 public void With <T0, T1, T2>(WithAction <T0, T1, T2> with)
 {
     this._Invoke(with);
 }
        /* Yikes, a lot of methods here */

        /// <summary>
        /// Maps each variable name to a matching property then calls the
        /// provided delegate with the parameters. This method IS case-sensitive
        /// </summary>
        public void With <T0>(WithAction <T0> with)
        {
            this._Invoke(with);
        }
 /// <summary>
 /// Appends a lambda as a function to this anonymous type
 /// </summary>
 public void SetMethod <T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(string name, WithAction <T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> action)
 {
     this.Set <WithAction <T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >(name, action);
 }
 /// <summary>
 /// Appends a lambda as a function to this anonymous type
 /// </summary>
 public void SetMethod <T0, T1, T2, T3, T4, T5>(string name, WithAction <T0, T1, T2, T3, T4, T5> action)
 {
     this.Set <WithAction <T0, T1, T2, T3, T4, T5> >(name, action);
 }
 /// <summary>
 /// Appends a lambda as a function to this anonymous type
 /// </summary>
 public void SetMethod <T0, T1>(string name, WithAction <T0, T1> action)
 {
     this.Set <WithAction <T0, T1> >(name, action);
 }