-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
2,526 additions
and
453 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.