コード例 #1
0
 private void CheckTitleCase(PropertyNameFormatter formatter)
 {
     Assert.That(formatter.Format("SomeCoolProperty"), Is.EqualTo("Some Cool Property"));
     Assert.That(formatter.Format("someCoolProperty"), Is.EqualTo("Some Cool Property"));
     Assert.That(formatter.Format("prop"), Is.EqualTo("Prop"));
     Assert.That(formatter.Format("PropP"), Is.EqualTo("Prop P"));
     Assert.That(formatter.Format("Some Cool Property"), Is.EqualTo("Some Cool Property"));
 }
コード例 #2
0
        public bool SetProperty(string propertyName, object value,
                                PropertyNameSource propertyNameSource = PropertyNameSource.Default)
        {
            if (string.IsNullOrEmpty(propertyName))
            {
                return(false);
            }

            var parsedProperty = _valueParser.Parse(value);

            if (!parsedProperty.IsValid)
            {
                return(false);
            }

            string bindingProp;

            if (_specialPropsBindings.TryGetValue(propertyName.ToLower(), out bindingProp))
            {
                SpecialProps[bindingProp] = parsedProperty.Value;
            }
            else
            {
                switch (_messagePropetiesRules)
                {
                case MessagePropetiesRules.None:
                    break;

                case MessagePropetiesRules.NumericsOnly:
                    if (!_valueParser.IsNumeric(parsedProperty.Value))
                    {
                        return(false);
                    }
                    break;

                case MessagePropetiesRules.ListsOnly:
                    if (!_valueParser.IsEnumerable(parsedProperty.Value))
                    {
                        return(false);
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                Props[_nameFormatter.Format(propertyName, propertyNameSource)] = parsedProperty.Value;
            }

            return(true);
        }
コード例 #3
0
        private void ProcessObjectProperty(ObjectProperty objectProperty)
        {
            string specialProperty = mapRawNameToSpecialPropertyFn(objectProperty.PropertyName);

            if (specialProperty != null)
            {
                SpecialProperties[specialProperty] = objectProperty;
            }
            else
            {
                string formattedPropertyName = PropertyNameFormatter.Format(objectProperty, config);
                UserProperties[formattedPropertyName] = objectProperty;
            }
        }
コード例 #4
0
 private void CheckDefault(PropertyNameFormatter formatter)
 {
     Assert.That(formatter.Format("SomeCoolProperty"), Is.EqualTo("SomeCoolProperty"));
     Assert.That(formatter.Format("someCoolProperty"), Is.EqualTo("someCoolProperty"));
 }