コード例 #1
0
        public override string ToString()
        {
            var sb = new StringBuilder();

            if (_value is Enum)
            {
                sb.Append(ConvertToClass((Enum)_value));
            }

            foreach (PropertyInfo pd in Utility.ReflectGetProperties(_value.GetType()))
            {
                try {
                    if (typeof(bool) == pd.PropertyType)
                    {
                        var boolStr = ConvertToClass((bool)pd.GetValue(_value), pd.Name);

                        if (boolStr.Length > 0)
                        {
                            sb.AppendSeparator(" ").Append(boolStr);
                        }
                    }
                    else if (typeof(Enum).IsAssignableFrom(pd.PropertyType))
                    {
                        sb.AppendSeparator(" ").Append(ConvertToClass((Enum)pd.GetValue(_value)));
                    }
                } catch (Exception ex) {
                    Traceables.HandleComponentModelReflection(pd, ex);
                }
            }

            sb.AppendSeparator(" ");
            sb.Append(Hyphenate(_value.GetType().Name));

            return(sb.ToString());
        }
コード例 #2
0
 private void Convert(string text)
 {
     try {
         valueCache = Activation.FromText(_pd.PropertyType, text);
     } catch (Exception ex) {
         Traceables.HandleComponentModelReflection(_pd, ex);
     }
 }
コード例 #3
0
        void GetElementData()
        {
            var elementData = _templateContext.GetElementData(true);
            var props       = HxlAttributeFragmentDefinition.ForComponent(this).ElementDataProperties;

            foreach (var prop in props)
            {
                try {
                    elementData[prop.Name] = prop.GetValue(this);
                } catch (Exception ex) {
                    Traceables.HandleComponentModelReflection(prop, ex);
                }
            }
        }
コード例 #4
0
        // TODO Error handling could be more robust

        private void ConvertBack(object value)
        {
            try {
                if (value == null)
                {
                    textCache = null;
                    return;
                }

                textCache = value.ToString();
            } catch (Exception ex) {
                Traceables.HandleComponentModelReflection(_pd, ex);
            }
        }