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


C# mdr.AsDouble方法代码示例

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


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

示例1: Run

 public static void Run(ref mdr.DValue i0, int i1)
 {
     switch (i0.ValueType)
     {
         case mdr.ValueTypes.Double:
             {
                 double oldValue = i0.DoubleValue;
                 double newValue = oldValue + i1;
                 i0.DoubleValue = newValue;
                 //i0.Set(newValue);
                 break;
             }
         case mdr.ValueTypes.Int32:
             {
                 int oldValue = i0.IntValue;
                 int newValue = oldValue + i1;
                 i0.IntValue = newValue;
                 //i0.Set(newValue);
                 break;
             }
         case mdr.ValueTypes.Boolean:
             {
                 int oldValue = i0.BooleanValue ? 1 : 0;
                 int newValue = oldValue + i1;
                 i0.Set(newValue);
                 break;
             }
         default:
             {
                 double oldValue = i0.AsDouble();
                 double newValue = oldValue + i1;
                 i0.Set(newValue);
                 break;
             }
     }
 }
开发者ID:reshadi2,项目名称:mcjs,代码行数:36,代码来源:IncDec.cs

示例2: AddConst

        //public static mdr.DValue IncDec(ref mdr.DValue i0, int i1)
        //{
        //    var result = new mdr.DValue();
        //    switch (i0.ValueType)
        //    {
        //        case mdr.ValueTypes.Int:
        //            {
        //                int oldValue = i0.IntValue;
        //                int newValue = oldValue + i1;
        //                result.Set(newValue);
        //                break;
        //            }
        //        case mdr.ValueTypes.Boolean:
        //            {
        //                int oldValue = i0.BoolValue ? 1 : 0;
        //                int newValue = oldValue + i1;
        //                result.Set(newValue);
        //                break;
        //            }
        //        default:
        //            {
        //                double oldValue = i0.ToDouble();
        //                double newValue = oldValue + i1;
        //                result.Set(newValue);
        //                break;
        //            }
        //    }
        //    return result;
        //}

        /// <summary>
        /// The following is used for inc/dec that involves DValue. To handle arrays and properties well, we will have a separate object for 
        /// reading the value, and another for setting. To make the inc/dec and assign, etc. uniform, we should consider that on the stack 
        /// we have all the paramertes always for all kinds of values (symbols, arrays, properties, ...)
        /// 
        /// followings:
        ///     dest for writing
        ///     DObject  for setting (for array/property will be a member of the object itself)
        ///     DObject  for reading (for array/property may be a member of the object's prototype)
        /// </summary>
        /// <param name="result">for returing the value that is used in the next instruction.</param>
        /// <param name="dest">For updating the source itself</param>
        /// <param name="i0">the source for reading the value</param>
        /// <param name="i1">1 for inc and -1 for dec</param>
        /// <param name="isPostfix"></param>
        /// <returns></returns>
        public static void AddConst(ref mdr.DValue dest, /*const*/ ref mdr.DValue i0, int i1, bool isPostfix, ref mdr.DValue result)
        {
            switch (i0.ValueType)
            {
                case mdr.ValueTypes.Int32:
                    {
                        int oldValue = i0.IntValue;
                        int newValue = oldValue + i1;
                        dest.Set(newValue);
                        result.Set(isPostfix ? oldValue : newValue);
                        break;
                    }
                case mdr.ValueTypes.Boolean:
                    {
                        int oldValue = i0.BooleanValue ? 1 : 0;
                        int newValue = oldValue + i1;
                        dest.Set(newValue);
                        result.Set(isPostfix ? oldValue : newValue);
                        break;
                    }
                default:
                    {
                        double oldValue = i0.AsDouble();
                        double newValue = oldValue + i1;
                        dest.Set(newValue);
                        result.Set(isPostfix ? oldValue : newValue);
                        break;
                    }
            }
        }
开发者ID:reshadi2,项目名称:mcjs,代码行数:76,代码来源:IncDec.cs


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