Skip to content

Commit

Permalink
Reorganize code.
Browse files Browse the repository at this point in the history
Decouple Send & Listen logic.
Better "Identity" handling.
Better "Software ID" handling.
File logging option
  • Loading branch information
xmegz committed Nov 2, 2018
1 parent da2a5c9 commit 807defc
Show file tree
Hide file tree
Showing 14 changed files with 948 additions and 280 deletions.
Binary file modified MndpTray/MndpTray/Images/favicon.ico
Binary file not shown.
6 changes: 4 additions & 2 deletions MndpTray/MndpTray/MndpTray.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Protocol\MndpDebug.cs" />
<Compile Include="Protocol\MndpExtensions.cs" />
<Compile Include="Protocol\MndpHost.cs" />
<Compile Include="Protocol\MndpSender.cs" />
<Compile Include="Visual\ListForm.cs">
<SubType>Form</SubType>
</Compile>
Expand All @@ -84,9 +87,8 @@
<Compile Include="Visual\NotifyContext.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Extensions\Extensions.cs" />
<Compile Include="Protocol\MndpMessage.cs" />
<Compile Include="Protocol\MndpThread.cs" />
<Compile Include="Protocol\MndpListener.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
Expand Down
4 changes: 2 additions & 2 deletions MndpTray/MndpTray/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
48 changes: 48 additions & 0 deletions MndpTray/MndpTray/Protocol/MndpDebug.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.IO;
using System.Reflection;

namespace MndpTray.Protocol
{
public static class MndpDebug
{
#region Variables
private static string LOG_FILE_NAME = Assembly.GetEntryAssembly().GetLocationWithExtension("txt");
private static bool LOG_IS_ENABLED = File.Exists(LOG_FILE_NAME);
private static object LOG_FILE_LOCK = new object();
#endregion

private static void File_WriteLine(string str)
{
if (!LOG_IS_ENABLED) return;

str = string.Concat("<", DateTime.Now.ToString(), "> ", str, "\r\n");

lock (LOG_FILE_LOCK)
{
File.AppendAllText(LOG_FILE_NAME, str);
}
}

public static void Debug(string format, params object[] args)
{
try
{
String str = String.Format(format, args);

System.Diagnostics.Debug.WriteLine(str);
File_WriteLine(str);
}
catch { }
}

public static void DebugException(string className, string methodName, Exception ex)
{
try
{
Debug("{0}, {1} Exception:\r\n {2}", className, methodName, ex.ToString());
}
catch { }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
using System;
using System.IO;
using System.Reflection;

namespace MndpTray
namespace MndpTray.Protocol
{
public static class AssembyExtension
{
public static string GetLocationWithExtension(this Assembly self, string extension)
{
string dir = Path.GetDirectoryName(self.Location);
string file = Path.GetFileNameWithoutExtension(self.Location);

file = Path.Combine(dir, file);
return file + "." + extension;
}
}

public static class BinaryReaderExtensions
{
public static UInt16 ReadUInt16Reverse(this BinaryReader self)
Expand Down
Loading

0 comments on commit 807defc

Please sign in to comment.