Skip to content

Commit fe69587

Browse files
committed
Remove Newtonsoft.Json as requirement to make it a single file
1 parent dfafbfd commit fe69587

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

ProcessAffinityWatcher/MainForm.cs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System.Windows.Forms;
1010
using System.Diagnostics;
1111
using System.Collections;
12-
using Newtonsoft.Json;
1312

1413
namespace ProcessAffinityWatcher
1514
{
@@ -211,17 +210,39 @@ private void ChkCPU_CheckedChanged(object sender, EventArgs e)
211210
private Dictionary<string, int> GetAffinitySettings()
212211
{
213212
//Debug.WriteLine("Settings loaded: " + Properties.Settings.Default.AffinitySettings);
214-
Dictionary<string, int> settings = JsonConvert.DeserializeObject<Dictionary<string, int>>(Properties.Settings.Default.AffinitySettings);
215-
if (settings == null)
213+
214+
Dictionary<string, int> settings = new Dictionary<string, int>();
215+
string s = Properties.Settings.Default.AffinitySettings;
216+
if(s != null && s.Length > 0)
216217
{
217-
settings = new Dictionary<string, int>();
218+
string[] parts = s.Split('\\');
219+
foreach (string p in parts)
220+
{
221+
string[] processAffinity = p.Split(new char[1] { ':' }, 2);
222+
if(processAffinity.Length == 2)
223+
{
224+
try
225+
{
226+
settings.Add(processAffinity[0], int.Parse(processAffinity[1]));
227+
} catch { }
228+
}
229+
}
218230
}
231+
219232
return settings;
220233
}
221234

222235
private void SaveAffinitySettings(Dictionary<string, int> settings)
223236
{
224-
Properties.Settings.Default.AffinitySettings = JsonConvert.SerializeObject(settings);
237+
string[] parts = new string[settings.Count];
238+
int i = 0;
239+
foreach(string key in settings.Keys)
240+
{
241+
parts[i] = key + ":" + settings[key];
242+
i++;
243+
}
244+
245+
Properties.Settings.Default.AffinitySettings = String.Join("\\", parts);
225246
Properties.Settings.Default.Save();
226247
}
227248

@@ -351,7 +372,7 @@ private void MainForm_Resize(object sender, EventArgs e)
351372

352373
private void btnInfo_Click(object sender, EventArgs e)
353374
{
354-
MessageBox.Show("Created by Pakl (pakl.dev) under the MIT license.\nIncludes Newtonsoft.Json. JamesNK/Newtonsoft.Json is licensed under the MIT License.\n\nThe MIT License (MIT)\n\nProcessAffinityWatcher Copyright(c) 2022 Pascal Pohl\nNewtonsoft.Json Copyright(c) 2007 James Newton - King\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", "Product Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
375+
MessageBox.Show("Created by Pakl (pakl.dev) under the MIT license.\n\nThe MIT License (MIT)\n\nCopyright(c) 2022 Pascal Pohl\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", "Product Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
355376
}
356377
}
357378

-686 KB
Binary file not shown.

ProcessAffinityWatcher/ProcessAffinityWatcher.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@
7070
<TargetZone>LocalIntranet</TargetZone>
7171
</PropertyGroup>
7272
<ItemGroup>
73-
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
74-
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
75-
</Reference>
7673
<Reference Include="System" />
7774
<Reference Include="System.Core" />
7875
<Reference Include="System.Xml.Linq" />
@@ -107,7 +104,6 @@
107104
<DependentUpon>Resources.resx</DependentUpon>
108105
</Compile>
109106
<None Include="app.manifest" />
110-
<None Include="packages.config" />
111107
<None Include="Properties\Settings.settings">
112108
<Generator>SettingsSingleFileGenerator</Generator>
113109
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -135,7 +131,6 @@
135131
</ItemGroup>
136132
<ItemGroup>
137133
<Content Include="cpuaffinity.ico" />
138-
<EmbeddedResource Include="Newtonsoft.Json.dll" />
139134
</ItemGroup>
140135
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
141136
</Project>

ProcessAffinityWatcher/packages.config

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)