Skip to content

DotNet64¤

Communicates with the dotnet_lib32 library via the DotNet32 class that is running on a server.

DotNet64 ¤

DotNet64()

Bases: Client64

Communicates with a 32-bit .NET library.

This class demonstrates how to communicate with a 32-bit .NET library if an instance of this class is created within a 64-bit Python interpreter.

Source code in src/msl/examples/loadlib/dotnet64.py
17
18
19
20
21
22
23
24
25
def __init__(self) -> None:
    """Communicates with the 32-bit .NET [dotnet_lib32.dll][dotnet-lib] library.

    This class demonstrates how to communicate with a 32-bit .NET library if an
    instance of this class is created within a 64-bit Python interpreter.
    """
    # specify the name of the corresponding 32-bit server module, dotnet32, which hosts
    # the 32-bit .NET library -- dotnet_lib32.dll.
    super().__init__("dotnet32", append_sys_path=Path(__file__).parent)

add_integers ¤

add_integers(a, b)

Add two integers.

See the corresponding DotNet32.add_integers method.

Parameters:

Name Type Description Default
a int

First integer.

required
b int

Second integer.

required

Returns:

Type Description
int

The sum, a + b.

Source code in src/msl/examples/loadlib/dotnet64.py
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def add_integers(self, a: int, b: int) -> int:
    """Add two integers.

    See the corresponding [DotNet32.add_integers][msl.examples.loadlib.dotnet32.DotNet32.add_integers] method.

    Args:
        a: First integer.
        b: Second integer.

    Returns:
        The sum, `a + b`.
    """
    reply: int = self.request32("add_integers", a, b)
    return reply

add_multiple ¤

add_multiple(a, b, c, d, e)

Add multiple integers.

Calls a static method in a static class.

See the corresponding DotNet32.add_multiple method.

Parameters:

Name Type Description Default
a int

First integer.

required
b int

Second integer.

required
c int

Third integer.

required
d int

Fourth integer.

required
e int

Fifth integer.

required

Returns:

Type Description
int

The sum of the input arguments.

Source code in src/msl/examples/loadlib/dotnet64.py
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
def add_multiple(self, a: int, b: int, c: int, d: int, e: int) -> int:
    """Add multiple integers.

    Calls a static method in a static class.

    See the corresponding [DotNet32.add_multiple][msl.examples.loadlib.dotnet32.DotNet32.add_multiple] method.

    Args:
        a: First integer.
        b: Second integer.
        c: Third integer.
        d: Fourth integer.
        e: Fifth integer.

    Returns:
        The sum of the input arguments.
    """
    reply: int = self.request32("add_multiple", a, b, c, d, e)
    return reply

add_or_subtract ¤

add_or_subtract(a, b, *, do_addition)

Add or subtract two C# double-precision numbers.

See the corresponding DotNet32.add_or_subtract method.

Parameters:

Name Type Description Default
a float

First double-precision number.

required
b float

Second double-precision number.

required
do_addition bool

Whether to add or subtract the numbers.

required

Returns:

Type Description
float

a + b if do_addition is True else a - b.

Source code in src/msl/examples/loadlib/dotnet64.py
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def add_or_subtract(self, a: float, b: float, *, do_addition: bool) -> float:
    """Add or subtract two C# double-precision numbers.

    See the corresponding [DotNet32.add_or_subtract][msl.examples.loadlib.dotnet32.DotNet32.add_or_subtract] method.

    Args:
        a: First double-precision number.
        b: Second double-precision number.
        do_addition: Whether to add or subtract the numbers.

    Returns:
        `a + b` if `do_addition` is `True` else `a - b`.
    """
    reply: float = self.request32("add_or_subtract", a, b, do_addition=do_addition)
    return reply

concatenate ¤

concatenate(a, b, c, d, e)

Concatenate strings.

Calls a static method in a static class.

See the corresponding DotNet32.concatenate method.

Parameters:

Name Type Description Default
a str

First string.

required
b str

Second string.

required
c str

Third string.

required
d bool

Whether to include e in the concatenation.

required
e str

Fourth string.

required

Returns:

Type Description
str

The strings concatenated together.

Source code in src/msl/examples/loadlib/dotnet64.py
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
def concatenate(self, a: str, b: str, c: str, d: bool, e: str) -> str:  # noqa: FBT001
    """Concatenate strings.

    Calls a static method in a static class.

    See the corresponding [DotNet32.concatenate][msl.examples.loadlib.dotnet32.DotNet32.concatenate] method.

    Args:
        a: First string.
        b: Second string.
        c: Third string.
        d: Whether to include `e` in the concatenation.
        e: Fourth string.

    Returns:
        The strings concatenated together.
    """
    reply: str = self.request32("concatenate", a, b, c, d, e)
    return reply

divide_floats ¤

divide_floats(a, b)

Divide two C# floating-point numbers.

See the corresponding DotNet32.divide_floats method.

Parameters:

Name Type Description Default
a float

