public static ScriptEngine AddHostType(this ScriptEngine engine, HostType hostType)
        {
            engine.AddHostType(hostType.Name, hostType.Flags, hostType.Type);

            return engine;
        }
Пример #2
0
 /// <summary>
 /// Adds a type to a host type collection.
 /// </summary>
 /// <param name="type">The type to add.</param>
 public void AddType(Type type)
 {
     MiscHelpers.VerifyNonNullArgument(type, "type");
     AddType(HostType.Wrap(type));
 }
Пример #3
0
 /// <summary>
 /// Converts a type to a host type for use with script code running in the specified
 /// script engine.
 /// </summary>
 /// <param name="type">The type to convert to a host type.</param>
 /// <param name="engine">The script engine in which the host type will be used.</param>
 /// <returns>A host type for use with script code.</returns>
 public static object ToHostType(this Type type, ScriptEngine engine)
 {
     MiscHelpers.VerifyNonNullArgument(type, nameof(type));
     MiscHelpers.VerifyNonNullArgument(engine, nameof(engine));
     return(HostItem.Wrap(engine, HostType.Wrap(type)));
 }
Пример #4
0
 /// <summary>
 /// Exposes a host type to script code with the specified options.
 /// </summary>
 /// <param name="itemName">A name for the new global script item that will represent the type.</param>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <param name="type">The type to expose.</param>
 /// <remarks>
 /// Host types are exposed to script code in the form of objects whose properties and
 /// methods are bound to the type's static members and nested types. If the type has
 /// generic parameters, the corresponding object will be invocable with type arguments to
 /// yield a specific type.
 /// <para>
 /// For more information about the mapping between host members and script-callable
 /// properties and methods, see <see cref="AddHostObject(string, HostItemFlags, object)"/>.
 /// </para>
 /// </remarks>
 public void AddHostType(string itemName, HostItemFlags flags, Type type)
 {
     MiscHelpers.VerifyNonNullArgument(type, "type");
     AddHostItem(itemName, flags, HostType.Wrap(type));
 }
Пример #5
0
 private void AddType(HostType hostType)
 {
     MiscHelpers.VerifyNonNullArgument(hostType, "hostType");
     foreach (var type in hostType.Types)
     {
         var namespaceNode = GetNamespaceNode(type);
         if (namespaceNode != null)
         {
             AddTypeToNamespaceNode(namespaceNode, type);
         }
     }
 }