Embeddings that wish to provide their own custom wrappings for Java objects may extend this class and call Context.SetWrapFactory(WrapFactory) Once an instance of this class or an extension of this class is enabled for a given context (by calling setWrapFactory on that context), Rhino will call the methods of this class whenever it needs to wrap a value resulting from a call to a Java method or an access to a Java field.
Esempio n. 1
0
		/// <summary>Return the current WrapFactory, or null if none is defined.</summary>
		/// <remarks>Return the current WrapFactory, or null if none is defined.</remarks>
		/// <seealso cref="WrapFactory">WrapFactory</seealso>
		/// <since>1.5 Release 4</since>
		public WrapFactory GetWrapFactory()
		{
			if (wrapFactory == null)
			{
				wrapFactory = new WrapFactory();
			}
			return wrapFactory;
		}
Esempio n. 2
0
		/// <summary>Set a WrapFactory for this Context.</summary>
		/// <remarks>
		/// Set a WrapFactory for this Context.
		/// <p>
		/// The WrapFactory allows custom object wrapping behavior for
		/// Java object manipulated with JavaScript.
		/// </remarks>
		/// <seealso cref="WrapFactory">WrapFactory</seealso>
		/// <since>1.5 Release 4</since>
		public void SetWrapFactory(WrapFactory wrapFactory)
		{
			if (@sealed)
			{
				OnSealedMutation();
			}
			if (wrapFactory == null)
			{
				throw new ArgumentException();
			}
			this.wrapFactory = wrapFactory;
		}