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


C# Core.Context类代码示例

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


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

示例1: SocketStream

 public SocketStream(Context ctx, Socket socket, string openedPath, StreamContext context, bool isAsync = false)
     : base(ctx, null, StreamAccessOptions.Read | StreamAccessOptions.Write, openedPath, context)
 {
     Debug.Assert(socket != null);
     this.socket = socket;
     this.IsWriteBuffered = false;
     this.eof = false;
     this.isAsync = isAsync;
     this.IsReadBuffered = false;
 }
开发者ID:iolevel,项目名称:peachpie,代码行数:10,代码来源:SocketStream.cs

示例2: interface_exists

        /// <summary>
		/// Tests whether a given interface is defined.
		/// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="ifaceName">The name of the interface.</param>
		/// <param name="autoload">Whether to attempt to call <c>__autoload</c>.</param>
		/// <returns><B>true</B> if the interface given by <paramref name="ifaceName"/> has been defined,
		/// <B>false</B> otherwise.</returns>
		public static bool interface_exists(Context ctx, string ifaceName, bool autoload = true)
        {
            var info = ctx.GetDeclaredType(ifaceName);
            if (info == null && autoload)
            {
                throw new NotImplementedException("autoload");
            }

            //
            return info != null && info.Type.GetTypeInfo().IsInterface;
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:19,代码来源:Objects.cs

示例3: class_exists

        /// <summary>
		/// Tests whether a given class is defined.
		/// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="className">The name of the class.</param>
		/// <param name="autoload">Whether to attempt to call <c>__autoload</c>.</param>
		/// <returns><B>true</B> if the class given by <paramref name="className"/> has been defined,
		/// <B>false</B> otherwise.</returns>
		public static bool class_exists(Context ctx, string className, bool autoload = true)
        {
            var info = ctx.GetDeclaredType(className);
            if (info == null && autoload)
            {
                throw new NotImplementedException("autoload");
            }

            //
            return info != null;
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:19,代码来源:Objects.cs

示例4: call_user_func

        /// <summary>
		/// Calls a function or a method defined by callback with given arguments.
		/// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="function">Target callback.</param>
		/// <param name="args">The arguments.</param>
		/// <returns>The return value.</returns>
		public static PhpValue call_user_func(Context ctx, IPhpCallable function, params PhpValue[] args)
        {
            if (function == null)
            {
                //PhpException.ArgumentNull("function");
                //return null;
                throw new ArgumentNullException();  // NOTE: should not be reached, runtime converts NULL to InvalidCallback instance
            }

            Debug.Assert(args != null);

            // invoke the callback:
            return function.Invoke(ctx, args);
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:21,代码来源:Functions.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: 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

示例7: get_defined_constants

        /// <summary>
        /// Retrieves defined constants.
        /// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="categorize">Returns a multi-dimensional array with categories in the keys of the first dimension and constants and their values in the second dimension. </param>
        /// <returns>Retrives the names and values of all the constants currently defined.</returns>
        public static PhpArray get_defined_constants(Context ctx, bool categorize = false)
        {
            var result = new PhpArray();

            if (categorize)
            {
                throw new NotImplementedException();
            }
            else
            {
                foreach (var c in ctx.GetConstants())
                {
                    result.Add(c.Key, c.Value);
                }
            }

            //
            return result;
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:25,代码来源:Constants.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: ob_start

        /// <summary>
        /// Increases the level of buffering, enables output buffering if disabled and assignes the filtering callback
        /// to the new level of buffering.
        /// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="filter">The filtering callback. Ignores invalid callbacks.</param>
        /// <param name="chunkSize">Not supported.</param>
        /// <param name="erase">Not supported.</param>
        /// <returns>Whether the filter is valid callback.</returns>
        public static bool ob_start(Context ctx, Delegate filter = null, int chunkSize = 0, bool erase = true)
        {
            if (chunkSize != 0)
                //PhpException.ArgumentValueNotSupported("chunkSize", "!= 0");
                throw new NotSupportedException("chunkSize != 0");
            if (!erase)
                //PhpException.ArgumentValueNotSupported("erase", erase);
                throw new NotSupportedException("erase == false");

            ctx.BufferedOutput.IncreaseLevel();

            bool result = true;

            // skips filter setting if filter is not specified or valid:
            if (filter != null) //  && (result = filter.Bind())) // TODO: PhpCallback.Bind -> Delegate, done by caller
                ctx.BufferedOutput.SetFilter(filter);

            ctx.IsOutputBuffered = true;

            return result;
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:30,代码来源:Output.cs

示例10: CheckIncludePath

        /// <summary>
        /// Check if the path lays inside of the directory tree specified 
        /// by the <c>open_basedir</c> configuration option and return the resulting <paramref name="absolutePath"/>.
        /// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="relativePath">The filename to search for.</param>
        /// <param name="absolutePath">The combined absolute path (either in the working directory 
        /// or in an include path wherever it has been found first).</param>
        /// <returns><c>true</c> if the file was found in an include path.</returns>
        private static bool CheckIncludePath(Context ctx, string relativePath, ref string absolutePath)
        {
            // Note: If the absolutePath exists, it overtakse the include_path search.
            if (Path.IsPathRooted(relativePath)) return false;
            if (File.Exists(absolutePath)) return false;

            var paths = ctx.IncludePaths;
            if (paths == null || paths.Length == 0) return false;

            foreach (string s in paths)
            {
                if (string.IsNullOrEmpty(s)) continue;
                string abs = Path.GetFullPath(Path.Combine(s, relativePath));
                if (File.Exists(abs))
                {
                    absolutePath = abs;
                    return true;
                }
            }
            return false;
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:30,代码来源:PhpStream.cs

示例11: Open

        /// <summary>
        /// Openes a PhpStream using the appropriate StreamWrapper.
        /// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="path">URI or filename of the resource to be opened.</param>
        /// <param name="mode">A file-access mode as passed to the PHP function.</param>
        /// <param name="options">A combination of <see cref="StreamOpenOptions"/>.</param>
        /// <param name="context">A valid StreamContext. Must not be <c>null</c>.</param>
        /// <returns></returns>
        public static PhpStream Open(Context ctx, string path, string mode, StreamOpenOptions options, StreamContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            Debug.Assert(ctx != null);

            StreamWrapper wrapper;
            if (!PhpStream.ResolvePath(ctx, ref path, out wrapper, CheckAccessMode.FileMayExist, (CheckAccessOptions)options))
                return null;

            return wrapper.Open(ctx, ref path, mode, options, context);

        }
开发者ID:iolevel,项目名称:peachpie,代码行数:23,代码来源:PhpStream.cs

示例12: OutputChunks

 static void OutputChunks(Context ctx, object[] chunks, int count)
 {
     for (int i = 0; i < count; i++)
     {
         OutputChunk(ctx, chunks[i]);
     }
 }
开发者ID:iolevel,项目名称:peachpie,代码行数:7,代码来源:PhpString.cs

示例13: Output

 internal void Output(Context ctx)
 {
     var chunks = _chunks;
     if (chunks != null)
     {
         if (chunks.GetType() == typeof(object[]))
         {
             OutputChunks(ctx, (object[])chunks, _chunksCount);
         }
         else
         {
             OutputChunk(ctx, chunks);
         }
     }
 }
开发者ID:iolevel,项目名称:peachpie,代码行数:15,代码来源:PhpString.cs

示例14: preg_match

 public static int preg_match(Context ctx, string pattern, string subject, out PhpArray matches, int flags = 0, long offset = 0)
 {
     throw new NotImplementedException();
 }
开发者ID:iolevel,项目名称:peachpie,代码行数:4,代码来源:pcre.cs

示例15: preg_match_all

 public static int preg_match_all(Context ctx, string pattern, string subject, out PhpArray matches, int flags = PREG_PATTERN_ORDER, int offset = 0)
 {
     throw new NotImplementedException();
 }
开发者ID:iolevel,项目名称:peachpie,代码行数:4,代码来源:pcre.cs


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