Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C#7.3 Compatibility, .Net Standart 2.0 #106

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Stira.WpfCore"]
path = Stira.WpfCore
url = https://github.com/Touseefelahi/Stira.WpfCore.git
2 changes: 1 addition & 1 deletion DeviceControl.Wpf/DeviceControl.Wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>library</OutputType>
<AssemblyName>DeviceControl.Wpf</AssemblyName>
<TargetFrameworks>net5.0-windows;net6.0-windows</TargetFrameworks>
<TargetFrameworks>net5.0</TargetFrameworks>
<UseWPF>true</UseWPF>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
1 change: 0 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project>
<PropertyGroup>
<Nullable>enable</Nullable>
<AvaloniaVersion>11.0.2</AvaloniaVersion>
</PropertyGroup>
</Project>
3 changes: 1 addition & 2 deletions GenICam.Tests/GenICam.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<Nullable>enable</Nullable>
<TargetFrameworks>net5.0</TargetFrameworks>

<IsPackable>false</IsPackable>

Expand Down
2 changes: 1 addition & 1 deletion GenICam.Tests/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void MathParser(string formula)

[Theory]
[InlineData("(8))")]
[InlineData("((8)")]
[InlineData("(8")]
public void GetBracket(string formula)
{
var expected = "(8)";
Expand Down
2 changes: 1 addition & 1 deletion GenICam/Exceptions/GenICamException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class GenICamException : Exception
/// </summary>
/// <param name="message">error message</param>
/// <param name="inner">inner exception that holds the original exception</param>
public GenICamException(string message, Exception? inner = null)
public GenICamException(string message, Exception inner = null)
: base(message, inner)
{
}
Expand Down
2 changes: 1 addition & 1 deletion GenICam/GenICam.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Platforms>x64</Platforms>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2.2</Version>
Expand Down
15 changes: 8 additions & 7 deletions GenICam/Helpers/MathParserHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace GenICam
/// </summary>
public class MathParserHelper
{
private static readonly List<char> opreations = new() { '(', '+', '-', '/', '*', '=', '?', ':', ')', '>', '<', '&', '|', '^', '~', '%' };
private static readonly List<char> opreations = new List<char>() { '(', '+', '-', '/', '*', '=', '?', ':', ')', '>', '<', '&', '|', '^', '~', '%' };

/// <summary>
/// Prepare a formula.
Expand Down Expand Up @@ -46,17 +46,18 @@ public static string PrepareFromula(string formula, Dictionary<string, string> e
/// <returns>The result.</returns>
public static double CalculateExpression(string experssion)
{
//throw new NotImplementedException();
try
{
if (experssion.Contains("?"))
{
var cases = experssion.Split(':', 2);
var subs = cases[0].Split("?", 2);
var cases = experssion.Split(new char[] { ':' }, 2);
var subs = cases[0].Split(new char[] { '?' }, 2);

experssion = $"if({GetBracketed(subs[0])}, {GetBracketed(subs[1])}, {CalculateExpression(GetBracketed(cases[1]))})";
}

return new Expression(experssion).calculate();
return new Expression(GetBracketed(experssion)).calculate();
}
catch (Exception ex)
{
Expand Down Expand Up @@ -96,7 +97,7 @@ public static string GetBracketed(string formula)

while (openBracketCounter > 0)
{
formula = formula.Remove(0, 1);
formula += ")";
--openBracketCounter;
}

Expand Down Expand Up @@ -149,7 +150,7 @@ public static double Evaluate(string expression)
{
if (word.StartsWith("0x"))
{
values.Push(long.Parse(word[2..], System.Globalization.NumberStyles.HexNumber));
values.Push(long.Parse(word.Substring(2), System.Globalization.NumberStyles.HexNumber));

// valuesList.Last().Push(values.Peek());
}
Expand Down Expand Up @@ -622,7 +623,7 @@ private string EvaluateFormula(string formula)
double result;
string equation;

foreach (var item in formula.Split('(', StringSplitOptions.None))
foreach (var item in formula.Split('('))
{
equation = item;
if (item.Contains(')'))
Expand Down
4 changes: 2 additions & 2 deletions GenICam/Interfaces/Helpers/IPValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ public interface IPValue
/// Gets the value async.
/// </summary>
/// <returns>The value as long.</returns>
public Task<long?> GetValueAsync();
Task<long?> GetValueAsync();

/// <summary>
/// Sets the value async.
/// </summary>
/// <param name="value">The value to set.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
public Task<IReplyPacket> SetValueAsync(long value);
Task<IReplyPacket> SetValueAsync(long value);
}
}
20 changes: 10 additions & 10 deletions GenICam/Interfaces/Helpers/IReplyPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,53 @@ public interface IReplyPacket
/// <summary>
/// Gets or sets error to display if any.
/// </summary>
public string Error { get; set; }
string Error { get; set; }

/// <summary>
/// Gets or sets iP address of the sender.
/// </summary>
public string IPSender { get; set; }
string IPSender { get; set; }

/// <summary>
/// Gets or sets a value indicating whether command sent.
/// </summary>
public bool IsSent { get; set; }
bool IsSent { get; set; }

/// <summary>
/// Gets or sets a value indicating whether command Sent and camera replied.
/// </summary>
public bool IsSentAndReplyReceived { get; set; }
bool IsSentAndReplyReceived { get; set; }

/// <summary>
/// Gets or sets sending Port.
/// </summary>
public int PortSender { get; set; }
int PortSender { get; set; }

/// <summary>
/// Gets raw reply packet.
/// </summary>
public List<byte> Reply { get; }
List<byte> Reply { get; }

/// <summary>
/// Gets or sets register value.
/// </summary>
public uint RegisterValue { get; set; }
uint RegisterValue { get; set; }

/// <summary>
/// Gets or sets memory Value.
/// </summary>
public byte[] MemoryValue { get; set; }
byte[] MemoryValue { get; set; }

/// <summary>
/// It sets the list of byte.
/// </summary>
/// <param name="reply">The reply bytes.</param>
public void SetReply(byte[] reply);
void SetReply(byte[] reply);

/// <summary>
/// It sets the list of byte.
/// </summary>
/// <param name="reply">The reply bytes.</param>
public void SetReply(List<byte> reply);
void SetReply(List<byte> reply);
}
}
4 changes: 2 additions & 2 deletions GenICam/Interfaces/IBoolean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ public interface IBoolean
/// Gets the value async.
/// </summary>
/// <returns>The value as boolean.</returns>
public Task<bool> GetValueAsync();
Task<bool> GetValueAsync();

/// <summary>
/// Sets the value async.
/// </summary>
/// <param name="value">The value to set.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
public Task<IReplyPacket> SetValueAsync(bool value);
Task<IReplyPacket> SetValueAsync(bool value);
}
}
6 changes: 3 additions & 3 deletions GenICam/Interfaces/ICategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ public interface ICategory
/// <summary>
/// Gets the category properties.
/// </summary>
public CategoryProperties CategoryProperties { get; }
CategoryProperties CategoryProperties { get; }

/// <summary>
/// Gets or sets the PFeatures.
/// </summary>
public List<ICategory> PFeatures { get; set; }
List<ICategory> PFeatures { get; set; }

/// <summary>
/// Gets the PValue.
/// </summary>
public IPValue PValue { get; }
IPValue PValue { get; }
}
}
4 changes: 2 additions & 2 deletions GenICam/Interfaces/ICommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public interface ICommand
/// Submits the command.
/// </summary>
/// <returns>A task.</returns>
public Task <IReplyPacket>Execute();
Task <IReplyPacket>Execute();

