Compare commits
21 commits
d22de33732
...
1ac34c7625
Author | SHA1 | Date | |
---|---|---|---|
1ac34c7625 | |||
a872555f93 | |||
724e95bc57 | |||
bedbe2ea84 | |||
7241a265e6 | |||
cad81ce7f1 | |||
08f6288f91 | |||
94cb10b3df | |||
f130b631fc | |||
af51421b63 | |||
b67f9953de | |||
9cdb89e033 | |||
1eee51205d | |||
a6967fd942 | |||
d518c74e77 | |||
da89471f75 | |||
a7d18f56e9 | |||
80a8817143 | |||
12a7fe3c17 | |||
ea670fdc3c | |||
972d364963 |
21 changed files with 663 additions and 298 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -383,7 +383,6 @@ FodyWeavers.xsd
|
||||||
!.vscode/tasks.json
|
!.vscode/tasks.json
|
||||||
!.vscode/launch.json
|
!.vscode/launch.json
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
*.code-workspace
|
|
||||||
|
|
||||||
# Local History for Visual Studio Code
|
# Local History for Visual Studio Code
|
||||||
.history/
|
.history/
|
||||||
|
|
26
Tasks/AdvancedConcepts/.vscode/launch.json
vendored
Normal file
26
Tasks/AdvancedConcepts/.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||||
|
// Use hover for the description of the existing attributes
|
||||||
|
// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md
|
||||||
|
"name": ".NET Core Launch (console)",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build",
|
||||||
|
// If you have changed target frameworks, make sure to update the program path.
|
||||||
|
"program": "${workspaceFolder}/bin/Debug/net8.0/AdvancedConcepts.dll",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
||||||
|
"console": "internalConsole",
|
||||||
|
"stopAtEntry": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": ".NET Core Attach",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "attach"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
41
Tasks/AdvancedConcepts/.vscode/tasks.json
vendored
Normal file
41
Tasks/AdvancedConcepts/.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"build",
|
||||||
|
"${workspaceFolder}/AdvancedConcepts.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "publish",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"publish",
|
||||||
|
"${workspaceFolder}/AdvancedConcepts.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "watch",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"watch",
|
||||||
|
"run",
|
||||||
|
"--project",
|
||||||
|
"${workspaceFolder}/AdvancedConcepts.csproj"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,11 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>disable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
|
|
26
Tasks/UrlTester/.vscode/launch.json
vendored
Normal file
26
Tasks/UrlTester/.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||||
|
// Use hover for the description of the existing attributes
|
||||||
|
// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md
|
||||||
|
"name": ".NET Core Launch (console)",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build",
|
||||||
|
// If you have changed target frameworks, make sure to update the program path.
|
||||||
|
"program": "${workspaceFolder}/bin/Debug/net8.0-windows/UrlTester.dll",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
||||||
|
"console": "internalConsole",
|
||||||
|
"stopAtEntry": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": ".NET Core Attach",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "attach"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
41
Tasks/UrlTester/.vscode/tasks.json
vendored
Normal file
41
Tasks/UrlTester/.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"build",
|
||||||
|
"${workspaceFolder}/UrlTester.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "publish",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"publish",
|
||||||
|
"${workspaceFolder}/UrlTester.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "watch",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"watch",
|
||||||
|
"run",
|
||||||
|
"--project",
|
||||||
|
"${workspaceFolder}/UrlTester.csproj"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
9
Tasks/UrlTester/App.xaml
Normal file
9
Tasks/UrlTester/App.xaml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<Application x:Class="UrlTester.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:UrlTester"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
12
Tasks/UrlTester/App.xaml.cs
Normal file
12
Tasks/UrlTester/App.xaml.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace UrlTester;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for App.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
}
|
10
Tasks/UrlTester/AssemblyInfo.cs
Normal file
10
Tasks/UrlTester/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
[assembly:ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
|
@ -88,16 +88,16 @@ namespace DT2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetUrlSync(string url) {
|
public int GetUrlSync(string url) {
|
||||||
PageStart(url);
|
PageStart?.Invoke(url);
|
||||||
int size = GetPageSize(url);
|
int size = GetPageSize(url);
|
||||||
PageLoaded(url, size);
|
PageLoaded?.Invoke(url, size);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GetUrlAsync(string url) {
|
public async Task<int> GetUrlAsync(string url) {
|
||||||
PageStart(url);
|
PageStart?.Invoke(url);
|
||||||
int size = await Task.Run(() => GetPageSize(url));
|
int size = await Task.Run(() => GetPageSize(url));
|
||||||
PageLoaded(url, size);
|
PageLoaded?.Invoke(url, size);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ namespace DT2 {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
size = await task.WaitAsync(TimeSpan.FromMilliseconds(millis));
|
size = await task.WaitAsync(TimeSpan.FromMilliseconds(millis));
|
||||||
PageLoaded(url, size);
|
PageLoaded?.Invoke(url, size);
|
||||||
}
|
}
|
||||||
catch (TimeoutException)
|
catch (TimeoutException)
|
||||||
{
|
{
|
||||||
|
@ -149,6 +149,7 @@ namespace DT2 {
|
||||||
LoadSummary("Total", totalSize, (int)sw.Elapsed.TotalMilliseconds);
|
LoadSummary("Total", totalSize, (int)sw.Elapsed.TotalMilliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DT2
|
||||||
public static void Main(string[] args) {
|
public static void Main(string[] args) {
|
||||||
Console.WriteLine("Starting ...");
|
Console.WriteLine("Starting ...");
|
||||||
UrlTester urlTester = new UrlTester();
|
UrlTester urlTester = new UrlTester();
|
||||||
|
@ -161,5 +162,6 @@ namespace DT2 {
|
||||||
Console.Write("Press any key to continue ...\n");
|
Console.Write("Press any key to continue ...\n");
|
||||||
Console.ReadKey(true);
|
Console.ReadKey(true);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
69
Tasks/UrlTester/DT3/DT3.cs
Normal file
69
Tasks/UrlTester/DT3/DT3.cs
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using DT2;
|
||||||
|
|
||||||
|
namespace DT3 {
|
||||||
|
|
||||||
|
public class UrlTesterModel : INotifyPropertyChanged {
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
int size;
|
||||||
|
int time;
|
||||||
|
string url;
|
||||||
|
DT2.UrlTester urlTester;
|
||||||
|
|
||||||
|
public UrlTesterModel() {
|
||||||
|
urlTester = new DT2.UrlTester();
|
||||||
|
IDictionary<string, Stopwatch> sw = new Dictionary<string, Stopwatch>();
|
||||||
|
urlTester.PageStart += url => { sw.Add(url, Stopwatch.StartNew()); };
|
||||||
|
urlTester.PageLoaded += (url, size) => {
|
||||||
|
sw[url].Stop();
|
||||||
|
int time = (int)sw[url].Elapsed.TotalMilliseconds;
|
||||||
|
Size = size;
|
||||||
|
Time = time;
|
||||||
|
sw.Remove(url);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Size {
|
||||||
|
get { return size; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
size = value;
|
||||||
|
NotifyPropertyChanged(nameof(Size));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Time {
|
||||||
|
get { return time; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
time = value;
|
||||||
|
NotifyPropertyChanged(nameof(Time));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Url {
|
||||||
|
get { return url; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
url = value;
|
||||||
|
NotifyPropertyChanged(nameof(Url));
|
||||||
|
var _ = urlTester.GetUrlAsync(Url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void NotifyPropertyChanged(string memberName)
|
||||||
|
{
|
||||||
|
if (PropertyChanged != null)
|
||||||
|
{
|
||||||
|
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(memberName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
BIN
Tasks/UrlTester/DT3/DT3.pdf
Normal file
BIN
Tasks/UrlTester/DT3/DT3.pdf
Normal file
Binary file not shown.
80
Tasks/UrlTester/MainWindow.xaml
Normal file
80
Tasks/UrlTester/MainWindow.xaml
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
<Window x:Class="UrlTester.MainWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:DT3"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="MainWindow"
|
||||||
|
Height="450"
|
||||||
|
Width="800">
|
||||||
|
<Window.Resources>
|
||||||
|
<Style x:Key="CommonStyle" TargetType="FrameworkElement">
|
||||||
|
<Setter Property="Margin" Value="10" />
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="Button" BasedOn="{StaticResource CommonStyle}">
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="15,0,15,0" />
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="TextBox" BasedOn="{StaticResource CommonStyle}" />
|
||||||
|
<Style TargetType="TextBlock" BasedOn="{StaticResource CommonStyle}" />
|
||||||
|
<Style TargetType="ProgressBar" BasedOn="{StaticResource CommonStyle}">
|
||||||
|
<Setter Property="Height"
|
||||||
|
Value="20" />
|
||||||
|
</Style>
|
||||||
|
</Window.Resources>
|
||||||
|
<Border>
|
||||||
|
<Grid>
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Button Content="GetUrl"
|
||||||
|
IsDefault="true" />
|
||||||
|
<TextBox Grid.Column="2"
|
||||||
|
Text="{Binding Url, Mode=OneWayToSource}" />
|
||||||
|
</Grid>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<StackPanel.Resources>
|
||||||
|
<Style TargetType="TextBlock" BasedOn="{StaticResource CommonStyle}">
|
||||||
|
<Setter Property="Background"
|
||||||
|
Value="LightGray" />
|
||||||
|
<Setter Property="Width"
|
||||||
|
Value="150" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="5"/>
|
||||||
|
</Style>
|
||||||
|
</StackPanel.Resources>
|
||||||
|
<TextBlock Text="{Binding Size, StringFormat={}{0} bytes}" />
|
||||||
|
<TextBlock Text="{Binding Time, StringFormat={}{0} ms}" />
|
||||||
|
</StackPanel>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ProgressBar x:Name="timeBar"
|
||||||
|
Minimum="0"
|
||||||
|
Maximum="1000"
|
||||||
|
Value="{Binding Time}"
|
||||||
|
Grid.ColumnSpan="3" />
|
||||||
|
<TextBlock Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
TextAlignment="Center"
|
||||||
|
Text="500 ms" />
|
||||||
|
<TextBlock Grid.Row="1"
|
||||||
|
Grid.Column="2"
|
||||||
|
TextAlignment="Right"
|
||||||
|
Text="1000 ms" />
|
||||||
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</Window>
|
27
Tasks/UrlTester/MainWindow.xaml.cs
Normal file
27
Tasks/UrlTester/MainWindow.xaml.cs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using DT2;
|
||||||
|
using DT3;
|
||||||
|
|
||||||
|
namespace UrlTester;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
DataContext = new UrlTesterModel();
|
||||||
|
}
|
||||||
|
}
|
20
Tasks/UrlTester/UrlTester.csproj
Normal file
20
Tasks/UrlTester/UrlTester.csproj
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>disable</Nullable>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<DefineConstants>$(DefineConstants);DT3</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.ObjectModel" Version="4.3.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
14
zhaw-dnet2.code-workspace
Normal file
14
zhaw-dnet2.code-workspace
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"name": "Solution Items",
|
||||||
|
"path": "."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./Tasks/AdvancedConcepts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./Tasks/UrlTester"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in a new issue