Esempio n. 1
0
        public void Handle(Input.PlacesSearch action)
        {
            Func <Country, bool> predicate;

            if (action.Value == "*")
            {
                predicate = s => true;
            }
            else
            {
                predicate = p => p.Name.ToLowerInvariant().StartsWith(action.Value.ToLowerInvariant());
            }

            this.FoundPlaces.Clear();
            foreach (var foundPlace in AvailableCountries.Where(predicate))
            {
                var json = FoundPlaces.Add();
                json.Name         = foundPlace.Name;
                json.SelectAction = () =>
                {
                    FoundPlaces.Clear();
                    PlacesSearch = foundPlace.Name;
                    PlacesText   = $"Capital of {foundPlace.Name} is {foundPlace.CapitalName}";
                };
            }
        }
 public Schema()
     : base()
 {
     InstanceType = typeof(__Autocomp__);
     ClassName    = "AutocompletePage";
     Properties.ClearExposed();
     Html = Add <__TString__>("Html");
     Html.DefaultValue = "/KitchenSink/AutocompletePage.html";
     Html.SetCustomAccessors((_p_) => { return(((__Autocomp__)_p_).__bf__Html__); }, (_p_, _v_) => { ((__Autocomp__)_p_).__bf__Html__ = (System.String)_v_; }, false);
     PlacesSearch = Add <__TString__>("PlacesSearch$");
     PlacesSearch.DefaultValue = "";
     PlacesSearch.Editable     = true;
     PlacesSearch.SetCustomAccessors((_p_) => { return(((__Autocomp__)_p_).__bf__PlacesSearch__); }, (_p_, _v_) => { ((__Autocomp__)_p_).__bf__PlacesSearch__ = (System.String)_v_; }, false);
     PlacesSearch.AddHandler((Json pup, Property <String> prop, String value) => { return(new Input.PlacesSearch()
         {
             App = (AutocompletePage)pup, Template = (TString)prop, Value = value
         }); }, (Json pup, Starcounter.Input <String> input) => { ((AutocompletePage)pup).Handle((Input.PlacesSearch)input); });
     PlacesText = Add <__TString__>("PlacesText");
     PlacesText.DefaultValue = "";
     PlacesText.SetCustomAccessors((_p_) => { return(((__Autocomp__)_p_).__bf__PlacesText__); }, (_p_, _v_) => { ((__Autocomp__)_p_).__bf__PlacesText__ = (System.String)_v_; }, false);
     ClearPlaces = Add <__TLong__>("ClearPlaces$");
     ClearPlaces.DefaultValue = 0L;
     ClearPlaces.Editable     = true;
     ClearPlaces.SetCustomAccessors((_p_) => { return(((__Autocomp__)_p_).__bf__ClearPlaces__); }, (_p_, _v_) => { ((__Autocomp__)_p_).__bf__ClearPlaces__ = (System.Int64)_v_; }, false);
     ClearPlaces.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.ClearPlaces()
         {
             App = (AutocompletePage)pup, Template = (TLong)prop, Value = value
         }); }, (Json pup, Starcounter.Input <Int64> input) => { ((AutocompletePage)pup).Handle((Input.ClearPlaces)input); });
     FoundPlaces = Add <__TArray__>("FoundPlaces");
     FoundPlaces.SetCustomGetElementType((arr) => { return(__AuFoundPla__.DefaultTemplate); });
     FoundPlaces.SetCustomAccessors((_p_) => { return(((__Autocomp__)_p_).__bf__FoundPlaces__); }, (_p_, _v_) => { ((__Autocomp__)_p_).__bf__FoundPlaces__ = (__Arr__)_v_; }, false);
     ProductsSearch = Add <__TString__>("ProductsSearch$");
     ProductsSearch.DefaultValue = "";
     ProductsSearch.Editable     = true;
     ProductsSearch.SetCustomAccessors((_p_) => { return(((__Autocomp__)_p_).__bf__ProductsSearch__); }, (_p_, _v_) => { ((__Autocomp__)_p_).__bf__ProductsSearch__ = (System.String)_v_; }, false);
     ProductsSearch.AddHandler((Json pup, Property <String> prop, String value) => { return(new Input.ProductsSearch()
         {
             App = (AutocompletePage)pup, Template = (TString)prop, Value = value
         }); }, (Json pup, Starcounter.Input <String> input) => { ((AutocompletePage)pup).Handle((Input.ProductsSearch)input); });
     ProductsText = Add <__TString__>("ProductsText");
     ProductsText.DefaultValue = "";
     ProductsText.SetCustomAccessors((_p_) => { return(((__Autocomp__)_p_).__bf__ProductsText__); }, (_p_, _v_) => { ((__Autocomp__)_p_).__bf__ProductsText__ = (System.String)_v_; }, false);
     ClearProducts = Add <__TLong__>("ClearProducts$");
     ClearProducts.DefaultValue = 0L;
     ClearProducts.Editable     = true;
     ClearProducts.SetCustomAccessors((_p_) => { return(((__Autocomp__)_p_).__bf__ClearProducts__); }, (_p_, _v_) => { ((__Autocomp__)_p_).__bf__ClearProducts__ = (System.Int64)_v_; }, false);
     ClearProducts.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.ClearProducts()
         {
             App = (AutocompletePage)pup, Template = (TLong)prop, Value = value
         }); }, (Json pup, Starcounter.Input <Int64> input) => { ((AutocompletePage)pup).Handle((Input.ClearProducts)input); });
     FoundProducts = Add <__TArray1__>("FoundProducts");
     FoundProducts.SetCustomGetElementType((arr) => { return(__AuFoundPro__.DefaultTemplate); });
     FoundProducts.SetCustomAccessors((_p_) => { return(((__Autocomp__)_p_).__bf__FoundProducts__); }, (_p_, _v_) => { ((__Autocomp__)_p_).__bf__FoundProducts__ = (__Arr1__)_v_; }, false);
 }