The numerator.

required
b float

The denominator.

required

Returns:

Type Description
float

The quotient, a / b.

Source code in src/msl/examples/loadlib/dotnet64.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
def divide_floats(self, a: float, b: float) -> float:
    """Divide two C# floating-point numbers.

    See the corresponding [DotNet32.divide_floats][msl.examples.loadlib.dotnet32.DotNet32.divide_floats] method.

    Args:
        a: The numerator.
        b: The denominator.

    Returns:
        The quotient, `a / b`.
    """
    reply: float = self.request32("divide_floats", a, b)
    return reply

get_class_names ¤

get_class_names()

Gets the class names in the library.

Calls GetTypes using the assembly property.

See the corresponding DotNet32.get_class_names method.

Returns:

Type Description
list[str]

The names of the classes that are available in dotnet_lib32.dll.

Source code in src/msl/examples/loadlib/dotnet64.py
27
28
29
30
31
32
33
34
35
36
37
38
39
def get_class_names(self) -> list[str]:
    """Gets the class names in the library.

    Calls [GetTypes](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assembly.gettypes){:target="_blank"}
    using the [assembly][msl.loadlib.load_library.LoadLibrary.assembly] property.

    See the corresponding [DotNet32.get_class_names][msl.examples.loadlib.dotnet32.DotNet32.get_class_names] method.

    Returns:
        The names of the classes that are available in [dotnet_lib32.dll][dotnet-lib].
    """
    reply: list[str] = self.request32("get_class_names")
    return reply

multiply_doubles ¤

multiply_doubles(a, b)

Multiply two C# double-precision numbers.

See the corresponding DotNet32.multiply_doubles method.

Parameters:

Name Type Description Default
a float

First double-precision number.

required
b float

Second double-precision number.

required

Returns:

Type Description
float

The product, a * b.

Source code in src/msl/examples/loadlib/dotnet64.py
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
def multiply_doubles(self, a: float, b: float) -> float:
    """Multiply two C# double-precision numbers.

    See the corresponding [DotNet32.multiply_doubles][msl.examples.loadlib.dotnet32.DotNet32.multiply_doubles]
    method.

    Args:
        a: First double-precision number.
        b: Second double-precision number.

    Returns:
        The product, `a * b`.
    """
    reply: float = self.request32("multiply_doubles", a, b)
    return reply

multiply_matrices ¤

multiply_matrices(a1, a2)

Multiply two matrices.

See the corresponding DotNet32.multiply_matrices method.

Parameters:

Name Type Description Default
a1 Sequence[Sequence[float]]

First matrix.

required
a2 Sequence[Sequence[float]]

Second matrix.

required
Return

The product, a1 @ a2.

Source code in src/msl/examples/loadlib/dotnet64.py
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
def multiply_matrices(self, a1: Sequence[Sequence[float]], a2: Sequence[Sequence[float]]) -> list[list[float]]:
    """Multiply two matrices.

    See the corresponding [DotNet32.multiply_matrices][msl.examples.loadlib.dotnet32.DotNet32.multiply_matrices]
    method.

    Args:
        a1: First matrix.
        a2: Second matrix.

    Return:
        The product, `a1 @ a2`.
    """
    reply: list[list[float]] = self.request32("multiply_matrices", a1, a2)
    return reply

reverse_string ¤

reverse_string(original)

Reverse a string.

See the corresponding DotNet32.reverse_string method.

Parameters:

Name Type Description Default
original str

The original string.

required

Returns:

Type Description
str

The string reversed.

Source code in src/msl/examples/loadlib/dotnet64.py
134
135
136
137
138
139
140
141
142
143
144
145
146
def reverse_string(self, original: str) -> str:
    """Reverse a string.

    See the corresponding [DotNet32.reverse_string][msl.examples.loadlib.dotnet32.DotNet32.reverse_string] method.

    Args:
        original: The original string.

    Returns:
        The string reversed.
    """
    reply: str = self.request32("reverse_string", original)
    return reply

scalar_multiply ¤

scalar_multiply(a, xin)

Multiply each element in an array by a number.

See the corresponding DotNet32.scalar_multiply method.

Parameters:

Name Type Description Default
a float

Scalar value.

required
xin Sequence[float]

Array to modify.

required

Returns:

Type Description
list[float]

A new array with each element in xin multiplied by a.

Source code in src/msl/examples/loadlib/dotnet64.py
103
104
105
106
107
108
109
110
111
112
113
114
115
116
def scalar_multiply(self, a: float, xin: Sequence[float]) -> list[float]:
    """Multiply each element in an array by a number.

    See the corresponding [DotNet32.scalar_multiply][msl.examples.loadlib.dotnet32.DotNet32.scalar_multiply] method.

    Args:
        a: Scalar value.
        xin: Array to modify.

    Returns:
        A new array with each element in `xin` multiplied by `a`.
    """
    reply: list[float] = self.request32("scalar_multiply", a, xin)
    return reply