/// <summary>
/// Returns true if the command has been executed; false as long as it still executes.
/// </summary>
/// <returns>True when it's finished.</returns>
public Task<bool> IsDone();
Task<bool> IsDone();
}
}
12 changes: 6 additions & 6 deletions GenICam/Interfaces/IEnumeration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ public interface IEnumeration
/// Gets the index value corresponding to the enumeration value.
/// </summary>
/// <returns>The index value as a long.</returns>
public Task<long> GetValueAsync();
Task<long> GetValueAsync();

/// <summary>
/// Sets the index value corresponding to the enumeration value.
/// </summary>
/// <param name="value">The index value to set.</param>
/// <returns>A task.</returns>
public Task<IReplyPacket> SetValueAsync(long value);
Task<IReplyPacket> SetValueAsync(long value);

/// <summary>
/// Gets the entries of the enumeration.
/// </summary>
/// <returns>A dictionation with the enumeration values.</returns>
public Dictionary<string, EnumEntry> GetEntries();
Dictionary<string, EnumEntry> GetEntries();

/// <summary>
/// Returns a list of valid enumeration values.
Expand All @@ -42,22 +42,22 @@ public interface IEnumeration
/// <param name="entryName">The entry name.</param>
/// <returns>An enumeration entry.</returns>
[Obsolete]
public EnumEntry GetEntryByName(string entryName);
EnumEntry GetEntryByName(string entryName);

/// <summary>
/// Gets the entry.
/// </summary>
/// <param name="entryValue">The entry index value.</param>
/// <returns>An enumeration entry.</returns>
[Obsolete]
public KeyValuePair<string, EnumEntry> GetEntry(long entryValue);
KeyValuePair<string, EnumEntry> GetEntry(long entryValue);

/// <summary>
/// Get the current entry.
/// </summary>
/// <param name="entryValue">The entry index value.</param>
/// <returns>An enumeration entry.</returns>
[Obsolete]
public KeyValuePair<string, EnumEntry> GetCurrentEntry();
KeyValuePair<string, EnumEntry> GetCurrentEntry();
}
}
Loading