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


C# Core.PhpValue类代码示例

本文整理汇总了C#中Pchp.Core.PhpValue的典型用法代码示例。如果您正苦于以下问题:C# PhpValue类的具体用法?C# PhpValue怎么用?C# PhpValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: BitNot

        /// <summary>
        /// Performs bitwise negation.
        /// </summary>
        internal static PhpValue BitNot(ref PhpValue x)
        {
            switch (x.TypeCode)
            {
                case PhpTypeCode.Long: return PhpValue.Create(~x.Long);

                case PhpTypeCode.Int32: return PhpValue.Create(~x.ToLong());

                case PhpTypeCode.Alias: return BitNot(ref x.Alias.Value);

                case PhpTypeCode.String:
                case PhpTypeCode.WritableString:
                    throw new NotImplementedException();    // bitwise negation of each character in string

                case PhpTypeCode.Object:
                    if (x.Object == null)
                    {
                        return PhpValue.Null;
                    }
                    goto default;

                default:
                    // TODO: Err UnsupportedOperandTypes
                    return PhpValue.Null;
            }
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:29,代码来源:Operators.cs

示例2: stdClass

 /// <summary>
 /// Constructs the object with single runtime field <c>scalar</c>.
 /// </summary>
 /// <param name="scalar">Value of <c>scalar</c> field.</param>
 internal stdClass(PhpValue scalar)
 {
     __peach__runtimeFields = new PhpArray(1)
     {
         { new IntStringKey("scalar"), scalar }
     };
 }
开发者ID:iolevel,项目名称:peachpie,代码行数:11,代码来源:stdClass.cs

示例3: PhpAlias

        /// <summary>
        /// Creates an aliased value.
        /// </summary>
        public PhpAlias(PhpValue value, int refcount = 1)
        {
            Debug.Assert(refcount >= 1);
            Debug.Assert(value.TypeCode != PhpTypeCode.Alias);

            Value = value;
            _refcount = refcount;
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:11,代码来源:PhpAlias.cs

示例4: BitOr

        /// <summary>
        /// Performs bitwise or operation.
        /// </summary>
        internal static PhpValue BitOr(ref PhpValue x, ref PhpValue y)
        {
            var xtype = x.TypeCode;
            if (xtype == PhpTypeCode.String || xtype == PhpTypeCode.WritableString)
            {
                var ytype = y.TypeCode;
                if (ytype == PhpTypeCode.String || ytype == PhpTypeCode.WritableString)
                {
                    throw new NotImplementedException();
                }
            }

            //
            return PhpValue.Create(x.ToLong() | y.ToLong());
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:18,代码来源:Operators.cs

示例5: call_user_func_array

        /// <summary>
        /// Calls a function or a method defined by callback with arguments stored in an array.
        /// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="function">Target callback.</param>
        /// <param name="args">Arguments. Can be null.</param>
        /// <returns>The returned value.</returns>
        public static PhpValue call_user_func_array(Context ctx, IPhpCallable function, PhpArray args)
        {
            PhpValue[] args_array;

            if (args != null && args.Count != 0)
            {
                args_array = new PhpValue[args.Count];
                args.CopyValuesTo(args_array, 0);
            }
            else
            {
                args_array = Core.Utilities.ArrayUtils.EmptyValues;
            }

            return call_user_func(ctx, function, args_array);
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:23,代码来源:Functions.cs

示例6: Compare

        public static int Compare(string sx, PhpValue y)
        {
            switch (y.TypeCode)
            {
                case PhpTypeCode.Double: return Compare(sx, y.Double);
                case PhpTypeCode.Long: return Compare(sx, y.Long);
                case PhpTypeCode.Boolean: return Compare(Convert.ToBoolean(sx), y.Boolean);
                case PhpTypeCode.String: return Compare(sx, y.String);
                case PhpTypeCode.WritableString: return Compare(sx, y.WritableString.ToString());
                case PhpTypeCode.Alias: return Compare(sx, y.Alias.Value);
                case PhpTypeCode.Undefined: return (sx.Length == 0) ? 0 : 1;
                case PhpTypeCode.Object:
                    if (y.Object == null) return (sx.Length == 0) ? 0 : 1;
                    break;
            }

            throw new NotImplementedException($"compare(String, {y.TypeCode})");
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:18,代码来源:Comparison.cs

示例7: FromValue

        public static TextElement FromValue(Context ctx, PhpValue value)
        {
            switch (value.TypeCode)
            {
                case PhpTypeCode.Object:
                    if (value.Object is byte[])
                    {
                        return new TextElement((byte[])value.Object);
                    }
                    goto default;

                case PhpTypeCode.WritableString:
                    return new TextElement(value.WritableString, ctx.StringEncoding);

                default:
                    return new TextElement(value.ToStringOrThrow(ctx));
            }
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:18,代码来源:Filters.cs

示例8: ProcessStatus

        int ProcessStatus(Context ctx, ref PhpValue status)
        {
            switch (status.TypeCode)
            {
                case PhpTypeCode.Alias:
                    return ProcessStatus(ctx, ref status.Alias.Value);

                case PhpTypeCode.Long:
                case PhpTypeCode.Int32:
                    return (int)status.ToLong();

                default:
                    if (ctx != null)
                    {
                        ctx.Echo(status);
                    }
                    return 0;
            }
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:19,代码来源:Exceptions.cs

示例9: NotSupportedException

 /// <summary>
 /// Add a value to the end of array.
 /// Value can be an alias.
 /// </summary>
 void IPhpArray.AddValue(PhpValue value) { throw new NotSupportedException(); }
开发者ID:iolevel,项目名称:peachpie,代码行数:5,代码来源:PhpString.cs

示例10: preg_replace

        static PhpValue preg_replace(Context ctx, string pattern, string replacement, PhpCallable callback, PhpValue subject, int limit, ref long count)
        {
            var regex = new PerlRegex.Regex(pattern);

            // TODO: count
            // TODO: callback

            var subject_array = subject.AsArray();
            if (subject_array == null)
            {
                return PhpValue.Create(regex.Replace(subject.ToStringOrThrow(ctx), replacement, limit));
            }
            else
            {
                var arr = new PhpArray(subject_array, false);
                var enumerator = arr.GetFastEnumerator();
                while (enumerator.MoveNext())
                {
                    var newvalue = regex.Replace(enumerator.CurrentValue.ToStringOrThrow(ctx), replacement, limit);
                    enumerator.CurrentValue = PhpValue.Create(newvalue);
                }

                return PhpValue.Create(arr);
            }
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:25,代码来源:pcre.cs

示例11: print_r

        //class HtmlDumpFormatter : DumpFormatter
        //{

        //}

        #endregion

        /// <summary>
        /// Outputs or returns human-readable information about a variable. 
        /// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="value">The variable.</param>
        /// <param name="returnString">Whether to return a string representation.</param>
        /// <returns>A string representation or <c>true</c> if <paramref name="returnString"/> is <c>false</c>.</returns>
        public static PhpValue print_r(Context ctx, PhpValue value, bool returnString = false)
        {
            var output = (new PrintFormatter(ctx, "\n")).Serialize(value);

            if (returnString)
            {
                // output to a string:
                return PhpValue.Create(output);
            }
            else
            {
                // output to script context:
                ctx.Echo(output);
                return PhpValue.True;
            }
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:30,代码来源:Variables.cs

示例12: is_callable

        /// <summary>
        /// Verifies that the contents of a variable can be called as a function.
        /// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="variable">The variable.</param>
        /// <param name="syntaxOnly">If <B>true</B>, it is only checked that has <pararef name="variable"/>
        /// a valid structure to be used as a callback. if <B>false</B>, the existence of the function (or
        /// method) is also verified.</param>
        /// <param name="callableName">Receives the name of the function or method (for example
        /// <c>SomeClass::SomeMethod</c>).</param>
        /// <returns><B>true</B> if <paramref name="variable"/> denotes a function, <B>false</B>
        /// otherwise.</returns>
        public static bool is_callable(Context ctx /*, caller*/, PhpValue variable, bool syntaxOnly, out string callableName)
        {
            var callback = variable.AsCallable();
            if (PhpVariable.IsValidCallback(callback))
            {
                callableName = callback.ToString();
                return true;
            }

            callableName = variable.ToString(ctx);
            return false;
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:24,代码来源:Variables.cs

示例13: is_numeric

        /// <summary>
        /// Checks whether a dereferenced variable is numeric.
        /// </summary>
        /// <param name="variable">The variable.</param>
        /// <returns>Whether <paramref name="variable"/> is integer, double or numeric string.
        /// <seealso cref="PHP.Core.Convert.StringToNumber"/></returns>
        public static bool is_numeric(PhpValue variable)
        {
            switch (variable.TypeCode)
            {
                case PhpTypeCode.Int32:
                case PhpTypeCode.Long:
                case PhpTypeCode.Double:
                    return true;

                case PhpTypeCode.String:
                case PhpTypeCode.WritableString:
                    PhpNumber tmp;
                    return (variable.ToNumber(out tmp) & Core.Convert.NumberInfo.IsNumber) != 0;

                default:
                    return false;
            }
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:24,代码来源:Variables.cs

示例14: is_null

 /// <summary>
 /// Checks whether a dereferenced variable is a <B>null</B> reference.
 /// </summary>
 /// <param name="variable">The variable.</param>
 /// <returns>Whether <paramref name="variable"/> is a <B>null</B> reference.</returns>
 public static bool is_null(PhpValue variable) => variable.IsNull;
开发者ID:iolevel,项目名称:peachpie,代码行数:6,代码来源:Variables.cs

示例15: is_scalar

 /// <summary>
 /// Checks whether a dereferenced variable is a scalar.
 /// </summary>
 /// <param name="variable">The variable.</param>
 /// <returns>Whether <paramref name="variable"/> is an integer, a double, a bool or a string after dereferencing.</returns>
 public static bool is_scalar(PhpValue variable) => PhpVariable.IsScalar(variable);
开发者ID:iolevel,项目名称:peachpie,代码行数:6,代码来源:Variables.cs


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