Description Usage Arguments Details Value Examples
Call a .Net method member for a given a .Net object.
1 | netCall(x, methodName, ..., wrap = FALSE, out_env = parent.frame())
|
x |
a .Net object, which can be an |
methodName |
Method name to call |
... |
Method arguments |
wrap |
Specify if you want to wrap |
out_env |
In case of a .Net method with |
Call a method member for a given .Net object. Ellipses has to keep the .Net arguments method order, the named arguments are not yet supported. If there is conflicts with a method name (many definition in .Net), a score is computed from your argument's order and type. We consider a higher score single value comparing to collection of values.
If you decide to set wrap
to TRUE
, the function returns a NetObject
instead of a raw externalptr
.
To remind an externalptr
is returned only if no one native converter has been found.
The NetObject R6
object wrapper can be an inherited R6
class. For more details about
inherited NetObject
class please see netGenerateR6
function.
The out_env
is usefull when the callee .Net method has some out
or ref
argument.
Because in .Net this argument set the given variable in the caller scope. We reflect this
mechanism in R. By default the given varable is modify in the parent R environment
which means
the caller or parent.frame()
. You can decide where to redirect the outputed value
by specifying another environment
. Of course be sure that the variable name exists in this
targetd environment
.
Returns the .Net result.
If a converter has been defined between the .Net type and a R
type, the R
type will be returned.
Otherwise an externalptr
or a NetObject
if wrap
is set to TRUE
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
library(sharper)
package_folder <- path.package("sharper")
netLoadAssembly(file.path(package_folder, "tests", "AssemblyForTests.dll"))
x <- netNew("AssemblyForTests.OneCtorData", 21L)
netCall(x, "ToString")
# wrap result
x <- NetObject$new(ptr = x)
clone <- netCall(x, "Clone", wrap = TRUE)
# out a variable
x <- netNew("AssemblyForTests.DefaultCtorData")
out_variable = 0
netCall(x, "TryGetValue", out_variable)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.