Skip to content

Commit

Permalink
Started new GUI Configurator
Browse files Browse the repository at this point in the history
related issues: #8, #9, #11, #14
  • Loading branch information
3F committed Sep 30, 2016
1 parent e5c64ec commit ba0da45
Show file tree
Hide file tree
Showing 42 changed files with 2,526 additions and 453 deletions.
22 changes: 11 additions & 11 deletions .vssbe
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@
"Mode": {
"$type": "net.r_eg.vsSBE.Events.ModeScript, vsSolutionBuildEvent",
"Type": "Script",
"Command": "#[$(dbin = \"bin/$(Configuration)/\")]\n\n$(pDllExport = \"RGiesecke.DllExport\")\n$(pMeta = \"Metadata\")\n$(pNSBin = \"NSBin\")\n$(pMSBuild = \"RGiesecke.DllExport.MSBuild\")\n$(odir = \"$(dbin)raw/\")\n\n#[IO delete.directory(\"$(dbin)\", true)]\n#[IO copy.directory(\"\", \"$(dbin)\", true)]",
"Command": "#[$(dbin = \"bin/$(Configuration)/\")]\n\n$(pDllExport = \"RGiesecke.DllExport\")\n$(pMeta = \"Metadata\")\n$(pNSBin = \"NSBin\")\n$(pConf = \"Configurator\")\n$(pMSBuild = \"RGiesecke.DllExport.MSBuild\")\n$(odir = \"$(dbin)raw/\")\n\n#[IO delete.directory(\"$(dbin)\", true)]\n#[IO copy.directory(\"\", \"$(dbin)\", true)]",
"Command__": [
"#[$(dbin = \"bin/$(Configuration)/\")]",
"",
"$(pDllExport = \"RGiesecke.DllExport\")",
"$(pMeta = \"Metadata\")",
"$(pNSBin = \"NSBin\")",
"$(pConf = \"Configurator\")",
"$(pMSBuild = \"RGiesecke.DllExport.MSBuild\")",
"$(odir = \"$(dbin)raw/\")",
"",
Expand Down Expand Up @@ -167,7 +168,7 @@
"Mode": {
"$type": "net.r_eg.vsSBE.Events.ModeScript, vsSolutionBuildEvent",
"Type": "Script",
"Command": "#[IO copy.file(\n \"$(SolutionDir)tools/*.*\", \n \"$(odir)/tools/\", \n true, \n {\"*.nuspec\"})]\n\n#[IO copy.file(\"tools/DllExport.nuspec\", \"$(odir)/DllExport.nuspec\", true)]\n\n#[IO copy.file(\"$(pDllExport)/$(OutDir:$(pDllExport))/*.*\", \n \"$(odir)/tools/\", true)]\n\n#[IO copy.file(\"$(pMSBuild)/$(OutDir:$(pMSBuild))/*.*\", \n \"$(odir)/tools/\", true)]\n \n#[IO copy.file(\"$(pMeta)/$(OutDir:$(pMeta))/*.dll\", \n \"$(odir)/lib/net20/\", true)]\n\n#[IO copy.file(\"$(pNSBin)/$(OutDir:$(pNSBin))/*.*\", \n \"$(odir)/tools/\", true)]\n\n#[IO copy.file(\"LICENSE\", \"$(odir)/\", true)]\n#[IO copy.file(\"Readme.md\", \"$(odir)/\", true)]",
"Command": "#[IO copy.file(\n \"$(SolutionDir)tools/*.*\", \n \"$(odir)/tools/\", \n true, \n {\"*.nuspec\"})]\n\n#[IO copy.file(\"tools/DllExport.nuspec\", \"$(odir)/DllExport.nuspec\", true)]\n\n#[IO copy.file({\n \"$(pDllExport)/$(OutDir:$(pDllExport))/*.*\",\n \"$(pMSBuild)/$(OutDir:$(pMSBuild))/*.*\",\n \"$(pNSBin)/$(OutDir:$(pNSBin))/*.*\",\n \"$(pConf)/$(OutDir:$(pConf))/*.*\"\n }, \n \"$(odir)/tools/\", true)]\n\n \n#[IO copy.file(\"$(pMeta)/$(OutDir:$(pMeta))/*.dll\", \n \"$(odir)/lib/net20/\", true)]\n\n#[IO copy.file({ \"LICENSE\", \"Readme.md\" }, \"$(odir)/\", true)]",
"Command__": [
"#[IO copy.file(",
" \"$(SolutionDir)tools/*.*\", ",
Expand All @@ -177,20 +178,19 @@
"",
"#[IO copy.file(\"tools/DllExport.nuspec\", \"$(odir)/DllExport.nuspec\", true)]",
"",
"#[IO copy.file(\"$(pDllExport)/$(OutDir:$(pDllExport))/*.*\", ",
" \"$(odir)/tools/\", true)]",
"#[IO copy.file({",
" \"$(pDllExport)/$(OutDir:$(pDllExport))/*.*\",",
" \"$(pMSBuild)/$(OutDir:$(pMSBuild))/*.*\",",
" \"$(pNSBin)/$(OutDir:$(pNSBin))/*.*\",",
" \"$(pConf)/$(OutDir:$(pConf))/*.*\"",
" }, ",
" \"$(odir)/tools/\", true)]",
"",
"#[IO copy.file(\"$(pMSBuild)/$(OutDir:$(pMSBuild))/*.*\", ",
" \"$(odir)/tools/\", true)]",
" ",
"#[IO copy.file(\"$(pMeta)/$(OutDir:$(pMeta))/*.dll\", ",
" \"$(odir)/lib/net20/\", true)]",
"",
"#[IO copy.file(\"$(pNSBin)/$(OutDir:$(pNSBin))/*.*\", ",
" \"$(odir)/tools/\", true)]",
"",
"#[IO copy.file(\"LICENSE\", \"$(odir)/\", true)]",
"#[IO copy.file(\"Readme.md\", \"$(odir)/\", true)]"
"#[IO copy.file({ \"LICENSE\", \"Readme.md\" }, \"$(odir)/\", true)]"
]
}
},
Expand Down
91 changes: 91 additions & 0 deletions Configurator/Configurator.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9B7723F1-C89F-43E1-B27D-A46A96C82034}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>net.r_eg.DllExport.Configurator</RootNamespace>
<AssemblyName>net.r_eg.DllExport.Configurator</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.PowerShell.5.ReferenceAssemblies.1.0.0\lib\net4\System.Management.Automation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="Dynamic\IProject.cs" />
<Compile Include="Dynamic\Project.cs" />
<Compile Include="Exceptions\InvalidObjectException.cs" />
<Compile Include="Exceptions\CommonException.cs" />
<Compile Include="IExecutor.cs" />
<Compile Include="Executor.cs" />
<Compile Include="InstallationForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="InstallationForm.Designer.cs">
<DependentUpon>InstallationForm.cs</DependentUpon>
</Compile>
<Compile Include="ScriptConfig.cs" />
<Compile Include="SetConfigurationCmdlet.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserConfig.cs" />
</ItemGroup>
<ItemGroup>
<None Include="key.snk" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="InstallationForm.resx">
<DependentUpon>InstallationForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NSBin\NSBin.csproj">
<Project>{311706a5-5ed2-4006-b794-055009d8a256}</Project>
<Name>NSBin</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
60 changes: 60 additions & 0 deletions Configurator/Dynamic/IProject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 Denis Kuzmin <[email protected]>
*
* Permission 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE 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.
*/

