示例#1
0
        public GridPageViewModel(CalculatorsAndStopwatchApplicationViewModel applicationViewModel)
        {
            _applicationViewModel = applicationViewModel;
            _navigationViewModel = new NavigationViewModel(_applicationViewModel);

            _items = new ReadOnlyProperty<ObservableCollection<SampleItemCollectionItem>>(new ObservableCollection<SampleItemCollectionItem>());
            IEnumerable<SampleItemCollectionItem> items = new[]
                {
                    new SampleItemCollectionItem(_items.Value, 2, "second", "sdkgsdgh", true),
                    new SampleItemCollectionItem(_items.Value, 3, "third", "weuirueifsd", false),
                    new SampleItemCollectionItem(_items.Value, 4, "fourth", "ioerhivfni", false),
                    new SampleItemCollectionItem(_items.Value, 5, "fifth", "zdiofernwiasu", true),
                    new SampleItemCollectionItem(_items.Value, 12, "second", "sdkgsdgh", true),
                    new SampleItemCollectionItem(_items.Value, 13, "third", "weuirueifsd", false),
                    new SampleItemCollectionItem(_items.Value, 14, "fourth", "ioerhivfni", false),
                    new SampleItemCollectionItem(_items.Value, 15, "fifth", "zdiofernwiasu", true),
                    new SampleItemCollectionItem(_items.Value, 22, "second", "sdkgsdgh", true),
                    new SampleItemCollectionItem(_items.Value, 23, "third", "weuirueifsd", false),
                    new SampleItemCollectionItem(_items.Value, 24, "fourth", "ioerhivfni", false),
                    new SampleItemCollectionItem(_items.Value, 25, "fifth", "zdiofernwiasu", true),
                    new SampleItemCollectionItem(_items.Value, 32, "second", "sdkgsdgh", true),
                    new SampleItemCollectionItem(_items.Value, 33, "third", "weuirueifsd", false),
                    new SampleItemCollectionItem(_items.Value, 34, "fourth", "ioerhivfni", false),
                    new SampleItemCollectionItem(_items.Value, 35, "fifth", "zdiofernwiasu", true),
                    new SampleItemCollectionItem(_items.Value, 42, "second", "sdkgsdgh", true),
                    new SampleItemCollectionItem(_items.Value, 43, "third", "weuirueifsd", false),
                    new SampleItemCollectionItem(_items.Value, 44, "fourth", "ioerhivfni", false),
                    new SampleItemCollectionItem(_items.Value, 45, "fifth", "zdiofernwiasu", true)
                };
            _items.Value.AddRange(items);
        }
示例#2
0
 public SampleItem(int id, string name, string something, bool boolean)
 {
     _id = new ReadOnlyProperty<int>(id);
     _name = new ReadOnlyProperty<string>(name);
     _something = new ReadOnlyProperty<string>(something);
     _boolean = new ReadOnlyProperty<bool>(boolean);
 }
示例#3
0
        protected CalculatorViewModelBase(bool supportsAsync)
        {
            _updateInRealTimeItems = new ObservableCollection<bool>(new[] { true, false });
            _updateInRealTimeSelection = new ObservableProperty<bool?>(true);
            _updateInRealTime = CalculatedProperty<bool>.Create(_updateInRealTimeSelection, updateInRealTimeSelection => updateInRealTimeSelection.Value.HasValue && updateInRealTimeSelection.Value.Value);
            _supportsAsync = new ReadOnlyProperty<bool>(supportsAsync);
            _simulateLatencyItems = new ObservableCollection<bool>(new[] { true, false });
            _simulateLatencySelection = new ObservableProperty<bool?>(true);
            _simulateLatency = CalculatedProperty<bool>.Create(_simulateLatencySelection, simulateLatencySelection => simulateLatencySelection.Value.HasValue && simulateLatencySelection.Value.Value);
            _operators = new ObservableCollection<Operator>(new[] { Operator.Add, Operator.Subtract, Operator.Multiply, Operator.Divide });
            _operand1 = new ObservableProperty<string>();
            _selectedOperator = new ObservableProperty<Operator?>();
            _selectedOperator.Value = Operator.Add;
            _selectedOperatorString = CalculatedProperty<string>.Create(_selectedOperator, selectedOperator =>
                {
                    if (selectedOperator.Value == null)
                    {
                        return null;
                    }

                    switch (selectedOperator.Value.Value)
                    {
                        case Operator.Add:
                            return "+";
                        case Operator.Subtract:
                            return "-";
                        case Operator.Multiply:
                            return "*";
                        case Operator.Divide:
                            return "/";
                        default:
                            throw new NotSupportedException("Unknown enum value " + selectedOperator.Value.Value + ".");
                    }
                });
            _operand2 = new ObservableProperty<string>();
        }
示例#4
0
 public EnumDictionaryMapper(ReadOnlyProperty <T> property)
 {
     _property = property;
 }
 public ObjectArrayDictionaryMapper(ReadOnlyProperty <T> property, IDictionaryConverter elementConverter)
 {
     _property         = property;
     _elementConverter = elementConverter;
 }
示例#6
0
 public ValueDictionaryMapper(ReadOnlyProperty <T> property)
 {
     _property = property;
 }
 public MessageLifetimeScopeIdAccessor(PropertyInfo propertyInfo)
 {
     _property = new ReadOnlyProperty <TMessage, TId>(propertyInfo);
 }
示例#8
0
 public LoadMessageDataPropertyProvider(IMessageDataRepository repository, PropertyInfo property)
 {
     _repository = repository;
     _property   = new ReadOnlyProperty <TInput, MessageData <TValue> >(property);
 }
 public ValueObjectDictionaryDictionaryMapper(ReadOnlyProperty <T> property, DictionaryConverter elementConverter)
 {
     _property         = property;
     _elementConverter = elementConverter;
 }
