Skip to content

Commit

Permalink
Update to .NET Core, part 2: source code
Browse files Browse the repository at this point in the history
  • Loading branch information
anders9ustafsson committed Feb 14, 2017
1 parent dbb966b commit 14b9199
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion EvilDICOM/EvilDICOM/Core/Helpers/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static class Constants
public static string EVIL_DICOM_IMP_UID = "1.2.598.0.1.2851334.2.1865.1";

public static string EVIL_DICOM_IMP_VERSION =
new AssemblyName(Assembly.GetCallingAssembly().FullName).Version.ToString();
new AssemblyName(Assembly.GetEntryAssembly().FullName).Version.ToString();

//APPLICATION CONTEXT
public static string DEFAULT_APPLICATION_CONTEXT = "1.2.840.10008.3.1.1.1";
Expand Down
4 changes: 4 additions & 0 deletions EvilDICOM/EvilDICOM/Network/DICOMSCP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ private void SpinUpAssociation(TcpClient client)
Logger.Log(asc.ToString());
asc.Listen();
Logger.Log("Closing association with {0}.", asc.IpAddress, asc.Port);
#if NET45
client.Close();
#else
client.Dispose();
#endif
});
}

Expand Down
6 changes: 3 additions & 3 deletions EvilDICOM/EvilDICOM/Network/DICOMSCU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public DICOMSCU(Entity ae) : base(ae) { }
public void SendMessage(AbstractDIMSERequest dimse, Entity ae)
{
var client = new TcpClient();
client.Connect(IPAddress.Parse(ae.IpAddress), ae.Port);
client.ConnectAsync(IPAddress.Parse(ae.IpAddress), ae.Port).Wait();
var assoc = new Association(this, client) { AeTitle = ae.AeTitle };
PDataMessenger.Send(dimse, assoc);
assoc.Listen();
Expand All @@ -30,7 +30,7 @@ public void SendMessage(AbstractDIMSERequest dimse, Entity ae)
public IEnumerable<CFindResponse> GetResponse(CFindRequest cFind, Entity ae)
{
var client = new TcpClient();
client.Connect(IPAddress.Parse(ae.IpAddress), ae.Port);
client.ConnectAsync(IPAddress.Parse(ae.IpAddress), ae.Port).Wait();
var assoc = new Association(this, client) { AeTitle = ae.AeTitle };
PDataMessenger.Send(cFind, assoc);
List<CFindResponse> responses = new List<CFindResponse>();
Expand All @@ -52,7 +52,7 @@ public IEnumerable<CFindResponse> GetResponse(CFindRequest cFind, Entity ae)
public IEnumerable<CMoveResponse> GetResponse(CMoveRequest cMove, Entity ae)
{
var client = new TcpClient();
client.Connect(IPAddress.Parse(ae.IpAddress), ae.Port);
client.ConnectAsync(IPAddress.Parse(ae.IpAddress), ae.Port).Wait();
var assoc = new Association(this, client) { AeTitle = ae.AeTitle };
PDataMessenger.Send(cMove, assoc);
List<CMoveResponse> responses = new List<CMoveResponse>();
Expand Down
3 changes: 1 addition & 2 deletions EvilDICOM/EvilDICOM/Network/DIMSE/IOD/CFindImageIOD.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.Serialization;
using EvilDICOM.Core.Element;
using EvilDICOM.Core.Element;
using EvilDICOM.Network.Enums;
using S = System;
using DF = EvilDICOM.Core.DICOMForge;
Expand Down
3 changes: 1 addition & 2 deletions EvilDICOM/EvilDICOM/Network/DIMSE/IOD/CFindSeriesIOD.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.Serialization;
using EvilDICOM.Core.Element;
using EvilDICOM.Core.Element;
using EvilDICOM.Network.Enums;
using S = System;
using DF = EvilDICOM.Core.DICOMForge;
Expand Down
3 changes: 1 addition & 2 deletions EvilDICOM/EvilDICOM/Network/DIMSE/IOD/CFindStudyIOD.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.Serialization;
using EvilDICOM.Core.Element;
using EvilDICOM.Core.Element;
using EvilDICOM.Network.Enums;
using S = System;
using DF = EvilDICOM.Core.DICOMForge;
Expand Down
2 changes: 1 addition & 1 deletion EvilDICOM/EvilDICOM/Network/Extensions/IIODExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static string GetLogString(this IIOD iod)
sb.AppendLine("-----------------------------------");
Type t = iod.GetType();
sb.AppendLine(t.Name);
foreach (PropertyInfo pi in t.GetProperties())
foreach (PropertyInfo pi in t.GetTypeInfo().GetProperties())
{
string name = pi.Name;
if (pi.Name != "Elements" && pi.Name != "LogString")
Expand Down
2 changes: 1 addition & 1 deletion EvilDICOM/EvilDICOM/Network/Helpers/IpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static string LocalIPAddress()
{
IPHostEntry host;
string localIP = "";
host = Dns.GetHostEntry(Dns.GetHostName());
host = Dns.GetHostEntryAsync(Dns.GetHostName()).Result;
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
Expand Down
2 changes: 1 addition & 1 deletion EvilDICOM/EvilDICOM/Network/Interfaces/IMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ namespace EvilDICOM.Network.Interfaces
public interface IMessage
{
MessageType Type { get; }
dynamic DynPayload { get; }
object DynPayload { get; }
}
}
2 changes: 1 addition & 1 deletion EvilDICOM/EvilDICOM/Network/Messaging/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Message<T> : IMessage
public T Payload { get; set; }
public MessageType Type { get; set; }

public dynamic DynPayload
public object DynPayload
{
get { return Payload; }
}
Expand Down
2 changes: 1 addition & 1 deletion EvilDICOM/EvilDICOM/Network/PDUs/Items/ItemWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static void WritePDVFragmentMessageHeader(DICOMBinaryWriter dw, PDVItemF
bits.Set(0, frag.IsCommandObject);
bits.Set(1, frag.IsLastItem);
var bytes = new byte[1];
bits.CopyTo(bytes, 0);
((ICollection)bits).CopyTo(bytes, 0);
dw.Write(bytes[0]);
}

Expand Down

0 comments on commit 14b9199

Please sign in to comment.