Skip to main content

This package contains the .NET Runtime for console-based applications, allowing seamless integration with the .NET Common Language Runtime (CLR) by leveraging the Python.NET package.

Project description

.NET Runtime: Integrating .NET with Python

This package is an indispensable resource for those planning to create console-based applications utilizing .NET assemblies from Python. It offers the .NET Runtime (Version 8.0.4), which works with the .NET Common Language Runtime (CLR) using the Python.NET package. With this integration, developers can concentrate on their development tasks without worrying about compatibility issues, allowing them to create smooth and efficient applications. This package is a valuable tool for creating high-quality console-based applications using .NET assemblies and Python.

Usage/Examples

# Python script to filter and print even numbers from a .NET List

# Ensure to import 'dnv.net.runtime' before any other import statements
import dnv.net.runtime
import clr

# Add references to required .NET assemblies
clr.AddReference("System")
clr.AddReference("System.Core")
clr.AddReference("System.Collections")

from System import Action, Array, Predicate
from System.Collections.Generic import List
from System.Linq import Enumerable

# Create a .NET Array of integers from 1 to 10
numbers = Array[int]([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

# Convert the array to a .NET List
listOfNumbers = List[int](numbers)

# Define a Predicate that checks if a number is even
predicate = Predicate[int](lambda x: x % 2 == 0)

# Use the FindAll method of the List to filter out the even numbers based on the Predicate
evenNumbers: List[int] = listOfNumbers.FindAll(predicate)

# Define an Action that prints a number
action = Action[int](lambda x: print(x))

# Use the ForEach method of the List to print each even number
evenNumbers.ForEach(action)
# Web Scraping Bing Search Results with Python and .NET HttpClient

# Ensure to import 'dnv.net.runtime' before any other import statements
import dnv.net.runtime
import clr
import re

# Add references to required .NET assemblies
clr.AddReference("System.Net.Http")

from System.Net.Http import HttpClient

# Create an HttpClient instance
client = HttpClient()

# Specify the URL
url = "https://www.bing.com/search?q=DNV"

# Send the GET request
response = client.GetAsync(url).Result

# Ensure the request was successful
response.EnsureSuccessStatusCode()

# Read the response content as a string
responseBody = response.Content.ReadAsStringAsync().Result

# Define a regular expression to extract the titles and URLs of the search results
regex = r'<h2.*?><a href="(.*?)" h=".*?">(.*?)</a></h2>'

# Find all matches of the regular expression in the response body
matches = re.findall(regex, responseBody)

# Print the titles and URLs of the search results
for match in matches:
    url, title = match
    print(f'Title: {title}')
    print(f'URL: {url}')
    print()

License

MIT

Support

If you encounter any issues, have questions, or want to provide feedback, please get in touch with our support team at software.support@dnv.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

dnv_net_runtime-1.0.0-py3-none-win_amd64.whl (33.1 MB view details)

Uploaded Python 3 Windows x86-64

File details

Details for the file dnv_net_runtime-1.0.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for dnv_net_runtime-1.0.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 f3a0b5b601b34902fa4e76b272c41d2df5da910ace266ae098a137fa1fdd5149
MD5 062822a5fc100a7b8d2111842a9dc18f
BLAKE2b-256 a0248f885fbb271a0a4f2bb670d6f4465ed41e2190ab59ba91964fe5753fc96a

See more details on using hashes here.

File details

Details for the file dnv_net_runtime-1.0.0-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for dnv_net_runtime-1.0.0-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 86d2c4079143d1aba77d8f57be5f89d3f43daddde3fceace40a48dee227bcbd2
MD5 e3c02297e68f16b2c83bafa17becac96
BLAKE2b-256 69dfb388999ffa83bc3f795f6c7e31afdd9e450d92f954ecbf38449a883df8f5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page