Example #1
0
 /// <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="userWrapperName">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_register_wrapper(Context ctx, string protocol, string userWrapperName, StreamWrapperRegisterFlags flags = StreamWrapperRegisterFlags.Default)
 {
     return(stream_wrapper_register(ctx, protocol, userWrapperName, flags));
 }
Example #2
0
 public static bool RegisterUserWrapperByName2(DTypeDesc caller, string protocol, string userWrapperName, StreamWrapperRegisterFlags flags/*=0*/)
 {
     return RegisterUserWrapperByName(caller, protocol, userWrapperName, flags);
 }
Example #3
0
        /// <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));
        }
Example #4
0
        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);
		}