Exemple #1
0
        /// <summary> Returns the IAnswerData preload value for the given preload type and parameters
        ///
        /// </summary>
        /// <param name="preloadType">The type of the preload to be returned
        /// </param>
        /// <param name="preloadParams">Parameters for the preload handler
        /// </param>
        /// <returns> An IAnswerData corresponding to a pre-loaded value for the given
        /// Arguments. null if no preload could successfully be derived due to either
        /// the lack of a handler, or to invalid parameters
        /// </returns>
        public virtual IAnswerData getQuestionPreload(System.String preloadType, System.String preloadParams)
        {
            IPreloadHandler handler = (IPreloadHandler)preloadHandlers.get(preloadType);

            if (handler != null)
            {
                return(handler.handlePreload(preloadParams));
            }
            else
            {
                System.Console.Error.WriteLine("Do not know how to handle preloader [" + preloadType + "]");
                return(null);
            }
        }
Exemple #2
0
        /// <param name="prototypeName">The name of the prototype to be instantiated
        /// </param>
        /// <returns> a new object of the type linked to the name given in this factory. Null
        /// if the name is not associated with any class in this factory.
        /// </returns>
        /// <throws>  IllegalAccessException If the empty constructor of the class given is not </throws>
        /// <summary> allowed to be accessed.
        /// </summary>
        /// <throws>  InstantiationException </throws>
        public virtual System.Object getNewInstance(System.String prototypeName)
        {
            if (prototypes.get(prototypeName) == null)
            {
                return(null);
            }
            try
            {
                //UPGRADE_TODO: Method 'java.lang.Class.newInstance' was converted to 'System.Activator.CreateInstance' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javalangClassnewInstance'"
                return(System.Activator.CreateInstance(((System.Type)prototypes.get(prototypeName))));
            }
            catch (System.UnauthorizedAccessException e)
            {
                throw new CannotCreateObjectException(prototypeName);
            }

            //UPGRADE_NOTE: Exception 'java.lang.InstantiationException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
            catch (System.Exception e)
            {
                throw new CannotCreateObjectException(prototypeName);
            }
        }