Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewDecorator"/> class.
        /// </summary>
        /// <param name="relativeLayout">Relative layout.</param>
        /// <param name="contents">Contents.</param>
        public ViewDecorator(RelativeLayout relativeLayout, View contents)
        {
            // Add contents
            relativeLayout.Children.Add(contents, () => relativeLayout.Bounds);

            // Create overlay
            var activityIndicatorOverlay = new RelativeLayout {
                BackgroundColor = Color.FromRgba(0x05, 0x05, 0x05, 0.75)
            };

            activityIndicatorOverlay.SetBinding(RelativeLayout.IsVisibleProperty,
                                                PropertyNameHelper.GetPropertyName <TViewModel>((vm) => vm.IsBusy));

            relativeLayout.Children.Add(activityIndicatorOverlay, () => relativeLayout.Bounds);

            // Create darker rectangle in the middle
            var activityIndicatorBackground = new RoundedBorderControl {
                BackgroundColor = Color.FromRgba(0, 0, 0, 0.78),
                CornerRadius    = 8,
            };

            activityIndicatorOverlay.Children.Add(activityIndicatorBackground, () =>
                                                  new Rectangle(activityIndicatorOverlay.Width / 2 - 81, activityIndicatorOverlay.Height / 2 - 41, 81 * 2, 82));

            // Create indicator
            var activityIndicator = new ActivityIndicator {
                Color = Color.White
            };

            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty,
                                         PropertyNameHelper.GetPropertyName <TViewModel>((vm) => vm.IsBusy));

            activityIndicatorOverlay.Children.Add(activityIndicator, () =>
                                                  new Rectangle(activityIndicatorOverlay.Width / 2 - 16, activityIndicatorOverlay.Height / 2 - 24, 32, 32));

            // Create label with progress text
            var activityLabel = new Label {
                TextColor       = Color.White,
                BackgroundColor = Color.Transparent,
                FontSize        = 12,
                XAlign          = TextAlignment.Center
            };

            activityLabel.SetBinding(Label.TextProperty,
                                     PropertyNameHelper.GetPropertyName <TViewModel>((vm) => vm.IsBusyText));

            activityLabel.SetBinding(Label.IsVisibleProperty,
                                     PropertyNameHelper.GetPropertyName <TViewModel>((vm) => vm.IsBusyTextVisible));

            activityIndicatorOverlay.Children.Add(activityLabel, () =>
                                                  new Rectangle(activityIndicatorOverlay.X, activityIndicatorOverlay.Height / 2 + 14,
                                                                activityIndicatorOverlay.Width, 32));
        }
        /// <summary>
        /// Adds a dependency between a command and a property. Whenever the property changes, the command's
        /// state will be updated
        /// </summary>
        /// <param name="property">Source Property.</param>
        /// <param name="command">Target Command.</param>
        protected void AddCommandDependency <TViewModel>(Expression <Func <object> > property, Command command)
        {
            var propertyName = PropertyNameHelper.GetPropertyName <TViewModel>(property);

            if (!_commandDependencies.ContainsKey(propertyName))
            {
                _commandDependencies.Add(propertyName, new List <Command> ());
            }

            var list = _commandDependencies [propertyName];

            list.Add(command);
        }
Exemple #3
0
        public Customer FindBy(string identityToken)
        {
            ICriteria criteriaQuery = SessionFactory.GetCurrentSession()
                                      .CreateCriteria(typeof(Customer))
                                      .Add(Expression.Eq(PropertyNameHelper
                                                         .ResolvePropertyName <Customer>
                                                             (c => c.IdentityToken), identityToken));

            IList <Customer> customers = criteriaQuery.List <Customer>();

            Customer customer = customers.FirstOrDefault();

            return(customer);
        }
        /// <summary>
        /// Adds a dependency between a property and another property. Whenever the property changes, the command's
        /// state will be updated
        /// </summary>
        /// <param name="property">Source property.</param>
        /// <param name="dependantProperty">Target property.</param>
        protected void AddPropertyDependency <TViewModel>(Expression <Func <object> > property,
                                                          Expression <Func <object> > dependantProperty)
        {
            var propertyName = PropertyNameHelper.GetPropertyName <TViewModel>(property);

            if (!_propertyDependencies.ContainsKey(propertyName))
            {
                _propertyDependencies.Add(propertyName, new List <Expression <Func <object> > > ());
            }

            var list = _propertyDependencies [propertyName];

            list.Add(dependantProperty);
        }
Exemple #5
0
        public GetFeaturedProductsResponse GetFeaturedProducts()
        {
            GetFeaturedProductsResponse response = new GetFeaturedProductsResponse();

            Query productQuery = new Query();

            productQuery.OrderByProperty = new OrderByClause()
            {
                Desc = true, PropertyName = PropertyNameHelper.ResolvePropertyName <ProductTitle>(pt => pt.Price)
            };

            response.Products = _productTitleRepository.FindBy(productQuery, 0, 6).ConvertToProductViews();

            return(response);
        }
        //Returns all the pseudo SKUs
        public async Task <GetAllPseudoSkusResponse> GetAllPseudoSkus()
        {
            GetAllPseudoSkusResponse response = new GetAllPseudoSkusResponse();

            Query pseudoSkuQuery = new Query();

            pseudoSkuQuery.OrderByProperty = new OrderByClause()
            {
                Desc         = true,
                PropertyName = PropertyNameHelper.ResolvePropertyName <PseudoSkuTitle>(pt => pt.Price)
            };

            var pseudoSkus = await _pseudoSkuTitleRepository.FindByAsync(pseudoSkuQuery, 0, 6);

            response.Products = _mapper.Map <IEnumerable <PseudoSkuSummaryView> >(pseudoSkus);

            return(response);
        }
