当前位置: 首页>>代码示例>>C#>>正文


C# IObjectFactory.CreateNumber方法代码示例

本文整理汇总了C#中IObjectFactory.CreateNumber方法的典型用法代码示例。如果您正苦于以下问题:C# IObjectFactory.CreateNumber方法的具体用法?C# IObjectFactory.CreateNumber怎么用?C# IObjectFactory.CreateNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IObjectFactory的用法示例。


在下文中一共展示了IObjectFactory.CreateNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseDouble

        /// <summary>
        /// Parse string as 'Double' and return a factory specific number wrapper.
        /// </summary>
        internal static object ParseDouble(IObjectFactory factory, string data)
        {
            Double number;

            if (NumericHelper.TryParseDouble(data, NumberStyles.Float, out number))
                return factory.CreateNumber(number);
            return null;
        }
开发者ID:phofman,项目名称:codetitans-libs,代码行数:11,代码来源:ObjectFactoryHelper.cs

示例2: ParseNumber

        /// <summary>
        /// Tries to parse a string into a number.
        /// First it tries to parse as Int64 or UInt64 and if the number 
        /// </summary>
        internal static object ParseNumber(IObjectFactory factory, string number)
        {
            Int64 resultInt64;
            UInt64 resultUInt64;
            double resultDouble;

            // if the number starts with '-' sign, then it might be Int64, also when it fits the range of Int64 values, we prefere Int64 to be used;
            // otherwise try UInt64, finally if both reading failed, assume it's Double:

            if (number.Length > 0 && number.IndexOf('.') == -1 && number.IndexOf('e') == -1 && number.IndexOf('E') == -1)
            {
                if (NumericHelper.TryParseInt64(number, out resultInt64) && string.Compare(resultInt64.ToString(CultureInfo.InvariantCulture), number, StringComparison.Ordinal) == 0)
                    return factory.CreateNumber(resultInt64);

                if (number[0] != '-' && NumericHelper.TryParseUInt64(number, out resultUInt64) &&
                    string.Compare(resultUInt64.ToString(CultureInfo.InvariantCulture), number, StringComparison.Ordinal) == 0)
                    return factory.CreateNumber(resultUInt64);
            }

            if (NumericHelper.TryParseDouble(number, NumberStyles.Float, out resultDouble))
                return factory.CreateNumber(resultDouble);

            return null;
        }
开发者ID:phofman,项目名称:codetitans-libs,代码行数:28,代码来源:ObjectFactoryHelper.cs

示例3: ParseInt32

        /// <summary>
        /// Parse string as 'Int32' and return a factory specific number wrapper.
        /// </summary>
        internal static object ParseInt32(IObjectFactory factory, string data)
        {
            Int32 number;

            if (NumericHelper.TryParseInt32(data, out number))
                return factory.CreateNumber(number);
            return null;
        }
开发者ID:phofman,项目名称:codetitans-libs,代码行数:11,代码来源:ObjectFactoryHelper.cs


注:本文中的IObjectFactory.CreateNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。