Skip to content

Commit

Permalink
Refine.
Browse files Browse the repository at this point in the history
- <configSections> checker.
- Open also https://github.com/kenjiuno/Npgsql/releases
- grant prompt message.
  • Loading branch information
kenjiuno committed Dec 22, 2015
1 parent 1beaaba commit 62df37f
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 53 deletions.
84 changes: 50 additions & 34 deletions src/NpgsqlDdexProvider/CheckNpgsqlForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 79 additions & 17 deletions src/NpgsqlDdexProvider/CheckNpgsqlForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,9 @@ private void bEFv5_Click(object sender, EventArgs e) {
}

private void UnsuggestAll() {
UnsuggestIt(llGrab);
UnsuggestIt(llADONet);
UnsuggestIt(llProvider);
UnsuggestIt(llEFv5);
UnsuggestIt(llEFv6);
UnsuggestIt(llRestart);
UnsuggestIt(llBuild);
foreach (var ll in tabPage3.Controls.OfType<LinkLabel>()) {
UnsuggestIt(ll);
}
}

private void SuggestIt(LinkLabel ll) {
Expand Down Expand Up @@ -163,7 +159,7 @@ void CheckEF(bool v6) {
Log(loc2, Color.Blue);
Newl();

Log("Check if 2 Npgsql assemblies are equivalent... ");
Log("Check if 2 Npgsql assemblies have equivalent file path... ");
if (loc1.Equals(loc2)) {
Log("Yes", Color.Blue);
Newl();
Expand Down Expand Up @@ -430,16 +426,33 @@ void CheckEF(bool v6) {
Log("Yes", Color.Blue);
Newl();

Log("Check <section name=\"entityFramework\" ...>... ");
var el3 = el2.SelectSingleNode("section[@name='entityFramework']") as XmlElement;
if (el3 != null) {
Log("Yes", Color.Blue);
Newl();
{
Log("Check <section name=\"entityFramework\" ...>... ");
var el3 = el2.SelectSingleNode("section[@name='entityFramework']") as XmlElement;
if (el3 != null) {
Log("Yes", Color.Blue);
Newl();

}
else {
Log("No", Color.Red);
Newl();
}
}
else {
Log("No", Color.Red);
Newl();

{
Log("Check <configSections> is located at first element... ");
var el3 = el2.PreviousSibling as XmlElement;
if (el3 == null) {
Log("Yes", Color.Blue);
Newl();
}
else {
Log("No", Color.Red);
Newl();

SuggestIt(llConfigSections);
}
}
}
else {
Expand Down Expand Up @@ -558,8 +571,17 @@ private bool TryOpen(String url) {
return false;
}

private bool TryOpen2(params String[] urls) {
if (MessageBox.Show(this, "Open them?\n\n" + String.Join("\n", urls), null, MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) {
foreach (var url in urls)
System.Diagnostics.Process.Start(url);
return true;
}
return false;
}

private void llGrab_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
if (TryOpen("https://github.com/npgsql/npgsql/releases")) {
if (TryOpen2("https://github.com/npgsql/npgsql/releases", "https://github.com/kenjiuno/Npgsql/releases")) {
//UnsuggestIt((LinkLabel)sender);
}
}
Expand Down Expand Up @@ -717,6 +739,7 @@ private void llEFv5_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
IVsPackageInstaller installer = componentModel.GetService<IVsPackageInstaller>();
installer.InstallPackage(null, proj, "EntityFramework5.Npgsql", typeof(NpgsqlConnection).Assembly.GetName().Version, false);

UnsuggestIt(llEFv5);
MessageBox.Show(this, "Done.", null, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception err) {
Expand All @@ -735,11 +758,50 @@ private void llEFv6_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
IVsPackageInstaller installer = componentModel.GetService<IVsPackageInstaller>();
installer.InstallPackage(null, proj, "EntityFramework6.Npgsql", typeof(NpgsqlConnection).Assembly.GetName().Version, false);

UnsuggestIt(llEFv6);
MessageBox.Show(this, "Done.", null, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception err) {
MessageBox.Show(this, "InstallPackage failed.\n\n" + err, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}

private void llConfigSections_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
if (MessageBox.Show(this, "Are you really?", null, MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) {
var proj = GetActiveProject();
if (proj != null) {
String fpXml = null;
foreach (EnvDTE.ProjectItem pi in proj.ProjectItems) {
if (false
|| "App.config".Equals(pi.Name, StringComparison.InvariantCultureIgnoreCase)
|| "Web.config".Equals(pi.Name, StringComparison.InvariantCultureIgnoreCase)
) {
fpXml = pi.FileNames[1];
break;
}
}
if (fpXml != null) {
XmlDocument xd = new XmlDocument();
xd.Load(fpXml);

var el2 = xd.SelectSingleNode("/configuration/configSections") as XmlElement;
if (el2 != null) {
if (el2.PreviousSibling as XmlElement != null) {
var el1 = el2.ParentNode as XmlElement;
el1.PrependChild(el2);

xd.Save(fpXml);
MessageBox.Show(this, "Done.", null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
UnsuggestIt((LinkLabel)sender);
return;
}
}
}
}
}

MessageBox.Show(this, "Not changed.", null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
}
}
Loading

0 comments on commit 62df37f

Please sign in to comment.