-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev'
- Loading branch information
Showing
14 changed files
with
317 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.4.2 | ||
3.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2022, Phoenix Contact GmbH & Co. KG | ||
// Licensed under the Apache License, Version 2.0 | ||
|
||
using System; | ||
|
||
namespace Moryx.Asp.Integration | ||
{ | ||
/// <summary> | ||
/// Decorator for web modules | ||
/// </summary> | ||
public class WebModuleAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Unique route of this module | ||
/// </summary> | ||
public string Route { get; } | ||
|
||
/// <summary> | ||
/// Recognizable icon of this module | ||
/// </summary> | ||
public string Icon { get; } | ||
|
||
/// <summary> | ||
/// Export page as web module under given route | ||
/// </summary> | ||
public WebModuleAttribute(string route) : this(route, "favorite") | ||
{ | ||
|
||
} | ||
|
||
/// <summary> | ||
/// Export page as web module under given route and icon | ||
/// </summary> | ||
public WebModuleAttribute(string route, string icon) | ||
{ | ||
Route = route; | ||
Icon = icon; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/Moryx/Communication/Endpoints/Connector/HttpClientBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) 2021, Phoenix Contact GmbH & Co. KG | ||
// Licensed under the Apache License, Version 2.0 | ||
|
||
using System; | ||
using System.Net; | ||
using System.Net.Http; | ||
|
||
namespace Moryx.Communication.Endpoints | ||
{ | ||
/// <summary> | ||
/// Helper class to get a configured HttpClient | ||
/// </summary> | ||
public static class HttpClientBuilder | ||
{ | ||
/// <summary> | ||
/// Creates a HttpClient based on the proxy config and base address | ||
/// </summary> | ||
public static HttpClient GetClient(string baseAddress, IProxyConfig proxyConfig) | ||
{ | ||
var httpClient = new HttpClient(); | ||
|
||
if (proxyConfig?.EnableProxy == true && !proxyConfig.UseDefaultWebProxy) | ||
{ | ||
var proxy = new WebProxy | ||
{ | ||
Address = new Uri($"http://{proxyConfig.Address}:{proxyConfig.Port}"), | ||
BypassProxyOnLocal = false, | ||
UseDefaultCredentials = true | ||
}; | ||
|
||
httpClient = new HttpClient(new HttpClientHandler { Proxy = proxy }); | ||
} | ||
|
||
httpClient.BaseAddress = new Uri(baseAddress); | ||
|
||
return httpClient; | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Moryx/Communication/Endpoints/Connector/IProxyConfigAccess.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) 2021, Phoenix Contact GmbH & Co. KG | ||
// Licensed under the Apache License, Version 2.0 | ||
|
||
namespace Moryx.Communication.Endpoints | ||
{ | ||
/// <summary> | ||
/// Enables the access to the used proxy configuration | ||
/// </summary> | ||
public interface IProxyConfigAccess | ||
{ | ||
/// <summary> | ||
/// Used proxy configuration | ||
/// </summary> | ||
IProxyConfig ProxyConfig { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/Moryx/Serialization/EntryConvert/CollectionStrategy/ArrayIListStrategy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
|
||
namespace Moryx.Serialization | ||
{ | ||
public class ArrayIListStrategy : ICollectionStrategy | ||
{ | ||
private readonly IList _list; | ||
private readonly IList _toDelete = new List<object>(); | ||
private readonly ICustomSerialization _customSerialization; | ||
private readonly ICustomAttributeProvider _property; | ||
private readonly object _instance; | ||
private readonly IList _toAdd = new List<object>(); | ||
|
||
public ArrayIListStrategy(IList list, ICustomSerialization customSerialization, | ||
ICustomAttributeProvider attributeProvider, object instance) | ||
{ | ||
_list = list; | ||
_customSerialization = customSerialization; | ||
_property = attributeProvider; | ||
_instance = instance; | ||
} | ||
|
||
public IEnumerable<Entry> Serialize() | ||
{ | ||
var entries = new List<Entry>(); | ||
for (int index = 0; index < _list.Count; index++) | ||
{ | ||
var entry = CollectionStrategyTools.CreateSub(_list[index], index, _customSerialization); | ||
entries.Add(entry); | ||
} | ||
return entries; | ||
} | ||
|
||
public IEnumerable<string> Keys() | ||
{ | ||
return CollectionStrategyTools.GenerateKeys(_list.Count); | ||
} | ||
|
||
public object ElementAt(string key) | ||
{ | ||
return _list[int.Parse(key)]; | ||
} | ||
|
||
public void Added(Entry entry, object addedValue) | ||
{ | ||
_toAdd.Add(addedValue); | ||
} | ||
|
||
public void Updated(Entry entry, object updatedValue) | ||
{ | ||
_list[int.Parse(entry.Identifier)] = updatedValue; | ||
} | ||
|
||
public void Removed(string key) | ||
{ | ||
_toDelete.Add(_list[int.Parse(key)]); | ||
} | ||
|
||
public void Flush() | ||
{ | ||
|
||
if(_property is PropertyInfo propertyInfo) | ||
{ | ||
var type = propertyInfo.PropertyType; | ||
var elementType = type.GenericTypeArguments[0]; | ||
var list = Array.CreateInstance(elementType,_list.Count - _toDelete.Count + _toAdd.Count); | ||
var index = 0; | ||
foreach (var e in _list) | ||
{ | ||
if (!_toDelete.Contains(e)) | ||
{ | ||
list.SetValue(e, index++); | ||
} | ||
} | ||
foreach(var e in _toAdd) | ||
{ | ||
list.SetValue(e, index++); | ||
} | ||
|
||
propertyInfo.SetValue(_instance, list); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.