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

FIX: work with ComposerPro v2.10.6 #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
32 changes: 15 additions & 17 deletions UI/Composer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,18 @@ public Composer( MainWindow MainWindow )
InitializeComponent();
}

private void PatchComposer( object sender, EventArgs eventargs )
private void PatchComposer(object sender, EventArgs eventargs)
{
var oldLine = @" <system.net>
<connectionManagement>
<add address=""*"" maxconnection=""20"" />
</connectionManagement>
</system.net>";
var oldLinePattern = @"<system\.net>\s*<connectionManagement>\s*<add address=""\*"" maxconnection=""20"" />\s*</connectionManagement>\s*</system\.net>";

var newLine = @" <system.net>
<connectionManagement>
<add address=""*"" maxconnection=""20"" />
</connectionManagement>
<defaultProxy>
<proxy usesystemdefault=""false"" proxyaddress=""http://127.0.0.1:31337/"" bypassonlocal=""True""/>
</defaultProxy>
</system.net>
<connectionManagement>
<add address=""*"" maxconnection=""20"" />
</connectionManagement>
<defaultProxy>
<proxy usesystemdefault=""false"" proxyaddress=""http://127.0.0.1:31337/"" bypassonlocal=""True""/>
</defaultProxy>
</system.net>

";

Expand Down Expand Up @@ -70,11 +67,12 @@ private void PatchComposer( object sender, EventArgs eventargs )

var contents = System.IO.File.ReadAllText( open.FileName );

if ( !contents.Contains( oldLine ) )
{
var regex = new Regex(oldLinePattern, RegexOptions.Singleline);
if (!regex.IsMatch(contents))
{
log.WriteHighlight( "Couldn't find the line - probably already patched??" );
return;
}
}

log.WriteHighlight( $"Writing Backup..\n" );
System.IO.File.WriteAllText( open.FileName + $".backup-{DateTime.Now.ToString( "yyyy-dd-M--HH-mm-ss" )}", contents );
Expand All @@ -86,7 +84,7 @@ private void PatchComposer( object sender, EventArgs eventargs )
log.WriteHighlight( $"Done!\n" );
}

private void SearchGoogleForComposer( object sender, EventArgs e )
private void SearchGoogleForComposer( object sender, EventArgs e )
{
System.Diagnostics.Process.Start( $"https://www.google.com/search?q=ComposerPro-3.1.3.574885-res.exe" );
}
Expand Down