Exemple #7
0
        public IEnumerable <Order> FindAllCustomersOrdersWithInOrderDateBy(Guid customerId, DateTime orderDate)
        {
            IEnumerable <Order> customerOrders = new List <Order>();

            Query query = new Query();

            //query.Add(new Criterion("CustomerId", customerId, CriteriaOperator.Equal));
            query.Add(Criterion.Create <Order>(x => x.CustomerId, customerId, CriteriaOperator.Equal));
            query.QueryOperator = QueryOperator.And;
            //query.Add(new Criterion("OrderDate", orderDate, CriteriaOperator.LessThanOrEqual));
            query.Add(Criterion.Create <Order>(x => x.OrderDate, orderDate, CriteriaOperator.LessThanOrEqual));
            //query.OrderByProperty = new OrderByClause { PropertyName = "OrderDate", Desc = true };
            query.OrderByProperty = new OrderByClause
            {
                PropertyName = PropertyNameHelper.ResolvePropertyName <Order>(x => x.OrderDate),
                Desc         = true
            };

            customerOrders = _orderRepository.FindBy(query);

            return(customerOrders);
        }
        /// <summary>
        /// Sets a value in viewmodel storage and raises property changed if value has changed
        /// </summary>
        /// <param name="name">Name.</param>
        /// <param name="value">Value.</param>
        /// <typeparam name="TValueType">The 1st type parameter.</typeparam>
        protected bool SetValue <TValueType>(Expression <Func <object> > property, TValueType value)
        {
            var existingValue = GetValue <TValueType>(property);
            var propertyName  = PropertyNameHelper.GetPropertyName <BaseViewModel>(property);

            // Check for equality
            if (!_notifyChangeForSameValues.Contains(propertyName) &&
                EqualityComparer <TValueType> .Default.Equals(existingValue, value))
            {
                return(false);
            }

            _viewModelStorage.SetObjectForKey <TValueType> (propertyName, value);

            RaisePropertyChangedEvent(property);

            // Dependent properties?
            if (_propertyDependencies.ContainsKey(propertyName))
            {
                foreach (var dependentProperty in _propertyDependencies[propertyName])
                {
                    RaisePropertyChangedEvent(dependentProperty);
                }
            }

            // Dependent commands
            if (_commandDependencies.ContainsKey(propertyName))
            {
                foreach (var dependentCommand in _commandDependencies[propertyName])
                {
                    RaiseCommandStateChangedEvent(dependentCommand);
                }
            }

            return(true);
        }
Exemple #9
0
 public void TestGetPropertyName()
 {
     Assert.AreEqual("StaticString", PropertyNameHelper.GetPropertyName(() => TestClass.StaticString));
     Assert.AreEqual("InstanceString", PropertyNameHelper.GetPropertyName((TestClass t) => t.InstanceString));
 }
Exemple #10
0
 protected void OnPropertyChanged <TModel>(Expression <Func <TModel, Object> > propertyExpression)
 {
     OnPropertyChanged(PropertyNameHelper.GetPropertyName(propertyExpression));
 }
 /// <summary>
 /// Calls the notify property changed event if it is attached. By using some
 /// Expression/Func magic we get compile time type checking on our property
 /// names by using this method instead of calling the event with a string in code.
 /// </summary>
 /// <param name="property">Property.</param>
 protected string GetPropertyName(Expression <Func <TViewModel, object> > property)
 {
     return(PropertyNameHelper.GetPropertyName <TViewModel> (property));
 }
 /// <summary>
 /// Calls the notify property changed event if it is attached. By using some
 /// Expression/Func magic we get compile time type checking on our property
 /// names by using this method instead of calling the event with a string in code.
 /// </summary>
 /// <param name="property">Property.</param>
 protected string GetPropertyName <TOwner>(Expression <Func <TOwner, object> > property)
 {
     return(PropertyNameHelper.GetPropertyName <TOwner> (property));
 }
        /// <summary>
        /// Adds the raise notify changed for property when value is the same.
        /// </summary>
        /// <param name="property">Property.</param>
        /// <param name="dependantProperty">Dependant property.</param>
        /// <typeparam name="TViewModel">The 1st type parameter.</typeparam>
        protected void AddRaiseNotifyChangedForPropertyWhenValueIsTheSame <TViewModel>(Expression <Func <object> > property)
        {
            var propertyName = PropertyNameHelper.GetPropertyName <TViewModel>(property);

            _notifyChangeForSameValues.Add(propertyName);
        }
        /// Returns a value from the viewmodel storage
        /// </summary>
        /// <returns>The value.</returns>
        /// <param name="name">Name.</param>
        /// <typeparam name="TValueType">The 1st type parameter.</typeparam>
        protected TValueType GetValue <TValueType>(Expression <Func <object> > property, TValueType defaultValue)
        {
            var propertyName = PropertyNameHelper.GetPropertyName <BaseViewModel> (property);

            return(_viewModelStorage.GetObjectForKey <TValueType> (propertyName, defaultValue));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidationError{TResource}"/> class.
 /// </summary>
 /// <param name="field">The field.</param>
 /// <param name="code">The code.</param>
 /// <param name="errorMessage">The error message.</param>
 public ValidationError(Expression <Func <TResource, object> > field, ValidationErrorCode code, string errorMessage = null)
     : base(typeof(TResource).Name, PropertyNameHelper.PropertyName(field), code, errorMessage)
 {
 }