コード例 #1
0
        public string StringValForCol(Object o)
        {
            var casted = Convert.ChangeType(o, SourceType);

            if (casted is string)
            {
                return(LongStringBehaviour.ProcessString(casted as string));
            }
            else
            {
                var ToStringMethod = SourceType.GetTypeInfo().DeclaredMethods.FirstOrDefault(m =>
                                                                                             m.Name == "ToString" &&
                                                                                             m.IsPublic &&
                                                                                             m.ReturnType == typeof(string) &&
                                                                                             m.GetParameters().Count() == 1 &&
                                                                                             m.GetParameters()[0].ParameterType == typeof(string));

                if (ToStringMethod == null)
                {
                    return(casted.ToString());
                }
                else
                {
                    return((string)ToStringMethod.Invoke(o, new object[] { FormatString }));
                }
            }
        }
コード例 #2
0
        public string StringValForCol(Object o)
        {
            var casted = Convert.ChangeType(o, SourceType);

            if (casted is string)
            {
                return(LongStringBehaviour.ProcessString(casted as string));
            }
            else
            {
                if (toStringMethod == null)
                {
                    return((casted ?? string.Empty).ToString());
                }
                else
                {
                    return((string)toStringMethod.Invoke(o, new object[] { FormatString }));
                }
            }
        }