/// <summary> /// Registers a user-wrapper specified by the name of a defining user-class. /// </summary> /// <param name="ctx">Runtime context.</param> /// <param name="protocol">The schema to be associated with the given wrapper.</param> /// <param name="classname">Name of the user class implementing the wrapper functions.</param> /// <param name="flags">Should be set to STREAM_IS_URL if protocol is a URL protocol. Default is 0, local stream.</param> /// <returns>False in case of failure (ex. schema already occupied).</returns> public static bool stream_wrapper_register(Context ctx, string protocol, string classname, StreamWrapperRegisterFlags flags = StreamWrapperRegisterFlags.Default) { // check if the scheme is already registered: if (string.IsNullOrEmpty(protocol) || StreamWrapper.GetWrapperInternal(ctx, protocol) == null) { // TODO: Warning? return(false); } var wrapperClass = ctx.GetDeclaredTypeOrThrow(classname, true); if (wrapperClass == null) { return(false); } // EX: [stream_wrapper_register]: create the user wrapper var wrapper = new UserStreamWrapper(ctx, protocol, wrapperClass, flags == StreamWrapperRegisterFlags.IsUrl); return(StreamWrapper.RegisterUserWrapper(ctx, protocol, wrapper)); }
public PhpUserStream(UserStreamWrapper/*!*/openingWrapper, StreamAccessOptions accessOptions, string openedPath, StreamContext context) : base(openingWrapper, accessOptions, openedPath, context) { }
public void TestSetup() { stream = Substitute.For <Stream>(); wrapper = new UserStreamWrapper(stream); buffer = new byte[1]; }
public static bool RegisterUserWrapperByName(DTypeDesc caller, string protocol, string classname, StreamWrapperRegisterFlags flags/*=0*/) { // check if the scheme is already registered: if (string.IsNullOrEmpty(protocol) || StreamWrapper.Exists(protocol)) { // TODO: Warning? return false; } DTypeDesc wrapperClass = ScriptContext.CurrentContext.ResolveType(classname, null, caller, null, ResolveTypeFlags.UseAutoload | ResolveTypeFlags.ThrowErrors); if (wrapperClass == null) return false; // EX: [stream_wrapper_register]: create the user wrapper StreamWrapper wrapper = new UserStreamWrapper(ScriptContext.CurrentContext, protocol, wrapperClass, flags == StreamWrapperRegisterFlags.IsUrl); return StreamWrapper.RegisterUserWrapper(protocol, wrapper); }
public PhpUserStream(Context ctx, UserStreamWrapper /*!*/ openingWrapper, StreamAccessOptions accessOptions, string openedPath, StreamContext context) : base(ctx, openingWrapper, accessOptions, openedPath, context) { }