@@ -47,6 +47,11 @@ protected void VerifyNotDisposed()
4747
4848 protected abstract void InnerRemoveVariable ( string variableName ) ;
4949
50+ protected virtual void InnerEmbedHostObject ( string itemName , object value )
51+ {
52+ throw new NotImplementedException ( ) ;
53+ }
54+
5055 #region IJsEngine implementation
5156
5257 public abstract string Name
@@ -361,6 +366,42 @@ public virtual void RemoveVariable(string variableName)
361366 InnerRemoveVariable ( variableName ) ;
362367 }
363368
369+ public virtual void EmbedHostObject ( string itemName , object value )
370+ {
371+ VerifyNotDisposed ( ) ;
372+
373+ if ( string . IsNullOrWhiteSpace ( itemName ) )
374+ {
375+ throw new ArgumentException (
376+ string . Format ( Strings . Common_ArgumentIsEmpty , "itemName" ) , "itemName" ) ;
377+ }
378+
379+ if ( ! ValidationHelpers . CheckNameFormat ( itemName ) )
380+ {
381+ throw new FormatException (
382+ string . Format ( Strings . Runtime_InvalidScriptItemNameFormat , itemName ) ) ;
383+ }
384+
385+ if ( value != null )
386+ {
387+ Type itemType = value . GetType ( ) ;
388+
389+ if ( ValidationHelpers . IsPrimitiveType ( itemType )
390+ || itemType == typeof ( Undefined )
391+ || itemType == typeof ( DateTime ) )
392+ {
393+ throw new NotSupportedTypeException (
394+ string . Format ( Strings . Runtime_EmbeddedHostObjectTypeNotSupported , itemType . FullName ) ) ;
395+ }
396+ }
397+ else
398+ {
399+ throw new ArgumentNullException ( "value" , string . Format ( Strings . Common_ArgumentIsNull , "value" ) ) ;
400+ }
401+
402+ InnerEmbedHostObject ( itemName , value ) ;
403+ }
404+
364405 #endregion
365406
366407 #region IDisposable implementation
0 commit comments