Skip to content

Commit

Permalink
Initial commit moving from CodePlex; change license
Browse files Browse the repository at this point in the history
  • Loading branch information
tfabraham committed Sep 12, 2017
1 parent b6c519c commit 3d5759d
Show file tree
Hide file tree
Showing 19 changed files with 2,923 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,6 @@ __pycache__/
*.btm.cs
*.odx.cs
*.xsd.cs

# Environment Settings Manager
Staging/
23 changes: 23 additions & 0 deletions EnvironmentSettingsManager.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="BuildExporter;PackageMain">
<PropertyGroup>
<Version>1_6_1</Version>
</PropertyGroup>

<ItemGroup>
<Main Include=".\docs\EnvironmentSettingsManagerGuide.pdf" />
<Main Include=".\template\EnvironmentSettingsTemplate.xml" />
<Main Include=".\template\EnvironmentSettingsTemplate.xls" />
<Main Include="License.txt" />
<Main Include=".\src\Exporter\bin\release\EnvironmentSettingsExporter.exe" />
</ItemGroup>

<Target Name="BuildExporter">
<MSBuild Projects="src\EnvironmentSettingsExporter.sln" Properties="Configuration=Release" Targets="Rebuild" />
</Target>

<Target Name="PackageMain">
<Delete Files="Staging\EnvironmentSettingsManagerV$(Version).zip" />
<Exec Command="tools\7za a -r -tzip Staging\EnvironmentSettingsManagerV$(Version).zip @(Main)" Condition="%(Identity) == %(Identity)" />
</Target>
</Project>
Binary file added docs/EnvironmentSettingsManagerGuide.docx
Binary file not shown.
Binary file added docs/EnvironmentSettingsManagerGuide.pdf
Binary file not shown.
20 changes: 20 additions & 0 deletions src/EnvironmentSettingsExporter.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EnvironmentSettingsExporter", "Exporter\EnvironmentSettingsExporter.csproj", "{85638D48-F3E0-4F88-BBDF-3884687770EE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{85638D48-F3E0-4F88-BBDF-3884687770EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85638D48-F3E0-4F88-BBDF-3884687770EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85638D48-F3E0-4F88-BBDF-3884687770EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85638D48-F3E0-4F88-BBDF-3884687770EE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
37 changes: 37 additions & 0 deletions src/Exporter/DataTableToAppSettingsXmlExporter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// (c) Copyright 2007-10 Thomas F. Abraham.
// This source is subject to the Microsoft Public License (Ms-PL).
// See http://www.opensource.org/licenses/ms-pl.html
// All other rights reserved.

using System.Xml;

namespace EnvironmentSettingsExporter
{
/// <summary>
/// Export the settings contained in a DataTable to multiple XML files, one per declared environment.
/// The output XML format is the .NET appSettings structure.
/// </summary>
internal class DataTableToAppSettingsXmlExporter : DataTableToXmlExporter
{
protected override void WriteHeader(XmlWriter xmlw, string environmentName)
{
xmlw.WriteStartElement("appSettings");
}

protected override void WriteValue(XmlWriter xmlw, string settingName, string settingValue, string environmentName, bool valueContainsReservedXmlCharacter)
{
xmlw.WriteStartElement("add");
xmlw.WriteAttributeString("key", settingName);

// Write the value to the XML stream
xmlw.WriteAttributeString("value", settingValue);

xmlw.WriteEndElement();
}

protected override void WriteFooter(XmlWriter xmlw, string environmentName)
{
xmlw.WriteEndElement();
}
}
}
91 changes: 91 additions & 0 deletions src/Exporter/DataTableToWixCustomTableXmlExporter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// (c) Copyright 2007-10 Thomas F. Abraham.
// This source is subject to the Microsoft Public License (Ms-PL).
// See http://www.opensource.org/licenses/ms-pl.html
// All other rights reserved.

using System.Xml;

namespace EnvironmentSettingsExporter
{
/// <summary>
/// Export the settings contained in a DataTable to a single XML file.
/// The output format is a WiX (Windows Installer XML) include file containing a custom table.
/// </summary>
internal class DataTableToWixCustomTableXmlExporter : DataTableToXmlExporter
{
private int index = 1;

protected override void WriteHeader(XmlWriter xmlw, string environmentName)
{
xmlw.WriteStartElement("include");

xmlw.WriteStartElement("CustomTable");
xmlw.WriteAttributeString("Id", "EnvironmentSettings");

xmlw.WriteStartElement("Column");
xmlw.WriteAttributeString("Id", "Id");
xmlw.WriteAttributeString("Category", "Identifier");
xmlw.WriteAttributeString("PrimaryKey", "yes");
xmlw.WriteAttributeString("Type", "int");
xmlw.WriteAttributeString("Width", "4");
xmlw.WriteEndElement();

xmlw.WriteStartElement("Column");
xmlw.WriteAttributeString("Id", "Environment");
xmlw.WriteAttributeString("Category", "Text");
xmlw.WriteAttributeString("Type", "string");
xmlw.WriteAttributeString("PrimaryKey", "no");
xmlw.WriteEndElement();

xmlw.WriteStartElement("Column");
xmlw.WriteAttributeString("Id", "Key");
xmlw.WriteAttributeString("Category", "Text");
xmlw.WriteAttributeString("Type", "string");
xmlw.WriteAttributeString("PrimaryKey", "no");
xmlw.WriteEndElement();

xmlw.WriteStartElement("Column");
xmlw.WriteAttributeString("Id", "Value");
xmlw.WriteAttributeString("Category", "Text");
xmlw.WriteAttributeString("Type", "string");
xmlw.WriteAttributeString("PrimaryKey", "no");
xmlw.WriteAttributeString("Nullable", "yes");
xmlw.WriteEndElement();
}

protected override void WriteValue(XmlWriter xmlw, string settingName, string settingValue, string environmentName, bool valueContainsReservedXmlCharacter)
{
xmlw.WriteStartElement("Row");

xmlw.WriteStartElement("Data");
xmlw.WriteAttributeString("Column", "Id");
xmlw.WriteValue(index);
xmlw.WriteEndElement();

xmlw.WriteStartElement("Data");
xmlw.WriteAttributeString("Column", "Environment");
xmlw.WriteValue(environmentName);
xmlw.WriteEndElement();

xmlw.WriteStartElement("Data");
xmlw.WriteAttributeString("Column", "Key");
xmlw.WriteValue(settingName);
xmlw.WriteEndElement();

xmlw.WriteStartElement("Data");
xmlw.WriteAttributeString("Column", "Value");
xmlw.WriteValue(settingValue);
xmlw.WriteEndElement();

xmlw.WriteEndElement();

index++;
}

protected override void WriteFooter(XmlWriter xmlw, string environmentName)
{
xmlw.WriteEndElement();
xmlw.WriteEndElement();
}
}
}
Loading

0 comments on commit 3d5759d

Please sign in to comment.