Esempio n. 1
0
        private KeyValuePair <string, object> FormatProperty(PropertyArgs propertyArgs)
        {
            var source       = propertyArgs.Source;
            var propertyName = propertyArgs.Name;
            var name         = _profile.CamelCaseName ? CamelCaseName(propertyName) : propertyName;

            // Return property formatting if available
            if (source is Item && _profile.PropertyFormatters.ContainsKey(name.ToLower()))
            {
                var prop = InvokeFormatter(_profile.PropertyFormatters[name.ToLower()], propertyArgs);

                if (prop != null)
                {
                    return(new KeyValuePair <string, object>(name, prop));
                }
            }

            // Otherwise proceed with property value formatting
            var valueFormatters = GetValueFormatters(source);
            var propValue       = propertyArgs.Info != null ? (propertyArgs.GetValue() ?? string.Empty) : string.Empty;

            var result = FormatValue(propertyArgs, valueFormatters).Result ?? propValue;

            return(new KeyValuePair <string, object>(name, result));
        }
Esempio n. 2
0
        public void Format(PropertyArgs propertyArgs)
        {
            var id = propertyArgs.GetValue() as ID;

            if (id.IsNull)
            {
                return;
            }

            Set(id.Guid.ToString("D"));
        }
        public void Format(PropertyArgs propertyArgs)
        {
            var regEx = new System.Text.RegularExpressions.Regex("[0-9][0-9][0-9][0-9][0-1][0-9][0-9][0-9]T[0-9][0-9][0-9][0-9][0-9][0-9]");
            var value = propertyArgs.GetValue().ToString();

            if (!regEx.IsMatch(value))
            {
                return;
            }

            Set(new DateField(propertyArgs.Source as Field).DateTime);
        }