示例#10
0
        IDictionaryMapper <T> GetDictionaryMapper(ReadOnlyProperty <T> property, Type valueType)
        {
            Type underlyingType;

            if (valueType.IsNullable(out underlyingType))
            {
                var converterType = typeof(NullableValueDictionaryMapper <,>).MakeGenericType(typeof(T),
                                                                                              underlyingType);

                return((IDictionaryMapper <T>)Activator.CreateInstance(converterType, property));
            }

            if (valueType.GetTypeInfo().IsEnum)
            {
                return(new EnumDictionaryMapper <T>(property));
            }

            if (valueType.IsArray)
            {
                var elementType = valueType.GetElementType();
                if (ValueObject.IsValueObjectType(elementType))
                {
                    return(new ValueDictionaryMapper <T>(property));
                }

                var elementConverter = _cache.GetConverter(elementType);

                var converterType = typeof(ObjectArrayDictionaryMapper <,>).MakeGenericType(typeof(T), elementType);
                return((IDictionaryMapper <T>)Activator.CreateInstance(converterType, property, elementConverter));
            }

            if (ValueObject.IsValueObjectType(valueType))
            {
                return(new ValueDictionaryMapper <T>(property));
            }

            if (valueType.HasInterface(typeof(IEnumerable <>)))
            {
                var elementType = valueType.GetClosingArguments(typeof(IEnumerable <>)).Single();

                if (valueType.ClosesType(typeof(IDictionary <,>)))
                {
                    var arguments = valueType.GetClosingArguments(typeof(IDictionary <,>)).ToArray();
                    var keyType   = arguments[0];
                    if (ValueObject.IsValueObjectType(keyType))
                    {
                        elementType = arguments[1];
                        if (ValueObject.IsValueObjectType(elementType))
                        {
                            var converterType = typeof(ValueValueDictionaryDictionaryMapper <, ,>).MakeGenericType(typeof(T), keyType, elementType);
                            return((IDictionaryMapper <T>)Activator.CreateInstance(converterType, property));
                        }
                        else
                        {
                            var converterType    = typeof(ValueObjectDictionaryDictionaryMapper <, ,>).MakeGenericType(typeof(T), keyType, elementType);
                            var elementConverter = _cache.GetConverter(elementType);
                            return((IDictionaryMapper <T>)Activator.CreateInstance(converterType, property, elementConverter));
                        }
                    }

                    throw new InvalidOperationException("Unable to map a reference type key dictionary");
                }

                if (valueType.ClosesType(typeof(IList <>)) || valueType.ClosesType(typeof(IEnumerable <>)))
                {
                    var converterType    = typeof(ObjectListDictionaryMapper <,>).MakeGenericType(typeof(T), elementType);
                    var elementConverter = _cache.GetConverter(elementType);

                    return((IDictionaryMapper <T>)Activator.CreateInstance(converterType, property, elementConverter));
                }
            }

            return(new ObjectDictionaryMapper <T>(property, _cache.GetConverter(valueType)));
        }
示例#11
0
 public ValueListSliceProvider(PropertyInfo propertyInfo, IValueFormatter <TValue> formatter)
 {
     _formatter = formatter;
     _property  = new ReadOnlyProperty <TEntity, ValueList <TValue> >(propertyInfo);
 }
示例#12
0
        public CorrelatedBySetCorrelationId()
        {
            var propertyInfo = typeof(CorrelatedBy <Guid>).GetProperty("CorrelationId");

            _property = new ReadOnlyProperty <CorrelatedBy <Guid>, Guid>(propertyInfo);
        }
示例#13
0
 public EntityValueEntityPropertyFormatter(PropertyInfo propertyInfo, IEntityFormatter <TEntityValue> entityFormatter)
 {
     _entityFormatter = entityFormatter;
     _property        = new ReadOnlyProperty <TEntity, Value <TEntityValue> >(propertyInfo);
 }
示例#14
0
 public EntityValueSliceProvider(PropertyInfo propertyInfo, IEntityMap <TComponent> entityMap)
 {
     _entityMap = entityMap;
     _property  = new ReadOnlyProperty <TEntity, Value <TComponent> >(propertyInfo);
 }
示例#15
0
 public InputValueTranslatePropertyProvider(PropertyInfo propertyInfo)
 {
     _property = new ReadOnlyProperty <TInput, Value <TValue> >(propertyInfo);
 }
示例#16
0
 public CopyValueListPropertyTranslator(Type implementationType, PropertyInfo entityPropertyInfo, PropertyInfo inputPropertyInfo)
 {
     _property      = new WriteProperty <TEntity, ValueList <TPropertyEntity> >(implementationType, entityPropertyInfo.Name);
     _inputProperty = new ReadOnlyProperty <TInput, ValueList <TPropertyEntity> >(inputPropertyInfo);
 }
示例#17
0
 public PropertySetCorrelationId(PropertyInfo propertyInfo)
 {
     _property = new ReadOnlyProperty <T, Guid>(propertyInfo);
 }
示例#18
0
 public ObjectDictionaryMapper(ReadOnlyProperty <T> property, IDictionaryConverter converter)
 {
     _property  = property;
     _converter = converter;
 }
示例#19
0
 public ValueEntityPropertyFormatter(PropertyInfo propertyInfo, IValueFormatter <TValue> formatter)
 {
     _formatter = formatter;
     _property  = new ReadOnlyProperty <TEntity, Value <TValue> >(propertyInfo);
 }
示例#20
0
 set => SetValue(ReadOnlyProperty, value);