namespace net.r_eg.DllExport.Configurator.Dynamic
{
internal interface IProject
{
/// <summary>
/// Property name for store ddNS.
/// </summary>
string NamespacePropertyName { get; }

/// <summary>
/// Check if ddNS is not yet defined.
/// </summary>
bool IsDefinedNamespace { get; }

/// <summary>
/// Define namespace value for current EnvDTE.Project.
/// </summary>
/// <param name="name"></param>
void defineNamespace(string name);

/// <summary>
/// To update namespace value for all available projects that contains this meta-library in references.
/// </summary>
/// <param name="name"></param>
/// <param name="metalibName">File name without extension of meta library.</param>
/// <param name="metalibKey">PublicKeyToken of meta library.</param>
void updateNamespaceForAllProjects(string name, string metalibName, string metalibKey);

/// <summary>
/// Get property value from current project.
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
string getPropertyValue(string name);
}
}
167 changes: 167 additions & 0 deletions Configurator/Dynamic/Project.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 Denis Kuzmin <[email protected]>
*
* Permission 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE 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.
*/

using System;
using net.r_eg.DllExport.Configurator.Exceptions;

namespace net.r_eg.DllExport.Configurator.Dynamic
{
internal class Project: IProject
{
public const string NS_PROP_NAME = "DllExportNamespace";

/// <summary>
/// EnvDTE.Project
/// </summary>
protected dynamic pdte;

/// <summary>
/// Microsoft.Build.Evaluation.ProjectCollection
/// </summary>
protected dynamic pmbe;

/// <summary>
/// Property name for store ddNS.
/// </summary>
public string NamespacePropertyName
{
get {
return NS_PROP_NAME;
}
}

/// <summary>
/// Check if ddNS is not yet defined.
/// </summary>
public bool IsDefinedNamespace
{
get {
string vNamespace = MBEProject.GetPropertyValue(NamespacePropertyName);
return String.IsNullOrEmpty(vNamespace);
}
}

protected dynamic MBEProjects
{
get {
return loadedMBEProjects(pdte.FullName);
}
}

protected dynamic MBEProject
{
get
{
foreach(var prj in MBEProjects) {
return prj;
}
throw new InvalidObjectException("Projects is invalid or empty");
}
}

protected dynamic DTEProjects
{
get {
return pdte.Collection;
}
}

/// <summary>
/// Define namespace value for current EnvDTE.Project.
/// </summary>
/// <param name="name"></param>
public void defineNamespace(string name)
{
checkName(ref name);

MBEProject.SetProperty(NamespacePropertyName, name);
pdte.Save();
}

/// <summary>
/// To update namespace value for all available projects that contains this meta-library in references.
/// TODO: another way
/// </summary>
/// <param name="name"></param>
/// <param name="metalibName">File name without extension of meta library.</param>
/// <param name="metalibKey">PublicKeyToken of meta library.</param>
public void updateNamespaceForAllProjects(string name, string metalibName, string metalibKey)
{
checkName(ref name);

foreach(var dtePrj in DTEProjects)
{
if(!hasReference(dtePrj.Object.References, metalibName, metalibKey)) {
continue;
}

foreach(var ePrj in loadedMBEProjects(dtePrj.FullName)) {
if(!ePrj.FullPath.EndsWith(".user", StringComparison.OrdinalIgnoreCase)) {
ePrj.SetProperty(NamespacePropertyName, name);
}
}
dtePrj.Save(dtePrj.FullName); // save it with EnvDTE to avoid 'modified outside the environment'
}
}

/// <summary>
/// Get property value from current project.
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public string getPropertyValue(string name)
{
return MBEProject.GetPropertyValue(name);
}

public Project(dynamic pdte, dynamic pmbe)
{
this.pdte = pdte;
this.pmbe = pmbe;
}

protected dynamic loadedMBEProjects(string fullname)
{
return pmbe.GetLoadedProjects(fullname);
}

protected bool hasReference(dynamic pRefs, string name, string pubkey)
{
foreach(var pRef in pRefs) {
// https://msdn.microsoft.com/en-us/library/vslangproj.reference.aspx
if(pRef.Name == name && pRef.PublicKeyToken == pubkey) {
return true;
}
}
return false;
}

protected void checkName(ref string name)
{
if(String.IsNullOrWhiteSpace(name)) {
throw new ArgumentException("Namespace cannot be null.");
}
}
}
}
Loading

0 comments on commit ba0da45

Please sign in to comment.