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


C# ScriptProcessor.CreateNumber方法代码示例

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


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

示例1: ToNumber

 internal override SNumber ToNumber(ScriptProcessor processor)
 {
     if (Value)
         return processor.CreateNumber(1);
     else
         return processor.CreateNumber(0);
 }
开发者ID:nilllzz,项目名称:Pokemon3D,代码行数:7,代码来源:SBool.cs

示例2: constructor

        private static SObject constructor(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
        {
            var obj = (SError)instance;

            if (parameters.Length > 0)
            {
                SString message;

                if (parameters[0] is SString)
                    message = (SString)parameters[0];
                else
                    message = parameters[0].ToString(processor);

                obj.Members[MEMBER_NAME_MESSAGE].Data = message;
            }

            if (parameters.Length > 1)
            {
                SString errorType;

                if (parameters[1] is SString)
                    errorType = (SString)parameters[1];
                else
                    errorType = parameters[1].ToString(processor);

                obj.Members[MEMBER_NAME_TYPE].Data = errorType;
            }
            else
            {
                obj.Members[MEMBER_NAME_TYPE].Data = processor.CreateString("UserError");
            }

            if (parameters.Length > 2)
            {
                SNumber errorLine;

                if (parameters[2] is SNumber)
                    errorLine = (SNumber)parameters[2];
                else
                    errorLine = parameters[2].ToNumber(processor);

                obj.Members[MEMBER_NAME_LINE].Data = errorLine;
            }
            else
            {
                obj.Members[MEMBER_NAME_LINE].Data = processor.CreateNumber(-1);
            }

            return obj;
        }
开发者ID:nilllzz,项目名称:Pokemon3D,代码行数:50,代码来源:ErrorPrototype.cs

示例3: ToNumber

 internal override SNumber ToNumber(ScriptProcessor processor)
 {
     return processor.CreateNumber(Value);
 }
开发者ID:Aragas,项目名称:Pokemon3D-1,代码行数:4,代码来源:SNumber.cs

示例4: NegateNumber

        /// <summary>
        /// Multiplies an object with -1.
        /// </summary>
        internal static SObject NegateNumber(ScriptProcessor processor, SObject obj)
        {
            double number;
            if (obj is SNumber)
                number = ((SNumber)obj).Value;
            else
                number = obj.ToNumber(processor).Value;

            return processor.CreateNumber(number * -1);
        }
开发者ID:Aragas,项目名称:Pokemon3D-1,代码行数:13,代码来源:ObjectOperators.cs

示例5: DecrementOperator

        internal static string DecrementOperator(ScriptProcessor processor, SObject obj)
        {
            // Only variables can be decremented:

            if (obj is SVariable)
            {
                var svar = (SVariable)obj;
                svar.Data = processor.CreateNumber(svar.Data.ToNumber(processor).Value - 1D);
                return svar.Identifier;
            }
            else
            {
                processor.ErrorHandler.ThrowError(ErrorType.SyntaxError, ErrorHandler.MESSAGE_SYNTAX_INVALID_DECREMENT);
                return "";
            }
        }
开发者ID:Aragas,项目名称:Pokemon3D-1,代码行数:16,代码来源:ObjectOperators.cs

示例6: ToNumber

 internal override SNumber ToNumber(ScriptProcessor processor)
 {
     if (Value.Trim() == "")
     {
         return processor.CreateNumber(0);
     }
     else
     {
         var dblResult = 0D;
         if (double.TryParse(Value, out dblResult))
         {
             return processor.CreateNumber(dblResult);
         }
         else
         {
             return processor.CreateNumber(double.NaN);
         }
     }
 }
开发者ID:nilllzz,项目名称:Pokemon3D,代码行数:19,代码来源:SString.cs

示例7: SetValue

        /// <summary>
        /// Sets the value and updates the length property.
        /// </summary>
        internal void SetValue(ScriptProcessor processor, string value)
        {
            Value = value;

            var length = processor.CreateNumber(value.Length);

            //TODO: add length to prototype.
            Members[STRING_LENGTH_PROPERTY_NAME].ForceSetData(length);
        }
开发者ID:Aragas,项目名称:Pokemon3D-1,代码行数:12,代码来源:SString.cs

示例8: Length

        public static SObject Length(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
        {
            var str = instance as SString;

            return processor.CreateNumber(str.Value.Length);
        }
开发者ID:nilllzz,项目名称:Pokemon3D,代码行数:6,代码来源:StringPrototype.cs

示例9: LastIndexOf

        public static SObject LastIndexOf(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
        {
            if (TypeContract.Ensure(parameters, typeof(SString)))
            {
                var str = instance as SString;
                var search = parameters[0] as SString;

                if (!str.Value.Contains(search.Value) || search.Value == "")
                    return processor.CreateNumber(-1);

                return processor.CreateNumber(str.Value.LastIndexOf(search.Value));
            }

            return processor.Undefined;
        }
开发者ID:nilllzz,项目名称:Pokemon3D,代码行数:15,代码来源:StringPrototype.cs

示例10: UpdateLength

 /// <summary>
 /// Updates the "length" property of this object.
 /// </summary>
 public void UpdateLength(ScriptProcessor processor)
 {
     //TODO: Add length to prototype
     Members["length"] = new SVariable("length", processor.CreateNumber(ArrayMembers.Length)) { IsReadOnly = true };
 }
开发者ID:Aragas,项目名称:Pokemon3D-1,代码行数:8,代码来源:SArray.cs

示例11: TranslateNumber

 private static SObject TranslateNumber(ScriptProcessor processor, double dblIn)
 {
     return processor.CreateNumber(dblIn);
 }
开发者ID:nilllzz,项目名称:Pokemon3D,代码行数:4,代码来源:ScriptInAdapter.cs

示例12: Length

 public static SObject Length(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
 {
     var arr = (SArray)instance;
     return processor.CreateNumber(arr.ArrayMembers.Length);
 }
开发者ID:nilllzz,项目名称:Pokemon3D,代码行数:5,代码来源:ArrayPrototype.cs

示例13: Count

        public static SObject Count(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
        {
            if (parameters.Length == 0)
            {
                var arr = (SArray)instance;
                return processor.CreateNumber(arr.ArrayMembers.Length);
            }

            if (parameters.Length >= 1)
            {
                var arr = (SArray)instance;
                var comparer = (SFunction)Unbox(parameters[0]);

                var result = arr.ArrayMembers.Count(m => ((SBool)comparer.Call(processor, This, This, new[] { m })).Value);
                return processor.CreateNumber(result);
            }

            return processor.Undefined;
        }
开发者ID:nilllzz,项目名称:Pokemon3D,代码行数:19,代码来源:ArrayPrototype.cs

示例14: Where

        public static SObject Where(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
        {
            if (parameters.Length >= 1)
            {
                var arr = (SArray)instance;
                var comparer = (SFunction)Unbox(parameters[0]);

                var results = arr.ArrayMembers.Where((m, i) => ((SBool)comparer.Call(processor, This, This, new[] {m, processor.CreateNumber(i)})).Value);
                return processor.CreateArray(results.ToArray());
            }

            return processor.Undefined;
        }
开发者ID:nilllzz,项目名称:Pokemon3D,代码行数:13,代码来源:ArrayPrototype.cs

示例15: ToNumber

 /// <summary>
 /// Returns the number representation of this object.
 /// </summary>
 internal virtual SNumber ToNumber(ScriptProcessor processor)
 {
     return processor.CreateNumber(double.NaN);
 }
开发者ID:nilllzz,项目名称:Pokemon3D,代码行数:7,代码来源:SObject.cs


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