com.javonet.api

Class NAssembly

  • java.lang.Object
    • com.javonet.api.NAssembly

  • public class NAssembly
    extends java.lang.Object
    A handle for .NET assembly loaded to memory on .NET side.

    This class can be used to perform operations on .NET assemblies loaded to memory

    • load types from that assembly
    • create instances of types defined in this assembly

    Creating Instance of NAssembly

    NAssembly is initialized by

    This method loads to memory appropriate .NET assembly with unique identifier and returns
    instance of NAssembly class associated to that identifier. This way all operation on NAssembly class
    are transfered and executed against associated .NET assembly.

    Using NAssembly is optional. Javonet automatically uses types of all loaded assemblies
    as it happens in regular .NET application. Javonet will lookup all assemblies loaded by
    calling Javonet.addReference(String...) method or by specifying their
    names in XML configuration file.

    Usage Sample

     
     NAssembly customDotNetAssembly = Javonet.getType("MyDotNetAssembly.dll");
     NClass myClass = customDotNetAssembly.create("MyClass","arg1","arg2");
     
     
    Version:
    1.0


    • Constructor Summary

      Constructors 
      Constructor and Description
      NAssembly(com.javonet.internal.IGateway gatewayManager,
      int oid,
      java.lang.String assemblyPath)

      Internal constructor that creates new instance of NAssembly associated to assembly
      loaded under specified unique identifier from specified assembly path.



    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      NObject create(java.lang.String typeName)

      Creates new instance of .NET class using parameter-less constructor specified by provided type name and located in associated assembly.
      NObject create(java.lang.String typeName,
      java.lang.Object... parameters)

      Creates new instance of .NET class using constructor with parameters specified by provided type name and located in associated assembly.
      java.lang.String getAssemblyPath()

      Returns path to associated assembly loaded on .NET side.
      int getOid()

      Returns unique identifier of associated assembly loaded on .NET side.
      NType getType(java.lang.String typeName)

      Returns new instance of NType class connected to .NET type defined in associated assembly
      with specified name.
      static NAssembly importAssembly(java.lang.String assemblyPath,
      com.javonet.internal.IGateway gm)

      Internal method that loads .NET assembly to memory and returns new instance of associated NAssembly class.


      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait



    • Constructor Detail



      • NAssembly

        public NAssembly(com.javonet.internal.IGateway gatewayManager,
                         int oid,
                         java.lang.String assemblyPath)
        Internal constructor that creates new instance of NAssembly associated to assembly
        loaded under specified unique identifier from specified assembly path.
        Parameters:
        gatewayManager – Gateway session in which assembly was loaded
        oid – Unique identifier of loaded assembly
        assemblyPath – Full assembly name or full/local path



    • Method Detail



      • create

        public NObject create(java.lang.String typeName)
                       throws JavonetException
        Creates new instance of .NET class using parameter-less constructor specified by provided type name and located in associated assembly.
        Parameters:
        typeName – Name of the type for which new instance should be created
        Returns:
        New instance of NObject associated to new instance of created object on .NET side
        Throws:
        JavonetException – If .NET exception occurs during initialization of .NET object



      • create

        public NObject create(java.lang.String typeName,
                              java.lang.Object... parameters)
                       throws JavonetException
        Creates new instance of .NET class using constructor with parameters specified by provided type name and located in associated assembly.

        Constructor is being matched by parameters count and type.

        Parameters can be specified as JAVA primitive types (string, integer, float..) or instances of NObject class for reference-type parameters.

        This method returns new instance of NObject class associated to newly created object on .NET side.

        Parameters:
        typeName – Name of the type for which new instance should be created
        parameters – Parameters to be passed to constructor during creation of new instance of associated .NET type
        Returns:
        New instance of NObject associated to new instance of created object on .NET side
        Throws:
        JavonetException – If .NET exception occurs during initialization of .NET object



      • getAssemblyPath

        public java.lang.String getAssemblyPath()
        Returns path to associated assembly loaded on .NET side.
        Returns:
        Path to .NET assembly loaded on .NET side



      • getOid

        public int getOid()
        Returns unique identifier of associated assembly loaded on .NET side.
        Associated assembly is specified during initialization of NAssembly class.
        Returns:
        Unique identifier of corresponding .NET assembly



      • getType

        public NType getType(java.lang.String typeName)
                      throws JavonetException
        Returns new instance of NType class connected to .NET type defined in associated assembly
        with specified name.
        Parameters:
        typeName – Name of the type to be loaded
        Returns:
        New instance of NType associated to loaded .NET type
        Throws:
        JavonetException – If .NET exception occurs during .NET type loading



      • importAssembly

        public static NAssembly importAssembly(java.lang.String assemblyPath,
                                               com.javonet.internal.IGateway gm)
                                        throws JavonetException
        Internal method that loads .NET assembly to memory and returns new instance of associated NAssembly class.

        Assemblies can be loaded from any location, local directory or GAC.

        Parameters:
        assemblyPath – Full assembly name or full/local path to assembly to be loaded
        gm – Gateway session instance
        Returns:
        NAssembly instance of object associated to loaded assembly
        Throws:
        JavonetException – If .NET exception occurs while assembly is being loaded