Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1952 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
45 changed files with 0 additions and 7577 deletions
@ -1,109 +0,0 @@ |
|||||||
<?xml version="1.0" ?> |
|
||||||
<!-- syntaxdefinition for XML 2000 by Mike Krueger --> |
|
||||||
<SyntaxDefinition name="Jay" extensions=".jay"> |
|
||||||
<Environment> |
|
||||||
<Default color = "SystemColors.WindowText" bgcolor = "SystemColors.Window"/> |
|
||||||
<Selection color = "SystemColors.HighlightText" bgcolor = "SystemColors.Highlight"/> |
|
||||||
<!-- <Selection bgcolor = "LightBlue"/> --> |
|
||||||
<VRuler color = "SystemColors.ControlLight"/> |
|
||||||
<InvalidLines color = "Red"/> |
|
||||||
<CaretMarker color = "Yellow"/> |
|
||||||
|
|
||||||
<LineNumbers color = "SystemColors.ControlDark" bgcolor = "SystemColors.Window"/> |
|
||||||
|
|
||||||
<FoldLine color = "#808080" bgcolor="Black"/> |
|
||||||
<FoldMarker color = "#808080" bgcolor="White"/> |
|
||||||
<SelectedFoldLine color = "Black" bgcolor="Black"/> |
|
||||||
|
|
||||||
<EOLMarkers color = "#E0E0E5"/> |
|
||||||
<SpaceMarkers color = "#E0E0E5"/> |
|
||||||
<TabMarkers color = "#E0E0E5"/> |
|
||||||
</Environment> |
|
||||||
<Digits name="Digits" bold="false" italic="false" color="DarkBlue" /> |
|
||||||
<RuleSets> |
|
||||||
<RuleSet ignorecase="false" noescapesequences="true"> |
|
||||||
<!-- It is not necessary to define span-delimiting characters as delimiters --> |
|
||||||
<Delimiters></Delimiters> |
|
||||||
|
|
||||||
|
|
||||||
<Span name="Jay" rule="CSharp" bold="false" italic="false" color="DarkSlateGray" stopateol="false"> |
|
||||||
<Begin bold = "true" color = "Black">%{</Begin> |
|
||||||
<End bold = "true" color = "Black">%}</End> |
|
||||||
</Span> |
|
||||||
|
|
||||||
<Span name="Jay" rule="JayDecl" bold="false" italic="false" color="DarkSlateGray" stopateol="false"> |
|
||||||
<Begin>%%</Begin> |
|
||||||
<End>%%</End> |
|
||||||
</Span> |
|
||||||
|
|
||||||
<Span name = "LINECOMMENT" bold = "false" italic = "true" color = "Gray" stopateol = "true"> |
|
||||||
<Begin>//</Begin> |
|
||||||
</Span> |
|
||||||
|
|
||||||
<Span name = "BLOCKCOMMENT" bold = "false" italic = "true" color = "Gray" stopateol = "false"> |
|
||||||
<Begin>/*</Begin> |
|
||||||
<End>*/</End> |
|
||||||
</Span> |
|
||||||
|
|
||||||
<Span name = "STRING" bold = "false" italic = "false" color = "Magenta" stopateol = "true"> |
|
||||||
<Begin>"</Begin> |
|
||||||
<End>"</End> |
|
||||||
</Span> |
|
||||||
|
|
||||||
<Span name = "CHAR" bold = "false" italic = "false" color = "Magenta" stopateol = "true"> |
|
||||||
<Begin>'</Begin> |
|
||||||
<End>'</End> |
|
||||||
</Span> |
|
||||||
|
|
||||||
<KeyWords name = "LexerDefinition" bold = "true" italic = "false" color = "Green"> |
|
||||||
<Key word = "%token" /> |
|
||||||
<Key word = "%nonassoc" /> |
|
||||||
<Key word = "%left" /> |
|
||||||
<Key word = "%right" /> |
|
||||||
<Key word = "%start" /> |
|
||||||
</KeyWords> |
|
||||||
|
|
||||||
</RuleSet> |
|
||||||
|
|
||||||
<RuleSet name="CSharp" reference = "C#" ignorecase="false" noescapesequences="true"> |
|
||||||
<Delimiters>/=</Delimiters> |
|
||||||
|
|
||||||
<KeyWords name = "LexerDefinition" bold = "true" italic = "false" color = "Red"> |
|
||||||
<Key word = "$1" /> |
|
||||||
<Key word = "$2" /> |
|
||||||
<Key word = "$3" /> |
|
||||||
<Key word = "$4" /> |
|
||||||
<Key word = "$$" /> |
|
||||||
</KeyWords> |
|
||||||
</RuleSet> |
|
||||||
|
|
||||||
<RuleSet name="JayDecl" ignorecase="false" noescapesequences="true"> |
|
||||||
<Delimiters>&<>~!@%^*()-+=|\#/{}[]:;"' , .?</Delimiters> |
|
||||||
|
|
||||||
<Span name="Jay" rule="CSharp" bold="false" italic="false" color="DarkSlateGray" stopateol="false"> |
|
||||||
<Begin bold = "true" color = "Black">{</Begin> |
|
||||||
<End bold = "true" color = "Black">}</End> |
|
||||||
</Span> |
|
||||||
|
|
||||||
<Span name = "LINECOMMENT" bold = "false" italic = "true" color = "Gray" stopateol = "true"> |
|
||||||
<Begin>//</Begin> |
|
||||||
</Span> |
|
||||||
|
|
||||||
<Span name = "BLOCKCOMMENT" bold = "false" italic = "true" color = "Gray" stopateol = "false"> |
|
||||||
<Begin>/*</Begin> |
|
||||||
<End>*/</End> |
|
||||||
</Span> |
|
||||||
|
|
||||||
<MarkPrevious bold = "true" italic = "false" color = "Red">:</MarkPrevious> |
|
||||||
|
|
||||||
<KeyWords name = "Punctuation" bold = "true" italic = "false" color = "Black"> |
|
||||||
<Key word = ";" /> |
|
||||||
<Key word = "|" /> |
|
||||||
<Key word = ":" /> |
|
||||||
</KeyWords> |
|
||||||
|
|
||||||
|
|
||||||
</RuleSet> |
|
||||||
</RuleSets> |
|
||||||
</SyntaxDefinition> |
|
||||||
|
|
@ -1,6 +0,0 @@ |
|||||||
Microsoft Visual Studio Solution File, Format Version 9.00 |
|
||||||
# SharpDevelop 2.0.0.612 |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyScout", "Project\AssemblyScout.csproj", "{DDD402CD-1D04-4E3F-B563-A4CACC500188}" |
|
||||||
EndProject |
|
||||||
Global |
|
||||||
EndGlobal |
|
@ -1,64 +0,0 @@ |
|||||||
<AddIn name = "Assembly Scout" |
|
||||||
author = "Mike Krueger" |
|
||||||
copyright = "GPL" |
|
||||||
url = "http://www.icsharpcode.net" |
|
||||||
description = "SharpDevelop Assembly Scout" |
|
||||||
version = "1.0.0"> |
|
||||||
|
|
||||||
<Runtime> |
|
||||||
<Import assembly="AssemblyScout.dll"/> |
|
||||||
</Runtime> |
|
||||||
|
|
||||||
<Path name = "/SharpDevelop/Workbench/DisplayBindings"> |
|
||||||
<DisplayBinding id = "AssemblyScout" |
|
||||||
insertbefore = "Text" |
|
||||||
fileNamePattern = "\.(dll|exe)$" |
|
||||||
languagePattern = "^AssemblyBinaryFile$" |
|
||||||
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.AssemblyScoutBinding" /> |
|
||||||
</Path> |
|
||||||
|
|
||||||
<Path name="/SharpDevelop/Workbench/FileFilter"> |
|
||||||
<FileFilter id = "Assemblies" |
|
||||||
insertbefore="AllFiles" |
|
||||||
name = "${res:SharpDevelop.FileFilter.AssemblyFiles}" |
|
||||||
extensions = "*.exe;*.dll"/> |
|
||||||
</Path> |
|
||||||
|
|
||||||
<Path name = "/SharpDevelop/Workbench/MainMenu/View"> |
|
||||||
<MenuItem id = "ShowAssemblyScout" |
|
||||||
insertafter = "ViewItemsSeparator" |
|
||||||
insertbefore = "FullScreen" |
|
||||||
label = "Assembly Scout" |
|
||||||
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.AssemblyScoutCommand"/> |
|
||||||
</Path> |
|
||||||
|
|
||||||
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions"> |
|
||||||
<DialogPanel id = "AssemblyScoutOptions" |
|
||||||
label = "${res:Dialog.Options.IDEOptions.AssemblyScout.PanelName}" |
|
||||||
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.AssemblyScoutOptionPanel"/> |
|
||||||
|
|
||||||
</Path> |
|
||||||
|
|
||||||
<Path name = "/SharpDevelop/Workbench/MainMenu"> |
|
||||||
<Condition name = "WindowActive" activewindow="ICSharpCode.SharpDevelop.AddIns.AssemblyScout.AssemblyScoutViewContent"> |
|
||||||
<MenuItem id = "AssemblyScout" insertafter="View" insertbefore="Tools" label="${res:Dialog.Options.IDEOptions.AssemblyScout.PanelName}"> |
|
||||||
<MenuItem id = "LoadAssembly" |
|
||||||
label = "${res:ObjectBrowser.Menu.LoadAssembly}" |
|
||||||
icon = "Icons.16x16.OpenAssembly" |
|
||||||
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.Commands.LoadAssemblyCommand"/> |
|
||||||
<MenuItem id = "LoadStdAssemblies" |
|
||||||
label = "${res:ObjectBrowser.Menu.LoadStd}" |
|
||||||
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.Commands.LoadStdAssembliesCommand"/> |
|
||||||
<MenuItem id = "LoadRefAssemblies" |
|
||||||
label = "${res:ObjectBrowser.Menu.LoadRef}" |
|
||||||
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.Commands.LoadRefAssembliesCommand"/> |
|
||||||
<MenuItem id = "AssemblySeparator" |
|
||||||
label = "-"/> |
|
||||||
<MenuItem id = "AssemblyScoutGoBack" |
|
||||||
label = "${res:ObjectBrowser.Menu.GoBack}" |
|
||||||
icon = "Icons.16x16.BrowserBefore" |
|
||||||
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.Commands.BackCommand"/> |
|
||||||
</MenuItem> |
|
||||||
</Condition> |
|
||||||
</Path> |
|
||||||
</AddIn> |
|
@ -1,98 +0,0 @@ |
|||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
||||||
<PropertyGroup> |
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
||||||
<ProductVersion>8.0.50215</ProductVersion> |
|
||||||
<SchemaVersion>2.0</SchemaVersion> |
|
||||||
<ProjectGuid>{DDD402CD-1D04-4E3F-B563-A4CACC500188}</ProjectGuid> |
|
||||||
<AssemblyName>AssemblyScout</AssemblyName> |
|
||||||
<OutputTarget>Library</OutputTarget> |
|
||||||
<WarningLevel>4</WarningLevel> |
|
||||||
<NoStdLib>False</NoStdLib> |
|
||||||
<NoConfig>False</NoConfig> |
|
||||||
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent> |
|
||||||
<OutputType>Library</OutputType> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
||||||
<DebugSymbols>True</DebugSymbols> |
|
||||||
<Optimize>False</Optimize> |
|
||||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
|
||||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\DisplayBindings\AssemblyScout\</OutputPath> |
|
||||||
<DefineConstants>DEBUG</DefineConstants> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
||||||
<DebugSymbols>False</DebugSymbols> |
|
||||||
<Optimize>True</Optimize> |
|
||||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
|
||||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\DisplayBindings\AssemblyScout\</OutputPath> |
|
||||||
</PropertyGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Reference Include="System" /> |
|
||||||
<Reference Include="System.Design" /> |
|
||||||
<Reference Include="System.Drawing" /> |
|
||||||
<Reference Include="System.Windows.Forms" /> |
|
||||||
<Reference Include="System.XML" /> |
|
||||||
<Reference Include="ICSharpCode.SharpAssembly"> |
|
||||||
<HintPath>..\..\..\..\..\bin\ICSharpCode.SharpAssembly.dll</HintPath> |
|
||||||
<SpecificVersion>False</SpecificVersion> |
|
||||||
<Private>False</Private> |
|
||||||
</Reference> |
|
||||||
<Reference Include="ICSharpCode.Core"> |
|
||||||
<HintPath>..\..\..\..\..\bin\ICSharpCode.Core.dll</HintPath> |
|
||||||
<SpecificVersion>False</SpecificVersion> |
|
||||||
<Private>False</Private> |
|
||||||
</Reference> |
|
||||||
<Reference Include="ICSharpCode.SharpDevelop"> |
|
||||||
<HintPath>..\..\..\..\..\bin\ICSharpCode.SharpDevelop.dll</HintPath> |
|
||||||
<SpecificVersion>False</SpecificVersion> |
|
||||||
<Private>False</Private> |
|
||||||
</Reference> |
|
||||||
<Reference Include="WeifenLuo.WinFormsUI.Docking"> |
|
||||||
<HintPath>..\..\..\..\..\bin\WeifenLuo.WinFormsUI.Docking.dll</HintPath> |
|
||||||
<SpecificVersion>False</SpecificVersion> |
|
||||||
</Reference> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<None Include="AssemblyScout.addin"> |
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|
||||||
</None> |
|
||||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
|
||||||
<Compile Include="Src\XmlView.cs" /> |
|
||||||
<Compile Include="Src\AssemblyScoutBinding.cs" /> |
|
||||||
<Compile Include="Src\AssemblyScoutCommand.cs" /> |
|
||||||
<Compile Include="Src\AssemblyScoutCommands.cs" /> |
|
||||||
<Compile Include="Src\AssemblyScoutOptionPanel.cs" /> |
|
||||||
<Compile Include="Src\AssemblyScoutViewContent.cs" /> |
|
||||||
<Compile Include="Src\AssemblyTree.cs" /> |
|
||||||
<Compile Include="Src\ExtendedPropPanel.cs" /> |
|
||||||
<Compile Include="Src\ILDasmView.cs" /> |
|
||||||
<Compile Include="Src\InfoView.cs" /> |
|
||||||
<Compile Include="Src\SearchPanel.cs" /> |
|
||||||
<Compile Include="Src\SourceView.cs" /> |
|
||||||
<Compile Include="Src\TempProject.cs" /> |
|
||||||
<Compile Include="Src\Nodes\TypeNode.cs" /> |
|
||||||
<Compile Include="Src\Nodes\AssemblyTreeNode.cs" /> |
|
||||||
<Compile Include="Src\Nodes\FolderNode.cs" /> |
|
||||||
<Compile Include="Src\Nodes\MemberNode.cs" /> |
|
||||||
<Compile Include="Src\Nodes\MethodNode.cs" /> |
|
||||||
<Compile Include="Src\Nodes\ResourceNode.cs" /> |
|
||||||
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyClass.cs" /> |
|
||||||
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyEvent.cs" /> |
|
||||||
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyField.cs" /> |
|
||||||
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyMethod.cs" /> |
|
||||||
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyParameter.cs" /> |
|
||||||
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyProperty.cs" /> |
|
||||||
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyReturnType.cs" /> |
|
||||||
<Compile Include="Src\SharpAssemblyLayer\SharpAssemblyAttribute.cs" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Folder Include="Configuration" /> |
|
||||||
<Folder Include="Src" /> |
|
||||||
<Folder Include="Src\Nodes" /> |
|
||||||
<Folder Include="Resources" /> |
|
||||||
<Folder Include="Src\SharpAssemblyLayer" /> |
|
||||||
</ItemGroup> |
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> |
|
||||||
</Project> |
|
@ -1,14 +0,0 @@ |
|||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
||||||
<PropertyGroup> |
|
||||||
<LastOpenVersion>8.0.50215</LastOpenVersion> |
|
||||||
<ProjectView>ShowAllFiles</ProjectView> |
|
||||||
<ProjectTrust>0</ProjectTrust> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
||||||
<StartProgram>..\..\..\..\..\bin\SharpDevelop.exe</StartProgram> |
|
||||||
<StartAction>Program</StartAction> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
||||||
<StartProgram>..\..\..\..\..\bin\SharpDevelop.exe</StartProgram> |
|
||||||
</PropertyGroup> |
|
||||||
</Project> |
|
@ -1,29 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System.Reflection; |
|
||||||
using System.Runtime.CompilerServices; |
|
||||||
|
|
||||||
[assembly: AssemblyTitle("Objectbrowser for SharpDevelop")] |
|
||||||
[assembly: AssemblyDescription("")] |
|
||||||
[assembly: AssemblyConfiguration("")] |
|
||||||
[assembly: AssemblyCompany("")] |
|
||||||
[assembly: AssemblyProduct("")] |
|
||||||
|
|
||||||
// the current contributor comes first in the copyright, the former second
|
|
||||||
// and so on :)
|
|
||||||
// SharpDevelop IS OUR project not MINE :)
|
|
||||||
// Mike
|
|
||||||
[assembly: AssemblyCopyright("Georg Brandl, Markus Palme, Mike Krüger")] |
|
||||||
[assembly: AssemblyTrademark("")] |
|
||||||
[assembly: AssemblyCulture("")] |
|
||||||
|
|
||||||
[assembly: AssemblyVersion("2.0.0.1")] |
|
||||||
|
|
||||||
[assembly: AssemblyDelaySign(false)] |
|
||||||
[assembly: AssemblyKeyFile("")] |
|
||||||
[assembly: AssemblyKeyName("")] |
|
@ -1,54 +0,0 @@ |
|||||||
<AddIn name = "Assembly Scout" |
|
||||||
author = "Mike Krueger" |
|
||||||
copyright = "GPL" |
|
||||||
url = "http://www.icsharpcode.net" |
|
||||||
description = "A .NET object browser" |
|
||||||
version = "1.0.0"> |
|
||||||
|
|
||||||
<Runtime> |
|
||||||
<Import assembly="AssemblyScout.dll"/> |
|
||||||
</Runtime> |
|
||||||
|
|
||||||
<Path name = "/SharpDevelop/Workbench/DisplayBindings"> |
|
||||||
<DisplayBinding id = "AssemblyScout" |
|
||||||
insertbefore = "Text" |
|
||||||
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.AssemblyScoutBinding" /> |
|
||||||
</Path> |
|
||||||
|
|
||||||
<Path name = "/SharpDevelop/Workbench/MainMenu/View"> |
|
||||||
<MenuItem id = "ShowAssemblyScout" |
|
||||||
insertafter = "ViewItemsSeparator" |
|
||||||
insertbefore = "FullScreen" |
|
||||||
label = "Assembly Scout" |
|
||||||
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.AssemblyScoutCommand"/> |
|
||||||
</Path> |
|
||||||
|
|
||||||
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions"> |
|
||||||
<DialogPanel id = "AssemblyScoutOptions" |
|
||||||
label = "${res:Dialog.Options.IDEOptions.AssemblyScout.PanelName}" |
|
||||||
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.AssemblyScoutOptionPanel"/> |
|
||||||
</Path> |
|
||||||
|
|
||||||
<Path name = "/SharpDevelop/Workbench/MainMenu"> |
|
||||||
<Condition openwindow="ICSharpCode.SharpDevelop.AddIns.AssemblyScout.AssemblyScoutViewContent"> |
|
||||||
<MenuItem id = "AssemblyScout" insertafter="View" insertbefore="Tools" label="${res:Dialog.Options.IDEOptions.AssemblyScout.PanelName}"> |
|
||||||
<MenuItem id = "LoadAssembly" |
|
||||||
label = "${res:ObjectBrowser.Menu.LoadAssembly}" |
|
||||||
icon = "Icons.16x16.OpenAssembly" |
|
||||||
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.Commands.LoadAssemblyCommand"/> |
|
||||||
<MenuItem id = "LoadStdAssemblies" |
|
||||||
label = "${res:ObjectBrowser.Menu.LoadStd}" |
|
||||||
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.Commands.LoadStdAssembliesCommand"/> |
|
||||||
<MenuItem id = "LoadRefAssemblies" |
|
||||||
label = "${res:ObjectBrowser.Menu.LoadRef}" |
|
||||||
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.Commands.LoadRefAssembliesCommand"/> |
|
||||||
<MenuItem id = "AssemblySeparator" |
|
||||||
type = "Separator"/> |
|
||||||
<MenuItem id = "AssemblyScoutGoBack" |
|
||||||
label = "${res:ObjectBrowser.Menu.GoBack}" |
|
||||||
icon = "Icons.16x16.BrowserBefore" |
|
||||||
class = "ICSharpCode.SharpDevelop.AddIns.AssemblyScout.Commands.BackCommand"/> |
|
||||||
</MenuItem> |
|
||||||
</Condition> |
|
||||||
</Path> |
|
||||||
</AddIn> |
|
@ -1,131 +0,0 @@ |
|||||||
<Components version="1.0"> |
|
||||||
<System.Windows.Forms.UserControl> |
|
||||||
<Name value="_panel" /> |
|
||||||
<DockPadding value="" /> |
|
||||||
<ClientSize value="{Width=376, Height=336}" /> |
|
||||||
<Controls> |
|
||||||
<System.Windows.Forms.GroupBox> |
|
||||||
<Name value="treeGroupBox" /> |
|
||||||
<TabIndex value="5" /> |
|
||||||
<Location value="{X=8,Y=8}" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<ClientSize value="{Width=360, Height=96}" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.AssemblyScout.TypesGroupBox}" /> |
|
||||||
<Controls> |
|
||||||
<System.Windows.Forms.ComboBox> |
|
||||||
<Name value="privateTypesBox" /> |
|
||||||
<Anchor value="Top, Right" /> |
|
||||||
<TabIndex value="3" /> |
|
||||||
<Location value="{X=248,Y=26}" /> |
|
||||||
<ClientSize value="{Width=96, Height=21}" /> |
|
||||||
<DropDownStyle value="DropDownList" /> |
|
||||||
</System.Windows.Forms.ComboBox> |
|
||||||
<System.Windows.Forms.Label> |
|
||||||
<Name value="privateMembers" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.AssemblyScout.PrivateTypes}" /> |
|
||||||
<TextAlign value="MiddleLeft" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<TabIndex value="2" /> |
|
||||||
<ClientSize value="{Width=232, Height=24}" /> |
|
||||||
<Location value="{X=16,Y=24}" /> |
|
||||||
</System.Windows.Forms.Label> |
|
||||||
<System.Windows.Forms.ComboBox> |
|
||||||
<Name value="internalTypesBox" /> |
|
||||||
<Anchor value="Top, Right" /> |
|
||||||
<TabIndex value="1" /> |
|
||||||
<Location value="{X=248,Y=58}" /> |
|
||||||
<ClientSize value="{Width=96, Height=21}" /> |
|
||||||
<DropDownStyle value="DropDownList" /> |
|
||||||
</System.Windows.Forms.ComboBox> |
|
||||||
<System.Windows.Forms.Label> |
|
||||||
<Name value="internalMembers" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.AssemblyScout.InternalTypes}" /> |
|
||||||
<TextAlign value="MiddleLeft" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<TabIndex value="0" /> |
|
||||||
<ClientSize value="{Width=232, Height=24}" /> |
|
||||||
<Location value="{X=16,Y=56}" /> |
|
||||||
</System.Windows.Forms.Label> |
|
||||||
</Controls> |
|
||||||
</System.Windows.Forms.GroupBox> |
|
||||||
<System.Windows.Forms.GroupBox> |
|
||||||
<Name value="groupBox" /> |
|
||||||
<TabIndex value="1" /> |
|
||||||
<Location value="{X=8,Y=216}" /> |
|
||||||
<Anchor value="Top, Bottom, Left, Right" /> |
|
||||||
<ClientSize value="{Width=360, Height=104}" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.AssemblyScout.OtherGroupBox}" /> |
|
||||||
<Controls> |
|
||||||
<System.Windows.Forms.CheckBox> |
|
||||||
<Name value="showReturnTypesBox" /> |
|
||||||
<Location value="{X=16,Y=24}" /> |
|
||||||
<ClientSize value="{Width=336, Height=24}" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.AssemblyScout.ShowReturnTypesBox}" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<TabIndex value="0" /> |
|
||||||
</System.Windows.Forms.CheckBox> |
|
||||||
<System.Windows.Forms.CheckBox> |
|
||||||
<Name value="showResourcePreviewBox" /> |
|
||||||
<Location value="{X=16,Y=48}" /> |
|
||||||
<ClientSize value="{Width=336, Height=24}" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.AssemblyScout.ShowResourcePreviewBox}" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<TabIndex value="0" /> |
|
||||||
</System.Windows.Forms.CheckBox> |
|
||||||
<System.Windows.Forms.CheckBox> |
|
||||||
<Name value="showSpecialMethodsBox" /> |
|
||||||
<Location value="{X=16,Y=72}" /> |
|
||||||
<ClientSize value="{Width=336, Height=24}" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.AssemblyScout.ShowSpecialMethods}" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<TabIndex value="0" /> |
|
||||||
</System.Windows.Forms.CheckBox> |
|
||||||
</Controls> |
|
||||||
</System.Windows.Forms.GroupBox> |
|
||||||
<System.Windows.Forms.GroupBox> |
|
||||||
<Name value="treeGroupBox" /> |
|
||||||
<TabIndex value="0" /> |
|
||||||
<Location value="{X=8,Y=112}" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<ClientSize value="{Width=360, Height=96}" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.AssemblyScout.MembersGroupBox}" /> |
|
||||||
<Controls> |
|
||||||
<System.Windows.Forms.ComboBox> |
|
||||||
<Name value="privateMembersBox" /> |
|
||||||
<Anchor value="Top, Right" /> |
|
||||||
<TabIndex value="3" /> |
|
||||||
<Location value="{X=248,Y=26}" /> |
|
||||||
<ClientSize value="{Width=96, Height=21}" /> |
|
||||||
<DropDownStyle value="DropDownList" /> |
|
||||||
</System.Windows.Forms.ComboBox> |
|
||||||
<System.Windows.Forms.Label> |
|
||||||
<Name value="privateMembers" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.AssemblyScout.PrivateMembers}" /> |
|
||||||
<TextAlign value="MiddleLeft" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<TabIndex value="2" /> |
|
||||||
<ClientSize value="{Width=232, Height=24}" /> |
|
||||||
<Location value="{X=16,Y=24}" /> |
|
||||||
</System.Windows.Forms.Label> |
|
||||||
<System.Windows.Forms.ComboBox> |
|
||||||
<Name value="internalMembersBox" /> |
|
||||||
<Anchor value="Top, Right" /> |
|
||||||
<TabIndex value="1" /> |
|
||||||
<Location value="{X=248,Y=58}" /> |
|
||||||
<ClientSize value="{Width=96, Height=21}" /> |
|
||||||
<DropDownStyle value="DropDownList" /> |
|
||||||
</System.Windows.Forms.ComboBox> |
|
||||||
<System.Windows.Forms.Label> |
|
||||||
<Name value="internalMembers" /> |
|
||||||
<Text value="${res:Dialog.Options.IDEOptions.AssemblyScout.InternalMembers}" /> |
|
||||||
<TextAlign value="MiddleLeft" /> |
|
||||||
<Anchor value="Top, Left, Right" /> |
|
||||||
<TabIndex value="0" /> |
|
||||||
<ClientSize value="{Width=232, Height=24}" /> |
|
||||||
<Location value="{X=16,Y=56}" /> |
|
||||||
</System.Windows.Forms.Label> |
|
||||||
</Controls> |
|
||||||
</System.Windows.Forms.GroupBox> |
|
||||||
</Controls> |
|
||||||
</System.Windows.Forms.UserControl> |
|
||||||
</Components> |
|
@ -1,51 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.IO; |
|
||||||
using System.Collections; |
|
||||||
using System.Resources; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
//using UI = WeifenLuo.WinFormsUI;
|
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
///////////////////////////////////////////
|
|
||||||
// AssemblyScoutBinding class
|
|
||||||
///////////////////////////////////////////
|
|
||||||
public class AssemblyScoutBinding : IDisplayBinding |
|
||||||
{ |
|
||||||
public bool CanCreateContentForFile(string fileName) |
|
||||||
{ |
|
||||||
return Path.GetExtension(fileName).ToUpper() == ".DLL" || |
|
||||||
Path.GetExtension(fileName).ToUpper() == ".EXE"; |
|
||||||
} |
|
||||||
|
|
||||||
public bool CanCreateContentForLanguage(string language) |
|
||||||
{ |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public IViewContent CreateContentForFile(string fileName) |
|
||||||
{ |
|
||||||
AssemblyScoutViewContent wrapper = new AssemblyScoutViewContent(); |
|
||||||
wrapper.Load(fileName); |
|
||||||
return wrapper; |
|
||||||
} |
|
||||||
|
|
||||||
public IViewContent CreateContentForLanguage(string language, string content) |
|
||||||
{ |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,25 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
public class AssemblyScoutCommand : AbstractMenuCommand |
|
||||||
{ |
|
||||||
|
|
||||||
public override void Run() { |
|
||||||
AssemblyScoutViewContent vw; |
|
||||||
vw = new AssemblyScoutViewContent(); |
|
||||||
vw.LoadStdAssemblies(); |
|
||||||
vw.LoadRefAssemblies(); |
|
||||||
WorkbenchSingleton.Workbench.ShowView(vw); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -1,84 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.IO; |
|
||||||
using System.Collections; |
|
||||||
using System.Resources; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
using ICSharpCode.SharpDevelop.Commands; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.AddIns.AssemblyScout; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout.Commands |
|
||||||
{ |
|
||||||
public class LoadAssemblyCommand : AssemblyScoutCommand |
|
||||||
{ |
|
||||||
public override void Run() |
|
||||||
{ |
|
||||||
AssemblyScoutViewContent vc = GetViewContent(); |
|
||||||
if (vc == null) return; |
|
||||||
|
|
||||||
vc.Tree.LoadAssembly(null, null); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class LoadRefAssembliesCommand : AssemblyScoutCommand |
|
||||||
{ |
|
||||||
public override void Run() |
|
||||||
{ |
|
||||||
AssemblyScoutViewContent vc = GetViewContent(); |
|
||||||
if (vc == null) return; |
|
||||||
|
|
||||||
vc.LoadRefAssemblies(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public class LoadStdAssembliesCommand : AssemblyScoutCommand |
|
||||||
{ |
|
||||||
public override void Run() |
|
||||||
{ |
|
||||||
AssemblyScoutViewContent vc = GetViewContent(); |
|
||||||
if (vc == null) return; |
|
||||||
|
|
||||||
vc.LoadStdAssemblies(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public class BackCommand : AssemblyScoutCommand |
|
||||||
{ |
|
||||||
public override void Run() |
|
||||||
{ |
|
||||||
AssemblyScoutViewContent vc = GetViewContent(); |
|
||||||
if (vc == null) return; |
|
||||||
|
|
||||||
vc.Tree.GoBack(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public class AssemblyScoutCommand : AbstractMenuCommand |
|
||||||
{ |
|
||||||
protected AssemblyScoutViewContent GetViewContent() |
|
||||||
{ |
|
||||||
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; |
|
||||||
|
|
||||||
return (window.ViewContent as AssemblyScoutViewContent); |
|
||||||
} |
|
||||||
|
|
||||||
public override void Run() |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,67 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.Reflection; |
|
||||||
using System.IO; |
|
||||||
using System.Drawing; |
|
||||||
using System.Collections; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Internal.ExternalTool; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
public class AssemblyScoutOptionPanel : AbstractOptionPanel |
|
||||||
{ |
|
||||||
Control[] combos = new Control[] {}; |
|
||||||
|
|
||||||
public override void LoadPanelContents() |
|
||||||
{ |
|
||||||
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("AssemblyScoutOptions.xfrm")); |
|
||||||
|
|
||||||
combos = new Control[] { |
|
||||||
ControlDictionary["privateTypesBox"], |
|
||||||
ControlDictionary["internalTypesBox"], |
|
||||||
ControlDictionary["privateMembersBox"], |
|
||||||
ControlDictionary["internalMembersBox"] |
|
||||||
}; |
|
||||||
|
|
||||||
foreach(ComboBox combo in combos) { |
|
||||||
Debug.Assert(combo != null); |
|
||||||
combo.Items.Add(StringParser.Parse("${res:Dialog.Options.IDEOptions.AssemblyScout.Show}")); |
|
||||||
combo.Items.Add(StringParser.Parse("${res:Dialog.Options.IDEOptions.AssemblyScout.GreyOut}")); |
|
||||||
combo.Items.Add(StringParser.Parse("${res:Dialog.Options.IDEOptions.AssemblyScout.Hide}")); |
|
||||||
|
|
||||||
combo.SelectedIndex = PropertyService.Get("AddIns.AssemblyScout." + combo.Name, 1); |
|
||||||
} |
|
||||||
|
|
||||||
((CheckBox)ControlDictionary["showReturnTypesBox"]).Checked |
|
||||||
= PropertyService.Get("AddIns.AssemblyScout.ShowReturnTypes", true); |
|
||||||
((CheckBox)ControlDictionary["showResourcePreviewBox"]).Checked |
|
||||||
= PropertyService.Get("AddIns.AssemblyScout.ShowResPreview", true); |
|
||||||
((CheckBox)ControlDictionary["showSpecialMethodsBox"]).Checked |
|
||||||
= PropertyService.Get("AddIns.AssemblyScout.ShowSpecialMethods", true); |
|
||||||
} |
|
||||||
|
|
||||||
public override bool StorePanelContents() |
|
||||||
{ |
|
||||||
PropertyService.Set("AddIns.AssemblyScout.ShowReturnTypes", ((CheckBox)ControlDictionary["showReturnTypesBox"]).Checked); |
|
||||||
PropertyService.Set("AddIns.AssemblyScout.ShowResPreview", ((CheckBox)ControlDictionary["showResourcePreviewBox"]).Checked); |
|
||||||
PropertyService.Set("AddIns.AssemblyScout.ShowSpecialMethods", ((CheckBox)ControlDictionary["showSpecialMethodsBox"]).Checked); |
|
||||||
|
|
||||||
foreach(ComboBox combo in combos) { |
|
||||||
PropertyService.Set("AddIns.AssemblyScout." + combo.Name, combo.SelectedIndex); |
|
||||||
} |
|
||||||
|
|
||||||
return true; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,288 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.IO; |
|
||||||
using System.Collections; |
|
||||||
using System.Resources; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
using UI = WeifenLuo.WinFormsUI; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
///////////////////////////////////////////
|
|
||||||
// AssemblyScoutViewContent Class
|
|
||||||
///////////////////////////////////////////
|
|
||||||
public class AssemblyScoutViewContent : AbstractViewContent |
|
||||||
{ |
|
||||||
public UI.DockPanel leftTabs, rightTabs; |
|
||||||
Control control = null; |
|
||||||
AssemblyTree tree = null; |
|
||||||
|
|
||||||
public override Control Control { |
|
||||||
get { |
|
||||||
return control; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public AssemblyTree Tree { |
|
||||||
get { |
|
||||||
return tree; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
string untitledName = ""; |
|
||||||
public override string UntitledName { |
|
||||||
get { |
|
||||||
return untitledName; |
|
||||||
} |
|
||||||
set { |
|
||||||
untitledName = value; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// public override string TitleName {
|
|
||||||
// get {
|
|
||||||
// return filename;
|
|
||||||
// }
|
|
||||||
// set {
|
|
||||||
// filename = value;
|
|
||||||
// OnTitleNameChanged(null);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public override string TabPageText { |
|
||||||
get { |
|
||||||
return "Assemblies"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override bool IsViewOnly { |
|
||||||
get { |
|
||||||
return true; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
IWorkbenchWindow workbenchWindow; |
|
||||||
public override IWorkbenchWindow WorkbenchWindow { |
|
||||||
get { |
|
||||||
return workbenchWindow; |
|
||||||
} |
|
||||||
set { |
|
||||||
workbenchWindow = value; |
|
||||||
if (FileName == "") { |
|
||||||
workbenchWindow.Title = StringParser.Parse("${res:ObjectBrowser.AssemblyScout}"); |
|
||||||
} else { |
|
||||||
workbenchWindow.Title = FileName; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override void RedrawContent() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public override void Dispose() |
|
||||||
{ |
|
||||||
try { |
|
||||||
foreach(Control ctl in Control.Controls) { |
|
||||||
ctl.Dispose(); |
|
||||||
} |
|
||||||
} catch { |
|
||||||
return; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void SaveFile() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public bool CanCreateContentForFile(string fileName) |
|
||||||
{ |
|
||||||
return Path.GetExtension(fileName) == ".dll" || Path.GetExtension(fileName) == ".exe"; |
|
||||||
} |
|
||||||
|
|
||||||
public bool CanCreateContentForLanguage(string language) |
|
||||||
{ |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public IViewContent CreateContentForFile(string fileName) |
|
||||||
{ |
|
||||||
Load(fileName); |
|
||||||
return this; |
|
||||||
} |
|
||||||
|
|
||||||
public void Undo() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public void Redo() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public IViewContent CreateContentForLanguage(string language, string content) |
|
||||||
{ |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public override void Save() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public override void Save(string filename) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public override void Load(string filename) |
|
||||||
{ |
|
||||||
tree.LoadFile(filename); |
|
||||||
this.FileName = filename; |
|
||||||
this.TitleName = Path.GetFileName(filename); |
|
||||||
} |
|
||||||
|
|
||||||
public AssemblyScoutViewContent() |
|
||||||
{ |
|
||||||
Panel panel = new Panel(); |
|
||||||
panel.Dock = DockStyle.Fill; |
|
||||||
|
|
||||||
leftTabs = new UI.DockPanel(); |
|
||||||
leftTabs.Dock = DockStyle.Left; |
|
||||||
leftTabs.Width = 400; |
|
||||||
leftTabs.AllowDrop = false; |
|
||||||
leftTabs.AllowRedocking = false; |
|
||||||
|
|
||||||
AssemblyTree assemblyTree = new AssemblyTree(this); |
|
||||||
this.tree = assemblyTree; |
|
||||||
|
|
||||||
UI.DockContent treeviewpage = new UI.DockContent(); |
|
||||||
treeviewpage.Text = StringParser.Parse("${res:ObjectBrowser.Tree}"); |
|
||||||
treeviewpage.Icon = ResourceService.GetIcon("Icons.16x16.Class"); |
|
||||||
treeviewpage.DockPadding.All = 8; |
|
||||||
treeviewpage.Controls.Add(assemblyTree); |
|
||||||
treeviewpage.DockableAreas = UI.DockAreas.Document; |
|
||||||
treeviewpage.CloseButton = false; |
|
||||||
treeviewpage.Show(leftTabs); |
|
||||||
|
|
||||||
UI.DockContent indexviewpage = new UI.DockContent(); |
|
||||||
indexviewpage.Text = StringParser.Parse("${res:ObjectBrowser.Search}"); |
|
||||||
indexviewpage.Icon = ResourceService.GetIcon("Icons.16x16.FindIcon"); |
|
||||||
SearchPanel SearchPanel = new SearchPanel(assemblyTree); |
|
||||||
SearchPanel.ParentDisplayInfo = this; |
|
||||||
indexviewpage.DockPadding.All = 8; |
|
||||||
indexviewpage.Controls.Add(SearchPanel); |
|
||||||
indexviewpage.DockableAreas = UI.DockAreas.Document; |
|
||||||
indexviewpage.CloseButton = false; |
|
||||||
indexviewpage.Show(leftTabs); |
|
||||||
|
|
||||||
Splitter vsplitter = new Splitter(); |
|
||||||
vsplitter.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; |
|
||||||
|
|
||||||
vsplitter.Location = new System.Drawing.Point(0, 200); |
|
||||||
vsplitter.TabIndex = 5; |
|
||||||
vsplitter.TabStop = false; |
|
||||||
vsplitter.Size = new System.Drawing.Size(3, 273); |
|
||||||
vsplitter.Dock = DockStyle.Left; |
|
||||||
|
|
||||||
|
|
||||||
rightTabs = new UI.DockPanel(); |
|
||||||
rightTabs.Dock = DockStyle.Fill; |
|
||||||
rightTabs.AllowDrop = false; |
|
||||||
rightTabs.AllowRedocking = false; |
|
||||||
|
|
||||||
UI.DockContent memberpage = new UI.DockContent(); |
|
||||||
memberpage.Text = StringParser.Parse("${res:ObjectBrowser.Info}"); |
|
||||||
memberpage.Icon = ResourceService.GetIcon("Icons.16x16.Information"); |
|
||||||
memberpage.DockPadding.All = 8; |
|
||||||
memberpage.Controls.Add(new InfoView(assemblyTree)); |
|
||||||
memberpage.DockableAreas = UI.DockAreas.Document; |
|
||||||
memberpage.CloseButton = false; |
|
||||||
memberpage.Show(rightTabs); |
|
||||||
|
|
||||||
UI.DockContent ildasmviewpage = new UI.DockContent(); |
|
||||||
ildasmviewpage.Text = StringParser.Parse("${res:ObjectBrowser.Disasm}"); |
|
||||||
ildasmviewpage.Icon = ResourceService.GetIcon("Icons.16x16.ILDasm"); |
|
||||||
ildasmviewpage.DockPadding.All = 8; |
|
||||||
ildasmviewpage.Controls.Add(new ILDasmView(assemblyTree)); |
|
||||||
ildasmviewpage.DockableAreas = UI.DockAreas.Document; |
|
||||||
ildasmviewpage.CloseButton = false; |
|
||||||
ildasmviewpage.Show(rightTabs); |
|
||||||
|
|
||||||
UI.DockContent sourceviewpage = new UI.DockContent(); |
|
||||||
sourceviewpage.Text = StringParser.Parse("${res:ObjectBrowser.Source}"); |
|
||||||
sourceviewpage.Icon = ResourceService.GetIcon("Icons.16x16.TextFileIcon"); |
|
||||||
sourceviewpage.DockPadding.All = 8; |
|
||||||
sourceviewpage.Controls.Add(new SourceView(assemblyTree)); |
|
||||||
sourceviewpage.DockableAreas = UI.DockAreas.Document; |
|
||||||
sourceviewpage.CloseButton = false; |
|
||||||
sourceviewpage.Show(rightTabs); |
|
||||||
|
|
||||||
UI.DockContent xmlviewpage = new UI.DockContent(); |
|
||||||
xmlviewpage.Text = StringParser.Parse("${res:ObjectBrowser.XML}"); |
|
||||||
xmlviewpage.Icon = ResourceService.GetIcon("Icons.16x16.XMLFileIcon"); |
|
||||||
xmlviewpage.DockPadding.All = 8; |
|
||||||
xmlviewpage.Controls.Add(new XmlView(assemblyTree)); |
|
||||||
xmlviewpage.DockableAreas = UI.DockAreas.Document; |
|
||||||
xmlviewpage.CloseButton = false; |
|
||||||
xmlviewpage.Show(rightTabs); |
|
||||||
|
|
||||||
UI.DockContent extproppage = new UI.DockContent(); |
|
||||||
extproppage.Text = StringParser.Parse("${res:ObjectBrowser.Extended}"); |
|
||||||
extproppage.Icon = ResourceService.GetIcon("Icons.16x16.Property"); |
|
||||||
extproppage.DockPadding.All = 8; |
|
||||||
extproppage.Controls.Add(new ExtendedPropsPanel(assemblyTree)); |
|
||||||
extproppage.DockableAreas = UI.DockAreas.Document; |
|
||||||
extproppage.CloseButton = false; |
|
||||||
extproppage.Show(rightTabs); |
|
||||||
|
|
||||||
panel.Controls.Add(rightTabs); |
|
||||||
panel.Controls.Add(vsplitter); |
|
||||||
panel.Controls.Add(leftTabs); |
|
||||||
|
|
||||||
treeviewpage.Activate(); |
|
||||||
memberpage.Activate(); |
|
||||||
|
|
||||||
this.control = panel; |
|
||||||
this.TitleName = StringParser.Parse("${res:ObjectBrowser.AssemblyScout}"); |
|
||||||
} |
|
||||||
|
|
||||||
public void LoadStdAssemblies() { |
|
||||||
//try {
|
|
||||||
tree.AddAssembly(SA.SharpAssembly.Load("mscorlib")); |
|
||||||
tree.AddAssembly(SA.SharpAssembly.Load("System")); |
|
||||||
tree.AddAssembly(SA.SharpAssembly.Load("System.Xml")); |
|
||||||
tree.AddAssembly(SA.SharpAssembly.Load("System.Windows.Forms")); |
|
||||||
tree.AddAssembly(SA.SharpAssembly.Load("System.Drawing")); |
|
||||||
tree.AddAssembly(SA.SharpAssembly.Load("System.Data")); |
|
||||||
tree.AddAssembly(SA.SharpAssembly.Load("System.Design")); |
|
||||||
tree.AddAssembly(SA.SharpAssembly.Load("System.Web")); |
|
||||||
//} catch {}
|
|
||||||
} |
|
||||||
|
|
||||||
public void LoadRefAssemblies() { |
|
||||||
try { |
|
||||||
if (ProjectService.CurrentProject == null) return; |
|
||||||
foreach(ProjectItem item in ProjectService.CurrentProject.Items) { |
|
||||||
if (item.ItemType == ItemType.Reference) { |
|
||||||
if (!tree.IsAssemblyLoaded(item.FileName)) { |
|
||||||
try { |
|
||||||
tree.LoadFile(item.FileName); |
|
||||||
} catch (Exception) { |
|
||||||
//MessageBox.Show("Object Browser error:\nError loading assembly " + pr.GetReferencedFileName(null) + ".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} catch (Exception) {} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,632 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Xml; |
|
||||||
using System.Collections; |
|
||||||
using System.IO; |
|
||||||
using System.Drawing; |
|
||||||
using System.Drawing.Printing; |
|
||||||
using System.Windows.Forms; |
|
||||||
using System.Threading; |
|
||||||
using System.Resources; |
|
||||||
using System.Text; |
|
||||||
|
|
||||||
using Microsoft.Win32; |
|
||||||
using System.Diagnostics; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
using ICSharpCode.SharpDevelop.Internal.ExternalTool; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
public class AssemblyTree : TreeView |
|
||||||
{ |
|
||||||
public static IAmbience CurrentAmbience = AmbienceService.CurrentAmbience; |
|
||||||
|
|
||||||
ArrayList assemblies = new ArrayList(); |
|
||||||
AssemblyScoutViewContent _parent; |
|
||||||
|
|
||||||
public ShowOptions showInternalTypes, showInternalMembers; |
|
||||||
public ShowOptions showPrivateTypes, showPrivateMembers; |
|
||||||
|
|
||||||
public bool showSpecial = false; |
|
||||||
|
|
||||||
MenuItem mnuBack; |
|
||||||
MenuItem mnuLoadAsm, mnuLoadStd, mnuLoadRef; |
|
||||||
MenuItem mnuRemAsm, mnuCopyTree, mnuSaveRes, mnuJump, mnuOpenRef, mnuDisAsm; |
|
||||||
|
|
||||||
Stack history = new Stack(); |
|
||||||
bool histback = false; |
|
||||||
|
|
||||||
AssemblyTreeNode selnode; |
|
||||||
|
|
||||||
public event EventHandler Changed; |
|
||||||
|
|
||||||
public AssemblyTree(AssemblyScoutViewContent parent) : base() |
|
||||||
{ |
|
||||||
if (Changed != null) {} // only to prevent these pesky compiler warning :) M.K.
|
|
||||||
|
|
||||||
Dock = DockStyle.Fill; |
|
||||||
|
|
||||||
string resPrefix = "ObjectBrowser.Menu."; |
|
||||||
|
|
||||||
this.ImageList = ClassBrowserIconService.ImageList; |
|
||||||
|
|
||||||
LabelEdit = false; |
|
||||||
HotTracking = false; |
|
||||||
AllowDrop = true; |
|
||||||
HideSelection = false; |
|
||||||
|
|
||||||
mnuBack = new MenuItem(StringParser.Parse("${res:" + resPrefix + "GoBack}"), new EventHandler(Back)); |
|
||||||
mnuLoadAsm = new MenuItem(StringParser.Parse("${res:" + resPrefix + "LoadAssembly}"), new EventHandler(LoadAssembly)); |
|
||||||
mnuLoadStd = new MenuItem(StringParser.Parse("${res:" + resPrefix + "LoadStd}"), new EventHandler(LoadStdAssemblies)); |
|
||||||
mnuLoadRef = new MenuItem(StringParser.Parse("${res:" + resPrefix + "LoadRef}"), new EventHandler(LoadRefAssemblies)); |
|
||||||
|
|
||||||
mnuRemAsm = new MenuItem(StringParser.Parse("${res:" + resPrefix + "RemoveAsm}"), new EventHandler(RemoveAssembly)); |
|
||||||
mnuCopyTree = new MenuItem(StringParser.Parse("${res:" + resPrefix + "CopyTree}"), new EventHandler(CopyAssemblyTree)); |
|
||||||
mnuSaveRes = new MenuItem(StringParser.Parse("${res:" + resPrefix + "SaveRes}"), new EventHandler(SaveCurrentResource)); |
|
||||||
mnuJump = new MenuItem(StringParser.Parse("${res:" + resPrefix + "JumpType}"), new EventHandler(JumpLink)); |
|
||||||
mnuOpenRef = new MenuItem(StringParser.Parse("${res:" + resPrefix + "OpenRef}"), new EventHandler(OpenReference)); |
|
||||||
mnuDisAsm = new MenuItem(StringParser.Parse("${res:" + resPrefix + "DisasmToFile}"), new EventHandler(DisAssembly)); |
|
||||||
|
|
||||||
ContextMenu = new ContextMenu(new MenuItem[] { |
|
||||||
mnuBack, |
|
||||||
new MenuItem("-"), |
|
||||||
mnuLoadAsm, |
|
||||||
mnuLoadStd, |
|
||||||
mnuLoadRef, |
|
||||||
new MenuItem("-"), |
|
||||||
mnuRemAsm, |
|
||||||
mnuCopyTree, |
|
||||||
mnuSaveRes, |
|
||||||
mnuJump, |
|
||||||
mnuOpenRef, |
|
||||||
mnuDisAsm |
|
||||||
}); |
|
||||||
|
|
||||||
showPrivateTypes = (ShowOptions)PropertyService.Get("AddIns.AssemblyScout.privateTypesBox", 1); |
|
||||||
showInternalTypes = (ShowOptions)PropertyService.Get("AddIns.AssemblyScout.internalTypesBox", 1); |
|
||||||
showPrivateMembers = (ShowOptions)PropertyService.Get("AddIns.AssemblyScout.privateMembersBox", 1); |
|
||||||
showInternalMembers = (ShowOptions)PropertyService.Get("AddIns.AssemblyScout.internalMembersBox", 1); |
|
||||||
showSpecial = PropertyService.Get("AddIns.AssemblyScout.ShowSpecialMethods", false); |
|
||||||
|
|
||||||
_parent = parent; |
|
||||||
} |
|
||||||
|
|
||||||
public ArrayList Assemblies { |
|
||||||
get { |
|
||||||
return assemblies; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public PrintDocument PrintDocument { |
|
||||||
get { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public bool WriteProtected { |
|
||||||
get { |
|
||||||
return false; |
|
||||||
} |
|
||||||
set { |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void LoadFile(string fileName) |
|
||||||
{ |
|
||||||
AddAssembly(SA.SharpAssembly.LoadFrom(fileName)); |
|
||||||
} |
|
||||||
|
|
||||||
public bool IsAssemblyLoaded(string filename) |
|
||||||
{ |
|
||||||
try { |
|
||||||
foreach(SA.SharpAssembly asm in assemblies) { |
|
||||||
if (asm.Location == filename) return true; |
|
||||||
} |
|
||||||
} catch { |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void SaveFile(string filename) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public void AddAssembly(SA.SharpAssembly assembly) |
|
||||||
{ |
|
||||||
try { |
|
||||||
if (IsAssemblyLoaded(assembly.Location)) return; |
|
||||||
|
|
||||||
assemblies.Add(assembly); |
|
||||||
|
|
||||||
TreeNode node = new FolderNode(System.IO.Path.GetFileNameWithoutExtension(assembly.Location), assembly, NodeType.Assembly, 0, 1); |
|
||||||
Nodes.Add(node); |
|
||||||
PopulateTree((AssemblyTreeNode)node); |
|
||||||
} catch (Exception e) { |
|
||||||
MessageBox.Show("Could not load assembly: " + e.ToString()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void RePopulateTreeView() |
|
||||||
{ |
|
||||||
foreach (AssemblyTreeNode node in Nodes) { |
|
||||||
node.Populate(showPrivateTypes, showInternalTypes); |
|
||||||
PopulateTree(node); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void PopulateTree(AssemblyTreeNode parentnode) |
|
||||||
{ |
|
||||||
if (!parentnode.Populated) |
|
||||||
parentnode.Populate(showPrivateTypes, showInternalTypes); |
|
||||||
|
|
||||||
foreach (AssemblyTreeNode node in parentnode.Nodes) { |
|
||||||
if (!node.Populated) { |
|
||||||
node.Populate(showPrivateTypes, showInternalTypes); |
|
||||||
} |
|
||||||
PopulateTree(node); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void GoToMember(IMember member) |
|
||||||
{ |
|
||||||
string paramtext = ""; |
|
||||||
SharpAssemblyClass declaringType = member.DeclaringType as SharpAssemblyClass; |
|
||||||
TypeNode typenode = GetTypeNode((SA.SharpAssembly)declaringType.DeclaredIn, declaringType.Namespace, declaringType.FullyQualifiedName); |
|
||||||
if (typenode == null) return; |
|
||||||
|
|
||||||
bool isEnum = false; |
|
||||||
if (member.DeclaringType != null && member.DeclaringType.ClassType == ClassType.Enum) isEnum = true; |
|
||||||
|
|
||||||
paramtext = MemberNode.GetShortMemberName(member, isEnum); |
|
||||||
|
|
||||||
if (!typenode.MembersPopulated) { |
|
||||||
typenode.PopulateMembers(showPrivateMembers, showInternalMembers, showSpecial); |
|
||||||
} |
|
||||||
|
|
||||||
TreeNode foundnode = typenode.GetNodeFromChildren(paramtext); |
|
||||||
if (foundnode == null) return; |
|
||||||
|
|
||||||
foundnode.EnsureVisible(); |
|
||||||
SelectedNode = foundnode; |
|
||||||
} |
|
||||||
|
|
||||||
public void GoToNamespace(SA.SharpAssembly asm, string name) |
|
||||||
{ |
|
||||||
foreach (AssemblyTreeNode node in Nodes) { |
|
||||||
SA.SharpAssembly assembly = (SA.SharpAssembly)node.Attribute; |
|
||||||
if (asm.FullName == assembly.FullName) { |
|
||||||
|
|
||||||
// curnode contains Filename node
|
|
||||||
AssemblyTreeNode curnode = (AssemblyTreeNode)node.GetNodeFromChildren(Path.GetFileName(assembly.Location)); |
|
||||||
|
|
||||||
TreeNode tnode = curnode.GetNodeFromChildren(name); // get namespace node
|
|
||||||
if (tnode == null) return; |
|
||||||
tnode.EnsureVisible(); |
|
||||||
SelectedNode = tnode; |
|
||||||
return; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// execute if assembly containing the type is not loaded
|
|
||||||
AddAssembly(asm); |
|
||||||
GoToNamespace(asm, name); |
|
||||||
} |
|
||||||
|
|
||||||
private TypeNode GetTypeNode(SA.SharpAssembly targetAssembly, string Namespace, string FullName) |
|
||||||
{ |
|
||||||
foreach (AssemblyTreeNode node in Nodes) { |
|
||||||
SA.SharpAssembly assembly = (SA.SharpAssembly)node.Attribute; |
|
||||||
if (targetAssembly.FullName == assembly.FullName) { |
|
||||||
|
|
||||||
// curnode contains Filename node
|
|
||||||
AssemblyTreeNode curnode = (AssemblyTreeNode)node.GetNodeFromChildren(Path.GetFileName(assembly.Location)); |
|
||||||
|
|
||||||
TreeNode path; |
|
||||||
|
|
||||||
if (Namespace == null || Namespace == "") { |
|
||||||
path = curnode; |
|
||||||
} else { |
|
||||||
TreeNode tnode = curnode.GetNodeFromChildren(Namespace); // get namespace node
|
|
||||||
if (tnode == null) { |
|
||||||
return null; // TODO : returns null if the tree isn't up to date.
|
|
||||||
} else { |
|
||||||
path = tnode; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
string nodename = FullName.Substring(Namespace.Length + 1); |
|
||||||
|
|
||||||
TreeNode foundnode = node.GetNodeFromCollection(path.Nodes, nodename); |
|
||||||
return (TypeNode)foundnode; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// execute if assembly containing the type is not loaded
|
|
||||||
AddAssembly(targetAssembly); |
|
||||||
return GetTypeNode(targetAssembly, Namespace, FullName); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public void GoToType(IClass type) |
|
||||||
{ |
|
||||||
AssemblyTreeNode node = GetTypeNode((SA.SharpAssembly)((SharpAssemblyClass)type).DeclaredIn, type.Namespace, type.FullyQualifiedName); |
|
||||||
if (node == null) { |
|
||||||
Console.WriteLine("No node for type found"); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
node.EnsureVisible(); |
|
||||||
SelectedNode = node; |
|
||||||
} |
|
||||||
|
|
||||||
public void GoToType(IReturnType type) |
|
||||||
{ |
|
||||||
AssemblyTreeNode node = GetTypeNode((SA.SharpAssembly)((SharpAssemblyClass)type).DeclaredIn, type.Namespace, type.FullyQualifiedName); |
|
||||||
if (node == null) return; |
|
||||||
|
|
||||||
node.EnsureVisible(); |
|
||||||
SelectedNode = node; |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnDoubleClick(EventArgs e) |
|
||||||
{ |
|
||||||
AssemblyTreeNode rn = (AssemblyTreeNode)SelectedNode; |
|
||||||
if (rn == null) |
|
||||||
return; |
|
||||||
switch (rn.Type) { |
|
||||||
|
|
||||||
case NodeType.Link: // clicked on link, jump to link.
|
|
||||||
if (rn.Attribute is Type) { |
|
||||||
GoToType((IClass)rn.Attribute); |
|
||||||
} |
|
||||||
break; |
|
||||||
|
|
||||||
case NodeType.Reference: // clicked on assembly reference, open assembly
|
|
||||||
// check if the assembly is open
|
|
||||||
RefNodeAttribute attr = (RefNodeAttribute)rn.Attribute; |
|
||||||
OpenAssemblyByName(attr); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void OpenAssemblyByName(RefNodeAttribute attr) |
|
||||||
{ |
|
||||||
foreach (AssemblyTreeNode node in Nodes) { |
|
||||||
if (node.Type == NodeType.Assembly) { |
|
||||||
if (attr.RefName.FullName == ((SA.SharpAssembly)node.Attribute).FullName) { // if yes, return
|
|
||||||
node.EnsureVisible(); |
|
||||||
SelectedNode = node; |
|
||||||
return; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
try { |
|
||||||
AddAssembly(SA.SharpAssembly.Load(attr.RefName.FullName, System.IO.Path.GetDirectoryName(attr.Assembly.Location))); |
|
||||||
OpenAssemblyByName(attr); |
|
||||||
} catch(Exception ex) { |
|
||||||
MessageBox.Show(String.Format(StringParser.Parse("${res:ObjectBrowser.LoadError}"), attr.RefName.Name, ex.Message), StringParser.Parse("${res:Global.ErrorText}"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnBeforeCollapse(TreeViewCancelEventArgs e) |
|
||||||
{ |
|
||||||
base.OnBeforeCollapse(e); |
|
||||||
((AssemblyTreeNode)e.Node).OnCollapse(); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnBeforeExpand(TreeViewCancelEventArgs e) |
|
||||||
{ |
|
||||||
base.OnBeforeExpand(e); |
|
||||||
|
|
||||||
AssemblyTreeNode rn = (AssemblyTreeNode)e.Node; |
|
||||||
if (!rn.Populated) |
|
||||||
rn.Populate(showPrivateTypes, showInternalTypes); |
|
||||||
|
|
||||||
if (e.Node is TypeNode) { |
|
||||||
TypeNode tn = e.Node as TypeNode; |
|
||||||
|
|
||||||
if (!tn.MembersPopulated) |
|
||||||
tn.PopulateMembers(showPrivateMembers, showInternalMembers, showSpecial); |
|
||||||
} |
|
||||||
|
|
||||||
((AssemblyTreeNode)e.Node).OnExpand(); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnMouseDown(MouseEventArgs ev) |
|
||||||
{ |
|
||||||
base.OnMouseDown(ev); |
|
||||||
|
|
||||||
AssemblyTreeNode node = GetNodeAt(ev.X, ev.Y) as AssemblyTreeNode; |
|
||||||
if (node != null) { |
|
||||||
if (ev.Button == MouseButtons.Right) histback = true; |
|
||||||
SelectedNode = node; |
|
||||||
histback = false; |
|
||||||
mnuRemAsm.Visible = (node.Type == NodeType.Assembly); |
|
||||||
mnuDisAsm.Visible = (node.Type == NodeType.Assembly); |
|
||||||
mnuCopyTree.Visible = (node.Type == NodeType.Library); |
|
||||||
mnuSaveRes.Visible = (node.Type == NodeType.Resource); |
|
||||||
mnuJump.Visible = (node.Type == NodeType.Link); |
|
||||||
mnuOpenRef.Visible = (node.Type == NodeType.Reference); |
|
||||||
selnode = node; |
|
||||||
} else { |
|
||||||
mnuRemAsm.Visible = false; |
|
||||||
mnuDisAsm.Visible = false; |
|
||||||
mnuCopyTree.Visible = false; |
|
||||||
mnuSaveRes.Visible = false; |
|
||||||
mnuJump.Visible = false; |
|
||||||
mnuOpenRef.Visible = false; |
|
||||||
selnode = null; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public void LoadAssembly(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
using (SelectReferenceDialog selDialog = new SelectReferenceDialog(new TempProject())) { |
|
||||||
if (selDialog.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) { |
|
||||||
|
|
||||||
foreach (ProjectItem item in selDialog.ReferenceInformations) { |
|
||||||
if (item.ItemType != ItemType.Reference) continue; |
|
||||||
|
|
||||||
if (!IsAssemblyLoaded(item.FileName)) { |
|
||||||
try { |
|
||||||
LoadFile(item.FileName); |
|
||||||
} catch (Exception) {} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void LoadStdAssemblies(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
_parent.LoadStdAssemblies(); |
|
||||||
} |
|
||||||
|
|
||||||
void LoadRefAssemblies(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
_parent.LoadRefAssemblies(); |
|
||||||
} |
|
||||||
/* |
|
||||||
void ShowPrivTypesEvt(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
showPrivateTypes = !showPrivateTypes; |
|
||||||
PropertyService.Set("ObjectBrowser.ShowPrivTypes", showPrivateTypes); |
|
||||||
mnuShowPrivTypes.Checked = showPrivateTypes; |
|
||||||
RePopulateTreeView(); |
|
||||||
} |
|
||||||
|
|
||||||
void ShowIntTypesEvt(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
showInternalTypes = !showInternalTypes; |
|
||||||
PropertyService.Set("ObjectBrowser.ShowIntTypes", showInternalTypes); |
|
||||||
mnuShowIntTypes.Checked = showInternalTypes; |
|
||||||
RePopulateTreeView(); |
|
||||||
} |
|
||||||
|
|
||||||
void ShowPrivMemEvt(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
showPrivateMembers = !showPrivateMembers; |
|
||||||
PropertyService.Set("ObjectBrowser.ShowPrivMembers", showPrivateMembers); |
|
||||||
mnuShowPrivMem.Checked = showPrivateMembers; |
|
||||||
RePopulateTreeView(); |
|
||||||
} |
|
||||||
|
|
||||||
void ShowIntMemEvt(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
showInternalMembers = !showInternalMembers; |
|
||||||
PropertyService.Set("ObjectBrowser.ShowIntMembers", showInternalMembers); |
|
||||||
mnuShowIntMem.Checked = showInternalMembers; |
|
||||||
RePopulateTreeView(); |
|
||||||
} |
|
||||||
|
|
||||||
void ShowSpecialEvt(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
showSpecial = !showSpecial; |
|
||||||
PropertyService.Set("ObjectBrowser.ShowSpecialMethods", showSpecial); |
|
||||||
mnuShowSpecial.Checked = showSpecial; |
|
||||||
RePopulateTreeView(); |
|
||||||
} |
|
||||||
*/ |
|
||||||
|
|
||||||
public void RemoveAssembly(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
if (selnode == null) return; |
|
||||||
if (selnode.Type != NodeType.Assembly) return; |
|
||||||
|
|
||||||
assemblies.Remove((SA.SharpAssembly)selnode.Attribute); |
|
||||||
selnode.Remove(); |
|
||||||
} |
|
||||||
|
|
||||||
public void CopyAssemblyTree(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
if (selnode == null) return; |
|
||||||
if (selnode.Type != NodeType.Library) return; |
|
||||||
|
|
||||||
StringBuilder stb = new StringBuilder(); |
|
||||||
|
|
||||||
stb.Append(selnode.Text + "\n"); |
|
||||||
GetSubNodeText(selnode, stb, 1); |
|
||||||
|
|
||||||
Clipboard.SetDataObject(stb.ToString(), true); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
private static void GetSubNodeText(TreeNode node, StringBuilder build, int indentLevel) { |
|
||||||
foreach (TreeNode tn in node.Nodes) { |
|
||||||
build.Append('\t', indentLevel); |
|
||||||
build.Append(tn.Text + "\n"); |
|
||||||
GetSubNodeText(tn, build, indentLevel + 1); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void DisAssembly(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
if (selnode == null) return; |
|
||||||
if (selnode.Type != NodeType.Assembly) return; |
|
||||||
|
|
||||||
SA.SharpAssembly asm = (SA.SharpAssembly)selnode.Attribute; |
|
||||||
|
|
||||||
SaveFileDialog sdialog = new SaveFileDialog(); |
|
||||||
sdialog.AddExtension = true; |
|
||||||
sdialog.FileName = asm.Name; |
|
||||||
sdialog.Filter = "IL files (*.il)|*.il"; |
|
||||||
sdialog.DefaultExt = ".il"; |
|
||||||
sdialog.InitialDirectory = Path.GetDirectoryName(asm.Location); |
|
||||||
|
|
||||||
DialogResult dr = sdialog.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm); |
|
||||||
sdialog.Dispose(); |
|
||||||
if(dr != DialogResult.OK) return; |
|
||||||
|
|
||||||
try { |
|
||||||
string args = '"' + asm.Location + "\" /NOBAR /OUT=\"" + sdialog.FileName + "\" /ALL "; |
|
||||||
ProcessStartInfo psi = new ProcessStartInfo(Path.Combine(FileUtility.NetSdkInstallRoot, "bin\\ildasm.exe"), args); |
|
||||||
|
|
||||||
psi.RedirectStandardError = true; |
|
||||||
psi.RedirectStandardOutput = true; |
|
||||||
psi.RedirectStandardInput = true; |
|
||||||
psi.UseShellExecute = false; |
|
||||||
psi.CreateNoWindow = true; |
|
||||||
|
|
||||||
Process process = Process.Start(psi); |
|
||||||
string output = process.StandardOutput.ReadToEnd(); |
|
||||||
process.WaitForExit(); |
|
||||||
|
|
||||||
MessageBox.Show(String.Format(StringParser.Parse("${res:ObjectBrowser.ILDasmOutput}"), output)); |
|
||||||
} catch(Exception ex) { |
|
||||||
MessageBox.Show(String.Format(StringParser.Parse("${res:ObjectBrowser.ILDasmError}"), ex.ToString())); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void SaveCurrentResource(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
if (selnode == null) return; |
|
||||||
if (selnode.Type != NodeType.Resource) return; |
|
||||||
|
|
||||||
SA.SharpAssembly asm = (SA.SharpAssembly)selnode.Attribute; |
|
||||||
SaveResource(asm, selnode.Text); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public void SaveResource(SA.SharpAssembly asm, string name) |
|
||||||
{ |
|
||||||
SaveFileDialog sdialog = new SaveFileDialog(); |
|
||||||
sdialog.AddExtension = true; |
|
||||||
sdialog.FileName = name; |
|
||||||
sdialog.Filter = StringParser.Parse("${res:ObjectBrowser.Filters.Binary}") + "|*.*"; |
|
||||||
sdialog.DefaultExt = ".bin"; |
|
||||||
|
|
||||||
DialogResult dr = sdialog.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm); |
|
||||||
sdialog.Dispose(); |
|
||||||
if(dr != DialogResult.OK) return; |
|
||||||
|
|
||||||
try { |
|
||||||
byte[] res = asm.GetManifestResource(name); |
|
||||||
FileStream fstr = new FileStream(sdialog.FileName, FileMode.Create); |
|
||||||
BinaryWriter wr = new BinaryWriter(fstr); |
|
||||||
wr.Write(res); |
|
||||||
fstr.Close(); |
|
||||||
} catch { |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public void JumpLink(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
if (selnode == null) return; |
|
||||||
if (selnode.Type != NodeType.Link) return; |
|
||||||
|
|
||||||
OnDoubleClick(e); |
|
||||||
} |
|
||||||
|
|
||||||
public void OpenReference(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
if (selnode == null) return; |
|
||||||
if (selnode.Type != NodeType.Reference) return; |
|
||||||
|
|
||||||
OnDoubleClick(e); |
|
||||||
} |
|
||||||
|
|
||||||
void Back(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
if (history.Count == 0) return; |
|
||||||
try { |
|
||||||
histback = true; |
|
||||||
TreeNode selnode = history.Pop() as TreeNode; |
|
||||||
if (selnode != null) { |
|
||||||
selnode.EnsureVisible(); |
|
||||||
SelectedNode = selnode; |
|
||||||
} |
|
||||||
} finally { |
|
||||||
histback = false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnBeforeSelect(TreeViewCancelEventArgs ev) |
|
||||||
{ |
|
||||||
base.OnBeforeSelect(ev); |
|
||||||
if (!histback) { |
|
||||||
// HACK : stack is cleared if too much elements
|
|
||||||
if (history.Count >= 100) history.Clear(); |
|
||||||
history.Push(SelectedNode); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void GoBack() |
|
||||||
{ |
|
||||||
try { |
|
||||||
Back(mnuBack, new EventArgs()); |
|
||||||
} catch {} |
|
||||||
} |
|
||||||
|
|
||||||
public class RefNodeAttribute |
|
||||||
{ |
|
||||||
public SA.SharpAssembly Assembly; |
|
||||||
public SA.SharpAssemblyName RefName; |
|
||||||
|
|
||||||
public RefNodeAttribute(SA.SharpAssembly asm, SA.SharpAssemblyName name) |
|
||||||
{ |
|
||||||
Assembly = asm; |
|
||||||
RefName = name; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e) |
|
||||||
{ |
|
||||||
base.OnMouseUp(e); |
|
||||||
|
|
||||||
if (e.Button == MouseButtons.XButton1) { |
|
||||||
GoBack(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public class TreeNodeComparer : IComparer |
|
||||||
{ |
|
||||||
public int Compare(object x, object y) |
|
||||||
{ |
|
||||||
return String.Compare(((TreeNode)x).Text, ((TreeNode)y).Text); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public enum ShowOptions |
|
||||||
{ |
|
||||||
Show = 0, |
|
||||||
GreyOut = 1, |
|
||||||
Hide = 2 |
|
||||||
} |
|
||||||
} |
|
@ -1,202 +0,0 @@ |
|||||||
// created on 11.12.2002 at 16:10
|
|
||||||
using System; |
|
||||||
using System.Windows.Forms; |
|
||||||
using System.Drawing; |
|
||||||
using System.Reflection; |
|
||||||
using ICSharpCode.Core; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout { |
|
||||||
|
|
||||||
public class ExtendedPropsPanel : System.Windows.Forms.Panel |
|
||||||
{ |
|
||||||
PropertyViewer props; |
|
||||||
AssemblyTree _tree; |
|
||||||
|
|
||||||
public ExtendedPropsPanel(AssemblyTree tree) |
|
||||||
{ |
|
||||||
_tree = tree; |
|
||||||
_tree.AfterSelect += new TreeViewEventHandler(SelectNode); |
|
||||||
|
|
||||||
InitializeComponents(); |
|
||||||
} |
|
||||||
|
|
||||||
void InitializeComponents() |
|
||||||
{ |
|
||||||
Dock = DockStyle.Fill; |
|
||||||
|
|
||||||
props = new PropertyViewer(_tree); |
|
||||||
props.Size = new Size(Width, Height); |
|
||||||
props.Dock = DockStyle.Fill; |
|
||||||
props.BackClick += new EventHandler(back_click); |
|
||||||
|
|
||||||
Controls.Add(props); |
|
||||||
} |
|
||||||
|
|
||||||
void back_click(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
try { |
|
||||||
_tree.GoBack(); |
|
||||||
} catch {} |
|
||||||
} |
|
||||||
|
|
||||||
void SelectNode(object sender, TreeViewEventArgs e) |
|
||||||
{ |
|
||||||
AssemblyTreeNode node = (AssemblyTreeNode)e.Node; |
|
||||||
object toShow = node.Attribute; |
|
||||||
|
|
||||||
switch(node.Type) { |
|
||||||
case NodeType.Assembly: |
|
||||||
case NodeType.Library: |
|
||||||
case NodeType.Reference: |
|
||||||
case NodeType.Module: |
|
||||||
case NodeType.Link: |
|
||||||
case NodeType.Type: |
|
||||||
case NodeType.Constructor: |
|
||||||
case NodeType.Event: |
|
||||||
case NodeType.Field: |
|
||||||
case NodeType.Method: |
|
||||||
case NodeType.Property: |
|
||||||
break; |
|
||||||
case NodeType.Resource: |
|
||||||
case NodeType.Folder: |
|
||||||
case NodeType.Namespace: |
|
||||||
case NodeType.SubTypes: |
|
||||||
case NodeType.SuperTypes: |
|
||||||
toShow = null; |
|
||||||
break; |
|
||||||
default: |
|
||||||
toShow = null; |
|
||||||
break; |
|
||||||
} |
|
||||||
props.ShowObject(toShow, node.Text, node.Type.ToString()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class PropertyViewer : System.Windows.Forms.UserControl |
|
||||||
{ |
|
||||||
ListView list = new ListView(); |
|
||||||
GradientLabel cap = new GradientLabel(); |
|
||||||
Label typ = new Label(); |
|
||||||
LinkLabel back = new LinkLabel(); |
|
||||||
ColumnHeader namecol; |
|
||||||
ColumnHeader valuecol; |
|
||||||
|
|
||||||
AssemblyTree tree; |
|
||||||
|
|
||||||
public event EventHandler BackClick; |
|
||||||
|
|
||||||
private System.ComponentModel.Container components = null; |
|
||||||
|
|
||||||
public PropertyViewer(AssemblyTree _tree) |
|
||||||
{ |
|
||||||
tree = _tree; |
|
||||||
InitializeComponent(); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
protected override void Dispose( bool disposing ) |
|
||||||
{ |
|
||||||
if( disposing ) |
|
||||||
{ |
|
||||||
if(components != null) |
|
||||||
{ |
|
||||||
components.Dispose(); |
|
||||||
} |
|
||||||
} |
|
||||||
base.Dispose( disposing ); |
|
||||||
} |
|
||||||
|
|
||||||
private void InitializeComponent() |
|
||||||
{ |
|
||||||
cap.Location = new Point(0, 0); |
|
||||||
cap.Size = new Size(Width, 32); |
|
||||||
cap.Text = StringParser.Parse("${res:ObjectBrowser.Welcome}"); |
|
||||||
cap.Font = new Font("Tahoma", 14); |
|
||||||
cap.BackColor = SystemColors.ControlLight; |
|
||||||
cap.TextAlign = ContentAlignment.MiddleLeft; |
|
||||||
cap.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; |
|
||||||
|
|
||||||
string backt = StringParser.Parse("${res:ObjectBrowser.Back}"); |
|
||||||
back.Size = new Size(40, 16); |
|
||||||
back.Location = new Point(Width - back.Width, 44); |
|
||||||
back.Text = backt; |
|
||||||
back.TextAlign = ContentAlignment.TopRight; |
|
||||||
back.Anchor = AnchorStyles.Top | AnchorStyles.Right; |
|
||||||
back.Links.Add(0, backt.Length); |
|
||||||
back.LinkClicked += new LinkLabelLinkClickedEventHandler(back_click); |
|
||||||
|
|
||||||
typ.Location = new Point(0, 44); |
|
||||||
typ.Size = new Size(Width - back.Width, 16); |
|
||||||
typ.Font = new Font(Font, FontStyle.Bold); |
|
||||||
typ.Text = StringParser.Parse("${res:ObjectBrowser.WelcomeText}"); |
|
||||||
typ.TextAlign = ContentAlignment.TopLeft; |
|
||||||
typ.Anchor = cap.Anchor; |
|
||||||
|
|
||||||
list.Location = new Point(0, 72); |
|
||||||
list.Size = new Size(Width, Height - list.Top); |
|
||||||
list.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; |
|
||||||
list.FullRowSelect = true; |
|
||||||
list.GridLines = true; |
|
||||||
list.View = View.Details; |
|
||||||
|
|
||||||
namecol = new ColumnHeader(); |
|
||||||
namecol.Text = StringParser.Parse("${res:ObjectBrowser.Props.Property}"); |
|
||||||
namecol.Width = 120; |
|
||||||
|
|
||||||
valuecol = new ColumnHeader(); |
|
||||||
valuecol.Text = StringParser.Parse("${res:ObjectBrowser.Props.Value}"); |
|
||||||
valuecol.Width = 300; |
|
||||||
|
|
||||||
list.Columns.Add(namecol); |
|
||||||
list.Columns.Add(valuecol); |
|
||||||
|
|
||||||
Controls.AddRange(new System.Windows.Forms.Control[] {cap, typ, list, back}); |
|
||||||
} |
|
||||||
|
|
||||||
public void ShowObject(object obj, string title, string subtitle) |
|
||||||
{ |
|
||||||
cap.Text = title; |
|
||||||
typ.Text = subtitle; |
|
||||||
list.Items.Clear(); |
|
||||||
|
|
||||||
if (obj == null) |
|
||||||
{ |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
SetProps(obj); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
void SetProps(object o) |
|
||||||
{ |
|
||||||
Type type = o.GetType(); |
|
||||||
PropertyInfo[] pi = type.GetProperties(); |
|
||||||
|
|
||||||
for(int i=0; i < pi.Length; ++i) |
|
||||||
{ |
|
||||||
object ret = null; |
|
||||||
try |
|
||||||
{ |
|
||||||
ret = type.InvokeMember(pi[i].Name, BindingFlags.GetProperty, null, o, new object [] {}); |
|
||||||
|
|
||||||
AddItem(pi[i].Name, (ret == null) ? "<null>" : ret.ToString()); |
|
||||||
} |
|
||||||
catch |
|
||||||
{ |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void AddItem(string name, string val) |
|
||||||
{ |
|
||||||
list.Items.Add(new ListViewItem(new string[] {name, val})); |
|
||||||
} |
|
||||||
|
|
||||||
void back_click(object sender, LinkLabelLinkClickedEventArgs ev) |
|
||||||
{ |
|
||||||
BackClick(this, EventArgs.Empty); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -1,144 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.IO; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.Drawing.Printing; |
|
||||||
using System.Windows.Forms; |
|
||||||
using System.Drawing; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using Microsoft.Win32; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
public class ILDasmView : UserControl |
|
||||||
{ |
|
||||||
CheckBox chk = new CheckBox(); |
|
||||||
RichTextBox tb = new RichTextBox(); |
|
||||||
AssemblyTree tree; |
|
||||||
|
|
||||||
public ILDasmView(AssemblyTree tree) |
|
||||||
{ |
|
||||||
this.tree = tree; |
|
||||||
|
|
||||||
Dock = DockStyle.Fill; |
|
||||||
|
|
||||||
tb.Location = new Point(0, 24); |
|
||||||
tb.Size = new Size(Width, Height - 24); |
|
||||||
tb.Font = new System.Drawing.Font("Courier New", 10); |
|
||||||
tb.ScrollBars = RichTextBoxScrollBars.Both; |
|
||||||
tb.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom; |
|
||||||
|
|
||||||
tb.WordWrap = false; |
|
||||||
tb.ReadOnly = true; |
|
||||||
|
|
||||||
chk.Location = new Point(0, 0); |
|
||||||
chk.Size = new Size(250, 16); |
|
||||||
chk.Text = StringParser.Parse("${res:ObjectBrowser.ILDasm.Enable}"); |
|
||||||
chk.FlatStyle = FlatStyle.System; |
|
||||||
|
|
||||||
chk.CheckedChanged += new EventHandler(Check); |
|
||||||
Check(null, null); |
|
||||||
|
|
||||||
Controls.Add(tb); |
|
||||||
Controls.Add(chk); |
|
||||||
|
|
||||||
tree.AfterSelect += new TreeViewEventHandler(SelectNode); |
|
||||||
} |
|
||||||
|
|
||||||
void Check(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
if(chk.Checked) { |
|
||||||
tb.BackColor = SystemColors.Window; |
|
||||||
} else { |
|
||||||
tb.BackColor = SystemColors.Control; |
|
||||||
tb.Text = ""; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void SelectNode(object sender, TreeViewEventArgs e) |
|
||||||
{ |
|
||||||
if (!chk.Checked) return; |
|
||||||
|
|
||||||
AssemblyTreeNode node = (AssemblyTreeNode)e.Node; |
|
||||||
|
|
||||||
SA.SharpAssembly assembly = null; |
|
||||||
string item = " /item="; |
|
||||||
|
|
||||||
if (node.Attribute is SA.SharpAssembly) { |
|
||||||
assembly = (SA.SharpAssembly)node.Attribute; |
|
||||||
} else if (node.Attribute is SharpAssemblyClass) { |
|
||||||
// TODO Check this works - was node.Attribute is IClass if statement.
|
|
||||||
SharpAssemblyClass type = (SharpAssemblyClass)node.Attribute; |
|
||||||
item += type.FullyQualifiedName; |
|
||||||
assembly = (SA.SharpAssembly)type.DeclaredIn; |
|
||||||
} else if (node.Attribute is SharpAssemblyMethod) { |
|
||||||
// TODO Check this works - was node.Attribute is IMethod if statement.
|
|
||||||
SharpAssemblyMethod method = (SharpAssemblyMethod)node.Attribute; |
|
||||||
item += method.DeclaringType.FullyQualifiedName + "::" + method.Name; |
|
||||||
SharpAssemblyClass type = method.DeclaringType as SharpAssemblyClass; |
|
||||||
if (type != null) { |
|
||||||
assembly = (SA.SharpAssembly)type.DeclaredIn; |
|
||||||
} else { |
|
||||||
LoggingService.Error("ILDasmView.SelectedNode - Should not be getting here."); |
|
||||||
tb.Text = StringParser.Parse("${res:ObjectBrowser.ILDasm.NoView}"); |
|
||||||
return; |
|
||||||
} |
|
||||||
} else { |
|
||||||
tb.Text = StringParser.Parse("${res:ObjectBrowser.ILDasm.NoView}"); |
|
||||||
return; |
|
||||||
} |
|
||||||
tb.Text = GetILDASMOutput(assembly, item).Replace("\n", "\r\n"); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private string GetILDASMOutput(SA.SharpAssembly assembly, string item) |
|
||||||
{ |
|
||||||
try { |
|
||||||
string args = '"' + assembly.Location + '"' + item + " /NOBAR /TEXT"; |
|
||||||
ProcessStartInfo psi = new ProcessStartInfo(Path.Combine(FileUtility.NetSdkInstallRoot, "bin\\ildasm.exe"), args); |
|
||||||
|
|
||||||
psi.RedirectStandardError = true; |
|
||||||
psi.RedirectStandardOutput = true; |
|
||||||
psi.RedirectStandardInput = true; |
|
||||||
psi.UseShellExecute = false; |
|
||||||
psi.CreateNoWindow = true; |
|
||||||
|
|
||||||
Process process = Process.Start(psi); |
|
||||||
string output = process.StandardOutput.ReadToEnd(); |
|
||||||
process.WaitForExit(); |
|
||||||
|
|
||||||
int cutpos = output.IndexOf(".namespace"); |
|
||||||
|
|
||||||
if (cutpos != -1) { |
|
||||||
return output.Substring(cutpos); |
|
||||||
} |
|
||||||
|
|
||||||
cutpos = output.IndexOf(".class"); |
|
||||||
if (cutpos != -1) { |
|
||||||
return output.Substring(cutpos); |
|
||||||
} |
|
||||||
|
|
||||||
cutpos = output.IndexOf(".method"); |
|
||||||
if (cutpos != -1) { |
|
||||||
return output.Substring(cutpos); |
|
||||||
} |
|
||||||
|
|
||||||
return output; |
|
||||||
} catch (Exception) { |
|
||||||
return StringParser.Parse("${res:ObjectBrowser.ILDasm.NotInstalled}"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -1,822 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.IO; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.Drawing.Printing; |
|
||||||
using System.Windows.Forms; |
|
||||||
using System.Drawing; |
|
||||||
using System.Drawing.Imaging; |
|
||||||
using System.Drawing.Drawing2D; |
|
||||||
using System.Xml; |
|
||||||
using System.Text; |
|
||||||
using System.Text.RegularExpressions; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
public class InfoView : UserControl |
|
||||||
{ |
|
||||||
GradientLabel cap = new GradientLabel(); |
|
||||||
Label typ = new Label(); |
|
||||||
LinkLabel back = new LinkLabel(); |
|
||||||
|
|
||||||
WebBrowser ht = new WebBrowser(); |
|
||||||
Panel pan = new Panel(); |
|
||||||
|
|
||||||
AssemblyTree tree; |
|
||||||
IAmbience ambience; |
|
||||||
|
|
||||||
ArrayList references = new ArrayList(); |
|
||||||
string cssPath; |
|
||||||
string imgPath; |
|
||||||
string resPath; |
|
||||||
|
|
||||||
public InfoView(AssemblyTree tree) |
|
||||||
{ |
|
||||||
ambience = AmbienceService.CurrentAmbience; |
|
||||||
|
|
||||||
this.tree = tree; |
|
||||||
|
|
||||||
imgPath = Path.Combine(PropertyService.ConfigDirectory, "tempPicture.png"); |
|
||||||
cssPath = Path.Combine(PropertyService.ConfigDirectory, "tempStylesheet.css"); |
|
||||||
resPath = Path.Combine(PropertyService.ConfigDirectory, "tempResource"); |
|
||||||
|
|
||||||
Color col = SystemColors.Control; |
|
||||||
string color = "#" + col.R.ToString("X") + col.G.ToString("X") + col.B.ToString("X"); |
|
||||||
|
|
||||||
StreamWriter sw = new StreamWriter(cssPath, false); |
|
||||||
sw.Write(@"body { margin: 0px; border: 0px; overflow: hidden; padding: 0px;
|
|
||||||
background-color: " + color + @"; |
|
||||||
background-image: url(" + imgPath + @"); |
|
||||||
background-position: bottom right; |
|
||||||
background-repeat: no-repeat } |
|
||||||
|
|
||||||
p { font: 8pt Tahoma } |
|
||||||
div { margin: 0px; width: 100% } |
|
||||||
p.bottomline { font: 8pt Tahoma; border-bottom: 1px solid black; margin-bottom: 3px } |
|
||||||
p.docmargin { font: 8pt Tahoma; margin-top: 0px; margin-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-bottom: 3px; border-bottom: 1px solid black } |
|
||||||
|
|
||||||
a { font: 8pt Tahoma; text-decoration: none; color: blue} |
|
||||||
a:visited { color: blue } |
|
||||||
a:active { color: blue } |
|
||||||
a:hover { color: red; text-decoration: underline }");
|
|
||||||
sw.Close(); |
|
||||||
|
|
||||||
cap.Location = new Point(0, 0); |
|
||||||
cap.Size = new Size(Width, 32); |
|
||||||
cap.Text = StringParser.Parse("${res:ObjectBrowser.Welcome}"); |
|
||||||
cap.Font = new Font("Tahoma", 14); |
|
||||||
cap.BackColor = SystemColors.ControlLight; |
|
||||||
cap.TextAlign = ContentAlignment.MiddleLeft; |
|
||||||
cap.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; |
|
||||||
|
|
||||||
string backt = StringParser.Parse("${res:ObjectBrowser.Back}"); |
|
||||||
back.Size = new Size(40, 16); |
|
||||||
back.Location = new Point(Width - back.Width, 44); |
|
||||||
back.Text = backt; |
|
||||||
back.TextAlign = ContentAlignment.TopRight; |
|
||||||
back.Anchor = AnchorStyles.Top | AnchorStyles.Right; |
|
||||||
back.Links.Add(0, backt.Length); |
|
||||||
back.LinkClicked += new LinkLabelLinkClickedEventHandler(back_click); |
|
||||||
|
|
||||||
typ.Location = new Point(0, 44); |
|
||||||
typ.Size = new Size(Width - back.Width, 16); |
|
||||||
typ.Font = new Font(Font, FontStyle.Bold); |
|
||||||
typ.Text = StringParser.Parse("${res:ObjectBrowser.WelcomeText}"); |
|
||||||
typ.TextAlign = ContentAlignment.TopLeft; |
|
||||||
typ.Anchor = cap.Anchor; |
|
||||||
|
|
||||||
ht = new WebBrowser(); |
|
||||||
//ht.Size = new Size(20, 20);
|
|
||||||
//ht.Location = new Point(20, 20);
|
|
||||||
//ht.Navigating += new WebBrowserNavigatingEventHandler (HtmlControlBeforeNavigate);
|
|
||||||
CreateImage(ResourceService.GetIcon("Icons.16x16.Class").ToBitmap()); |
|
||||||
// TODO: StyleSheet
|
|
||||||
// ht.CascadingStyleSheet = cssPath;
|
|
||||||
string html = RenderHead() + StringParser.Parse("${res:ObjectBrowser.Info.SelectNode}") + RenderFoot(); |
|
||||||
LoggingService.Debug("Html=" + html); |
|
||||||
ht.DocumentText = html; |
|
||||||
|
|
||||||
pan.Location = new Point(0, 72); |
|
||||||
pan.DockPadding.Left = 10; |
|
||||||
pan.DockPadding.Bottom = 75; |
|
||||||
pan.Size = new Size(Width, Height - ht.Top); |
|
||||||
pan.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; |
|
||||||
pan.Controls.Add(ht); |
|
||||||
|
|
||||||
ht.Dock = DockStyle.Fill; |
|
||||||
|
|
||||||
Controls.AddRange(new Control[] { |
|
||||||
cap, typ, back, pan |
|
||||||
}); |
|
||||||
|
|
||||||
Dock = DockStyle.Fill; |
|
||||||
tree.AfterSelect += new TreeViewEventHandler(SelectNode); |
|
||||||
} |
|
||||||
|
|
||||||
~InfoView() { |
|
||||||
System.IO.File.Delete(imgPath); |
|
||||||
System.IO.File.Delete(cssPath); |
|
||||||
} |
|
||||||
|
|
||||||
void HtmlControlBeforeNavigate(object sender, WebBrowserNavigatingEventArgs e) |
|
||||||
{ |
|
||||||
e.Cancel = true; |
|
||||||
|
|
||||||
try { |
|
||||||
string url = e.Url.ToString(); |
|
||||||
url = e.Url.OriginalString; |
|
||||||
Console.WriteLine("url=" + url); |
|
||||||
// int refnr = Int32.Parse(url.Substring(5, url.Length - 6));
|
|
||||||
// object obj = references[refnr];
|
|
||||||
//
|
|
||||||
// if (obj is IClass) {
|
|
||||||
// // Go To Type
|
|
||||||
// tree.GoToType((IClass)obj);
|
|
||||||
// // try {
|
|
||||||
// // tree.SelectedNode.Expand();
|
|
||||||
// // } catch {}
|
|
||||||
// } else if (obj is AssemblyTree.RefNodeAttribute) {
|
|
||||||
// // Open Assembly Reference
|
|
||||||
// tree.OpenAssemblyByName((AssemblyTree.RefNodeAttribute)obj);
|
|
||||||
// } else if (obj is SaveResLink) {
|
|
||||||
// SaveResLink link = (SaveResLink)obj;
|
|
||||||
// tree.SaveResource(link.Asm, link.Name);
|
|
||||||
// } else if (obj is NamespaceLink) {
|
|
||||||
// NamespaceLink ns = (NamespaceLink)obj;
|
|
||||||
// tree.GoToNamespace(ns.Asm, ns.Name);
|
|
||||||
// }
|
|
||||||
|
|
||||||
} catch (Exception ex){ |
|
||||||
LoggingService.Debug("Something failed following this link.\r\n" + ex.ToString()); |
|
||||||
MessageService.ShowError("Something failed following this link."); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
string RenderHead() |
|
||||||
{ |
|
||||||
return String.Concat("<html><head><link rel='stylesheet' type='text/css' href='", cssPath, "'/></head><body><div><p>"); |
|
||||||
} |
|
||||||
|
|
||||||
string RenderFoot() |
|
||||||
{ |
|
||||||
return "</div></body></html>"; |
|
||||||
} |
|
||||||
|
|
||||||
void SelectNode(object sender, TreeViewEventArgs e) |
|
||||||
{ |
|
||||||
AssemblyTreeNode node = (AssemblyTreeNode)e.Node; |
|
||||||
cap.Text = node.Text; |
|
||||||
typ.Text = node.Type.ToString(); |
|
||||||
|
|
||||||
references.Clear(); |
|
||||||
|
|
||||||
ambience.LinkArrayList = references; |
|
||||||
ambience.ConversionFlags = ConversionFlags.AssemblyScoutDefaults; |
|
||||||
|
|
||||||
CreateImage(tree.ImageList.Images[node.ImageIndex]); |
|
||||||
//ht.Cursor = Cursors.Default;
|
|
||||||
StringBuilder htmlSB = new StringBuilder(RenderHead()); |
|
||||||
|
|
||||||
try { |
|
||||||
|
|
||||||
switch(node.Type) { |
|
||||||
case NodeType.Assembly: |
|
||||||
htmlSB.Append(GetAssemblyInfo((SA.SharpAssembly)node.Attribute)); |
|
||||||
break; |
|
||||||
case NodeType.Library: |
|
||||||
htmlSB.Append(GetLibInfo((SA.SharpAssembly)node.Attribute)); |
|
||||||
break; |
|
||||||
case NodeType.Reference: |
|
||||||
htmlSB.Append(GetRefInfo((AssemblyTree.RefNodeAttribute)node.Attribute)); |
|
||||||
break; |
|
||||||
case NodeType.Resource: |
|
||||||
htmlSB.Append(GetResInfo((SA.SharpAssembly)node.Attribute, node.Text)); |
|
||||||
break; |
|
||||||
case NodeType.SingleResource: |
|
||||||
htmlSB.Append(GetSingleResInfo(node.Attribute, node.Text)); |
|
||||||
break; |
|
||||||
case NodeType.Folder: |
|
||||||
htmlSB.Append(GetFolderInfo(node.Text)); |
|
||||||
break; |
|
||||||
case NodeType.Namespace: |
|
||||||
htmlSB.Append(GetNSInfo((SA.SharpAssembly)node.Attribute)); |
|
||||||
break; |
|
||||||
case NodeType.SubTypes: |
|
||||||
htmlSB.Append(GetSubInfo()); |
|
||||||
break; |
|
||||||
case NodeType.SuperTypes: |
|
||||||
htmlSB.Append(GetSuperInfo()); |
|
||||||
break; |
|
||||||
case NodeType.Link: |
|
||||||
htmlSB.Append(GetLinkInfo((IClass)node.Attribute)); |
|
||||||
break; |
|
||||||
case NodeType.Type: |
|
||||||
htmlSB.Append(GetTypeInfo((IClass)node.Attribute)); |
|
||||||
break; |
|
||||||
case NodeType.Event: |
|
||||||
htmlSB.Append(GetEventInfo((IEvent)node.Attribute)); |
|
||||||
break; |
|
||||||
case NodeType.Field: |
|
||||||
htmlSB.Append(GetFieldInfo((IField)node.Attribute)); |
|
||||||
break; |
|
||||||
case NodeType.Constructor: |
|
||||||
case NodeType.Method: |
|
||||||
htmlSB.Append(GetMethodInfo((IMethod)node.Attribute)); |
|
||||||
break; |
|
||||||
case NodeType.Property: |
|
||||||
htmlSB.Append(GetPropInfo((IProperty)node.Attribute)); |
|
||||||
break; |
|
||||||
default: |
|
||||||
break; |
|
||||||
} |
|
||||||
} catch(Exception ex) { |
|
||||||
htmlSB.Append("<p class='bottomline'>" + StringParser.Parse("${res:ObjectBrowser.Info.CollectError}") + "<p>" + ex.ToString().Replace("\n", "<br>")); |
|
||||||
} |
|
||||||
|
|
||||||
htmlSB.Append(RenderFoot()); |
|
||||||
|
|
||||||
ht.DocumentText = htmlSB.ToString(); |
|
||||||
LoggingService.Debug("Html=" + htmlSB.ToString()); |
|
||||||
} |
|
||||||
|
|
||||||
string GetLinkInfo(IClass type) |
|
||||||
{ |
|
||||||
StringBuilder text = new StringBuilder(ln(references.Add(type), RT("GotoType"))); |
|
||||||
text.Append("<p>"); |
|
||||||
text.Append(RT("LinkedType")); |
|
||||||
text.Append(" "); |
|
||||||
SharpAssemblyClass sharpAssemblyType = type as SharpAssemblyClass; |
|
||||||
text.Append(GetInAsm((SA.SharpAssembly)sharpAssemblyType.DeclaredIn)); |
|
||||||
return text.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string GetSubInfo() |
|
||||||
{ |
|
||||||
return RT("SubInfo"); |
|
||||||
} |
|
||||||
|
|
||||||
string GetSuperInfo() |
|
||||||
{ |
|
||||||
return RT("SuperInfo"); |
|
||||||
} |
|
||||||
|
|
||||||
string GetNSInfo(SA.SharpAssembly asm) |
|
||||||
{ |
|
||||||
return GetInAsm(asm); |
|
||||||
} |
|
||||||
|
|
||||||
string GetFolderInfo(string folder) |
|
||||||
{ |
|
||||||
if (folder == StringParser.Parse("${res:ObjectBrowser.Nodes.Resources}")) |
|
||||||
return RT("ResFInfo"); |
|
||||||
else if (folder == StringParser.Parse("${res:ObjectBrowser.Nodes.References}")) |
|
||||||
return RT("RefFInfo"); |
|
||||||
else if (folder == StringParser.Parse("${res:ObjectBrowser.Nodes.Modules}")) |
|
||||||
return RT("ModFInfo"); |
|
||||||
else |
|
||||||
return RT("NoInfo"); |
|
||||||
} |
|
||||||
|
|
||||||
string GetLibInfo(SA.SharpAssembly asm) |
|
||||||
{ |
|
||||||
return String.Concat(RT("LibInfo"), "<p>", GetInAsm(asm)); |
|
||||||
} |
|
||||||
|
|
||||||
string GetRefInfo(AssemblyTree.RefNodeAttribute asn) |
|
||||||
{ |
|
||||||
string text = String.Format(RT("RefInfo"), asn.RefName.Name, asn.RefName.FullName, asn.RefName.Version.ToString(), ""); |
|
||||||
return String.Concat(text, ln(references.Add(asn), RT("OpenRef"))); |
|
||||||
} |
|
||||||
|
|
||||||
string GetResInfo(SA.SharpAssembly asm, string name) |
|
||||||
{ |
|
||||||
long size = 0; |
|
||||||
try { |
|
||||||
size = asm.GetManifestResourceSize(name); |
|
||||||
} catch {} |
|
||||||
|
|
||||||
StringBuilder text = new StringBuilder(String.Format(RT("ResInfo"), name, size)); |
|
||||||
text.Append(GetInAsm(asm)); |
|
||||||
|
|
||||||
text.Append("<p>"); |
|
||||||
text.Append(ln(references.Add(new SaveResLink(asm, name)), RT("SaveRes"))); |
|
||||||
|
|
||||||
if (PropertyService.Get("AddIns.AssemblyScout.ShowResPreview", true) == false) { |
|
||||||
return text.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
try { |
|
||||||
if (name.ToLower().EndsWith(".bmp") || name.ToLower().EndsWith(".gif") |
|
||||||
|| name.ToLower().EndsWith(".png") || name.ToLower().EndsWith(".jpg")) { |
|
||||||
byte[] res = asm.GetManifestResource(name); |
|
||||||
FileStream fstr = new FileStream(resPath, FileMode.Create); |
|
||||||
BinaryWriter wr = new BinaryWriter(fstr); |
|
||||||
wr.Write(res); |
|
||||||
fstr.Close(); |
|
||||||
|
|
||||||
text.Append("<p>Preview:<p>"); |
|
||||||
text.Append("<img src=\""); |
|
||||||
text.Append(resPath); |
|
||||||
text.Append("\">"); |
|
||||||
} |
|
||||||
if (name.ToLower().EndsWith(".tif")) { |
|
||||||
byte[] res = asm.GetManifestResource(name); |
|
||||||
Image tifImg = Image.FromStream(new MemoryStream(res)); |
|
||||||
tifImg.Save(resPath, ImageFormat.Bmp); |
|
||||||
|
|
||||||
text.Append("<p>Preview:<p>"); |
|
||||||
text.Append("<img src=\""); |
|
||||||
text.Append(resPath); |
|
||||||
text.Append("\">"); |
|
||||||
} |
|
||||||
if (name.ToLower().EndsWith(".ico")) { |
|
||||||
byte[] res = asm.GetManifestResource(name); |
|
||||||
Icon icon = new Icon(new MemoryStream(res)); |
|
||||||
using (Bitmap b = new Bitmap(icon.Width, icon.Height)) { |
|
||||||
Graphics g = Graphics.FromImage(b); |
|
||||||
g.FillRectangle(SystemBrushes.Control, 0, 0, b.Width, b.Height); |
|
||||||
g.DrawIcon(icon, 0, 0); |
|
||||||
|
|
||||||
b.Save(resPath, System.Drawing.Imaging.ImageFormat.Png); |
|
||||||
} |
|
||||||
text.Append("<p>Preview:<p>"); |
|
||||||
text.Append("<img src=\""); |
|
||||||
text.Append(resPath); |
|
||||||
text.Append("\">"); |
|
||||||
} |
|
||||||
if (name.ToLower().EndsWith(".cur")) { |
|
||||||
byte[] res = asm.GetManifestResource(name); |
|
||||||
Cursor cursor = new Cursor(new MemoryStream(res)); |
|
||||||
|
|
||||||
using (Bitmap b = new Bitmap(cursor.Size.Width, cursor.Size.Height)) { |
|
||||||
Graphics g = Graphics.FromImage(b); |
|
||||||
g.FillRectangle(SystemBrushes.Control, 0, 0, b.Width, b.Height); |
|
||||||
cursor.Draw(g, new Rectangle(0, 0, 32, 32)); |
|
||||||
|
|
||||||
b.Save(resPath, System.Drawing.Imaging.ImageFormat.Png); |
|
||||||
} |
|
||||||
|
|
||||||
text.Append("<p>Preview:<p>"); |
|
||||||
text.Append("<img src=\""); |
|
||||||
text.Append(resPath); |
|
||||||
text.Append("\">"); |
|
||||||
} |
|
||||||
if (name.ToLower().EndsWith(".txt") || name.ToLower().EndsWith(".xml") || |
|
||||||
name.ToLower().EndsWith(".xsd") || name.ToLower().EndsWith(".htm") || |
|
||||||
name.ToLower().EndsWith(".html") || name.ToLower().EndsWith(".xshd") || |
|
||||||
name.ToLower().EndsWith(".xsl") || name.ToLower().EndsWith(".txt")) { |
|
||||||
byte[] res = asm.GetManifestResource(name); |
|
||||||
string utf = System.Text.UTF8Encoding.UTF8.GetString(res); |
|
||||||
|
|
||||||
text.Append("<p>Preview:<br>"); |
|
||||||
text.Append("<textarea style='border: 1px solid black; width: 300px; height: 400px; font: 8pt Tahoma'>"); |
|
||||||
text.Append(utf); |
|
||||||
text.Append("</textarea>"); |
|
||||||
} |
|
||||||
} catch {} |
|
||||||
|
|
||||||
return text.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string GetSingleResInfo(object singleRes, string name) |
|
||||||
{ |
|
||||||
int len = name.Length; |
|
||||||
if (name.LastIndexOf(":") != -1) len = name.LastIndexOf(":"); |
|
||||||
StringBuilder ret = new StringBuilder("Name: "); |
|
||||||
ret.Append(name.Substring(0, len)); |
|
||||||
ret.Append("<p>"); |
|
||||||
|
|
||||||
if (singleRes != null) { |
|
||||||
ret.Append("Type: "); |
|
||||||
ret.Append(singleRes.GetType().Name); |
|
||||||
ret.Append("<p>"); |
|
||||||
ret.Append("Value:<br>"); |
|
||||||
ret.Append(singleRes.ToString()); |
|
||||||
} |
|
||||||
|
|
||||||
return ret.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string GetAssemblyInfo(SA.SharpAssembly asm) |
|
||||||
{ |
|
||||||
string text = String.Format(RT("AsmInfo"), |
|
||||||
asm.Name, asm.FullName, asm.GetAssemblyName().Version.ToString(), |
|
||||||
asm.Location, asm.FromGAC); |
|
||||||
return text + GetCustomAttribs(asm); |
|
||||||
} |
|
||||||
|
|
||||||
string GetEventInfo(IEvent info) |
|
||||||
{ |
|
||||||
StringBuilder ret = new StringBuilder(ambience.Convert(info)); |
|
||||||
|
|
||||||
ret.Append("<p>"); |
|
||||||
ret.Append(RT("Attributes")); |
|
||||||
ret.Append("<br>"); |
|
||||||
ret.Append(GetCustomAttribs(info)); |
|
||||||
|
|
||||||
//IClass c = ParserService.GetClass(info.DeclaringType.FullyQualifiedName.Replace("+", "."));
|
|
||||||
IClass c = info.DeclaringType; |
|
||||||
if(c == null) goto noDoc; |
|
||||||
foreach(IEvent e in c.Events) { |
|
||||||
if(e.Name == info.Name) { |
|
||||||
if (e.Documentation == null || e.Documentation == "") continue; |
|
||||||
ret.Append("<p class='bottomline'>"); |
|
||||||
ret.Append(RT("Documentation")); |
|
||||||
ret.Append("<p class='docmargin'>"); |
|
||||||
ret.Append(GetDocumentation(e.Documentation)); |
|
||||||
ret.Append("<p>"); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
noDoc: |
|
||||||
|
|
||||||
ret.Append("<br>"); |
|
||||||
ret.Append(GetInType(info.DeclaringType)); |
|
||||||
ret.Append("<p>"); |
|
||||||
SharpAssemblyClass declaringType = info.DeclaringType as SharpAssemblyClass; |
|
||||||
ret.Append(GetInAsm((SA.SharpAssembly)declaringType.DeclaredIn)); |
|
||||||
|
|
||||||
return ret.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string GetFieldInfo(IField info) |
|
||||||
{ |
|
||||||
StringBuilder ret = new StringBuilder(ambience.Convert(info)); |
|
||||||
|
|
||||||
if (info is SharpAssemblyField) { |
|
||||||
SharpAssemblyField saField = info as SharpAssemblyField; |
|
||||||
if (saField.InitialValue != null) { |
|
||||||
ret.Append(" = "); |
|
||||||
ret.Append(saField.InitialValue.ToString()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
ret.Append("<p>"); |
|
||||||
ret.Append(RT("Attributes")); |
|
||||||
ret.Append("<br>"); |
|
||||||
ret.Append(GetCustomAttribs(info)); |
|
||||||
|
|
||||||
//IClass c = ParserService.GetClass(info.DeclaringType.FullyQualifiedName.Replace("+", "."));
|
|
||||||
IClass c = info.DeclaringType; |
|
||||||
if(c == null) goto noDoc; |
|
||||||
foreach(IField f in c.Fields) { |
|
||||||
if(f.Name == info.Name) { |
|
||||||
if (f.Documentation == null || f.Documentation == "") continue; |
|
||||||
ret.Append("<p class='bottomline'>"); |
|
||||||
ret.Append(RT("Documentation")); |
|
||||||
ret.Append("<p class='docmargin'>"); |
|
||||||
ret.Append(GetDocumentation(f.Documentation)); |
|
||||||
ret.Append("<p>"); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
noDoc: |
|
||||||
|
|
||||||
ret.Append("<br>"); |
|
||||||
ret.Append(GetInType(info.DeclaringType)); |
|
||||||
ret.Append("<p>"); |
|
||||||
SharpAssemblyClass declaringType = info.DeclaringType as SharpAssemblyClass; |
|
||||||
ret.Append(GetInAsm((SA.SharpAssembly)declaringType.DeclaredIn)); |
|
||||||
|
|
||||||
return ret.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string GetMethodInfo(IMethod info) |
|
||||||
{ |
|
||||||
StringBuilder ret = new StringBuilder(ambience.Convert(info)); |
|
||||||
|
|
||||||
ret.Append("<p>"); |
|
||||||
ret.Append(RT("Attributes")); |
|
||||||
ret.Append("<br>"); |
|
||||||
ret.Append(GetCustomAttribs(info)); |
|
||||||
|
|
||||||
//IClass c = ParserService.GetClass(info.DeclaringType.FullyQualifiedName.Replace("+", "."));
|
|
||||||
IClass c = info.DeclaringType; |
|
||||||
if(c == null) goto noDoc; |
|
||||||
foreach(IMethod cc in c.Methods) { |
|
||||||
if (cc.Name == info.Name) { |
|
||||||
if (cc.Documentation == null || cc.Documentation == "") continue; |
|
||||||
ret.Append("<p class='bottomline'>"); |
|
||||||
ret.Append(RT("Documentation")); |
|
||||||
ret.Append("<p class='docmargin'>"); |
|
||||||
ret.Append(GetDocumentation(cc.Documentation)); |
|
||||||
ret.Append("<p>"); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
noDoc: |
|
||||||
|
|
||||||
ret.Append("<br>"); |
|
||||||
ret.Append(GetInType(info.DeclaringType)); |
|
||||||
ret.Append("<p>"); |
|
||||||
SharpAssemblyClass declaringType = info.DeclaringType as SharpAssemblyClass; |
|
||||||
ret.Append(GetInAsm((SA.SharpAssembly)declaringType.DeclaredIn)); |
|
||||||
|
|
||||||
return ret.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string GetPropInfo(IProperty info) |
|
||||||
{ |
|
||||||
StringBuilder ret = new StringBuilder(ambience.Convert(info)); |
|
||||||
|
|
||||||
ret.Append("<p>"); |
|
||||||
ret.Append(RT("Attributes")); |
|
||||||
ret.Append("<br>"); |
|
||||||
ret.Append(GetCustomAttribs(info)); |
|
||||||
|
|
||||||
//IClass c = ParserService.GetClass(info.DeclaringType.FullyQualifiedName.Replace("+", "."));
|
|
||||||
IClass c = info.DeclaringType; |
|
||||||
if(c == null) goto noDoc; |
|
||||||
foreach(IProperty p in c.Properties) { |
|
||||||
if(p.Name == info.Name) { |
|
||||||
if (p.Documentation == null || p.Documentation == "") continue; |
|
||||||
ret.Append("<p class='bottomline'>"); |
|
||||||
ret.Append(RT("Documentation")); |
|
||||||
ret.Append("<p class='docmargin'>"); |
|
||||||
ret.Append(GetDocumentation(p.Documentation)); |
|
||||||
ret.Append("<p>"); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
noDoc: |
|
||||||
|
|
||||||
ret.Append("<br>"); |
|
||||||
ret.Append(GetInType(info.DeclaringType)); |
|
||||||
ret.Append("<p>"); |
|
||||||
SharpAssemblyClass declaringType = info.DeclaringType as SharpAssemblyClass; |
|
||||||
ret.Append(GetInAsm((SA.SharpAssembly)declaringType.DeclaredIn)); |
|
||||||
|
|
||||||
return ret.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string GetTypeInfo(IClass type) |
|
||||||
{ |
|
||||||
StringBuilder t = new StringBuilder(ambience.Convert(type)); |
|
||||||
|
|
||||||
t.Append("<p>"); |
|
||||||
t.Append(RT("BaseTypes")); |
|
||||||
t.Append("<br>"); |
|
||||||
t.Append(GetBaseTypes(type as SharpAssemblyClass)); |
|
||||||
|
|
||||||
t.Append("<br>"); |
|
||||||
t.Append(RT("Attributes")); |
|
||||||
t.Append("<br>"); |
|
||||||
t.Append(GetCustomAttribs(type)); |
|
||||||
|
|
||||||
//IClass c = ParserService.GetClass(type.FullyQualifiedName.Replace("+", "."));
|
|
||||||
IClass c = type; |
|
||||||
if (c == null) goto noDoc; |
|
||||||
if (c.Documentation == null || c.Documentation == "") goto noDoc; |
|
||||||
t.Append("<p class='bottomline'>"); |
|
||||||
t.Append(RT("Documentation")); |
|
||||||
t.Append("<p class='docmargin'>"); |
|
||||||
t.Append(GetDocumentation(c.Documentation)); |
|
||||||
t.Append("<p>"); |
|
||||||
|
|
||||||
noDoc: |
|
||||||
|
|
||||||
if (type.Namespace == null || type.Namespace == "") goto inAsm; |
|
||||||
t.Append("<br>"); |
|
||||||
t.Append(GetInNS((SA.SharpAssembly)((SharpAssemblyClass)type).DeclaredIn, type.Namespace)); |
|
||||||
|
|
||||||
inAsm: |
|
||||||
t.Append("<p>"); |
|
||||||
t.Append(GetInAsm((SA.SharpAssembly)((SharpAssemblyClass)type).DeclaredIn)); |
|
||||||
|
|
||||||
return t.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string GetCustomAttribs(SA.SharpAssembly assembly) |
|
||||||
{ |
|
||||||
return GetCustomAttribs(SharpAssemblyAttribute.GetAssemblyAttributes(assembly)); |
|
||||||
} |
|
||||||
|
|
||||||
string GetCustomAttribs(IClass type) |
|
||||||
{ |
|
||||||
if (type.Attributes.Count == 0) return ""; |
|
||||||
return GetCustomAttribs(type.Attributes); |
|
||||||
} |
|
||||||
|
|
||||||
string GetCustomAttribs(IMember member) |
|
||||||
{ |
|
||||||
if (member.Attributes.Count == 0) return ""; |
|
||||||
return GetCustomAttribs(member.Attributes); |
|
||||||
//return GetCustomAttribs(member.Attributes[0].Attributes);
|
|
||||||
} |
|
||||||
|
|
||||||
string GetCustomAttribs(IList<IAttribute> ca) |
|
||||||
{ |
|
||||||
StringBuilder text = new StringBuilder(); |
|
||||||
try { |
|
||||||
foreach(SharpAssemblyAttribute obj in ca) { |
|
||||||
text.Append(ln(references.Add(obj.AttributeType), obj.Name)); |
|
||||||
text.Append(obj.ToString().Substring(obj.Name.Length)); |
|
||||||
text.Append("<br>"); |
|
||||||
|
|
||||||
} |
|
||||||
} catch { |
|
||||||
return "An error occured while looking for attributes.<br>"; |
|
||||||
} |
|
||||||
return text.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string GetBaseTypes(SharpAssemblyClass type) |
|
||||||
{ |
|
||||||
if (type == null || type.BaseTypeCollection.Count == 0) { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
|
|
||||||
StringBuilder text = new StringBuilder(); |
|
||||||
|
|
||||||
foreach (SharpAssemblyClass basetype in type.BaseTypeCollection) { |
|
||||||
text.Append(ln(references.Add(basetype), basetype.FullyQualifiedName)); |
|
||||||
text.Append("<br>"); |
|
||||||
} |
|
||||||
|
|
||||||
return text.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string GetInAsm(SA.SharpAssembly asm) |
|
||||||
{ |
|
||||||
StringBuilder text = new StringBuilder(RT("ContainedIn")); |
|
||||||
text.Append(" "); |
|
||||||
text.Append(ln(references.Add(new AssemblyTree.RefNodeAttribute(asm, asm.GetAssemblyName())), asm.Name)); |
|
||||||
return text.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string GetInNS(SA.SharpAssembly asm, string ns) |
|
||||||
{ |
|
||||||
return String.Concat(RT("Namespace"), |
|
||||||
" ", |
|
||||||
ln(references.Add(new NamespaceLink(asm, ns)), ns)); |
|
||||||
} |
|
||||||
|
|
||||||
string GetInType(IClass type) |
|
||||||
{ |
|
||||||
return String.Concat(RT("Type"), |
|
||||||
" ", |
|
||||||
ln(references.Add(type), type.FullyQualifiedName)); |
|
||||||
} |
|
||||||
|
|
||||||
void back_click(object sender, LinkLabelLinkClickedEventArgs ev) |
|
||||||
{ |
|
||||||
try { |
|
||||||
tree.GoBack(); |
|
||||||
} catch {} |
|
||||||
} |
|
||||||
|
|
||||||
class SaveResLink |
|
||||||
{ |
|
||||||
public SA.SharpAssembly Asm; |
|
||||||
public string Name; |
|
||||||
public SaveResLink(SA.SharpAssembly asm, string name) |
|
||||||
{ |
|
||||||
Asm = asm; |
|
||||||
Name = name; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
class NamespaceLink |
|
||||||
{ |
|
||||||
public SA.SharpAssembly Asm; |
|
||||||
public string Name; |
|
||||||
public NamespaceLink(SA.SharpAssembly asm, string name) |
|
||||||
{ |
|
||||||
Asm = asm; |
|
||||||
Name = name; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
readonly static Regex whitespace = new Regex(@"\s+"); |
|
||||||
public string GetDocumentation(string doc) |
|
||||||
{ |
|
||||||
StringReader reader = new StringReader(String.Concat("<docroot>", doc, "</docroot>")); |
|
||||||
XmlTextReader xml = new XmlTextReader(reader); |
|
||||||
StringBuilder ret = new StringBuilder(); |
|
||||||
|
|
||||||
try { |
|
||||||
xml.Read(); |
|
||||||
do { |
|
||||||
if (xml.NodeType == XmlNodeType.Element) { |
|
||||||
string elname = xml.Name.ToLower(); |
|
||||||
if (elname == "remarks") { |
|
||||||
ret.Append(String.Concat("<b>", RTD("Remarks"), "</b><br>")); |
|
||||||
} else if (elname == "example") { |
|
||||||
ret.Append(String.Concat("<b>", RTD("Example"), "</b><br>")); |
|
||||||
} else if (elname == "exception") { |
|
||||||
ret.Append(String.Concat("<b>", RTD("Exception"), "</b> ", GetCref(xml["cref"]), ":<br>")); |
|
||||||
} else if (elname == "returns") { |
|
||||||
ret.Append(String.Concat("<b>", RTD("Returns"), "</b> ")); |
|
||||||
} else if (elname == "see") { |
|
||||||
ret.Append(String.Concat(GetCref(xml["cref"]), xml["langword"])); |
|
||||||
} else if (elname == "seealso") { |
|
||||||
ret.Append(String.Concat("<b>", RTD("SeeAlso"), "</b> ", GetCref(xml["cref"]), xml["langword"])); |
|
||||||
} else if (elname == "paramref") { |
|
||||||
ret.Append(String.Concat("<i>", xml["name"], "</i>")); |
|
||||||
} else if (elname == "param") { |
|
||||||
ret.Append(String.Concat("<i>", xml["name"].Trim(), "</i>: ")); |
|
||||||
} else if (elname == "value") { |
|
||||||
ret.Append(String.Concat("<b>", RTD("Value"), "</b> ")); |
|
||||||
} else if (elname == "summary") { |
|
||||||
ret.Append(String.Concat("<b>", RTD("Summary"), "</b> ")); |
|
||||||
} |
|
||||||
} else if (xml.NodeType == XmlNodeType.EndElement) { |
|
||||||
string elname = xml.Name.ToLower(); |
|
||||||
if (elname == "para" || elname == "param") { |
|
||||||
ret.Append("<br>"); |
|
||||||
} |
|
||||||
if (elname == "exception") { |
|
||||||
ret.Append("<br>"); |
|
||||||
} |
|
||||||
} else if (xml.NodeType == XmlNodeType.Text) { |
|
||||||
ret.Append(whitespace.Replace(xml.Value, " ")); |
|
||||||
} |
|
||||||
} while(xml.Read()); |
|
||||||
} catch { |
|
||||||
return doc; |
|
||||||
} |
|
||||||
return ret.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string GetCref(string cref) |
|
||||||
{ |
|
||||||
if (cref == null) { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
if (cref.Length < 2) { |
|
||||||
return cref; |
|
||||||
} |
|
||||||
if (cref.Substring(1, 1) == ":") { |
|
||||||
return String.Concat("<u>", cref.Substring(2, cref.Length - 2), "</u>"); |
|
||||||
} |
|
||||||
return String.Concat("<u>", cref, "</u>"); |
|
||||||
} |
|
||||||
|
|
||||||
string RT(string ResName) |
|
||||||
{ |
|
||||||
return StringParser.Parse(String.Concat("${res:", "ObjectBrowser.Info.", ResName, "}")); |
|
||||||
} |
|
||||||
|
|
||||||
string RTD(string ResName) |
|
||||||
{ |
|
||||||
return StringParser.Parse(String.Concat("${res:", "ObjectBrowser.Info.Doc.", ResName, "}")); |
|
||||||
} |
|
||||||
|
|
||||||
string ln(int rnr, string text) |
|
||||||
{ |
|
||||||
return String.Concat("<a href='as://", rnr, "'>", text, "</a>"); |
|
||||||
} |
|
||||||
|
|
||||||
bool CreateImage(Image pv) |
|
||||||
{ |
|
||||||
try { |
|
||||||
using (Bitmap b = new Bitmap(170, 170, PixelFormat.Format24bppRgb)) { |
|
||||||
Graphics g = Graphics.FromImage(b); |
|
||||||
g.FillRectangle(SystemBrushes.Control, 0, 0, 170, 170); |
|
||||||
g.InterpolationMode = InterpolationMode.NearestNeighbor; |
|
||||||
|
|
||||||
g.DrawImage(pv, 5, 5, 160, 160); |
|
||||||
using (Brush brush = new SolidBrush(Color.FromArgb(220, SystemColors.Control))) { |
|
||||||
g.FillRectangle(brush, 0, 0, 170, 170); |
|
||||||
} |
|
||||||
g.Dispose(); |
|
||||||
|
|
||||||
b.Save(imgPath, System.Drawing.Imaging.ImageFormat.Png); |
|
||||||
} |
|
||||||
return true; |
|
||||||
} catch { return false; } |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class GradientLabel : Label |
|
||||||
{ |
|
||||||
protected override void OnPaintBackground(PaintEventArgs pe) |
|
||||||
{ |
|
||||||
base.OnPaintBackground(pe); |
|
||||||
Graphics g = pe.Graphics; |
|
||||||
g.FillRectangle(SystemBrushes.Control, pe.ClipRectangle); |
|
||||||
using (Brush brush = new LinearGradientBrush(new Point(0, 0), new Point(Width, Height), |
|
||||||
SystemColors.ControlLightLight, |
|
||||||
SystemColors.Control)) { |
|
||||||
g.FillRectangle(brush, new Rectangle(0, 0, Width, Height)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,246 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Windows.Forms; |
|
||||||
using System.Drawing; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
public enum NodeType { |
|
||||||
Folder, |
|
||||||
Resource, |
|
||||||
Assembly, |
|
||||||
Library, |
|
||||||
Namespace, |
|
||||||
Type, |
|
||||||
Constructor, |
|
||||||
Method, |
|
||||||
Field, |
|
||||||
Property, |
|
||||||
SubTypes, |
|
||||||
SuperTypes, |
|
||||||
Reference, |
|
||||||
Event, |
|
||||||
Link, |
|
||||||
Module, |
|
||||||
SingleResource, |
|
||||||
} |
|
||||||
|
|
||||||
public class AssemblyTreeNode : TreeNode |
|
||||||
{ |
|
||||||
protected const int CLASSINDEX = 14; |
|
||||||
protected const int STRUCTINDEX = CLASSINDEX + 1 * 4; |
|
||||||
protected const int INTERFACEINDEX = CLASSINDEX + 2 * 4; |
|
||||||
protected const int ENUMINDEX = CLASSINDEX + 3 * 4; |
|
||||||
protected const int METHODINDEX = CLASSINDEX + 4 * 4; |
|
||||||
protected const int PROPERTYINDEX = CLASSINDEX + 5 * 4; |
|
||||||
protected const int FIELDINDEX = CLASSINDEX + 6 * 4; |
|
||||||
protected const int DELEGATEINDEX = CLASSINDEX + 7 * 4; |
|
||||||
|
|
||||||
protected NodeType type; |
|
||||||
protected object attribute; |
|
||||||
|
|
||||||
protected bool populated = false; |
|
||||||
|
|
||||||
public NodeType Type { |
|
||||||
get { |
|
||||||
return type; |
|
||||||
} |
|
||||||
set { |
|
||||||
type = value; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public object Attribute { |
|
||||||
get { |
|
||||||
return attribute; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public bool Populated { |
|
||||||
get { |
|
||||||
return populated; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public AssemblyTreeNode(string name, object attribute, NodeType type) : base(name) |
|
||||||
{ |
|
||||||
this.attribute = attribute; |
|
||||||
this.type = type; |
|
||||||
Name = name; |
|
||||||
|
|
||||||
SetIcon(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
protected virtual void SetIcon() |
|
||||||
{ |
|
||||||
switch (type) { |
|
||||||
case NodeType.Link: |
|
||||||
break; |
|
||||||
|
|
||||||
case NodeType.Resource: |
|
||||||
case NodeType.SingleResource: // TODO : single res icon
|
|
||||||
ImageIndex = SelectedImageIndex = 11; |
|
||||||
break; |
|
||||||
|
|
||||||
case NodeType.Reference: |
|
||||||
ImageIndex = SelectedImageIndex = 8; |
|
||||||
break; |
|
||||||
|
|
||||||
case NodeType.Module: |
|
||||||
ImageIndex = SelectedImageIndex = 46; |
|
||||||
break; |
|
||||||
|
|
||||||
case NodeType.SubTypes: |
|
||||||
ImageIndex = SelectedImageIndex = 4; |
|
||||||
break; |
|
||||||
|
|
||||||
case NodeType.SuperTypes: |
|
||||||
ImageIndex = SelectedImageIndex = 5; |
|
||||||
break; |
|
||||||
|
|
||||||
default: |
|
||||||
throw new Exception("ReflectionFolderNode.SetIcon : unknown ReflectionNodeType " + type.ToString()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public virtual void Populate(ShowOptions Private, ShowOptions Internal) |
|
||||||
{ |
|
||||||
switch (type) { |
|
||||||
case NodeType.Assembly: |
|
||||||
PopulateAssembly((SA.SharpAssembly)attribute, this); |
|
||||||
break; |
|
||||||
|
|
||||||
case NodeType.Library: |
|
||||||
PopulateLibrary((SA.SharpAssembly)attribute, this, Private, Internal); |
|
||||||
break; |
|
||||||
} |
|
||||||
populated = true; |
|
||||||
} |
|
||||||
|
|
||||||
public AssemblyTreeNode GetNodeFromChildren(string title) |
|
||||||
{ |
|
||||||
foreach (AssemblyTreeNode node in this.Nodes) { |
|
||||||
if (node.Text == title) { |
|
||||||
return node; |
|
||||||
} |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public AssemblyTreeNode GetNodeFromCollection(TreeNodeCollection collection, string title) |
|
||||||
{ |
|
||||||
foreach (AssemblyTreeNode node in collection) |
|
||||||
if (node.Text == title) { |
|
||||||
return node; |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
void PopulateLibrary(SA.SharpAssembly assembly, TreeNode parentnode, ShowOptions Private, ShowOptions Internal) |
|
||||||
{ |
|
||||||
parentnode.Nodes.Clear(); |
|
||||||
IClass[] types = new IClass[0]; |
|
||||||
|
|
||||||
try { |
|
||||||
types = SharpAssemblyClass.GetAssemblyTypes(assembly); |
|
||||||
} catch { |
|
||||||
MessageBox.Show(StringParser.Parse("${res:ObjectBrowser.ErrorLoadingTypes}"), StringParser.Parse("${res:Global.WarningText}"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); |
|
||||||
} |
|
||||||
|
|
||||||
ArrayList nodes = new ArrayList(); |
|
||||||
ArrayList namespaces = new ArrayList(); |
|
||||||
ArrayList namespacenames = new ArrayList(); |
|
||||||
TreeNodeComparer comp = new TreeNodeComparer(); |
|
||||||
|
|
||||||
foreach (IClass type in types) { |
|
||||||
if(type.FullyQualifiedName.IndexOf("PrivateImplementationDetails") != -1) continue; |
|
||||||
if(type.IsInternal && Internal == ShowOptions.Hide) continue; |
|
||||||
if(type.IsPrivate && Private == ShowOptions.Hide) continue; |
|
||||||
|
|
||||||
TypeNode typenode = new TypeNode(GetShortTypeName(type.FullyQualifiedName), type); |
|
||||||
if ((type.IsInternal && Internal == ShowOptions.GreyOut) || |
|
||||||
(type.IsPrivate && Private == ShowOptions.GreyOut)) { |
|
||||||
typenode.ForeColor = SystemColors.GrayText; |
|
||||||
} |
|
||||||
nodes.Add(typenode); |
|
||||||
if (type.Namespace != null && type.Namespace != "") { |
|
||||||
if (!namespacenames.Contains(type.Namespace)) { |
|
||||||
namespaces.Add(new FolderNode(type.Namespace, assembly, NodeType.Namespace, 3, 3)); |
|
||||||
namespacenames.Add(type.Namespace); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
nodes.Sort(comp); |
|
||||||
namespaces.Sort(comp); |
|
||||||
foreach (TreeNode tn in namespaces) { |
|
||||||
parentnode.Nodes.Add(tn); |
|
||||||
} |
|
||||||
foreach (TreeNode tn in nodes) { |
|
||||||
IClass type = (IClass)((AssemblyTreeNode)tn).Attribute; |
|
||||||
if (type.Namespace != null && type.Namespace != "") { |
|
||||||
GetNodeFromCollection(parentnode.Nodes, type.Namespace).Nodes.Add(tn); |
|
||||||
} else { |
|
||||||
parentnode.Nodes.Add(tn); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
string GetShortTypeName(string typename) |
|
||||||
{ |
|
||||||
if (typename == null) return ""; |
|
||||||
int lastIndex; |
|
||||||
|
|
||||||
lastIndex = typename.LastIndexOf('.'); |
|
||||||
|
|
||||||
if (lastIndex < 0) { |
|
||||||
return typename; |
|
||||||
} else { |
|
||||||
return typename.Substring(lastIndex + 1); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
void PopulateAssembly(SA.SharpAssembly assembly, TreeNode parentnode) |
|
||||||
{ |
|
||||||
parentnode.Nodes.Clear(); |
|
||||||
|
|
||||||
TreeNode node = new FolderNode(System.IO.Path.GetFileName(assembly.Location), assembly, NodeType.Library, 2, 2); |
|
||||||
parentnode.Nodes.Add(node); |
|
||||||
|
|
||||||
FolderNode resourcefolder = new FolderNode(StringParser.Parse("${res:ObjectBrowser.Nodes.Resources}"), assembly, NodeType.Folder, 6, 7); |
|
||||||
string[] resources = assembly.GetManifestResourceNames(); |
|
||||||
foreach (string resource in resources) { |
|
||||||
resourcefolder.Nodes.Add(new ResourceNode(resource, assembly, true)); |
|
||||||
} |
|
||||||
parentnode.Nodes.Add(resourcefolder); |
|
||||||
|
|
||||||
FolderNode referencefolder = new FolderNode(StringParser.Parse("${res:ObjectBrowser.Nodes.References}"), assembly, NodeType.Folder, 9, 10); |
|
||||||
SA.SharpAssemblyName[] references = assembly.GetReferencedAssemblies(); |
|
||||||
foreach (SA.SharpAssemblyName name in references) { |
|
||||||
referencefolder.Nodes.Add(new AssemblyTreeNode(name.Name, new AssemblyTree.RefNodeAttribute(assembly, name), NodeType.Reference)); |
|
||||||
} |
|
||||||
parentnode.Nodes.Add(referencefolder); |
|
||||||
} |
|
||||||
|
|
||||||
public virtual void OnExpand() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public virtual void OnCollapse() |
|
||||||
{ |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,42 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
public class FolderNode : AssemblyTreeNode |
|
||||||
{ |
|
||||||
int openindex; |
|
||||||
int closeindex; |
|
||||||
|
|
||||||
public FolderNode(string name, object attribute, NodeType type,int openindex, int closeindex) : |
|
||||||
base(name, attribute, type) |
|
||||||
{ |
|
||||||
this.openindex = openindex; |
|
||||||
this.closeindex = closeindex; |
|
||||||
OnCollapse(); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void SetIcon() |
|
||||||
{ |
|
||||||
OnCollapse(); |
|
||||||
} |
|
||||||
|
|
||||||
public override void OnExpand() |
|
||||||
{ |
|
||||||
ImageIndex = SelectedImageIndex = closeindex; |
|
||||||
} |
|
||||||
|
|
||||||
public override void OnCollapse() |
|
||||||
{ |
|
||||||
ImageIndex = SelectedImageIndex = openindex; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,175 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Windows.Forms; |
|
||||||
using System.Drawing; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
public class MemberNode : AssemblyTreeNode |
|
||||||
{ |
|
||||||
bool special = false; |
|
||||||
bool isEnum = false; |
|
||||||
|
|
||||||
public MemberNode(IMethod methodinfo2) : base ("", methodinfo2, NodeType.Method) |
|
||||||
{ |
|
||||||
SetNodeName(); |
|
||||||
} |
|
||||||
|
|
||||||
public MemberNode(IProperty prop, bool Special) : base ("", prop, NodeType.Property) |
|
||||||
{ |
|
||||||
SetNodeName(); |
|
||||||
if(special = Special) CreateSpecialNodes(prop); |
|
||||||
} |
|
||||||
|
|
||||||
public MemberNode(IEvent evt, bool Special) : base ("", evt, NodeType.Event) |
|
||||||
{ |
|
||||||
SetNodeName(); |
|
||||||
if(special = Special) CreateSpecialNodes(evt); |
|
||||||
} |
|
||||||
|
|
||||||
public MemberNode(IField fld, bool IsEnum) : base ("", fld, NodeType.Field) |
|
||||||
{ |
|
||||||
isEnum = IsEnum; |
|
||||||
SetNodeName(); |
|
||||||
} |
|
||||||
|
|
||||||
void SetNodeName() |
|
||||||
{ |
|
||||||
if (attribute == null) { |
|
||||||
Text = "no name"; |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
Text = GetShortMemberName((IMember)attribute, isEnum); |
|
||||||
if (Text.EndsWith("[static]")) { |
|
||||||
this.NodeFont = new Font("Tahoma", 8, FontStyle.Italic); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void CreateSpecialNodes(IProperty prop) |
|
||||||
{ |
|
||||||
// TODO - No IProperty.Getter/Setter Method.
|
|
||||||
// IMethod getm = prop.GetterMethod;
|
|
||||||
// IMethod setm = prop.SetterMethod;
|
|
||||||
//
|
|
||||||
// if (getm != null)
|
|
||||||
// Nodes.Add(new MethodNode(getm));
|
|
||||||
// if (setm != null)
|
|
||||||
// Nodes.Add(new MethodNode(setm));
|
|
||||||
} |
|
||||||
|
|
||||||
void CreateSpecialNodes(IEvent evt) |
|
||||||
{ |
|
||||||
IMethod addm = evt.AddMethod; |
|
||||||
IMethod raisem = evt.RaiseMethod; |
|
||||||
IMethod removem = evt.RemoveMethod; |
|
||||||
|
|
||||||
if (addm != null) |
|
||||||
Nodes.Add(new MethodNode(addm)); |
|
||||||
if (raisem != null) |
|
||||||
Nodes.Add(new MethodNode(raisem)); |
|
||||||
if (removem != null) |
|
||||||
Nodes.Add(new MethodNode(removem)); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void SetIcon() |
|
||||||
{ |
|
||||||
if (attribute == null) |
|
||||||
return; |
|
||||||
switch (type) { |
|
||||||
case NodeType.Method: |
|
||||||
IMethod methodinfo = (IMethod)attribute; |
|
||||||
ImageIndex = SelectedImageIndex = ClassBrowserIconService.GetIcon(methodinfo); |
|
||||||
break; |
|
||||||
|
|
||||||
case NodeType.Event: |
|
||||||
IEvent eventinfo = (IEvent)attribute; |
|
||||||
ImageIndex = SelectedImageIndex = ClassBrowserIconService.GetIcon(eventinfo); |
|
||||||
break; |
|
||||||
|
|
||||||
case NodeType.Property: |
|
||||||
IProperty propertyinfo = (IProperty)attribute; |
|
||||||
ImageIndex = SelectedImageIndex = ClassBrowserIconService.GetIcon(propertyinfo); |
|
||||||
break; |
|
||||||
|
|
||||||
case NodeType.Field: |
|
||||||
IField fieldinfo = (IField)attribute; |
|
||||||
ImageIndex = SelectedImageIndex = ClassBrowserIconService.GetIcon(fieldinfo); |
|
||||||
break; |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public static string GetShortMemberName(IMember mi, bool IsEnum) { |
|
||||||
string ret = ""; |
|
||||||
|
|
||||||
ret = mi.Name; |
|
||||||
|
|
||||||
try { |
|
||||||
|
|
||||||
bool dispReturn = PropertyService.Get("AddIns.AssemblyScout.ShowReturnTypes", true); |
|
||||||
|
|
||||||
if (mi is IMethod) { |
|
||||||
IMethod mii = mi as IMethod; |
|
||||||
|
|
||||||
if (mii.IsConstructor) { |
|
||||||
dispReturn = false; |
|
||||||
ret = mi.DeclaringType.Name; |
|
||||||
} |
|
||||||
|
|
||||||
ret += GetParams(mii.Parameters, true); |
|
||||||
|
|
||||||
} else if (mi is IProperty) { |
|
||||||
IProperty ppi = mi as IProperty; |
|
||||||
|
|
||||||
ret += GetParams(ppi.Parameters, false); |
|
||||||
} |
|
||||||
|
|
||||||
if (dispReturn && !IsEnum) ret += " : " + GetNestedName(AssemblyTree.CurrentAmbience.GetIntrinsicTypeName(mi.ReturnType.FullyQualifiedName)); |
|
||||||
|
|
||||||
if (mi.IsStatic && !IsEnum) ret += " [static]"; |
|
||||||
|
|
||||||
if (IsEnum && mi is SharpAssemblyField) { |
|
||||||
SharpAssemblyField saField = mi as SharpAssemblyField; |
|
||||||
if (saField.InitialValue != null) { |
|
||||||
ret += " = " + saField.InitialValue.ToString(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} catch { |
|
||||||
Console.WriteLine("GetShortMemberName: Error"); |
|
||||||
} |
|
||||||
|
|
||||||
return ret; |
|
||||||
} |
|
||||||
|
|
||||||
public static string GetParams(IList<IParameter> piarr, bool IncludeBrackets) { |
|
||||||
string param = ""; |
|
||||||
foreach(IParameter pi in piarr) { |
|
||||||
param += GetNestedName(AssemblyTree.CurrentAmbience.GetIntrinsicTypeName(pi.ReturnType.FullyQualifiedName)) + ", "; |
|
||||||
} |
|
||||||
if (param.Length > 0) param = param.Substring(0, param.Length - 2); |
|
||||||
if (param != "" || IncludeBrackets) param = "(" + param + ")"; |
|
||||||
return param; |
|
||||||
} |
|
||||||
|
|
||||||
public static string GetNestedName(string name) { |
|
||||||
int i = name.LastIndexOf("."); |
|
||||||
if (i == -1) return name; |
|
||||||
return name.Substring(i + 1); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -1,43 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.Core; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
public class MethodNode : AssemblyTreeNode |
|
||||||
{ |
|
||||||
public MethodNode(IMethod methodinfo2) : base ("", methodinfo2, NodeType.Method) |
|
||||||
{ |
|
||||||
if (attribute == null) { |
|
||||||
Text = "no name"; |
|
||||||
return; |
|
||||||
} |
|
||||||
Text = MemberNode.GetShortMemberName((IMethod)attribute, false); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void SetIcon() |
|
||||||
{ |
|
||||||
if (attribute == null) |
|
||||||
return; |
|
||||||
IMethod methodinfo = (IMethod)attribute; |
|
||||||
|
|
||||||
if (methodinfo.IsPrivate) { // private
|
|
||||||
ImageIndex = SelectedImageIndex = METHODINDEX + 3; |
|
||||||
} else |
|
||||||
if (methodinfo.IsProtected) { // protected
|
|
||||||
ImageIndex = SelectedImageIndex = METHODINDEX + 2; |
|
||||||
} |
|
||||||
ImageIndex = SelectedImageIndex = METHODINDEX; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,56 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.IO; |
|
||||||
using System.Collections; |
|
||||||
using System.Resources; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
public class ResourceNode : AssemblyTreeNode |
|
||||||
{ |
|
||||||
bool isTopLevel; |
|
||||||
|
|
||||||
public ResourceNode(string name, object attribute, bool isTopLevel) |
|
||||||
: base(name, attribute, isTopLevel ? NodeType.Resource : NodeType.SingleResource) |
|
||||||
{ |
|
||||||
this.isTopLevel = isTopLevel; |
|
||||||
} |
|
||||||
|
|
||||||
public override void Populate(ShowOptions Private, ShowOptions Internal) |
|
||||||
{ |
|
||||||
if (Name.ToLower().EndsWith(".resources")) { |
|
||||||
SA.SharpAssembly assembly = (SA.SharpAssembly)attribute; |
|
||||||
byte[] res = assembly.GetManifestResource(Name); |
|
||||||
ResourceReader resreader = new ResourceReader(new MemoryStream(res)); |
|
||||||
|
|
||||||
IDictionaryEnumerator en = resreader.GetEnumerator(); |
|
||||||
|
|
||||||
ArrayList newNodes = new ArrayList(); |
|
||||||
|
|
||||||
while (en.MoveNext()) { |
|
||||||
string nodename = (string)en.Key; |
|
||||||
if (en.Value != null) nodename += " : " + en.Value.GetType().Name; |
|
||||||
newNodes.Add(new ResourceNode(nodename, en.Value, false)); |
|
||||||
} |
|
||||||
resreader.Close(); |
|
||||||
|
|
||||||
newNodes.Sort(new TreeNodeComparer()); |
|
||||||
foreach (ResourceNode resnode in newNodes) { |
|
||||||
Nodes.Add(resnode); |
|
||||||
} |
|
||||||
} |
|
||||||
populated = true; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,142 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Windows.Forms; |
|
||||||
using System.Drawing; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
public class TypeNode : AssemblyTreeNode |
|
||||||
{ |
|
||||||
public bool MembersPopulated; |
|
||||||
|
|
||||||
public TypeNode(string name, IClass type) : base (name, type, NodeType.Type) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
protected override void SetIcon() |
|
||||||
{ |
|
||||||
ImageIndex = SelectedImageIndex = ClassBrowserIconService.GetIcon((IClass)attribute); |
|
||||||
} |
|
||||||
|
|
||||||
public override void Populate(ShowOptions Private, ShowOptions Internal) |
|
||||||
{ |
|
||||||
IClass type = attribute as IClass; |
|
||||||
|
|
||||||
Nodes.Clear(); |
|
||||||
|
|
||||||
AssemblyTreeNode supertype = new AssemblyTreeNode(StringParser.Parse("${res:ObjectBrowser.Nodes.SuperTypes}"), type, NodeType.SuperTypes); |
|
||||||
Nodes.Add(supertype); |
|
||||||
|
|
||||||
SharpAssemblyClass sharptype = type as SharpAssemblyClass; |
|
||||||
if (sharptype == null) goto nobase; |
|
||||||
|
|
||||||
AddBaseTypes(sharptype, supertype); |
|
||||||
|
|
||||||
nobase: |
|
||||||
|
|
||||||
populated = true; |
|
||||||
} |
|
||||||
|
|
||||||
private void AddBaseTypes(SharpAssemblyClass type, AssemblyTreeNode node) |
|
||||||
{ |
|
||||||
foreach (SharpAssemblyClass rettype in type.BaseTypeCollection) { |
|
||||||
AssemblyTreeNode basetype = new AssemblyTreeNode(rettype.Name, rettype, NodeType.Link); |
|
||||||
basetype.ImageIndex = basetype.SelectedImageIndex = ClassBrowserIconService.GetIcon(rettype); |
|
||||||
node.Nodes.Add(basetype); |
|
||||||
AddBaseTypes(rettype, basetype); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void PopulateMembers(ShowOptions Private, ShowOptions Internal, bool Special) |
|
||||||
{ |
|
||||||
IClass type = (IClass)attribute; |
|
||||||
ArrayList nodes = new ArrayList(); |
|
||||||
TreeNodeComparer comp = new TreeNodeComparer(); |
|
||||||
|
|
||||||
nodes.Clear(); |
|
||||||
foreach (IMethod info in type.Methods) { |
|
||||||
if (Private == ShowOptions.Hide && info.IsPrivate) continue; |
|
||||||
if (Internal == ShowOptions.Hide && info.IsInternal) continue; |
|
||||||
if (!info.IsConstructor && SharpAssemblyMethod.IsSpecial(info)) continue; |
|
||||||
|
|
||||||
MemberNode node = new MemberNode(info); |
|
||||||
if ((info.IsInternal && Internal == ShowOptions.GreyOut) || |
|
||||||
(info.IsPrivate && Private == ShowOptions.GreyOut)) { |
|
||||||
node.ForeColor = SystemColors.GrayText; |
|
||||||
} |
|
||||||
|
|
||||||
nodes.Add(node); |
|
||||||
} |
|
||||||
nodes.Sort(comp); |
|
||||||
foreach (AssemblyTreeNode tn in nodes) { |
|
||||||
Nodes.Add(tn); |
|
||||||
} |
|
||||||
|
|
||||||
nodes.Clear(); |
|
||||||
foreach (IProperty info in type.Properties) { |
|
||||||
if (Private == ShowOptions.Hide && info.IsPrivate) continue; |
|
||||||
if (Internal == ShowOptions.Hide && info.IsInternal) continue; |
|
||||||
|
|
||||||
MemberNode node = new MemberNode(info, Special); |
|
||||||
if ((info.IsInternal && Internal == ShowOptions.GreyOut) || |
|
||||||
(info.IsPrivate && Private == ShowOptions.GreyOut)) { |
|
||||||
node.ForeColor = SystemColors.GrayText; |
|
||||||
} |
|
||||||
nodes.Add(node); |
|
||||||
} |
|
||||||
nodes.Sort(comp); |
|
||||||
foreach (AssemblyTreeNode tn in nodes) { |
|
||||||
Nodes.Add(tn); |
|
||||||
} |
|
||||||
|
|
||||||
nodes.Clear(); |
|
||||||
foreach (IField info in type.Fields) { |
|
||||||
if (Private == ShowOptions.Hide && info.IsPrivate) continue; |
|
||||||
if (Internal == ShowOptions.Hide && info.IsInternal) continue; |
|
||||||
if (SharpAssemblyField.IsSpecial(info)) continue; |
|
||||||
|
|
||||||
MemberNode node = new MemberNode(info, type.ClassType == ClassType.Enum); |
|
||||||
if ((info.IsInternal && Internal == ShowOptions.GreyOut) || |
|
||||||
(info.IsPrivate && Private == ShowOptions.GreyOut)) { |
|
||||||
node.ForeColor = SystemColors.GrayText; |
|
||||||
} |
|
||||||
nodes.Add(node); |
|
||||||
} |
|
||||||
nodes.Sort(comp); |
|
||||||
foreach (AssemblyTreeNode tn in nodes) { |
|
||||||
Nodes.Add(tn); |
|
||||||
} |
|
||||||
|
|
||||||
nodes.Clear(); |
|
||||||
foreach (IEvent info in type.Events) { |
|
||||||
if (Private == ShowOptions.Hide && info.IsPrivate) continue; |
|
||||||
if (Internal == ShowOptions.Hide && info.IsInternal) continue; |
|
||||||
|
|
||||||
MemberNode node = new MemberNode(info, Special); |
|
||||||
if ((info.IsInternal && Internal == ShowOptions.GreyOut) || |
|
||||||
(info.IsPrivate && Private == ShowOptions.GreyOut)) { |
|
||||||
node.ForeColor = SystemColors.GrayText; |
|
||||||
} |
|
||||||
nodes.Add(node); |
|
||||||
} |
|
||||||
nodes.Sort(comp); |
|
||||||
foreach (AssemblyTreeNode tn in nodes) { |
|
||||||
Nodes.Add(tn); |
|
||||||
} |
|
||||||
|
|
||||||
MembersPopulated = true; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -1,262 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.IO; |
|
||||||
using System.Drawing; |
|
||||||
using System.Drawing.Printing; |
|
||||||
using System.Windows.Forms; |
|
||||||
using System.Threading; |
|
||||||
using System.Resources; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
public class SearchPanel : UserControl |
|
||||||
{ |
|
||||||
System.Windows.Forms.Label searchfor = new System.Windows.Forms.Label(); |
|
||||||
System.Windows.Forms.Label foundcount = new System.Windows.Forms.Label(); |
|
||||||
TextBox searchstringbox = new TextBox(); |
|
||||||
ListView itemsfound = new ListView(); |
|
||||||
Button button = new Button(); |
|
||||||
ComboBox searchtypes = new ComboBox(); |
|
||||||
|
|
||||||
AssemblyTree tree; |
|
||||||
AssemblyScoutViewContent _parent; |
|
||||||
|
|
||||||
public SearchPanel(AssemblyTree tree) |
|
||||||
{ |
|
||||||
Dock = DockStyle.Fill; |
|
||||||
|
|
||||||
this.tree = tree; |
|
||||||
|
|
||||||
searchfor.Text = StringParser.Parse("${res:ObjectBrowser.Search.SearchFor}"); |
|
||||||
searchfor.Location = new Point(0, 0); |
|
||||||
searchfor.Size = new Size(70, 12); |
|
||||||
searchfor.Anchor = AnchorStyles.Top | AnchorStyles.Left; |
|
||||||
searchfor.FlatStyle = FlatStyle.System; |
|
||||||
|
|
||||||
foundcount.Text = "0 " + StringParser.Parse("${res:ObjectBrowser.Search.ItemsFound}"); |
|
||||||
foundcount.Location = new Point(searchfor.Width + 5, 0); |
|
||||||
foundcount.Size = new Size(Width - searchfor.Width - 5, searchfor.Height); |
|
||||||
foundcount.TextAlign = ContentAlignment.TopRight; |
|
||||||
foundcount.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left; |
|
||||||
foundcount.FlatStyle = FlatStyle.System; |
|
||||||
|
|
||||||
searchstringbox.Location = new Point(0, 17); |
|
||||||
searchstringbox.Width = Width; |
|
||||||
searchstringbox.Height = 30; |
|
||||||
searchstringbox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; |
|
||||||
searchstringbox.KeyUp += new KeyEventHandler(searchbox_keyup); |
|
||||||
|
|
||||||
button.Location = new Point(Width - 52, 44); |
|
||||||
button.Size = new Size(52, 21); |
|
||||||
button.Text = StringParser.Parse("${res:ObjectBrowser.Search.Search}"); |
|
||||||
button.Anchor = AnchorStyles.Top | AnchorStyles.Right; |
|
||||||
button.Click += new EventHandler(DoSearch); |
|
||||||
button.FlatStyle = FlatStyle.System; |
|
||||||
|
|
||||||
searchtypes.Location = new Point(0, 44); |
|
||||||
searchtypes.Width = Width - 60; |
|
||||||
searchtypes.Height = 30; |
|
||||||
searchtypes.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; |
|
||||||
searchtypes.DropDownStyle = ComboBoxStyle.DropDownList; |
|
||||||
searchtypes.Items.Add(StringParser.Parse("${res:ObjectBrowser.Search.TypesAndMembers}")); |
|
||||||
searchtypes.Items.Add(StringParser.Parse("${res:ObjectBrowser.Search.TypesOnly}")); |
|
||||||
searchtypes.SelectedIndex = 0; |
|
||||||
|
|
||||||
itemsfound.Location = new Point(0, 71); |
|
||||||
itemsfound.Width = Width; |
|
||||||
itemsfound.FullRowSelect = true; |
|
||||||
itemsfound.MultiSelect = false; |
|
||||||
itemsfound.Height = Height - 71; |
|
||||||
itemsfound.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom; |
|
||||||
itemsfound.View = View.Details; |
|
||||||
itemsfound.SmallImageList = tree.ImageList; |
|
||||||
|
|
||||||
itemsfound.Columns.Add(StringParser.Parse("${res:ObjectBrowser.Search.Name}"), 160, HorizontalAlignment.Left); |
|
||||||
itemsfound.Columns.Add(StringParser.Parse("${res:ObjectBrowser.Search.Type}"), 70, HorizontalAlignment.Left); |
|
||||||
itemsfound.Columns.Add("Namespace", 125, HorizontalAlignment.Left); |
|
||||||
itemsfound.Columns.Add("Assembly", 75, HorizontalAlignment.Left); |
|
||||||
itemsfound.DoubleClick += new EventHandler(SelectItem); |
|
||||||
|
|
||||||
Controls.Add(button); |
|
||||||
Controls.Add(searchfor); |
|
||||||
Controls.Add(foundcount); |
|
||||||
Controls.Add(searchstringbox); |
|
||||||
Controls.Add(itemsfound); |
|
||||||
Controls.Add(searchtypes); |
|
||||||
} |
|
||||||
|
|
||||||
public AssemblyScoutViewContent ParentDisplayInfo { |
|
||||||
get { |
|
||||||
return _parent; |
|
||||||
} |
|
||||||
set { |
|
||||||
_parent = value; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void SelectItem(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
if (itemsfound.SelectedItems.Count != 1) |
|
||||||
return; |
|
||||||
|
|
||||||
if(itemsfound.SelectedItems[0] is TypeItem) { |
|
||||||
TypeItem item = (TypeItem)itemsfound.SelectedItems[0]; |
|
||||||
tree.GoToType(item.type); |
|
||||||
|
|
||||||
} else if (itemsfound.SelectedItems[0] is MemberItem) { |
|
||||||
MemberItem member = (MemberItem)itemsfound.SelectedItems[0]; |
|
||||||
tree.GoToMember(member.member); |
|
||||||
} |
|
||||||
|
|
||||||
//ParentDisplayInfo.leftTabs.ActiveDocument =
|
|
||||||
ParentDisplayInfo.leftTabs.Documents[0].Activate(); |
|
||||||
} |
|
||||||
|
|
||||||
class TypeItem : ListViewItem { |
|
||||||
public IClass type; |
|
||||||
public TypeItem(string Namespace, IClass type, Color forecolor) : |
|
||||||
base (new string[] {type.Name, GetType(type), Namespace, ((SA.SharpAssembly)((SharpAssemblyClass)type).DeclaredIn).Name}) |
|
||||||
{ |
|
||||||
this.type = type; |
|
||||||
this.ImageIndex = ClassBrowserIconService.GetIcon(type); |
|
||||||
this.ForeColor = forecolor; |
|
||||||
} |
|
||||||
|
|
||||||
private static string GetType(IClass type) { |
|
||||||
if(type.ClassType == ClassType.Enum) { |
|
||||||
return "Enum"; |
|
||||||
} else if(type.ClassType == ClassType.Interface) { |
|
||||||
return "Interface"; |
|
||||||
} else if(type.ClassType == ClassType.Struct) { |
|
||||||
return "Structure"; |
|
||||||
} else { |
|
||||||
return "Class"; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
class MemberItem : ListViewItem { |
|
||||||
public IMember member; |
|
||||||
|
|
||||||
public MemberItem(string Namespace, IMember member, Color forecolor) : |
|
||||||
base (new string[] {member.DeclaringType.Name + "." + member.Name, GetType(member), Namespace, ((SA.SharpAssembly)((SharpAssemblyClass)member.DeclaringType).DeclaredIn).Name}) |
|
||||||
{ |
|
||||||
this.ForeColor = forecolor; |
|
||||||
this.member = member; |
|
||||||
if(member is IMethod) { |
|
||||||
this.ImageIndex = ClassBrowserIconService.GetIcon(member as IMethod); |
|
||||||
} else if(member is IField) { |
|
||||||
this.ImageIndex = ClassBrowserIconService.GetIcon(member as IField); |
|
||||||
} else if(member is IProperty) { |
|
||||||
this.ImageIndex = ClassBrowserIconService.GetIcon(member as IProperty); |
|
||||||
} else if(member is IEvent) { |
|
||||||
this.ImageIndex = ClassBrowserIconService.GetIcon(member as IEvent); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private static string GetType(IMember member) { |
|
||||||
if(member is IMethod) { |
|
||||||
if ((member as IMethod).IsConstructor) return "Constructor"; |
|
||||||
return "Method"; |
|
||||||
} else if(member is IField) { |
|
||||||
return "Field"; |
|
||||||
} else if(member is IProperty) { |
|
||||||
return "Property"; |
|
||||||
} else if(member is IEvent) { |
|
||||||
return "Event"; |
|
||||||
} else { |
|
||||||
return "unknown"; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void searchbox_keyup(object sender, KeyEventArgs e) |
|
||||||
{ |
|
||||||
if (e.KeyCode == Keys.Return) |
|
||||||
DoSearch(sender, new EventArgs()); |
|
||||||
} |
|
||||||
|
|
||||||
void DoSearch(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
bool searchMembers = (searchtypes.SelectedIndex == 0); |
|
||||||
|
|
||||||
if(searchstringbox.Text == "") return; |
|
||||||
string searchfor = searchstringbox.Text.ToLower(); |
|
||||||
|
|
||||||
itemsfound.Items.Clear(); |
|
||||||
itemsfound.BeginUpdate(); |
|
||||||
|
|
||||||
foreach (AssemblyTreeNode tn in tree.Nodes) { // assembly nodes
|
|
||||||
SA.SharpAssembly assembly = (SA.SharpAssembly)tn.Attribute; |
|
||||||
foreach (AssemblyTreeNode libnode in tn.Nodes) { |
|
||||||
if (libnode.Type != NodeType.Library) continue; |
|
||||||
foreach (AssemblyTreeNode nsnode in libnode.Nodes) { |
|
||||||
if (nsnode.Type == NodeType.Type) { |
|
||||||
ProcessType("", searchfor, searchMembers, (IClass)nsnode.Attribute, nsnode.ForeColor); |
|
||||||
continue; |
|
||||||
} |
|
||||||
foreach (AssemblyTreeNode typenode in nsnode.Nodes) { |
|
||||||
ProcessType(nsnode.Text, searchfor, searchMembers, (IClass)typenode.Attribute, nsnode.ForeColor); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
itemsfound.EndUpdate(); |
|
||||||
foundcount.Text = itemsfound.Items.Count.ToString() + " " + StringParser.Parse("${res:ObjectBrowser.Search.ItemsFound}"); |
|
||||||
} |
|
||||||
|
|
||||||
void ProcessType(string Namespace, string searchfor, bool searchMembers, IClass type, Color nodecolor) |
|
||||||
{ |
|
||||||
if (type.Name.ToLower().IndexOf(searchfor) >= 0) { |
|
||||||
itemsfound.Items.Add(new TypeItem(Namespace, type, nodecolor)); |
|
||||||
} |
|
||||||
|
|
||||||
if (!searchMembers) return; |
|
||||||
|
|
||||||
//if (!type.MembersLoaded) type.LoadMembers();
|
|
||||||
|
|
||||||
foreach (IMethod method in type.Methods) |
|
||||||
ProcessMember(Namespace, method, searchfor); |
|
||||||
foreach (IProperty prop in type.Properties) |
|
||||||
ProcessMember(Namespace, prop, searchfor); |
|
||||||
foreach (IField field in type.Fields) |
|
||||||
ProcessMember(Namespace, field, searchfor); |
|
||||||
foreach (IEvent evt in type.Events) |
|
||||||
ProcessMember(Namespace, evt, searchfor); |
|
||||||
} |
|
||||||
|
|
||||||
private void ProcessMember(string Namespace, IMember member, string searchfor) |
|
||||||
{ |
|
||||||
if(member is IMethod) { |
|
||||||
if (SharpAssemblyMethod.IsSpecial(member as IMethod)) return; |
|
||||||
} |
|
||||||
|
|
||||||
if(member.IsPrivate && (tree.showPrivateMembers == ShowOptions.Hide)) return; |
|
||||||
if(member.IsInternal && (tree.showInternalMembers == ShowOptions.Hide)) return; |
|
||||||
|
|
||||||
if(member.Name.ToLower().IndexOf(searchfor) >= 0) { |
|
||||||
Color color = SystemColors.WindowText; |
|
||||||
if ((member.IsInternal && tree.showInternalMembers == ShowOptions.GreyOut) || |
|
||||||
(member.IsPrivate && tree.showPrivateMembers == ShowOptions.GreyOut)) { |
|
||||||
color = SystemColors.GrayText; |
|
||||||
} |
|
||||||
itemsfound.Items.Add(new MemberItem(Namespace, member, color)); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -1,262 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Text; |
|
||||||
using System.Reflection; |
|
||||||
using System.Xml; |
|
||||||
using System.IO; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata.Rows; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata; |
|
||||||
using ICSharpCode.SharpAssembly.PE; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
[Serializable] |
|
||||||
public class SharpAssemblyAttribute : DefaultAttribute |
|
||||||
{ |
|
||||||
SharpAssemblyClass attributeType; |
|
||||||
|
|
||||||
public SharpAssemblyClass AttributeType { |
|
||||||
get { |
|
||||||
return attributeType; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpAssemblyAttribute(SA.SharpAssembly assembly, SA.SharpCustomAttribute attribute) : base(null) |
|
||||||
{ |
|
||||||
uint sigOffset = 0; |
|
||||||
|
|
||||||
if (attribute.IsMemberRef) { |
|
||||||
MemberRef[] memberTable = assembly.Tables.MemberRef; |
|
||||||
TypeRef[] typeRefTable = assembly.Tables.TypeRef; |
|
||||||
|
|
||||||
sigOffset = memberTable[attribute.MemberIndex].Signature; |
|
||||||
uint trIndex = memberTable[attribute.MemberIndex].Class; |
|
||||||
|
|
||||||
int table = assembly.Reader.GetCodedIndexTable(CodedIndex.MemberRefParent, ref trIndex); |
|
||||||
if (table != 1) { |
|
||||||
Console.WriteLine("SharpAssemblyAttribute: unsupported MemberRefParent coded index"); |
|
||||||
return; // unsupported
|
|
||||||
} |
|
||||||
|
|
||||||
attributeType = SharpAssemblyClass.FromTypeRef(assembly, trIndex); |
|
||||||
|
|
||||||
} else { |
|
||||||
TypeDef[] typeDefTable = assembly.Tables.TypeDef; |
|
||||||
|
|
||||||
sigOffset = assembly.Tables.Method[attribute.MemberIndex].Signature; |
|
||||||
uint tdIndex = 0; |
|
||||||
|
|
||||||
for (uint i = 1; i <= typeDefTable.GetUpperBound(0); ++i) { |
|
||||||
if (typeDefTable[i].MethodList <= attribute.MemberIndex && i == typeDefTable.GetUpperBound(0)) { |
|
||||||
tdIndex = i; |
|
||||||
break; |
|
||||||
} |
|
||||||
if (typeDefTable[i].MethodList <= attribute.MemberIndex && typeDefTable[i+1].MethodList > attribute.MemberIndex) { |
|
||||||
tdIndex = i; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
attributeType = SharpAssemblyClass.FromTypeDef(assembly, tdIndex); |
|
||||||
} |
|
||||||
if (attributeType != null) Name = attributeType.FullyQualifiedName; |
|
||||||
|
|
||||||
if (attribute.ValueIndex == 0) return; |
|
||||||
|
|
||||||
try { |
|
||||||
|
|
||||||
// Get return types of positional arguments by inspecting the method signature
|
|
||||||
int size = assembly.Reader.LoadBlob(ref sigOffset); |
|
||||||
sigOffset += 1; // skip calling convention
|
|
||||||
int numReturnTypes = assembly.Reader.LoadBlob(ref sigOffset); |
|
||||||
|
|
||||||
SharpAssemblyReturnType dummy = SharpAssemblyReturnType.Create(assembly, ref sigOffset); |
|
||||||
|
|
||||||
SharpAssemblyReturnType[] returnTypes = new SharpAssemblyReturnType[numReturnTypes]; |
|
||||||
for (int i = 0; i < returnTypes.Length; ++i) { |
|
||||||
returnTypes[i] = SharpAssemblyReturnType.Create(assembly, ref sigOffset); |
|
||||||
} |
|
||||||
|
|
||||||
// Get the return type values and the named arguments
|
|
||||||
byte[] argBlob = assembly.Reader.GetBlobFromHeap(attribute.ValueIndex); |
|
||||||
Stream str = new MemoryStream(argBlob); |
|
||||||
BinaryReader binaryReader = new BinaryReader(str); |
|
||||||
|
|
||||||
ushort prolog = binaryReader.ReadUInt16(); |
|
||||||
if (prolog != 1) { |
|
||||||
Console.WriteLine("SharpAssemblyAttribute: Wrong prolog in argument list"); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
// read positional arguments
|
|
||||||
for (int i = 0; i < returnTypes.Length; ++i) { |
|
||||||
string rettypename = returnTypes[i].Name; |
|
||||||
|
|
||||||
SharpAssemblyClass underlyingClass = returnTypes[i].UnderlyingClass; |
|
||||||
|
|
||||||
// enum -> determine base integer size and try to display the user-friendly name of the value
|
|
||||||
if (underlyingClass != null && underlyingClass.IsSubclassOf("System.Enum")) { |
|
||||||
//underlyingClass.LoadMembers();
|
|
||||||
foreach (IField field in underlyingClass.Fields) { |
|
||||||
if (field.Name.EndsWith("value__")) { |
|
||||||
rettypename = field.ReturnType.Name; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
object argValue = GetFixedArg(argBlob, binaryReader, rettypename); |
|
||||||
|
|
||||||
foreach (IField field in underlyingClass.Fields) { |
|
||||||
if (field is SharpAssemblyField) { |
|
||||||
try { |
|
||||||
if (((field as SharpAssemblyField).InitialValue as IComparable).CompareTo(argValue) == 0) { |
|
||||||
// TODO PositionArguments
|
|
||||||
//PositionalArguments.Add(underlyingClass.Name + "." + field.Name);
|
|
||||||
goto namefound; |
|
||||||
} |
|
||||||
} catch {} |
|
||||||
} |
|
||||||
} |
|
||||||
// if the value cannot be found
|
|
||||||
// TODO PositionArguments
|
|
||||||
//PositionalArguments.Add(argValue.ToString());
|
|
||||||
|
|
||||||
namefound: ; |
|
||||||
|
|
||||||
} else { |
|
||||||
// TODO PositionArguments
|
|
||||||
//PositionalArguments.Add(GetFixedArg(argBlob, binaryReader, rettypename).ToString());
|
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
ushort numnamed = binaryReader.ReadUInt16(); |
|
||||||
|
|
||||||
for (int i = 0; i < numnamed; ++i) { |
|
||||||
byte field_or_prop = binaryReader.ReadByte(); |
|
||||||
byte type = binaryReader.ReadByte(); |
|
||||||
|
|
||||||
string typename = ""; |
|
||||||
if (type == 0x50) { |
|
||||||
typename = "Type"; |
|
||||||
} else { |
|
||||||
DataType dt = (DataType)type; |
|
||||||
typename = dt.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string argname = GetSerString(argBlob, binaryReader.BaseStream); |
|
||||||
|
|
||||||
// TODO NamedArgs
|
|
||||||
//NamedArguments.Add(argname, GetFixedArg(argBlob, binaryReader, typename).ToString());
|
|
||||||
} |
|
||||||
|
|
||||||
binaryReader.Close(); |
|
||||||
} catch (Exception ex) { |
|
||||||
LoggingService.Error("SharpAssemblyAttribute: Error loading arguments. " + ex.ToString()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
object GetFixedArg(byte[] argBlob, BinaryReader binaryReader, string name) |
|
||||||
{ |
|
||||||
switch (name) { |
|
||||||
case "Boolean": |
|
||||||
return binaryReader.ReadBoolean(); |
|
||||||
case "Char": |
|
||||||
return binaryReader.ReadChar(); |
|
||||||
case "SByte": |
|
||||||
return binaryReader.ReadSByte(); |
|
||||||
case "Byte": |
|
||||||
return binaryReader.ReadByte(); |
|
||||||
case "Int16": |
|
||||||
return binaryReader.ReadInt16(); |
|
||||||
case "UInt16": |
|
||||||
return binaryReader.ReadUInt16(); |
|
||||||
case "Int32": |
|
||||||
return binaryReader.ReadInt32(); |
|
||||||
case "UInt32": |
|
||||||
return binaryReader.ReadUInt32(); |
|
||||||
case "Int64": |
|
||||||
return binaryReader.ReadInt64(); |
|
||||||
case "UInt64": |
|
||||||
return binaryReader.ReadUInt64(); |
|
||||||
case "Single": |
|
||||||
return binaryReader.ReadSingle(); |
|
||||||
case "Double": |
|
||||||
return binaryReader.ReadDouble(); |
|
||||||
case "String": |
|
||||||
case "Type": |
|
||||||
return '"' + GetSerString(argBlob, binaryReader.BaseStream) + '"'; |
|
||||||
default: |
|
||||||
return ""; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
string GetSerString(byte[] blob, Stream stream) |
|
||||||
{ |
|
||||||
uint pos2 = (uint)stream.Position; |
|
||||||
int size = SA.AssemblyReader.GetCompressedInt(blob, ref pos2); |
|
||||||
|
|
||||||
string str; |
|
||||||
try { |
|
||||||
str = System.Text.Encoding.UTF8.GetString(blob, (int)pos2, size); |
|
||||||
} catch { |
|
||||||
str = "<error with string>"; |
|
||||||
} |
|
||||||
|
|
||||||
stream.Position = pos2 + size; |
|
||||||
|
|
||||||
return str; |
|
||||||
} |
|
||||||
|
|
||||||
public override string ToString() |
|
||||||
{ |
|
||||||
string ret = Name + " ("; |
|
||||||
|
|
||||||
foreach (AttributeArgument arg in PositionalArguments) { |
|
||||||
ret += arg.Type.FullyQualifiedName + ", "; |
|
||||||
} |
|
||||||
|
|
||||||
// TODO NamedArguments
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string, AttributeArgument> item in NamedArguments) { |
|
||||||
try { |
|
||||||
ret += item.Key + " = " + item.Value.Type.FullyQualifiedName + ", "; |
|
||||||
} catch { |
|
||||||
LoggingService.Error("Error in NamedArguments."); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
// delete last bracket
|
|
||||||
if (ret.EndsWith(", ")) ret = ret.Substring(0, ret.Length - 2); |
|
||||||
|
|
||||||
return ret + ")"; |
|
||||||
} |
|
||||||
|
|
||||||
public static List<IAttribute> GetAssemblyAttributes(SA.SharpAssembly assembly) |
|
||||||
{ |
|
||||||
List<IAttribute> attributes = new List<IAttribute>(); |
|
||||||
|
|
||||||
foreach (ArrayList al in assembly.Attributes.Assembly.Values) { |
|
||||||
foreach (SA.SharpCustomAttribute attr in al) { |
|
||||||
attributes.Add(new SharpAssemblyAttribute(assembly, attr)); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return attributes; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
@ -1,484 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Text; |
|
||||||
using System.Xml; |
|
||||||
using System.Collections.Specialized; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata.Rows; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata; |
|
||||||
using ICSharpCode.SharpAssembly.PE; |
|
||||||
using ICSharpCode.SharpAssembly.Assembly; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
[Serializable] |
|
||||||
public class SharpAssemblyClass : DefaultClass |
|
||||||
{ |
|
||||||
List<IClass> baseTypeCollection = new List<IClass>(); |
|
||||||
|
|
||||||
object declaredIn; |
|
||||||
|
|
||||||
public object DeclaredIn { |
|
||||||
get { |
|
||||||
return declaredIn; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override string DocumentationTag { |
|
||||||
get { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public List<IClass> BaseTypeCollection { |
|
||||||
get { |
|
||||||
if (baseTypeCollection == null) baseTypeCollection = new List<IClass>(); |
|
||||||
return baseTypeCollection; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public static string GetNestedName(SA.SharpAssembly asm, TypeRef[] typeRefTable, uint index) |
|
||||||
{ |
|
||||||
uint val = typeRefTable[index].ResolutionScope; |
|
||||||
int table = asm.Reader.GetCodedIndexTable(CodedIndex.ResolutionScope, ref val); |
|
||||||
|
|
||||||
switch (table) { |
|
||||||
case 2: // AssemblyRef
|
|
||||||
return asm.Reader.GetStringFromHeap(typeRefTable[index].Nspace) + "." + asm.Reader.GetStringFromHeap(typeRefTable[index].Name); |
|
||||||
case 3: // TypeRef -- nested type
|
|
||||||
return GetNestedName(asm, typeRefTable, val) + "+" + asm.Reader.GetStringFromHeap(typeRefTable[index].Name); |
|
||||||
default: // other token - not supported
|
|
||||||
Console.WriteLine("GetNestedName: Unsupported resolution scope!"); |
|
||||||
goto case 3; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public static string GetNestedName(SA.SharpAssembly asm, TypeDef[] typeDefTable, uint index) |
|
||||||
{ |
|
||||||
uint nestedParent = asm.GetNestedTypeParent(index); |
|
||||||
|
|
||||||
if (nestedParent == 0) { |
|
||||||
return asm.Reader.GetStringFromHeap(typeDefTable[index].NSpace) + "." + asm.Reader.GetStringFromHeap(typeDefTable[index].Name); |
|
||||||
} |
|
||||||
|
|
||||||
return GetNestedName(asm, typeDefTable, nestedParent) + "+" + asm.Reader.GetStringFromHeap(typeDefTable[index].Name); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructs a SharpAssemblyClass from an entry in the assembly's TypeRef table
|
|
||||||
/// by looking in the referencing assembly's TypeDef table
|
|
||||||
/// </summary>
|
|
||||||
public static SharpAssemblyClass FromTypeRef(SA.SharpAssembly referencingAssembly, uint index) |
|
||||||
{ |
|
||||||
if (referencingAssembly.TypeRefObjects[index] as SharpAssemblyClass != null) { |
|
||||||
return (SharpAssemblyClass)referencingAssembly.TypeRefObjects[index]; |
|
||||||
} |
|
||||||
|
|
||||||
TypeRef[] typeRefTable = referencingAssembly.Tables.TypeRef; |
|
||||||
|
|
||||||
string name = referencingAssembly.Reader.GetStringFromHeap(typeRefTable[index].Name); |
|
||||||
|
|
||||||
SA.SharpAssembly declaringAssembly = referencingAssembly.GetRefAssemblyFor(index); |
|
||||||
if (declaringAssembly == null) { |
|
||||||
Console.Write("FromTypeRef failed for: " + name + " declared in assembly " + referencingAssembly.Name); |
|
||||||
Console.WriteLine(": Declaring assembly not found."); |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
TypeDef[] typeDefTable = declaringAssembly.Tables.TypeDef; |
|
||||||
if (typeDefTable == null) { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
string nestedName = GetNestedName(referencingAssembly, typeRefTable, index); |
|
||||||
|
|
||||||
for (uint i = 1; i <= typeDefTable.GetUpperBound(0); ++i) { |
|
||||||
if (declaringAssembly.Reader.GetStringFromHeap(typeDefTable[i].Name) == name) { |
|
||||||
if (GetNestedName(declaringAssembly, typeDefTable, i) == nestedName) { |
|
||||||
SharpAssemblyClass newclass = FromTypeDef(declaringAssembly, i); |
|
||||||
|
|
||||||
// store new class object in assembly's cache
|
|
||||||
if (newclass != null) referencingAssembly.TypeRefObjects[index] = newclass; |
|
||||||
return newclass; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
Console.Write("FromTypeRef failed for: " + name + " declared in assembly " + referencingAssembly.Name); |
|
||||||
Console.WriteLine(": Matching type not found for nested name: " + nestedName); |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructs a SharpAssemblyClass from an entry in the assembly's TypeDef table
|
|
||||||
/// Looks in the class cache for the assembly first
|
|
||||||
/// </summary>
|
|
||||||
public static SharpAssemblyClass FromTypeDef(SA.SharpAssembly assembly, uint index) |
|
||||||
{ |
|
||||||
if (assembly.TypeDefObjects[index] as SharpAssemblyClass != null) { |
|
||||||
SharpAssemblyClass exclass = (SharpAssemblyClass)assembly.TypeDefObjects[index]; |
|
||||||
|
|
||||||
return exclass; |
|
||||||
} |
|
||||||
|
|
||||||
return new SharpAssemblyClass(assembly, assembly.Tables.TypeDef, index); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The constructor is private because the only way to construct SharpAssemblyClass objects
|
|
||||||
/// is to call FromTypeRef/Def to make us of the cache
|
|
||||||
/// </summary>
|
|
||||||
SharpAssemblyClass(SA.SharpAssembly assembly, TypeDef[] typeDefTable, uint index) : base(null, String.Empty) |
|
||||||
{ |
|
||||||
if (assembly == null) { |
|
||||||
throw new System.ArgumentNullException("assembly"); |
|
||||||
} |
|
||||||
if (typeDefTable == null) { |
|
||||||
throw new System.ArgumentNullException("typeDefTable"); |
|
||||||
} |
|
||||||
if (index > typeDefTable.GetUpperBound(0) || index < 1) { |
|
||||||
throw new System.ArgumentOutOfRangeException("index", index, String.Format("must be between 1 and {0}!", typeDefTable.GetUpperBound(0))); |
|
||||||
} |
|
||||||
|
|
||||||
TypeDef typeDef = typeDefTable[index]; |
|
||||||
typeDefIndex = index; // store index for use in LoadMembers()
|
|
||||||
|
|
||||||
declaredIn = assembly; |
|
||||||
|
|
||||||
FullyQualifiedName = GetNestedName(assembly, typeDefTable, index); |
|
||||||
|
|
||||||
// store in assembly's cache
|
|
||||||
assembly.TypeDefObjects[index] = this; |
|
||||||
|
|
||||||
if (typeDef.IsFlagSet(TypeDef.FLAG_INTERFACE)) { |
|
||||||
ClassType = ClassType.Interface; |
|
||||||
} else if (typeDef.IsFlagSet(TypeDef.FLAG_CLASS)) { |
|
||||||
ClassType = ClassType.Class; |
|
||||||
} |
|
||||||
|
|
||||||
if (typeDef.Extends == 0) goto noext; |
|
||||||
|
|
||||||
SharpAssemblyClass extend = GetTypeRefOrDefClass(assembly, typeDef.Extends); |
|
||||||
|
|
||||||
if (extend == null) goto noext; |
|
||||||
|
|
||||||
if (extend.FullyQualifiedName == "System.Enum") { |
|
||||||
ClassType = ClassType.Enum; |
|
||||||
} else if (extend.FullyQualifiedName == "System.ValueType") { |
|
||||||
ClassType = ClassType.Struct; |
|
||||||
} |
|
||||||
|
|
||||||
baseTypeCollection.Add(extend); |
|
||||||
|
|
||||||
if (IsSubclassOf("System.Delegate")) ClassType = ClassType.Delegate; |
|
||||||
|
|
||||||
noext: |
|
||||||
|
|
||||||
InterfaceImpl[] ifaces = assembly.Tables.InterfaceImpl; |
|
||||||
if (ifaces == null) goto nointerfaces; |
|
||||||
|
|
||||||
for (int i = 1; i <= ifaces.GetUpperBound(0); ++i) { |
|
||||||
if (ifaces[i].Class == index) { |
|
||||||
SharpAssemblyClass impl = GetTypeRefOrDefClass(assembly, ifaces[i].Interface); |
|
||||||
if (impl != null) { |
|
||||||
baseTypeCollection.Add(impl); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
nointerfaces: |
|
||||||
|
|
||||||
NestedClass[] nestedClasses = assembly.Tables.NestedClass; |
|
||||||
if (nestedClasses == null) goto nonested; |
|
||||||
|
|
||||||
for (int i = 1; i <= nestedClasses.GetUpperBound(0); ++i) { |
|
||||||
if (nestedClasses[i].EnclosingClass == index) { |
|
||||||
IClass newclass = FromTypeDef(assembly, nestedClasses[i].NestedClassIndex); |
|
||||||
InnerClasses.Add(newclass); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
nonested: |
|
||||||
|
|
||||||
// Attributes
|
|
||||||
ArrayList attrib = assembly.Attributes.TypeDef[index] as ArrayList; |
|
||||||
if (attrib == null) goto modifiers; |
|
||||||
|
|
||||||
foreach(SharpCustomAttribute customattribute in attrib) { |
|
||||||
Attributes.Add(new SharpAssemblyAttribute(assembly, customattribute)); |
|
||||||
} |
|
||||||
|
|
||||||
modifiers: |
|
||||||
|
|
||||||
Modifiers = ModifierEnum.None; |
|
||||||
|
|
||||||
if (typeDef.IsFlagSet(TypeDef.FLAG_SEALED)) { |
|
||||||
Modifiers |= ModifierEnum.Sealed; |
|
||||||
} |
|
||||||
|
|
||||||
if (typeDef.IsFlagSet(TypeDef.FLAG_ABSTRACT)) { |
|
||||||
Modifiers |= ModifierEnum.Abstract; |
|
||||||
} |
|
||||||
|
|
||||||
if (typeDef.IsMaskedFlagSet(TypeDef.FLAG_NESTEDPRIVATE, TypeDef.FLAG_VISIBILITYMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Private; |
|
||||||
} else if (typeDef.IsMaskedFlagSet(TypeDef.FLAG_NESTEDPUBLIC, TypeDef.FLAG_VISIBILITYMASK) || typeDef.IsMaskedFlagSet(TypeDef.FLAG_PUBLIC, TypeDef.FLAG_VISIBILITYMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Public; |
|
||||||
} else if (typeDef.IsMaskedFlagSet(TypeDef.FLAG_NESTEDASSEMBLY, TypeDef.FLAG_VISIBILITYMASK) || |
|
||||||
typeDef.IsMaskedFlagSet(TypeDef.FLAG_NOTPUBLIC, TypeDef.FLAG_VISIBILITYMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Internal; |
|
||||||
} else if (typeDef.IsMaskedFlagSet(TypeDef.FLAG_NESTEDFAMILY, TypeDef.FLAG_VISIBILITYMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Protected; |
|
||||||
} else if (typeDef.IsMaskedFlagSet(TypeDef.FLAG_NESTEDFAMORASSEM, TypeDef.FLAG_VISIBILITYMASK)) { |
|
||||||
Modifiers |= ModifierEnum.ProtectedOrInternal; |
|
||||||
} else if (typeDef.IsMaskedFlagSet(TypeDef.FLAG_NESTEDFAMANDASSEM, TypeDef.FLAG_VISIBILITYMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Protected; |
|
||||||
Modifiers |= ModifierEnum.Internal; |
|
||||||
} |
|
||||||
|
|
||||||
if (typeDef.IsFlagSet(TypeDef.FLAG_SPECIALNAME)) { |
|
||||||
Modifiers |= ModifierEnum.Volatile | ModifierEnum.Unsafe | ModifierEnum.Extern; |
|
||||||
} |
|
||||||
|
|
||||||
/* members are loaded on demand now |
|
||||||
if (classType != ClassType.Delegate && loadMembers) { |
|
||||||
AddMethods(assembly, typeDefTable, index); |
|
||||||
AddFields(assembly, typeDefTable, index); |
|
||||||
AddProperties(assembly, typeDefTable, index); |
|
||||||
AddEvents(assembly, typeDefTable, index); |
|
||||||
|
|
||||||
membersLoaded = true; |
|
||||||
} |
|
||||||
*/ |
|
||||||
} |
|
||||||
|
|
||||||
uint typeDefIndex = 0; |
|
||||||
|
|
||||||
bool membersLoaded = false; |
|
||||||
|
|
||||||
void LoadMembers() |
|
||||||
{ |
|
||||||
if (membersLoaded) return; |
|
||||||
|
|
||||||
membersLoaded = true; |
|
||||||
|
|
||||||
SA.SharpAssembly assembly = (SA.SharpAssembly)declaredIn; |
|
||||||
TypeDef[] typeDefTable = assembly.Tables.TypeDef; |
|
||||||
|
|
||||||
AddMethods(assembly, typeDefTable, typeDefIndex); |
|
||||||
AddFields(assembly, typeDefTable, typeDefIndex); |
|
||||||
AddProperties(assembly, typeDefTable, typeDefIndex); |
|
||||||
AddEvents(assembly, typeDefTable, typeDefIndex); |
|
||||||
} |
|
||||||
|
|
||||||
public bool IsSubclassOf(string FullName) |
|
||||||
{ |
|
||||||
foreach (SharpAssemblyClass basetype in baseTypeCollection) { |
|
||||||
if (basetype.FullyQualifiedName == FullName) return true; |
|
||||||
|
|
||||||
if (basetype.IsSubclassOf(FullName)) return true; |
|
||||||
} |
|
||||||
|
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
private static SharpAssemblyClass GetTypeRefOrDefClass(SA.SharpAssembly assembly, uint cind) { |
|
||||||
uint nTable = cind & 0x03; |
|
||||||
uint nIndex = cind >> 2; |
|
||||||
|
|
||||||
switch (nTable) { |
|
||||||
case 0: // TypeDef
|
|
||||||
return FromTypeDef(assembly, nIndex); |
|
||||||
case 1: // TypeRef
|
|
||||||
return FromTypeRef(assembly, nIndex); |
|
||||||
default: |
|
||||||
Console.WriteLine("GetTypeRefOrDefClass: Wrong TypeDefOrRef coded index!"); |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void AddEvents(SA.SharpAssembly asm, TypeDef[] typeDefTable, uint index) |
|
||||||
{ |
|
||||||
EventMap[] eventMapTable = asm.Tables.EventMap; |
|
||||||
Event[] eventTable = asm.Tables.Event; |
|
||||||
if (eventMapTable == null || eventTable == null) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
for (int i = 1; i <= eventMapTable.GetUpperBound(0); ++i) { |
|
||||||
EventMap eventMap = eventMapTable[i]; |
|
||||||
|
|
||||||
if (eventMap.Parent == index) { |
|
||||||
uint eventIndexStart = eventMap.EventList; |
|
||||||
|
|
||||||
// 0 means no events
|
|
||||||
if (eventIndexStart == 0) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
uint eventIndexEnd = (uint)eventTable.GetUpperBound(0) + 1; |
|
||||||
if (i < eventMapTable.GetUpperBound(0)) { |
|
||||||
eventIndexEnd = eventMapTable[i + 1].EventList; |
|
||||||
} |
|
||||||
|
|
||||||
for (uint j = eventIndexStart; j < eventIndexEnd; ++j) { |
|
||||||
IEvent newEvent = new SharpAssemblyEvent(asm, eventTable, this, j); |
|
||||||
Events.Add(newEvent); |
|
||||||
} |
|
||||||
|
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void AddProperties(SA.SharpAssembly asm, TypeDef[] typeDefTable, uint index) |
|
||||||
{ |
|
||||||
PropertyMap[] propertyMapTable = asm.Tables.PropertyMap; |
|
||||||
Property[] propertyTable = asm.Tables.Property; |
|
||||||
if (propertyMapTable == null || propertyTable == null) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
for (int i = 1; i <= propertyMapTable.GetUpperBound(0); ++i) { |
|
||||||
PropertyMap propertyMap = propertyMapTable[i]; |
|
||||||
|
|
||||||
if (propertyMap.Parent == index) { |
|
||||||
uint propertyIndexStart = propertyMap.PropertyList; |
|
||||||
|
|
||||||
// 0 means no properties
|
|
||||||
if (propertyIndexStart == 0) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
uint propertyIndexEnd = (uint)propertyTable.GetUpperBound(0) + 1; |
|
||||||
if (i < propertyMapTable.GetUpperBound(0)) { |
|
||||||
propertyIndexEnd = propertyMapTable[i + 1].PropertyList; |
|
||||||
} |
|
||||||
|
|
||||||
for (uint j = propertyIndexStart; j < propertyIndexEnd; ++j) { |
|
||||||
IProperty newProperty = new SharpAssemblyProperty(asm, propertyTable, this, j); |
|
||||||
Properties.Add(newProperty); |
|
||||||
} |
|
||||||
|
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void AddFields(SA.SharpAssembly asm, TypeDef[] typeDefTable, uint index) |
|
||||||
{ |
|
||||||
Field[] fieldTable = asm.Tables.Field; |
|
||||||
if (fieldTable == null) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
uint fieldIndexStart = typeDefTable[index].FieldList; |
|
||||||
|
|
||||||
// 0 means no fields
|
|
||||||
if (fieldIndexStart == 0) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
uint fieldIndexEnd = (uint)fieldTable.GetUpperBound(0) + 1; |
|
||||||
if (index < typeDefTable.GetUpperBound(0)) { |
|
||||||
fieldIndexEnd = typeDefTable[index + 1].FieldList; |
|
||||||
} |
|
||||||
|
|
||||||
for (uint i = fieldIndexStart; i < fieldIndexEnd; ++i) { |
|
||||||
IField newField = new SharpAssemblyField(asm, fieldTable, this, i); |
|
||||||
Fields.Add(newField); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void AddMethods(SA.SharpAssembly asm, TypeDef[] typeDefTable, uint index) |
|
||||||
{ |
|
||||||
Method[] methodDefTable = asm.Tables.Method; |
|
||||||
if (methodDefTable == null) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
uint methodIndexStart = typeDefTable[index].MethodList; |
|
||||||
|
|
||||||
// 0 means no methods
|
|
||||||
if (methodIndexStart == 0) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
uint methodIndexEnd = (uint)methodDefTable.GetUpperBound(0) + 1; |
|
||||||
if (index < typeDefTable.GetUpperBound(0)) { |
|
||||||
methodIndexEnd = typeDefTable[index + 1].MethodList; |
|
||||||
} |
|
||||||
|
|
||||||
for (uint i = methodIndexStart; i < methodIndexEnd; ++i) { |
|
||||||
IMethod newMethod = new SharpAssemblyMethod(asm, methodDefTable, this, i); |
|
||||||
Methods.Add(newMethod); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public static SharpAssemblyClass[] GetAssemblyTypes(SA.SharpAssembly assembly) |
|
||||||
{ |
|
||||||
|
|
||||||
TypeDef[] typeDefTable = assembly.Tables.TypeDef; |
|
||||||
if (typeDefTable == null) return new SharpAssemblyClass[0]; |
|
||||||
|
|
||||||
ArrayList classes = new ArrayList(); |
|
||||||
|
|
||||||
for (uint i = 1; i <= typeDefTable.GetUpperBound(0); ++i) { |
|
||||||
try { |
|
||||||
IClass newclass = new SharpAssemblyClass(assembly, typeDefTable, i); |
|
||||||
classes.Add(newclass); |
|
||||||
} catch { |
|
||||||
Console.WriteLine("GetAssemblyTypes: Error loading class " + i); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return (SharpAssemblyClass[])classes.ToArray(typeof(SharpAssemblyClass)); |
|
||||||
} |
|
||||||
|
|
||||||
public override string ToString() |
|
||||||
{ |
|
||||||
return FullyQualifiedName; |
|
||||||
} |
|
||||||
|
|
||||||
public override List<IField> Fields { |
|
||||||
get { |
|
||||||
if (!membersLoaded) LoadMembers(); |
|
||||||
return base.Fields; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override List<IProperty> Properties { |
|
||||||
get { |
|
||||||
if (!membersLoaded) LoadMembers(); |
|
||||||
return base.Properties; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override List<IMethod> Methods { |
|
||||||
get { |
|
||||||
if (!membersLoaded) LoadMembers(); |
|
||||||
return base.Methods; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override List<IEvent> Events { |
|
||||||
get { |
|
||||||
if (!membersLoaded) LoadMembers(); |
|
||||||
return base.Events; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,135 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Text; |
|
||||||
using System.Reflection; |
|
||||||
using System.Xml; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata.Rows; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata; |
|
||||||
using ICSharpCode.SharpAssembly.PE; |
|
||||||
using ICSharpCode.SharpAssembly.Assembly; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
[Serializable] |
|
||||||
public class SharpAssemblyEvent : DefaultEvent |
|
||||||
{ |
|
||||||
public override string DocumentationTag { |
|
||||||
get { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpAssemblyEvent(SA.SharpAssembly asm, Event[] eventTable, SharpAssemblyClass declaringType, uint index) : base(declaringType, null) |
|
||||||
{ |
|
||||||
if (asm == null) { |
|
||||||
throw new System.ArgumentNullException("asm"); |
|
||||||
} |
|
||||||
if (eventTable == null) { |
|
||||||
throw new System.ArgumentNullException("eventTable"); |
|
||||||
} |
|
||||||
if (declaringType == null) { |
|
||||||
throw new System.ArgumentNullException("declaringtype"); |
|
||||||
} |
|
||||||
if (index > eventTable.GetUpperBound(0) || index < 1) { |
|
||||||
throw new System.ArgumentOutOfRangeException("index", index, String.Format("must be between 1 and {0}!", eventTable.GetUpperBound(0))); |
|
||||||
} |
|
||||||
|
|
||||||
AssemblyReader assembly = asm.Reader; |
|
||||||
|
|
||||||
Event evt = eventTable[index]; |
|
||||||
string name = assembly.GetStringFromHeap(evt.Name); |
|
||||||
FullyQualifiedName = String.Concat(DeclaringType.FullyQualifiedName, ".", name); |
|
||||||
|
|
||||||
MethodSemantics[] sem = asm.Tables.MethodSemantics; |
|
||||||
Method[] method = asm.Tables.Method; |
|
||||||
if (sem == null) goto nosem; |
|
||||||
|
|
||||||
for (int i = 1; i <= sem.GetUpperBound(0); ++i) { |
|
||||||
uint table = sem[i].Association & 1; |
|
||||||
uint ident = sem[i].Association >> 1; |
|
||||||
|
|
||||||
if (table == 0 && ident == index) { // table: Event
|
|
||||||
Modifiers = ModifierEnum.None; |
|
||||||
Method methodDef = method[sem[i].Method]; |
|
||||||
|
|
||||||
if (methodDef.IsFlagSet(Method.FLAG_STATIC)) { |
|
||||||
Modifiers |= ModifierEnum.Static; |
|
||||||
} |
|
||||||
|
|
||||||
if (methodDef.IsMaskedFlagSet(Method.FLAG_PRIVATE, Method.FLAG_MEMBERACCESSMASK)) { // I assume that private is used most and public last (at least should be)
|
|
||||||
Modifiers |= ModifierEnum.Private; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMILY, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Protected; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_PUBLIC, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Public; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_ASSEM, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Internal; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMORASSEM, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.ProtectedOrInternal; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMANDASSEM, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Protected; |
|
||||||
Modifiers |= ModifierEnum.Internal; |
|
||||||
} |
|
||||||
|
|
||||||
if ((sem[i].Semantics & MethodSemantics.SEM_ADDON) == MethodSemantics.SEM_ADDON) { |
|
||||||
addMethod = new SharpAssemblyMethod(asm, method, declaringType, sem[i].Method); |
|
||||||
} |
|
||||||
|
|
||||||
if ((sem[i].Semantics & MethodSemantics.SEM_REMOVEON) == MethodSemantics.SEM_REMOVEON) { |
|
||||||
removeMethod = new SharpAssemblyMethod(asm, method, declaringType, sem[i].Method); |
|
||||||
} |
|
||||||
|
|
||||||
if ((sem[i].Semantics & MethodSemantics.SEM_FIRE) == MethodSemantics.SEM_FIRE) { |
|
||||||
raiseMethod = new SharpAssemblyMethod(asm, method, declaringType, sem[i].Method); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
nosem: |
|
||||||
|
|
||||||
// Attributes
|
|
||||||
ArrayList attrib = asm.Attributes.Event[index] as ArrayList; |
|
||||||
if (attrib == null) goto noatt; |
|
||||||
|
|
||||||
foreach(SharpCustomAttribute customattribute in attrib) { |
|
||||||
Attributes.Add(new SharpAssemblyAttribute(asm, customattribute)); |
|
||||||
} |
|
||||||
|
|
||||||
noatt: |
|
||||||
|
|
||||||
if ((evt.EventFlags & Event.FLAG_SPECIALNAME) == Event.FLAG_SPECIALNAME) Modifiers |= ModifierEnum.Extern | ModifierEnum.Volatile | ModifierEnum.Unsafe; |
|
||||||
|
|
||||||
uint typtab = evt.EventType & 0x03; |
|
||||||
uint typid = evt.EventType >> 2; |
|
||||||
|
|
||||||
if (typtab == 0) { // TypeDef
|
|
||||||
TypeDef[] typedef = (TypeDef[])assembly.MetadataTable.Tables[TypeDef.TABLE_ID]; |
|
||||||
ReturnType = SharpAssemblyReturnType.Create(asm, typedef, typid); |
|
||||||
|
|
||||||
} else if (typtab == 1) { // TypeRef
|
|
||||||
TypeRef[] typeref = (TypeRef[])assembly.MetadataTable.Tables[TypeRef.TABLE_ID]; |
|
||||||
ReturnType = SharpAssemblyReturnType.Create(asm, typeref, typid); |
|
||||||
|
|
||||||
} else { // TypeSpec
|
|
||||||
ReturnType = SharpAssemblyReturnType.Create("NOT_SUPPORTED"); |
|
||||||
Console.WriteLine("SharpAssemblyEvent: TypeSpec -- not supported"); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public override string ToString() |
|
||||||
{ |
|
||||||
return FullyQualifiedName; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,161 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Text; |
|
||||||
using System.IO; |
|
||||||
using System.Xml; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata.Rows; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata; |
|
||||||
using ICSharpCode.SharpAssembly.PE; |
|
||||||
using ICSharpCode.SharpAssembly.Assembly; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
[Serializable] |
|
||||||
public class SharpAssemblyField : DefaultField |
|
||||||
{ |
|
||||||
public override string DocumentationTag { |
|
||||||
get { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpAssemblyField(SA.SharpAssembly assembly, Field[] fieldTable, SharpAssemblyClass declaringType, uint index) : base(declaringType, null) |
|
||||||
{ |
|
||||||
if (assembly == null) { |
|
||||||
throw new System.ArgumentNullException("assembly"); |
|
||||||
} |
|
||||||
if (fieldTable == null) { |
|
||||||
throw new System.ArgumentNullException("fieldTable"); |
|
||||||
} |
|
||||||
if (declaringType == null) { |
|
||||||
throw new System.ArgumentNullException("declaringType"); |
|
||||||
} |
|
||||||
if (index > fieldTable.GetUpperBound(0) || index < 0) { |
|
||||||
throw new System.ArgumentOutOfRangeException("index", index, String.Format("must be between 1 and {0}!", fieldTable.GetUpperBound(0))); |
|
||||||
} |
|
||||||
|
|
||||||
Field field = fieldTable[index]; |
|
||||||
string name = assembly.Reader.GetStringFromHeap(field.Name); |
|
||||||
FullyQualifiedName = String.Concat(DeclaringType.FullyQualifiedName, ".", name); |
|
||||||
|
|
||||||
// Attributes
|
|
||||||
ArrayList attrib = assembly.Attributes.Field[index] as ArrayList; |
|
||||||
if (attrib == null) goto noatt; |
|
||||||
|
|
||||||
foreach(SharpCustomAttribute customattribute in attrib) { |
|
||||||
Attributes.Add(new SharpAssemblyAttribute(assembly, customattribute)); |
|
||||||
} |
|
||||||
|
|
||||||
noatt: |
|
||||||
|
|
||||||
if (field.IsFlagSet(Field.FLAG_INITONLY)) { |
|
||||||
Modifiers |= ModifierEnum.Readonly; |
|
||||||
} |
|
||||||
|
|
||||||
if (field.IsFlagSet(Field.FLAG_STATIC)) { |
|
||||||
Modifiers |= ModifierEnum.Static; |
|
||||||
} |
|
||||||
|
|
||||||
if (field.IsMaskedFlagSet(Field.FLAG_PRIVATE, Field.FLAG_FIELDACCESSMASK)) { // I assume that private is used most and public last (at least should be)
|
|
||||||
Modifiers |= ModifierEnum.Private; |
|
||||||
} else if (field.IsMaskedFlagSet(Field.FLAG_FAMILY, Field.FLAG_FIELDACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Protected; |
|
||||||
} else if (field.IsMaskedFlagSet(Field.FLAG_PUBLIC, Field.FLAG_FIELDACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Public; |
|
||||||
} else if (field.IsMaskedFlagSet(Field.FLAG_ASSEMBLY, Field.FLAG_FIELDACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Internal; |
|
||||||
} else if (field.IsMaskedFlagSet(Field.FLAG_FAMORASSEM, Field.FLAG_FIELDACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.ProtectedOrInternal; |
|
||||||
} else if (field.IsMaskedFlagSet(Field.FLAG_FAMANDASSEM, Field.FLAG_FIELDACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Protected; |
|
||||||
Modifiers |= ModifierEnum.Internal; |
|
||||||
} |
|
||||||
|
|
||||||
if (field.IsFlagSet(Field.FLAG_LITERAL)) { |
|
||||||
Modifiers |= ModifierEnum.Const; |
|
||||||
} |
|
||||||
|
|
||||||
if (field.IsFlagSet(Field.FLAG_SPECIALNAME)) { |
|
||||||
Modifiers |= ModifierEnum.Extern | ModifierEnum.Unsafe | ModifierEnum.Volatile; |
|
||||||
} |
|
||||||
|
|
||||||
// field return type
|
|
||||||
uint sigOffset = field.Signature; |
|
||||||
int sigSize = assembly.Reader.LoadBlob(ref sigOffset); |
|
||||||
sigOffset++; // skip field id
|
|
||||||
ReturnType = SharpAssemblyReturnType.Create(assembly, ref sigOffset); |
|
||||||
|
|
||||||
// field constant value -- for enums
|
|
||||||
Constant cst = (Constant)assembly.FieldConstantTable[index]; |
|
||||||
if (declaringType.ClassType == ClassType.Enum && cst != null) { |
|
||||||
try { |
|
||||||
DataType dt = (DataType)cst.Type; |
|
||||||
|
|
||||||
byte[] blob = assembly.Reader.GetBlobFromHeap(cst.Val); |
|
||||||
BinaryReader binReader = new BinaryReader(new MemoryStream(blob)); |
|
||||||
|
|
||||||
switch (dt) { |
|
||||||
case DataType.Byte: |
|
||||||
initialValue = binReader.ReadByte(); |
|
||||||
break; |
|
||||||
case DataType.Int16: |
|
||||||
initialValue = binReader.ReadInt16(); |
|
||||||
break; |
|
||||||
case DataType.Int32: |
|
||||||
initialValue = binReader.ReadInt32(); |
|
||||||
break; |
|
||||||
case DataType.Int64: |
|
||||||
initialValue = binReader.ReadInt64(); |
|
||||||
break; |
|
||||||
case DataType.SByte: |
|
||||||
initialValue = binReader.ReadSByte(); |
|
||||||
break; |
|
||||||
case DataType.UInt16: |
|
||||||
initialValue = binReader.ReadUInt16(); |
|
||||||
break; |
|
||||||
case DataType.UInt32: |
|
||||||
initialValue = binReader.ReadUInt32(); |
|
||||||
break; |
|
||||||
case DataType.UInt64: |
|
||||||
initialValue = binReader.ReadUInt64(); |
|
||||||
break; |
|
||||||
default: // not supported
|
|
||||||
break; |
|
||||||
} |
|
||||||
binReader.Close(); |
|
||||||
} catch { |
|
||||||
Console.WriteLine("SharpAssemblyField: Error reading constant value"); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override string ToString() |
|
||||||
{ |
|
||||||
return FullyQualifiedName; |
|
||||||
} |
|
||||||
|
|
||||||
object initialValue; |
|
||||||
|
|
||||||
public object InitialValue { |
|
||||||
get { |
|
||||||
return initialValue; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public static bool IsSpecial(IField field) |
|
||||||
{ |
|
||||||
return ((field.Modifiers & ModifierEnum.Extern) == ModifierEnum.Extern) || |
|
||||||
((field.Modifiers & ModifierEnum.Volatile) == ModifierEnum.Volatile) || |
|
||||||
((field.Modifiers & ModifierEnum.Unsafe) == ModifierEnum.Unsafe); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,158 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
using System; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.Collections; |
|
||||||
using System.Text; |
|
||||||
using System.Reflection; |
|
||||||
using System.Xml; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata.Rows; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata; |
|
||||||
using ICSharpCode.SharpAssembly.PE; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
[Serializable] |
|
||||||
public class SharpAssemblyMethod : DefaultMethod |
|
||||||
{ |
|
||||||
public override string DocumentationTag { |
|
||||||
get { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpAssemblyMethod(SA.SharpAssembly asm, Method[] methodTable, SharpAssemblyClass declaringType, uint index) : base(declaringType, null) |
|
||||||
{ |
|
||||||
if (asm == null) { |
|
||||||
throw new System.ArgumentNullException("asm"); |
|
||||||
} |
|
||||||
if (methodTable == null) { |
|
||||||
throw new System.ArgumentNullException("methodTable"); |
|
||||||
} |
|
||||||
if (declaringType == null) { |
|
||||||
throw new System.ArgumentNullException("declaringType"); |
|
||||||
} |
|
||||||
if (index > methodTable.GetUpperBound(0) || index < 1) { |
|
||||||
throw new System.ArgumentOutOfRangeException("index", index, String.Format("must be between 1 and {0}!", methodTable.GetUpperBound(0))); |
|
||||||
} |
|
||||||
SA.AssemblyReader assembly = asm.Reader; |
|
||||||
|
|
||||||
Method methodDef = methodTable[index]; |
|
||||||
string name = assembly.GetStringFromHeap(methodDef.Name); |
|
||||||
|
|
||||||
FullyQualifiedName = String.Concat(DeclaringType.FullyQualifiedName, ".", name); |
|
||||||
|
|
||||||
// Attributes
|
|
||||||
ArrayList attrib = asm.Attributes.Method[index] as ArrayList; |
|
||||||
if (attrib == null) goto noatt; |
|
||||||
|
|
||||||
foreach(SA.SharpCustomAttribute customattribute in attrib) { |
|
||||||
Attributes.Add(new SharpAssemblyAttribute(asm, customattribute)); |
|
||||||
} |
|
||||||
|
|
||||||
noatt: |
|
||||||
|
|
||||||
Modifiers = ModifierEnum.None; |
|
||||||
|
|
||||||
if (methodDef.IsFlagSet(Method.FLAG_STATIC)) { |
|
||||||
Modifiers |= ModifierEnum.Static; |
|
||||||
} |
|
||||||
|
|
||||||
if (methodDef.IsMaskedFlagSet(Method.FLAG_PRIVATE, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Private; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_PUBLIC, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Public; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMILY, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Protected; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_ASSEM, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Internal; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMORASSEM, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.ProtectedOrInternal; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMANDASSEM, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Protected; |
|
||||||
Modifiers |= ModifierEnum.Internal; |
|
||||||
} |
|
||||||
|
|
||||||
if (methodDef.IsFlagSet(Method.FLAG_VIRTUAL)) { |
|
||||||
Modifiers |= ModifierEnum.Virtual; |
|
||||||
} |
|
||||||
|
|
||||||
if (methodDef.IsFlagSet(Method.FLAG_FINAL)) { |
|
||||||
Modifiers |= ModifierEnum.Default; |
|
||||||
} |
|
||||||
|
|
||||||
if (methodDef.IsFlagSet(Method.FLAG_ABSTRACT)) { |
|
||||||
Modifiers |= ModifierEnum.Abstract; |
|
||||||
} |
|
||||||
|
|
||||||
if (methodDef.IsFlagSet(Method.FLAG_SPECIALNAME)) { |
|
||||||
Modifiers |= ModifierEnum.Extern | ModifierEnum.Volatile | ModifierEnum.Unsafe; |
|
||||||
} |
|
||||||
|
|
||||||
uint offset = methodDef.Signature; |
|
||||||
int size = assembly.LoadBlob(ref offset); |
|
||||||
offset += 1; // skip calling convention
|
|
||||||
int numReturnTypes = assembly.LoadBlob(ref offset); |
|
||||||
|
|
||||||
ReturnType = SharpAssemblyReturnType.Create(asm, ref offset); |
|
||||||
|
|
||||||
IReturnType[] returnTypes = new IReturnType[numReturnTypes]; |
|
||||||
for (int i = 0; i < returnTypes.Length; ++i) { |
|
||||||
returnTypes[i] = SharpAssemblyReturnType.Create(asm, ref offset); |
|
||||||
} |
|
||||||
|
|
||||||
AddParameters(asm, methodTable, index, returnTypes); |
|
||||||
} |
|
||||||
|
|
||||||
public static bool IsSpecial(IMethod method) |
|
||||||
{ |
|
||||||
return ((method.Modifiers & ModifierEnum.Extern) == ModifierEnum.Extern) || |
|
||||||
((method.Modifiers & ModifierEnum.Volatile) == ModifierEnum.Volatile) || |
|
||||||
((method.Modifiers & ModifierEnum.Unsafe) == ModifierEnum.Unsafe); |
|
||||||
} |
|
||||||
|
|
||||||
void AddParameters(SA.SharpAssembly asm, Method[] methodDefTable, uint index, IReturnType[] returnTypes) |
|
||||||
{ |
|
||||||
Param[] paramTable = asm.Tables.Param; |
|
||||||
if (paramTable == null) return; |
|
||||||
|
|
||||||
uint paramIndexStart = methodDefTable[index].ParamList; |
|
||||||
|
|
||||||
// 0 means no parameters
|
|
||||||
if (paramIndexStart > paramTable.GetUpperBound(0) || paramIndexStart == 0) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
uint paramIndexEnd = (uint)paramTable.GetUpperBound(0); |
|
||||||
if (index < methodDefTable.GetUpperBound(0)) { |
|
||||||
paramIndexEnd = methodDefTable[index + 1].ParamList; |
|
||||||
} |
|
||||||
|
|
||||||
if (paramTable[paramIndexStart].Sequence == 0) paramIndexStart++; |
|
||||||
|
|
||||||
for (uint i = paramIndexStart; i < paramIndexEnd; ++i) { |
|
||||||
uint j = (i - paramIndexStart); |
|
||||||
Parameters.Add(new SharpAssemblyParameter(asm, paramTable, i, j < returnTypes.Length ? returnTypes[j] : null)); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override bool IsConstructor { |
|
||||||
get { |
|
||||||
return FullyQualifiedName.IndexOf("..") != -1; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override string ToString() |
|
||||||
{ |
|
||||||
return FullyQualifiedName; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
@ -1,83 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Text; |
|
||||||
using System.Reflection; |
|
||||||
using System.Xml; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata.Rows; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata; |
|
||||||
using ICSharpCode.SharpAssembly.PE; |
|
||||||
using ICSharpCode.SharpAssembly.Assembly; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
[Serializable] |
|
||||||
public class SharpAssemblyParameter : DefaultParameter |
|
||||||
{ |
|
||||||
public SharpAssemblyParameter(SA.SharpAssembly asm, Param[] paramTable, uint index, IReturnType type) : base(String.Empty) |
|
||||||
{ |
|
||||||
if (asm == null) { |
|
||||||
throw new System.ArgumentNullException("asm"); |
|
||||||
} |
|
||||||
if (paramTable == null) { |
|
||||||
throw new System.ArgumentNullException("paramTable"); |
|
||||||
} |
|
||||||
if (index > paramTable.GetUpperBound(0) || index < 1) { |
|
||||||
throw new System.ArgumentOutOfRangeException("index", index, String.Format("must be between 1 and {0}!", paramTable.GetUpperBound(0))); |
|
||||||
} |
|
||||||
AssemblyReader assembly = asm.Reader; |
|
||||||
|
|
||||||
Param param = asm.Tables.Param[index]; |
|
||||||
|
|
||||||
Name = assembly.GetStringFromHeap(param.Name); |
|
||||||
|
|
||||||
if (param.IsFlagSet(Param.FLAG_OUT)) { |
|
||||||
Modifiers |= ParameterModifiers.Out; |
|
||||||
} |
|
||||||
|
|
||||||
// Attributes
|
|
||||||
ArrayList attrib = asm.Attributes.Param[index] as ArrayList; |
|
||||||
if (attrib == null) goto noatt; |
|
||||||
|
|
||||||
foreach(SharpCustomAttribute customattribute in attrib) { |
|
||||||
SharpAssemblyAttribute newatt = new SharpAssemblyAttribute(asm, customattribute); |
|
||||||
if (newatt.Name == "System.ParamArrayAttribute") Modifiers |= ParameterModifiers.Params; |
|
||||||
Attributes.Add(newatt); |
|
||||||
} |
|
||||||
|
|
||||||
noatt: |
|
||||||
|
|
||||||
if (type == null) { |
|
||||||
returnType = SharpAssemblyReturnType.Create("PARAMETER_UNKNOWN"); |
|
||||||
} else { |
|
||||||
if (type.Name.EndsWith("&")) { |
|
||||||
Modifiers |= ParameterModifiers.Ref; |
|
||||||
} |
|
||||||
returnType = type; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public SharpAssemblyParameter(SA.SharpAssembly asm, string paramName, IReturnType type) : base(String.Empty) |
|
||||||
{ |
|
||||||
Name = paramName; |
|
||||||
if (type.Name.EndsWith("&")) { |
|
||||||
Modifiers |= ParameterModifiers.Ref; |
|
||||||
} |
|
||||||
returnType = type; |
|
||||||
} |
|
||||||
|
|
||||||
public override string ToString() |
|
||||||
{ |
|
||||||
return "Parameter : " + returnType.FullyQualifiedName; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,184 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Text; |
|
||||||
using System.Reflection; |
|
||||||
using System.Xml; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata.Rows; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata; |
|
||||||
using ICSharpCode.SharpAssembly.PE; |
|
||||||
using ICSharpCode.SharpAssembly.Assembly; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
[Serializable] |
|
||||||
public class SharpAssemblyProperty : DefaultProperty |
|
||||||
{ |
|
||||||
public override string DocumentationTag { |
|
||||||
get { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpAssemblyProperty(SA.SharpAssembly asm, Property[] propertyTable, SharpAssemblyClass declaringType, uint index) : base(declaringType, String.Empty) |
|
||||||
{ |
|
||||||
if (asm == null) { |
|
||||||
throw new System.ArgumentNullException("asm"); |
|
||||||
} |
|
||||||
if (propertyTable == null) { |
|
||||||
throw new System.ArgumentNullException("propertyTable"); |
|
||||||
} |
|
||||||
if (declaringType == null) { |
|
||||||
throw new System.ArgumentNullException("declaringType"); |
|
||||||
} |
|
||||||
if (index > propertyTable.GetUpperBound(0) || index < 1) { |
|
||||||
throw new System.ArgumentOutOfRangeException("index", index, String.Format("must be between 1 and {0}!", propertyTable.GetUpperBound(0))); |
|
||||||
} |
|
||||||
|
|
||||||
AssemblyReader assembly = asm.Reader; |
|
||||||
|
|
||||||
Property property = asm.Tables.Property[index]; |
|
||||||
string name = assembly.GetStringFromHeap(property.Name); |
|
||||||
FullyQualifiedName = String.Concat(DeclaringType.FullyQualifiedName, ".", name); |
|
||||||
|
|
||||||
MethodSemantics[] sem = (MethodSemantics[])assembly.MetadataTable.Tables[MethodSemantics.TABLE_ID]; |
|
||||||
Method[] method = (Method[])assembly.MetadataTable.Tables[Method.TABLE_ID]; |
|
||||||
|
|
||||||
uint getterMethodIndex = 0; // used later for parameters
|
|
||||||
|
|
||||||
if (sem == null) goto nosem; |
|
||||||
|
|
||||||
for (int i = 1; i <= sem.GetUpperBound(0); ++i) { |
|
||||||
uint table = sem[i].Association & 1; |
|
||||||
uint ident = sem[i].Association >> 1; |
|
||||||
|
|
||||||
if (table == 1 && ident == index) { // table: Property
|
|
||||||
Modifiers = ModifierEnum.None; |
|
||||||
Method methodDef = method[sem[i].Method]; |
|
||||||
|
|
||||||
if (methodDef.IsFlagSet(Method.FLAG_STATIC)) { |
|
||||||
Modifiers |= ModifierEnum.Static; |
|
||||||
} |
|
||||||
|
|
||||||
if (methodDef.IsFlagSet(Method.FLAG_ABSTRACT)) { |
|
||||||
Modifiers |= ModifierEnum.Abstract; |
|
||||||
} |
|
||||||
|
|
||||||
if (methodDef.IsFlagSet(Method.FLAG_VIRTUAL)) { |
|
||||||
Modifiers |= ModifierEnum.Virtual; |
|
||||||
} |
|
||||||
if (methodDef.IsFlagSet(Method.FLAG_FINAL)) { |
|
||||||
Modifiers |= ModifierEnum.Default; |
|
||||||
} |
|
||||||
|
|
||||||
if (methodDef.IsMaskedFlagSet(Method.FLAG_PRIVATE, Method.FLAG_MEMBERACCESSMASK)) { // I assume that private is used most and public last (at least should be)
|
|
||||||
Modifiers |= ModifierEnum.Private; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMILY, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Protected; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_PUBLIC, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Public; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_ASSEM, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Internal; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMORASSEM, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.ProtectedOrInternal; |
|
||||||
} else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMANDASSEM, Method.FLAG_MEMBERACCESSMASK)) { |
|
||||||
Modifiers |= ModifierEnum.Protected; |
|
||||||
Modifiers |= ModifierEnum.Internal; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
if ((sem[i].Semantics & MethodSemantics.SEM_GETTER) == MethodSemantics.SEM_GETTER) { |
|
||||||
GetterRegion = new DomRegion(0, 0, 0, 0); |
|
||||||
// TODO GetterMethod missing.
|
|
||||||
// GetterMethod = new SharpAssemblyMethod(asm, method, declaringtype, sem[i].Method);
|
|
||||||
// GetterMethodIndex = sem[i].Method;
|
|
||||||
} |
|
||||||
|
|
||||||
if ((sem[i].Semantics & MethodSemantics.SEM_SETTER) == MethodSemantics.SEM_SETTER) { |
|
||||||
SetterRegion = new DomRegion(0, 0, 0, 0); |
|
||||||
// TODO SetterMethod missing.
|
|
||||||
// SetterMethod = new SharpAssemblyMethod(asm, method, declaringtype, sem[i].Method);
|
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
nosem: |
|
||||||
|
|
||||||
// Attributes
|
|
||||||
ArrayList attrib = asm.Attributes.Property[index] as ArrayList; |
|
||||||
if (attrib == null) goto noatt; |
|
||||||
|
|
||||||
foreach(SA.SharpCustomAttribute customattribute in attrib) { |
|
||||||
Attributes.Add(new SharpAssemblyAttribute(asm, customattribute)); |
|
||||||
} |
|
||||||
|
|
||||||
noatt: |
|
||||||
|
|
||||||
if ((property.Flags & Property.FLAG_SPECIALNAME) == Property.FLAG_SPECIALNAME) Modifiers |= ModifierEnum.Extern | ModifierEnum.Volatile | ModifierEnum.Unsafe; |
|
||||||
|
|
||||||
uint offset = property.Type; |
|
||||||
int sigSize = assembly.LoadBlob(ref offset); |
|
||||||
offset += 1; // skip calling convention
|
|
||||||
int paramCount = assembly.LoadBlob(ref offset); |
|
||||||
|
|
||||||
ReturnType = SharpAssemblyReturnType.Create(asm, ref offset); |
|
||||||
|
|
||||||
IReturnType[] returnTypes = new IReturnType[paramCount]; |
|
||||||
for (int i = 0; i < returnTypes.Length; ++i) { |
|
||||||
returnTypes[i] = SharpAssemblyReturnType.Create(asm, ref offset); |
|
||||||
} |
|
||||||
|
|
||||||
if (getterMethodIndex != 0) { |
|
||||||
AddParameters(asm, asm.Tables.Method, getterMethodIndex, returnTypes); |
|
||||||
} else { |
|
||||||
AddParameters(asm, returnTypes); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void AddParameters(SA.SharpAssembly asm, Method[] methodTable, uint index, IReturnType[] returnTypes) |
|
||||||
{ |
|
||||||
Param[] paramTable = asm.Tables.Param; |
|
||||||
if (paramTable == null) return; |
|
||||||
|
|
||||||
uint paramIndexStart = methodTable[index].ParamList; |
|
||||||
|
|
||||||
// 0 means no parameters
|
|
||||||
if (paramIndexStart > paramTable.GetUpperBound(0) || paramIndexStart == 0) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
uint paramIndexEnd = (uint)paramTable.GetUpperBound(0); |
|
||||||
if (index < methodTable.GetUpperBound(0)) { |
|
||||||
paramIndexEnd = methodTable[index + 1].ParamList; |
|
||||||
} |
|
||||||
|
|
||||||
if (paramTable[paramIndexStart].Sequence == 0) paramIndexStart++; |
|
||||||
|
|
||||||
for (uint i = paramIndexStart; i < paramIndexEnd; ++i) { |
|
||||||
uint j = (i - paramIndexStart); |
|
||||||
Parameters.Add(new SharpAssemblyParameter(asm, paramTable, i, j < returnTypes.Length ? returnTypes[j] : null)); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void AddParameters(SA.SharpAssembly asm, IReturnType[] returnTypes) |
|
||||||
{ |
|
||||||
for (uint i = 0; i < returnTypes.GetUpperBound(0); ++i) { |
|
||||||
Parameters.Add(new SharpAssemblyParameter(asm, "param_" + i, returnTypes[i])); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override string ToString() |
|
||||||
{ |
|
||||||
return FullyQualifiedName; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,225 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Text; |
|
||||||
using System.Reflection; |
|
||||||
using System.Xml; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata.Rows; |
|
||||||
using ICSharpCode.SharpAssembly.Metadata; |
|
||||||
using ICSharpCode.SharpAssembly.PE; |
|
||||||
using ICSharpCode.SharpAssembly.Assembly; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
[Serializable] |
|
||||||
public class SharpAssemblyReturnType : DefaultReturnType |
|
||||||
{ |
|
||||||
object declaredIn; |
|
||||||
|
|
||||||
SharpAssemblyClass underlyingClass; |
|
||||||
|
|
||||||
public SharpAssemblyClass UnderlyingClass { |
|
||||||
get { |
|
||||||
return underlyingClass; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public object DeclaredIn { |
|
||||||
get { |
|
||||||
return declaredIn; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override string ToString() |
|
||||||
{ |
|
||||||
return FullyQualifiedName; |
|
||||||
} |
|
||||||
|
|
||||||
public static SharpAssemblyReturnType Create(string name) |
|
||||||
{ |
|
||||||
return new SharpAssemblyReturnType(name); |
|
||||||
} |
|
||||||
|
|
||||||
public static SharpAssemblyReturnType Create(SA.SharpAssembly assembly, TypeRef[] typeRefTable, uint index) |
|
||||||
{ |
|
||||||
string fullyQualifiedName = String.Empty; |
|
||||||
SharpAssemblyClass underlyingClass = SharpAssemblyClass.FromTypeRef(assembly, index); |
|
||||||
if (underlyingClass != null) { |
|
||||||
fullyQualifiedName = underlyingClass.FullyQualifiedName; |
|
||||||
} else { |
|
||||||
fullyQualifiedName = assembly.Reader.GetStringFromHeap(typeRefTable[index].Nspace) + "." + |
|
||||||
assembly.Reader.GetStringFromHeap(typeRefTable[index].Name); |
|
||||||
LoggingService.Warn("SharpAssemblyReturnType from TypeRef: TypeRef not resolved!"); |
|
||||||
} |
|
||||||
|
|
||||||
return new SharpAssemblyReturnType(fullyQualifiedName, underlyingClass, assembly.GetRefAssemblyFor(index)); |
|
||||||
} |
|
||||||
|
|
||||||
public static SharpAssemblyReturnType Create(SA.SharpAssembly assembly, TypeDef[] typeDefTable, uint index) |
|
||||||
{ |
|
||||||
string fullyQualifiedName = String.Empty; |
|
||||||
SharpAssemblyClass underlyingClass = SharpAssemblyClass.FromTypeDef(assembly, index); |
|
||||||
if (underlyingClass != null) { |
|
||||||
fullyQualifiedName = underlyingClass.FullyQualifiedName; |
|
||||||
} else { |
|
||||||
fullyQualifiedName = assembly.Reader.GetStringFromHeap(typeDefTable[index].NSpace) + "." + |
|
||||||
assembly.Reader.GetStringFromHeap(typeDefTable[index].Name); |
|
||||||
} |
|
||||||
|
|
||||||
return new SharpAssemblyReturnType(fullyQualifiedName, underlyingClass, assembly); |
|
||||||
} |
|
||||||
|
|
||||||
public static SharpAssemblyReturnType Create(SA.SharpAssembly assembly, ref uint blobSignatureIndex) |
|
||||||
{ |
|
||||||
ArrayList arrayRanks = new ArrayList(); |
|
||||||
string fullyQualifiedName = String.Empty; |
|
||||||
SA.SharpAssembly declaredIn = null; |
|
||||||
SharpAssemblyClass underlyingClass = null; |
|
||||||
|
|
||||||
try { |
|
||||||
GetDataType(assembly, ref blobSignatureIndex, ref arrayRanks, ref fullyQualifiedName, ref underlyingClass, ref declaredIn); |
|
||||||
} catch (Exception e) { |
|
||||||
LoggingService.Error("Got exception in ReturnType creation: " + e.ToString()); |
|
||||||
fullyQualifiedName = "GOT_EXCEPTION"; |
|
||||||
} |
|
||||||
|
|
||||||
// if (this.arrayRanks.Count > 0) {
|
|
||||||
// arrayDimensions = new int[arrayRanks.Count];
|
|
||||||
// arrayRanks.CopyTo(arrayDimensions, 0);
|
|
||||||
// } else {
|
|
||||||
// arrayRanks = null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
return new SharpAssemblyReturnType(fullyQualifiedName, underlyingClass, declaredIn); |
|
||||||
} |
|
||||||
|
|
||||||
SharpAssemblyReturnType(string name) : base(new DefaultClass(null, name)) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
SharpAssemblyReturnType(string name, SharpAssemblyClass underlyingClass, SA.SharpAssembly declaredIn) : this(name) |
|
||||||
{ |
|
||||||
this.declaredIn = declaredIn; |
|
||||||
this.underlyingClass = underlyingClass; |
|
||||||
} |
|
||||||
|
|
||||||
static void GetDataType(SA.SharpAssembly asm, ref uint offset, ref ArrayList arrayRanks, ref string fullyQualifiedName, ref SharpAssemblyClass underlyingClass, ref SA.SharpAssembly declaredIn) |
|
||||||
{ |
|
||||||
AssemblyReader assembly = asm.Reader; |
|
||||||
DataType dt = (DataType)assembly.LoadBlob(ref offset); |
|
||||||
switch (dt) { |
|
||||||
case DataType.Void: |
|
||||||
case DataType.Boolean: |
|
||||||
case DataType.Char: |
|
||||||
case DataType.SByte: |
|
||||||
case DataType.Byte: |
|
||||||
case DataType.Int16: |
|
||||||
case DataType.UInt16: |
|
||||||
case DataType.Int32: |
|
||||||
case DataType.UInt32: |
|
||||||
case DataType.Int64: |
|
||||||
case DataType.UInt64: |
|
||||||
case DataType.Single: |
|
||||||
case DataType.Double: |
|
||||||
case DataType.String: |
|
||||||
case DataType.Object: |
|
||||||
case DataType.IntPtr: |
|
||||||
case DataType.UIntPtr: |
|
||||||
fullyQualifiedName = "System." + dt.ToString(); |
|
||||||
|
|
||||||
declaredIn = asm.GetReference("mscorlib"); |
|
||||||
break; |
|
||||||
|
|
||||||
case DataType.SZArray: |
|
||||||
GetDataType(asm, ref offset, ref arrayRanks, ref fullyQualifiedName, ref underlyingClass, ref declaredIn); |
|
||||||
arrayRanks.Add(0); |
|
||||||
break; |
|
||||||
|
|
||||||
case DataType.Array: |
|
||||||
GetDataType(asm, ref offset, ref arrayRanks, ref fullyQualifiedName, ref underlyingClass, ref declaredIn); |
|
||||||
int rank = assembly.LoadBlob(ref offset); |
|
||||||
int num_sizes = assembly.LoadBlob(ref offset); |
|
||||||
int[] sizes = new int[num_sizes]; |
|
||||||
for (int i = 0; i < num_sizes; ++i) { |
|
||||||
sizes[i] = assembly.LoadBlob(ref offset); |
|
||||||
} |
|
||||||
int num_lowerBounds = assembly.LoadBlob(ref offset); |
|
||||||
int[] lowerBounds = new int[num_lowerBounds]; |
|
||||||
for (int i = 0; i < num_lowerBounds; ++i) { |
|
||||||
lowerBounds[i] = assembly.LoadBlob(ref offset); |
|
||||||
} |
|
||||||
arrayRanks.Add(rank - 1); |
|
||||||
break; |
|
||||||
|
|
||||||
case DataType.ValueType: |
|
||||||
case DataType.Class: |
|
||||||
uint idx = (uint)assembly.LoadBlob(ref offset); |
|
||||||
bool isTypeRef = (idx & 1) == 1; |
|
||||||
uint index = (idx >> 2); |
|
||||||
|
|
||||||
TypeDef[] typeDefTable = asm.Tables.TypeDef; |
|
||||||
TypeRef[] typeRefTable = asm.Tables.TypeRef; |
|
||||||
|
|
||||||
if (isTypeRef) { |
|
||||||
underlyingClass = SharpAssemblyClass.FromTypeRef(asm, index); |
|
||||||
if (underlyingClass != null) { |
|
||||||
fullyQualifiedName = underlyingClass.FullyQualifiedName; |
|
||||||
} else { |
|
||||||
fullyQualifiedName = assembly.GetStringFromHeap(typeRefTable[index].Nspace) + "." + |
|
||||||
assembly.GetStringFromHeap(typeRefTable[index].Name); |
|
||||||
LoggingService.Warn("GetDataType: TypeRef not resolved!"); |
|
||||||
} |
|
||||||
declaredIn = asm.GetRefAssemblyFor(index); |
|
||||||
} else { |
|
||||||
underlyingClass = SharpAssemblyClass.FromTypeDef(asm, index); |
|
||||||
if (underlyingClass != null) { |
|
||||||
fullyQualifiedName = underlyingClass.FullyQualifiedName; |
|
||||||
} else { |
|
||||||
fullyQualifiedName = assembly.GetStringFromHeap(typeDefTable[index].NSpace) + "." + |
|
||||||
assembly.GetStringFromHeap(typeDefTable[index].Name); |
|
||||||
} |
|
||||||
declaredIn = asm; |
|
||||||
} |
|
||||||
|
|
||||||
break; |
|
||||||
|
|
||||||
case DataType.Ptr: |
|
||||||
GetDataType(asm, ref offset, ref arrayRanks, ref fullyQualifiedName, ref underlyingClass, ref declaredIn); |
|
||||||
break; |
|
||||||
case DataType.ByRef: |
|
||||||
GetDataType(asm, ref offset, ref arrayRanks, ref fullyQualifiedName, ref underlyingClass, ref declaredIn); |
|
||||||
fullyQualifiedName += "&"; |
|
||||||
break; |
|
||||||
|
|
||||||
case DataType.TypeReference: |
|
||||||
fullyQualifiedName = "typedref"; |
|
||||||
break; |
|
||||||
|
|
||||||
case DataType.Pinned: |
|
||||||
GetDataType(asm, ref offset, ref arrayRanks, ref fullyQualifiedName, ref underlyingClass, ref declaredIn); |
|
||||||
//fullyQualifiedName += " pinned";
|
|
||||||
break; |
|
||||||
|
|
||||||
case DataType.CModOpt: |
|
||||||
case DataType.CModReq: |
|
||||||
GetDataType(asm, ref offset, ref arrayRanks, ref fullyQualifiedName, ref underlyingClass, ref declaredIn); |
|
||||||
break; |
|
||||||
|
|
||||||
default: |
|
||||||
//Console.WriteLine("NOT supported: " + dt.ToString());
|
|
||||||
fullyQualifiedName += " NOT_SUPPORTED [" + dt.ToString() + "]"; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,229 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Text; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.IO; |
|
||||||
using System.Drawing; |
|
||||||
using System.Drawing.Printing; |
|
||||||
using System.Windows.Forms; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
public class SourceView : UserControl |
|
||||||
{ |
|
||||||
RichTextBox rtb; |
|
||||||
CheckBox chk; |
|
||||||
|
|
||||||
AssemblyTree tree; |
|
||||||
IAmbience ambience; |
|
||||||
|
|
||||||
void CopyEvent(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
Clipboard.SetDataObject(new DataObject(DataFormats.Text, rtb.Text)); |
|
||||||
} |
|
||||||
|
|
||||||
public SourceView(AssemblyTree tree) |
|
||||||
{ |
|
||||||
rtb = new RichTextBox(); |
|
||||||
rtb.ReadOnly = true; |
|
||||||
|
|
||||||
ambience = AmbienceService.CurrentAmbience; |
|
||||||
|
|
||||||
rtb.Font = ResourceService.LoadFont("Courier New", 10); |
|
||||||
|
|
||||||
this.tree = tree; |
|
||||||
|
|
||||||
Dock = DockStyle.Fill; |
|
||||||
|
|
||||||
tree.AfterSelect += new TreeViewEventHandler(SelectNode); |
|
||||||
|
|
||||||
rtb.Location = new Point(0, 24); |
|
||||||
rtb.Size = new Size(Width, Height - 24); |
|
||||||
rtb.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom; |
|
||||||
|
|
||||||
rtb.ContextMenu = new ContextMenu(new MenuItem[] { |
|
||||||
new MenuItem("Copy", new EventHandler(CopyEvent)) |
|
||||||
}); |
|
||||||
|
|
||||||
chk = new CheckBox(); |
|
||||||
chk.Location = new Point(0, 0); |
|
||||||
chk.Size = new Size(250, 16); |
|
||||||
chk.Text = StringParser.Parse("${res:ObjectBrowser.SourceView.Enable}"); |
|
||||||
chk.FlatStyle = FlatStyle.System; |
|
||||||
chk.CheckedChanged += new EventHandler(Check); |
|
||||||
Check(null, null); |
|
||||||
|
|
||||||
Controls.Add(rtb); |
|
||||||
Controls.Add(chk); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void Check(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
if(chk.Checked) { |
|
||||||
rtb.BackColor = SystemColors.Window; |
|
||||||
} else { |
|
||||||
rtb.BackColor = SystemColors.Control; |
|
||||||
rtb.Text = ""; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
string GetAttributes(int indent, IMember member) |
|
||||||
{ |
|
||||||
if (member.Attributes.Count == 0) { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
return GetAttributes(indent, member.Attributes); |
|
||||||
} |
|
||||||
|
|
||||||
string GetAttributes(int indent, IClass type) |
|
||||||
{ |
|
||||||
if (type.Attributes.Count == 0) { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
return GetAttributes(indent, type.Attributes); |
|
||||||
} |
|
||||||
|
|
||||||
string GetAttributes(int indent, SA.SharpAssembly assembly) |
|
||||||
{ |
|
||||||
return GetAttributes(indent, SharpAssemblyAttribute.GetAssemblyAttributes(assembly)); |
|
||||||
} |
|
||||||
|
|
||||||
string GetAttributes(int indent, IList<IAttribute> ca) |
|
||||||
{ |
|
||||||
StringBuilder text = new StringBuilder(); |
|
||||||
try { |
|
||||||
foreach(SharpAssemblyAttribute obj in ca) { |
|
||||||
string attrString = obj.ToString(); |
|
||||||
text.Append(ambience.WrapAttribute(attrString)); |
|
||||||
text.Append('\n'); |
|
||||||
} |
|
||||||
} catch { |
|
||||||
} |
|
||||||
return text.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string GetTypeInfo(IClass type) |
|
||||||
{ |
|
||||||
StringBuilder rt = new StringBuilder(); |
|
||||||
{ |
|
||||||
string attr2 = GetAttributes(0, (SA.SharpAssembly)((SharpAssemblyClass)type).DeclaredIn); |
|
||||||
rt.Append(ambience.WrapComment("assembly attributes\n") + attr2 + "\n" + ambience.WrapComment("declaration\n")); |
|
||||||
} |
|
||||||
string attr = GetAttributes(0, type); |
|
||||||
rt.Append(attr); |
|
||||||
rt.Append(ambience.Convert(type)); |
|
||||||
rt.Append("\n"); |
|
||||||
|
|
||||||
if (type.ClassType != ClassType.Enum) { |
|
||||||
|
|
||||||
rt.Append("\t" + ambience.WrapComment("events\n")); |
|
||||||
|
|
||||||
foreach (IField fieldinfo in type.Fields) { |
|
||||||
rt.Append(GetAttributes(1, fieldinfo)); |
|
||||||
rt.Append("\t" + ambience.Convert(fieldinfo) + "\n"); |
|
||||||
} |
|
||||||
|
|
||||||
rt.Append("\t" + ambience.WrapComment("methods\n")); |
|
||||||
|
|
||||||
foreach (IMethod methodinfo in type.Methods) { |
|
||||||
if (SharpAssemblyMethod.IsSpecial(methodinfo)) { |
|
||||||
continue; |
|
||||||
} |
|
||||||
ambience.ConversionFlags |= ConversionFlags.ShowReturnType; |
|
||||||
rt.Append(GetAttributes(1, methodinfo)); |
|
||||||
rt.Append("\t" + ambience.Convert(methodinfo)); |
|
||||||
if (type.ClassType == ClassType.Interface) |
|
||||||
rt.Append("\n\n"); |
|
||||||
else { |
|
||||||
rt.Append("\n\t\t" + ambience.WrapComment("TODO") + "\n\t" + ambience.ConvertEnd(methodinfo) + "\n\n"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
rt.Append("\t" + ambience.WrapComment("properties\n")); |
|
||||||
|
|
||||||
foreach (IProperty propertyinfo in type.Properties) { |
|
||||||
rt.Append(GetAttributes(1, propertyinfo)); |
|
||||||
rt.Append("\t" + ambience.Convert(propertyinfo) + "\n"); |
|
||||||
} |
|
||||||
|
|
||||||
rt.Append("\t" + ambience.WrapComment("events\n")); |
|
||||||
|
|
||||||
foreach (IEvent eventinfo in type.Events) { |
|
||||||
rt.Append(GetAttributes(1, eventinfo)); |
|
||||||
rt.Append("\t" + ambience.Convert(eventinfo) + "\n"); |
|
||||||
} |
|
||||||
} else { // Enum
|
|
||||||
foreach (IField fieldinfo in type.Fields) { |
|
||||||
if (fieldinfo.IsConst) { |
|
||||||
attr = GetAttributes(1, fieldinfo); |
|
||||||
rt.Append(attr); |
|
||||||
rt.Append("\t" + fieldinfo.Name); |
|
||||||
|
|
||||||
if (fieldinfo is SharpAssemblyField) { |
|
||||||
SharpAssemblyField saField = fieldinfo as SharpAssemblyField; |
|
||||||
if (saField.InitialValue != null) { |
|
||||||
rt.Append(" = " + saField.InitialValue.ToString()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
rt.Append(",\n"); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
rt.Append(ambience.ConvertEnd(type)); |
|
||||||
|
|
||||||
return rt.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
string GenNodeSource(AssemblyTreeNode node) |
|
||||||
{ |
|
||||||
if (node.Attribute is IClass) { |
|
||||||
ambience.ConversionFlags = ConversionFlags.All | ConversionFlags.QualifiedNamesOnlyForReturnTypes | ConversionFlags.IncludeBodies; |
|
||||||
/* |
|
||||||
if (node.Attribute is SharpAssemblyClass) { |
|
||||||
if (!(node.Attribute as SharpAssemblyClass).MembersLoaded) (node.Attribute as SharpAssemblyClass).LoadMembers(); |
|
||||||
} |
|
||||||
*/ |
|
||||||
return GetTypeInfo((IClass)node.Attribute); |
|
||||||
} else { |
|
||||||
switch (node.Type) { |
|
||||||
case NodeType.Namespace: |
|
||||||
StringBuilder nsContents = new StringBuilder("namespace " + node.Text + "\n{\n"); |
|
||||||
foreach (AssemblyTreeNode childNode in node.Nodes) { |
|
||||||
nsContents.Append(GenNodeSource(childNode)); |
|
||||||
nsContents.Append("\n"); |
|
||||||
} |
|
||||||
|
|
||||||
nsContents.Append("\n}"); |
|
||||||
return nsContents.ToString(); |
|
||||||
default: |
|
||||||
return StringParser.Parse("${res:ObjectBrowser.SourceView.NoView}"); |
|
||||||
} |
|
||||||
} |
|
||||||
// return String.Empty;
|
|
||||||
} |
|
||||||
|
|
||||||
void SelectNode(object sender, TreeViewEventArgs e) |
|
||||||
{ |
|
||||||
if(!chk.Checked) return; |
|
||||||
|
|
||||||
AssemblyTreeNode node = (AssemblyTreeNode)e.Node; |
|
||||||
|
|
||||||
rtb.Text = GenNodeSource(node);; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,266 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Drawing; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.ComponentModel; |
|
||||||
using System.Windows.Forms; |
|
||||||
using System.Data; |
|
||||||
using System.Reflection; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.CodeDom.Compiler; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
using UI = WeifenLuo.WinFormsUI; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
internal class TempProject : IProject |
|
||||||
{ |
|
||||||
public string ProjectType { |
|
||||||
get { return ""; } |
|
||||||
} |
|
||||||
|
|
||||||
public string BaseDirectory { |
|
||||||
get { return System.IO.Path.GetTempPath(); } |
|
||||||
} |
|
||||||
|
|
||||||
public string Name { |
|
||||||
get { return "Temp"; } |
|
||||||
set {} |
|
||||||
} |
|
||||||
|
|
||||||
public string StandardNamespace { |
|
||||||
get { return "Temp"; } |
|
||||||
set {} |
|
||||||
} |
|
||||||
|
|
||||||
public string Description { |
|
||||||
get { return ""; } |
|
||||||
set {} |
|
||||||
} |
|
||||||
|
|
||||||
public List<ProjectItem> Items { |
|
||||||
get { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public bool IsDirty { |
|
||||||
get { |
|
||||||
return false; |
|
||||||
} |
|
||||||
set { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string Language { |
|
||||||
get { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public LanguageProperties LanguageProperties { |
|
||||||
get { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public IAmbience Ambience { |
|
||||||
get { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string FileName { |
|
||||||
get { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string Directory { |
|
||||||
get { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string Configuration { |
|
||||||
get { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string Platform { |
|
||||||
get { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string OutputAssemblyFullPath { |
|
||||||
get { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public OutputType OutputType { |
|
||||||
get { |
|
||||||
return OutputType.Library; |
|
||||||
} |
|
||||||
set { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string RootNamespace { |
|
||||||
get { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
set { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string AppDesignerFolder { |
|
||||||
get { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
set { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public bool IsStartable { |
|
||||||
get { |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public ISolutionFolderContainer Parent { |
|
||||||
get { |
|
||||||
return null; |
|
||||||
} |
|
||||||
set { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string TypeGuid { |
|
||||||
get { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
set { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string IdGuid { |
|
||||||
get { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
set { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string Location { |
|
||||||
get { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
set { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public bool CanCompile(string fileName) { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public void Save() { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public void Save(string fileName) { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public void Start(bool withDebugging) { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public ParseProjectContent CreateProjectContent() { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public CompilerResults Build() { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public CompilerResults Rebuild() { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public CompilerResults Clean() { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public CompilerResults Publish() { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public Properties CreateMemento() { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public void SetMemento(Properties memento) { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public bool EnableViewState { |
|
||||||
get { return false; } |
|
||||||
set {} |
|
||||||
} |
|
||||||
|
|
||||||
public string GetParseableFileContent(string fileContent) |
|
||||||
{ |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
|
|
||||||
public bool IsCompileable(string fileName) { return false; } |
|
||||||
|
|
||||||
public void LoadProject(string fileName) { } |
|
||||||
|
|
||||||
public void SaveProject(string fileName) { } |
|
||||||
public void CopyReferencesToOutputPath(bool b) {} |
|
||||||
public void CopyReferencesToPath(string destination, bool force){} |
|
||||||
public void CopyReferencesToPath(string destination, bool force, ArrayList alreadyCopiedReferences) {} |
|
||||||
public bool IsFileInProject(string fileName) { return false; } |
|
||||||
|
|
||||||
// public IConfiguration CreateConfiguration(string name) { return null; }
|
|
||||||
//
|
|
||||||
// public IConfiguration CreateConfiguration() { return null; }
|
|
||||||
// public IConfiguration CloneConfiguration(IConfiguration configuration) { return null; }
|
|
||||||
//
|
|
||||||
protected virtual void OnNameChanged(EventArgs e) |
|
||||||
{ |
|
||||||
if (NameChanged != null) { |
|
||||||
NameChanged(this, e); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public event EventHandler NameChanged; |
|
||||||
|
|
||||||
public void Dispose() |
|
||||||
{ |
|
||||||
// nothing to do here
|
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,239 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
|
||||||
// <version value="$version"/>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.IO; |
|
||||||
using System.Xml; |
|
||||||
using System.Drawing; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using SA = ICSharpCode.SharpAssembly.Assembly; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.Core; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.AddIns.AssemblyScout |
|
||||||
{ |
|
||||||
public class XmlView : UserControl |
|
||||||
{ |
|
||||||
private Button saveButton = new Button(); |
|
||||||
private CheckBox exportEvents = new CheckBox(); |
|
||||||
private CheckBox exportFields = new CheckBox(); |
|
||||||
private CheckBox exportMethods = new CheckBox(); |
|
||||||
private CheckBox exportProperties = new CheckBox(); |
|
||||||
private Label captionLabel = new Label(); |
|
||||||
|
|
||||||
private AssemblyTreeNode SelectedNode; |
|
||||||
private XmlTextWriter writer; |
|
||||||
|
|
||||||
AssemblyTree tree; |
|
||||||
|
|
||||||
public XmlView(AssemblyTree _tree) |
|
||||||
{ |
|
||||||
tree = _tree; |
|
||||||
|
|
||||||
captionLabel.Location = new Point(5, 0); |
|
||||||
captionLabel.Text = StringParser.Parse("${res:ObjectBrowser.XML.Desc}"); |
|
||||||
captionLabel.Size = new Size(300, 25); |
|
||||||
captionLabel.FlatStyle = FlatStyle.System; |
|
||||||
|
|
||||||
exportEvents.Location = new Point(15, 40); |
|
||||||
exportEvents.Text = StringParser.Parse("${res:ObjectBrowser.XML.ExpEvt}"); |
|
||||||
exportEvents.Checked = true; |
|
||||||
exportEvents.Width = 300; |
|
||||||
exportEvents.FlatStyle = FlatStyle.System; |
|
||||||
|
|
||||||
exportFields.Location = new Point(15, 65); |
|
||||||
exportFields.Text = StringParser.Parse("${res:ObjectBrowser.XML.ExpFld}"); |
|
||||||
exportFields.Checked = true; |
|
||||||
exportFields.Width = 300; |
|
||||||
exportFields.FlatStyle = FlatStyle.System; |
|
||||||
|
|
||||||
exportMethods.Location = new Point(15, 90); |
|
||||||
exportMethods.Text = StringParser.Parse("${res:ObjectBrowser.XML.ExpMeth}"); |
|
||||||
exportMethods.Checked = true; |
|
||||||
exportMethods.Width = 300; |
|
||||||
exportMethods.FlatStyle = FlatStyle.System; |
|
||||||
|
|
||||||
exportProperties.Location = new Point(15, 115); |
|
||||||
exportProperties.Width = 300; |
|
||||||
exportProperties.Text = StringParser.Parse("${res:ObjectBrowser.XML.ExpProp}"); |
|
||||||
exportProperties.Checked = true; |
|
||||||
exportProperties.FlatStyle = FlatStyle.System; |
|
||||||
|
|
||||||
saveButton.Text = StringParser.Parse("${res:ObjectBrowser.XML.Save}"); |
|
||||||
saveButton.Location = new Point(5, 160); |
|
||||||
saveButton.Enabled = false; |
|
||||||
saveButton.Click += new EventHandler(saveButton_Clicked); |
|
||||||
saveButton.FlatStyle = FlatStyle.System; |
|
||||||
|
|
||||||
Dock = DockStyle.Fill; |
|
||||||
Controls.AddRange(new Control[] { |
|
||||||
captionLabel, |
|
||||||
saveButton, |
|
||||||
exportEvents, |
|
||||||
exportFields, |
|
||||||
exportMethods, |
|
||||||
exportProperties}); |
|
||||||
|
|
||||||
tree.AfterSelect += new TreeViewEventHandler(SelectNode); |
|
||||||
} |
|
||||||
|
|
||||||
void saveButton_Clicked(object sender, System.EventArgs e) { |
|
||||||
|
|
||||||
SaveFileDialog fdialog = new SaveFileDialog(); |
|
||||||
fdialog.Filter = StringParser.Parse("${res:ObjectBrowser.Filters.XML}") + "|*.xml"; |
|
||||||
DialogResult result = fdialog.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm); |
|
||||||
|
|
||||||
if(result != DialogResult.Cancel) { |
|
||||||
|
|
||||||
if (SelectedNode.Attribute is IClass) { |
|
||||||
writeStart(fdialog.FileName, ((SelectedNode.Attribute as IClass).DeclaringType as SA.SharpAssembly).FullName); |
|
||||||
exportClass((IClass)SelectedNode.Attribute); |
|
||||||
} else if (SelectedNode.Attribute is SA.SharpAssembly) { |
|
||||||
writeStart(fdialog.FileName, ((SA.SharpAssembly)SelectedNode.Attribute).FullName); |
|
||||||
foreach (SharpAssemblyClass type in SharpAssemblyClass.GetAssemblyTypes((SA.SharpAssembly)SelectedNode.Attribute)) { |
|
||||||
if(type.ToString().IndexOf("PrivateImplementationDetails") == -1) { |
|
||||||
exportClass(type); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
writeEnd(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
string GetScope(IDecoration type) |
|
||||||
{ |
|
||||||
string retval; |
|
||||||
|
|
||||||
if (type.IsPublic) |
|
||||||
retval = "Public"; |
|
||||||
else if (type.IsPrivate) |
|
||||||
retval = "Private"; |
|
||||||
else if (type.IsProtectedOrInternal) |
|
||||||
retval = "ProtectedOrInternal"; |
|
||||||
else if (type.IsProtectedAndInternal) |
|
||||||
retval = "Protected Internal"; |
|
||||||
else if (type.IsProtected) |
|
||||||
retval = "Protected"; |
|
||||||
else |
|
||||||
retval = "Internal"; |
|
||||||
return retval; |
|
||||||
} |
|
||||||
|
|
||||||
void writeStart(string filename, string assemblyname) { |
|
||||||
try { |
|
||||||
writer = new XmlTextWriter(filename ,new System.Text.ASCIIEncoding()); |
|
||||||
} catch (Exception e) { |
|
||||||
System.Windows.Forms.MessageBox.Show(e.Message); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
writer.Formatting = Formatting.Indented; |
|
||||||
writer.Indentation = 3; |
|
||||||
|
|
||||||
writer.WriteRaw("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"); |
|
||||||
writer.WriteRaw("<?xml-stylesheet type=\"text/xsl\" href=\"xml2html.xsl\" ?>"); |
|
||||||
|
|
||||||
writer.WriteStartElement("assembly"); |
|
||||||
writer.WriteAttributeString("name", assemblyname); |
|
||||||
} |
|
||||||
|
|
||||||
void writeEnd() { |
|
||||||
writer.WriteEndElement(); |
|
||||||
writer.Flush(); |
|
||||||
writer.Close(); |
|
||||||
writer = null; |
|
||||||
} |
|
||||||
|
|
||||||
void exportClass(IClass type) { |
|
||||||
writer.WriteStartElement("class"); |
|
||||||
writer.WriteAttributeString("name", type.Name); |
|
||||||
writer.WriteAttributeString("scope", GetScope(type)); |
|
||||||
writer.WriteAttributeString("namespace", type.Namespace); |
|
||||||
|
|
||||||
// events
|
|
||||||
if(exportEvents.Checked) { |
|
||||||
writer.WriteStartElement("events"); |
|
||||||
foreach(IEvent event_ in type.Events) { |
|
||||||
if(event_.DeclaringType == type) { |
|
||||||
writer.WriteStartElement("event"); |
|
||||||
writer.WriteAttributeString("name", event_.Name); |
|
||||||
writer.WriteEndElement(); |
|
||||||
} |
|
||||||
} |
|
||||||
writer.WriteEndElement(); |
|
||||||
} |
|
||||||
|
|
||||||
// fields
|
|
||||||
if(exportFields.Checked) { |
|
||||||
writer.WriteStartElement("fields"); |
|
||||||
foreach(IField field in type.Fields) { |
|
||||||
if(field.DeclaringType == type) { |
|
||||||
writer.WriteStartElement("field"); |
|
||||||
writer.WriteAttributeString("name", field.Name); |
|
||||||
writer.WriteAttributeString("type", field.ReturnType.ToString()); |
|
||||||
writer.WriteAttributeString("scope", GetScope(field)); |
|
||||||
writer.WriteEndElement(); |
|
||||||
} |
|
||||||
} |
|
||||||
writer.WriteEndElement(); |
|
||||||
} |
|
||||||
|
|
||||||
// methods
|
|
||||||
if(exportMethods.Checked) { |
|
||||||
writer.WriteStartElement("methods"); |
|
||||||
foreach(IMethod method in type.Methods) { |
|
||||||
if(!SharpAssemblyMethod.IsSpecial(method)) { |
|
||||||
if(method.DeclaringType == type) { |
|
||||||
|
|
||||||
writer.WriteStartElement("method"); |
|
||||||
writer.WriteAttributeString("name", method.Name); |
|
||||||
writer.WriteAttributeString("scope", GetScope(method)); |
|
||||||
writer.WriteAttributeString("type", method.ReturnType.ToString()); |
|
||||||
|
|
||||||
WriteParameters(writer, method); |
|
||||||
writer.WriteEndElement(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
writer.WriteEndElement(); |
|
||||||
} |
|
||||||
|
|
||||||
// properties
|
|
||||||
if(exportProperties.Checked) { |
|
||||||
writer.WriteStartElement("properties"); |
|
||||||
foreach(IProperty property in type.Properties) { |
|
||||||
if(property.DeclaringType == type) { |
|
||||||
writer.WriteStartElement("property"); |
|
||||||
writer.WriteAttributeString("name", property.Name); |
|
||||||
writer.WriteAttributeString("type", property.ReturnType.ToString()); |
|
||||||
writer.WriteEndElement(); |
|
||||||
} |
|
||||||
} |
|
||||||
writer.WriteEndElement(); |
|
||||||
} |
|
||||||
writer.WriteEndElement(); |
|
||||||
} |
|
||||||
|
|
||||||
void WriteParameters(XmlTextWriter writer, IMethod member) { |
|
||||||
foreach(IParameter param in member.Parameters) { |
|
||||||
writer.WriteStartElement("param"); |
|
||||||
writer.WriteAttributeString("name", param.Name); |
|
||||||
writer.WriteAttributeString("type", param.ReturnType.ToString()); |
|
||||||
writer.WriteEndElement(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void SelectNode(object sender, TreeViewEventArgs e) |
|
||||||
{ |
|
||||||
SelectedNode = (AssemblyTreeNode)e.Node; |
|
||||||
saveButton.Enabled = (SelectedNode.Attribute is IClass || SelectedNode.Attribute is SA.SharpAssembly); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,151 +0,0 @@ |
|||||||
// GacUtil2
|
|
||||||
// Copyright (c) 2004, Christoph Wille
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
|
||||||
// permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// - Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
// of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// - Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
|
||||||
// provided with the distribution.
|
|
||||||
//
|
|
||||||
// - Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to
|
|
||||||
// endorse or promote products derived from this software without specific prior written
|
|
||||||
// permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
|
|
||||||
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
||||||
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
|
||||||
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
||||||
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q317540&
|
|
||||||
// this was used to make changes to FusionNative.cs where I felt it was necessary
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Text; |
|
||||||
using MSjogren.Fusion.Native; |
|
||||||
using System.Security.Permissions; |
|
||||||
using System.Reflection; |
|
||||||
|
|
||||||
namespace GacUtil2 |
|
||||||
{ |
|
||||||
public enum UninstallDisposition |
|
||||||
{ |
|
||||||
UnInstalled, // - The assembly files have been removed from the GAC.
|
|
||||||
InUse, // - An application is using the assembly. This value is returned on Microsoft Windows 95 and Microsoft Windows 98.
|
|
||||||
AlreadyUnInstalled, // - The assembly does not exist in the GAC.
|
|
||||||
DeletePending, // - Not used.
|
|
||||||
HasInstallReferences, // - The assembly has not been removed from the GAC because another application reference exists.
|
|
||||||
ReferenceNotFound // - The reference that is specified in pRefData is not found in the GAC.
|
|
||||||
} |
|
||||||
|
|
||||||
public class AssemblyCache |
|
||||||
{ |
|
||||||
private AssemblyCache() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public static void Install(string AssemblyPath) |
|
||||||
{ |
|
||||||
try |
|
||||||
{ |
|
||||||
SecurityPermission unmanagedPermission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode); |
|
||||||
unmanagedPermission.Demand(); |
|
||||||
|
|
||||||
IAssemblyCache theCache = null; |
|
||||||
|
|
||||||
// NOTE: we are dealing with HRESULT's here
|
|
||||||
int retVal = FusionApi.CreateAssemblyCache(ref theCache, 0); |
|
||||||
if (0 == retVal) |
|
||||||
{ |
|
||||||
retVal = theCache.InstallAssembly(0, AssemblyPath, null); |
|
||||||
} |
|
||||||
|
|
||||||
if (0 == retVal) |
|
||||||
{ |
|
||||||
return; |
|
||||||
} |
|
||||||
throw new ApplicationException("Installation in GAC failed for assembly: " + AssemblyPath); |
|
||||||
} |
|
||||||
catch (Exception e) |
|
||||||
{ |
|
||||||
throw e; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public static void Uninstall(string AssemblyPath) |
|
||||||
{ |
|
||||||
try |
|
||||||
{ |
|
||||||
SecurityPermission unmanagedPermission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode); |
|
||||||
unmanagedPermission.Demand(); |
|
||||||
|
|
||||||
AssemblyName an = AssemblyName.GetAssemblyName(AssemblyPath); |
|
||||||
StringBuilder stb = new StringBuilder(); |
|
||||||
stb.Append(an.Name); |
|
||||||
|
|
||||||
/* |
|
||||||
stb.Append(", Version="); |
|
||||||
stb.Append(an.Version.ToString()); |
|
||||||
|
|
||||||
byte[] pt = an.GetPublicKeyToken(); |
|
||||||
stb.Append(", PublicKeyToken="); |
|
||||||
for (int i=0;i<pt.GetLength(0);i++) |
|
||||||
stb.AppendFormat("{0:x}", pt[i]); |
|
||||||
*/ |
|
||||||
|
|
||||||
string VersionedName = stb.ToString(); |
|
||||||
|
|
||||||
Console.WriteLine(VersionedName); |
|
||||||
|
|
||||||
IAssemblyCache theCache = null; |
|
||||||
int retVal = FusionApi.CreateAssemblyCache(ref theCache, 0); |
|
||||||
uint iDisposition = 0; |
|
||||||
|
|
||||||
if (0 == retVal) |
|
||||||
{ |
|
||||||
retVal = theCache.UninstallAssembly(0, VersionedName, null, out iDisposition); |
|
||||||
} |
|
||||||
|
|
||||||
if (0 == retVal) |
|
||||||
{ |
|
||||||
// simply return on success
|
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
switch((UninstallDisposition)iDisposition) |
|
||||||
{ |
|
||||||
case UninstallDisposition.UnInstalled: |
|
||||||
// Assembly was removed from GAC
|
|
||||||
break; |
|
||||||
case UninstallDisposition.InUse: |
|
||||||
throw new ApplicationException("An application is using " + AssemblyPath + " so it could not be uninstalled."); |
|
||||||
case UninstallDisposition.AlreadyUnInstalled: |
|
||||||
// Assembly is not in the assembly cache
|
|
||||||
throw new ApplicationException(AssemblyPath + " is not in the GAC."); |
|
||||||
case UninstallDisposition.DeletePending: |
|
||||||
//Not used.
|
|
||||||
break; |
|
||||||
case UninstallDisposition.HasInstallReferences: |
|
||||||
throw new ApplicationException(AssemblyPath + " was not uninstalled from the GAC because another reference exists to it."); |
|
||||||
case UninstallDisposition.ReferenceNotFound: |
|
||||||
//Problem where a reference doesn't exist to the pointer.
|
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
throw new ApplicationException("Removal from GAC failed for assembly: " + AssemblyPath); |
|
||||||
} |
|
||||||
catch (Exception e) |
|
||||||
{ |
|
||||||
throw e; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,32 +0,0 @@ |
|||||||
using System.Reflection; |
|
||||||
using System.Runtime.CompilerServices; |
|
||||||
|
|
||||||
// Information about this assembly is defined by the following
|
|
||||||
// attributes.
|
|
||||||
//
|
|
||||||
// change them to the information which is associated with the assembly
|
|
||||||
// you compile.
|
|
||||||
|
|
||||||
[assembly: AssemblyTitle("Another GacUtil")] |
|
||||||
[assembly: AssemblyDescription("")] |
|
||||||
[assembly: AssemblyConfiguration("")] |
|
||||||
[assembly: AssemblyCompany("AlphaSierraPapa")] |
|
||||||
[assembly: AssemblyProduct("GacUtil2")] |
|
||||||
[assembly: AssemblyCopyright("(c) 2004 Christoph Wille")] |
|
||||||
[assembly: AssemblyTrademark("")] |
|
||||||
[assembly: AssemblyCulture("")] |
|
||||||
|
|
||||||
// The assembly version has following format :
|
|
||||||
//
|
|
||||||
// Major.Minor.Build.Revision
|
|
||||||
//
|
|
||||||
// You can specify all values by your own or you can build default build and revision
|
|
||||||
// numbers with the '*' character (the default):
|
|
||||||
|
|
||||||
[assembly: AssemblyVersion("2.0.0.1")] |
|
||||||
|
|
||||||
// The following attributes specify the key for the sign of your assembly. See the
|
|
||||||
// .NET Framework documentation for more information about signing.
|
|
||||||
// This is not required, if you don't want signing let these attributes like they're.
|
|
||||||
[assembly: AssemblyDelaySign(false)] |
|
||||||
[assembly: AssemblyKeyFile("")] |
|
@ -1,68 +0,0 @@ |
|||||||
using System; |
|
||||||
|
|
||||||
namespace RJH.CommandLineHelper |
|
||||||
{ |
|
||||||
/// <summary>Implements a basic command-line switch by taking the
|
|
||||||
/// switching name and the associated description.</summary>
|
|
||||||
/// <remark>Only currently is implemented for properties, so all
|
|
||||||
/// auto-switching variables should have a get/set method supplied.</remark>
|
|
||||||
[AttributeUsage( AttributeTargets.Property )] |
|
||||||
public class CommandLineSwitchAttribute : System.Attribute |
|
||||||
{ |
|
||||||
#region Private Variables
|
|
||||||
private string m_name = ""; |
|
||||||
private string m_description = ""; |
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public Properties
|
|
||||||
/// <summary>Accessor for retrieving the switch-name for an associated
|
|
||||||
/// property.</summary>
|
|
||||||
public string Name { get { return m_name; } } |
|
||||||
|
|
||||||
/// <summary>Accessor for retrieving the description for a switch of
|
|
||||||
/// an associated property.</summary>
|
|
||||||
public string Description { get { return m_description; } } |
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
/// <summary>Attribute constructor.</summary>
|
|
||||||
public CommandLineSwitchAttribute( string name, |
|
||||||
string description ) |
|
||||||
{ |
|
||||||
m_name = name; |
|
||||||
m_description = description; |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This class implements an alias attribute to work in conjunction
|
|
||||||
/// with the <see cref="CommandLineSwitchAttribute">CommandLineSwitchAttribute</see>
|
|
||||||
/// attribute. If the CommandLineSwitchAttribute exists, then this attribute
|
|
||||||
/// defines an alias for it.
|
|
||||||
/// </summary>
|
|
||||||
[AttributeUsage( AttributeTargets.Property )] |
|
||||||
public class CommandLineAliasAttribute : System.Attribute |
|
||||||
{ |
|
||||||
#region Private Variables
|
|
||||||
protected string m_Alias = ""; |
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public Properties
|
|
||||||
public string Alias |
|
||||||
{ |
|
||||||
get { return m_Alias; } |
|
||||||
} |
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
public CommandLineAliasAttribute( string alias ) |
|
||||||
{ |
|
||||||
m_Alias = alias; |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,419 +0,0 @@ |
|||||||
/* |
|
||||||
* Managed Fusion API definitions |
|
||||||
* |
|
||||||
* 2002-09-29: Some API defs corrected, thanks to Rotor and MS KB article 317540 |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Text; |
|
||||||
using System.Runtime.InteropServices; |
|
||||||
|
|
||||||
namespace MSjogren.Fusion.Native |
|
||||||
{ |
|
||||||
[Flags] |
|
||||||
enum ASM_CACHE_FLAGS |
|
||||||
{ |
|
||||||
ASM_CACHE_ZAP = 0x1, |
|
||||||
ASM_CACHE_GAC = 0x2, |
|
||||||
ASM_CACHE_DOWNLOAD = 0x4 |
|
||||||
} |
|
||||||
|
|
||||||
[Flags] |
|
||||||
enum ASM_DISPLAY_FLAGS |
|
||||||
{ |
|
||||||
VERSION = 0x1, |
|
||||||
CULTURE = 0x2, |
|
||||||
PUBLIC_KEY_TOKEN = 0x4, |
|
||||||
PUBLIC_KEY = 0x8, |
|
||||||
CUSTOM = 0x10, |
|
||||||
PROCESSORARCHITECTURE = 0x20, |
|
||||||
LANGUAGEID = 0x40 |
|
||||||
} |
|
||||||
|
|
||||||
[Flags] |
|
||||||
enum ASM_CMP_FLAGS |
|
||||||
{ |
|
||||||
NAME = 0x1, |
|
||||||
MAJOR_VERSION = 0x2, |
|
||||||
MINOR_VERSION = 0x4, |
|
||||||
BUILD_NUMBER = 0x8, |
|
||||||
REVISION_NUMBER = 0x10, |
|
||||||
PUBLIC_KEY_TOKEN = 0x20, |
|
||||||
CULTURE = 0x40, |
|
||||||
CUSTOM = 0x80, |
|
||||||
ALL = NAME | MAJOR_VERSION | MINOR_VERSION | |
|
||||||
REVISION_NUMBER | BUILD_NUMBER | |
|
||||||
PUBLIC_KEY_TOKEN | CULTURE | CUSTOM, |
|
||||||
DEFAULT = 0x100 |
|
||||||
} |
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] |
|
||||||
struct FUSION_INSTALL_REFERENCE |
|
||||||
{ |
|
||||||
public uint cbSize; |
|
||||||
public uint dwFlags; |
|
||||||
public Guid guidScheme; |
|
||||||
public string szIdentifier; |
|
||||||
public string szNonCannonicalData; |
|
||||||
} |
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] |
|
||||||
struct ASSEMBLY_INFO |
|
||||||
{ |
|
||||||
public uint cbAssemblyInfo; |
|
||||||
public uint dwAssemblyFlags; |
|
||||||
public ulong uliAssemblySizeInKB; |
|
||||||
public string pszCurrentAssemblyPathBuf; |
|
||||||
public uint cchBuf; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
[ |
|
||||||
ComImport(), |
|
||||||
Guid("E707DCDE-D1CD-11D2-BAB9-00C04F8ECEAE"), |
|
||||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown) |
|
||||||
] |
|
||||||
interface IAssemblyCache |
|
||||||
{ |
|
||||||
[PreserveSig()] |
|
||||||
int UninstallAssembly( |
|
||||||
uint dwFlags, |
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] string pszAssemblyName, |
|
||||||
[MarshalAs(UnmanagedType.LPArray)] FUSION_INSTALL_REFERENCE[] pRefData, |
|
||||||
out uint pulDisposition); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int QueryAssemblyInfo( |
|
||||||
uint dwFlags, |
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] string pszAssemblyName, |
|
||||||
ref ASSEMBLY_INFO pAsmInfo); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int CreateAssemblyCacheItem( |
|
||||||
uint dwFlags, |
|
||||||
IntPtr pvReserved, |
|
||||||
out IAssemblyCacheItem ppAsmItem, |
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] string pszAssemblyName); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int CreateAssemblyScavenger( |
|
||||||
[MarshalAs(UnmanagedType.IUnknown)] out object ppAsmScavenger); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int InstallAssembly( |
|
||||||
uint dwFlags, |
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] string pszManifestFilePath, |
|
||||||
[MarshalAs(UnmanagedType.LPArray)] FUSION_INSTALL_REFERENCE[] pRefData); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
[ |
|
||||||
ComImport(), |
|
||||||
Guid("9E3AAEB4-D1CD-11D2-BAB9-00C04F8ECEAE"), |
|
||||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown) |
|
||||||
] |
|
||||||
interface IAssemblyCacheItem |
|
||||||
{ |
|
||||||
void CreateStream( |
|
||||||
uint dwFlags, |
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] string pszStreamName, |
|
||||||
uint dwFormat, |
|
||||||
uint dwFormatFlags, |
|
||||||
out UCOMIStream ppIStream, |
|
||||||
ref long puliMaxSize); |
|
||||||
|
|
||||||
void Commit( |
|
||||||
uint dwFlags, |
|
||||||
out long pulDisposition); |
|
||||||
|
|
||||||
void AbortItem(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
enum ASM_NAME |
|
||||||
{ |
|
||||||
PUBLIC_KEY = 0, // byte[]
|
|
||||||
PUBLIC_KEY_TOKEN, // byte[8]
|
|
||||||
HASH_VALUE, |
|
||||||
NAME, // LPWSTR
|
|
||||||
MAJOR_VERSION, // ushort
|
|
||||||
MINOR_VERSION, // ushort
|
|
||||||
BUILD_NUMBER, // ushort
|
|
||||||
REVISION_NUMBER, // ushort
|
|
||||||
CULTURE, // LPWSTR
|
|
||||||
PROCESSOR_ID_ARRAY, |
|
||||||
OSINFO_ARRAY, |
|
||||||
HASH_ALGID, |
|
||||||
ALIAS, |
|
||||||
CODEBASE_URL, // LPWSTR
|
|
||||||
CODEBASE_LASTMOD, // FILETIME
|
|
||||||
NULL_PUBLIC_KEY, |
|
||||||
NULL_PUBLIC_KEY_TOKEN, |
|
||||||
CUSTOM, // LPWSTR; ZAP string for NGEN assemblies
|
|
||||||
NULL_CUSTOM, |
|
||||||
MVID, // byte[16] / Guid
|
|
||||||
//MAX_PARAMS
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
[ |
|
||||||
ComImport(), |
|
||||||
Guid("CD193BC0-B4BC-11D2-9833-00C04FC31D2E"), |
|
||||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown) |
|
||||||
] |
|
||||||
interface IAssemblyName |
|
||||||
{ |
|
||||||
[PreserveSig()] |
|
||||||
int Set( |
|
||||||
ASM_NAME PropertyId, |
|
||||||
IntPtr pvProperty, |
|
||||||
uint cbProperty); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int Get( |
|
||||||
ASM_NAME PropertyId, |
|
||||||
IntPtr pvProperty, |
|
||||||
ref uint pcbProperty); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int Finalize(); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int GetDisplayName( |
|
||||||
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder szDisplayName, |
|
||||||
ref uint pccDisplayName, |
|
||||||
ASM_DISPLAY_FLAGS dwDisplayFlags); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int BindToObject( |
|
||||||
ref Guid refIID, |
|
||||||
[MarshalAs(UnmanagedType.IUnknown)] object pUnkSink, |
|
||||||
[MarshalAs(UnmanagedType.IUnknown)] object pUnkContext, // IApplicationContext
|
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] string szCodeBase, |
|
||||||
long llFlags, |
|
||||||
IntPtr pvReserved, |
|
||||||
uint cbReserved, |
|
||||||
out IntPtr ppv); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int GetName( |
|
||||||
ref uint lpcwBuffer, |
|
||||||
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwzName); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int GetVersion( |
|
||||||
out uint pdwVersionHi, |
|
||||||
out uint pdwVersionLow); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int IsEqual( |
|
||||||
IAssemblyName pName, |
|
||||||
ASM_CMP_FLAGS dwCmpFlags); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int Clone( |
|
||||||
out IAssemblyName pName); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
[ |
|
||||||
ComImport(), |
|
||||||
Guid("21B8916C-F28E-11D2-A473-00C04F8EF448"), |
|
||||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown) |
|
||||||
] |
|
||||||
interface IAssemblyEnum |
|
||||||
{ |
|
||||||
[PreserveSig()] |
|
||||||
int GetNextAssembly( |
|
||||||
IntPtr pvReserved, |
|
||||||
out IAssemblyName ppName, |
|
||||||
uint dwFlags); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int Reset(); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int Clone( |
|
||||||
out IAssemblyEnum ppEnum); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
[ |
|
||||||
ComImport(), |
|
||||||
Guid("1D23DF4D-A1E2-4B8B-93D6-6EA3DC285A54"), |
|
||||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown) |
|
||||||
] |
|
||||||
interface IHistoryReader |
|
||||||
{ |
|
||||||
[PreserveSig()] |
|
||||||
int GetFilePath( |
|
||||||
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFilePath, |
|
||||||
ref uint pdwSize); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int GetApplicationName( |
|
||||||
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzAppName, |
|
||||||
ref uint pdwSize); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int GetEXEModulePath( |
|
||||||
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzExePath, |
|
||||||
ref uint pdwSize); |
|
||||||
|
|
||||||
void GetNumActivations( |
|
||||||
out uint pdwNumActivations); |
|
||||||
|
|
||||||
void GetActivationDate( |
|
||||||
uint dwIdx, // One-based!
|
|
||||||
out long /* FILETIME */ pftDate); |
|
||||||
|
|
||||||
[PreserveSig()] |
|
||||||
int GetRunTimeVersion( |
|
||||||
ref long /* FILETIME */ pftActivationDate, |
|
||||||
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzRunTimeVersion, |
|
||||||
ref uint pdwSize); |
|
||||||
|
|
||||||
void GetNumAssemblies( |
|
||||||
ref long /* FILETIME */ pftActivationDate, |
|
||||||
out uint pdwNumAsms); |
|
||||||
|
|
||||||
void GetHistoryAssembly( |
|
||||||
ref long /* FILETIME */ pftActivationDate, |
|
||||||
uint dwIdx, // One-based!
|
|
||||||
[MarshalAs(UnmanagedType.IUnknown)] out object ppHistAsm); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
[ |
|
||||||
ComImport(), |
|
||||||
Guid("582dac66-e678-449f-aba6-6faaec8a9394"), |
|
||||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown) |
|
||||||
] |
|
||||||
interface IInstallReferenceItem |
|
||||||
{ |
|
||||||
[PreserveSig()] |
|
||||||
int GetReference( |
|
||||||
out IntPtr ppRefData, // FUSION_INSTALL_REFERENCE**
|
|
||||||
uint dwFlags, |
|
||||||
IntPtr pvReserved); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
[ |
|
||||||
ComImport(), |
|
||||||
Guid("56b1a988-7c0c-4aa2-8639-c3eb5a90226f"), |
|
||||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown) |
|
||||||
] |
|
||||||
interface IInstallReferenceEnum |
|
||||||
{ |
|
||||||
[PreserveSig()] |
|
||||||
int GetNextInstallReferenceItem( |
|
||||||
out IInstallReferenceItem ppRefItem, |
|
||||||
uint dwFlags, |
|
||||||
IntPtr pvReserved); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FusionApi |
|
||||||
{ |
|
||||||
// Install reference scheme identifiers
|
|
||||||
public static readonly Guid FUSION_REFCOUNT_UNINSTALL_SUBKEY_GUID = new Guid("8cedc215-ac4b-488b-93c0-a50a49cb2fb8"); |
|
||||||
public static readonly Guid FUSION_REFCOUNT_FILEPATH_GUID = new Guid("b02f9d65-fb77-4f7a-afa5-b391309f11c9"); |
|
||||||
public static readonly Guid FUSION_REFCOUNT_OPAQUE_STRING_GUID = new Guid("2ec93463-b0c3-45e1-8364-327e96aea856"); |
|
||||||
public static readonly Guid FUSION_REFCOUNT_MSI_GUID = new Guid("25df0fc1-7f97-4070-add7-4b13bbfd7cb8"); |
|
||||||
|
|
||||||
const uint IASSEMBLYCACHE_INSTALL_FLAG_REFRESH = 0x00000001; |
|
||||||
const uint IASSEMBLYCACHE_INSTALL_FLAG_FORCE_REFRESH = 0x00000002; |
|
||||||
|
|
||||||
const uint IASSEMBLYCACHE_UNINSTALL_DISPOSITION_UNINSTALLED = 1; |
|
||||||
const uint IASSEMBLYCACHE_UNINSTALL_DISPOSITION_STILL_IN_USE = 2; |
|
||||||
const uint IASSEMBLYCACHE_UNINSTALL_DISPOSITION_ALREADY_UNINSTALLED = 3; |
|
||||||
const uint IASSEMBLYCACHE_UNINSTALL_DISPOSITION_DELETE_PENDING = 4; |
|
||||||
const uint IASSEMBLYCACHE_UNINSTALL_DISPOSITION_HAS_INSTALL_REFERENCES = 5; |
|
||||||
const uint IASSEMBLYCACHE_UNINSTALL_DISPOSITION_REFERENCE_NOT_FOUND = 6; |
|
||||||
|
|
||||||
|
|
||||||
[DllImport("fusion.dll", CharSet=CharSet.Unicode, PreserveSig=false)] |
|
||||||
public static extern void GetCachePath( |
|
||||||
ASM_CACHE_FLAGS dwCacheFlags, |
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwzCachePath, |
|
||||||
ref uint pcchPath); |
|
||||||
|
|
||||||
[DllImport("fusion.dll", PreserveSig=false)] |
|
||||||
public static extern int CreateAssemblyCache( |
|
||||||
ref IAssemblyCache ppAsmCache, |
|
||||||
uint dwReserved); |
|
||||||
|
|
||||||
[DllImport("fusion.dll", PreserveSig=false)] |
|
||||||
public static extern void CreateAssemblyEnum( |
|
||||||
out IAssemblyEnum ppEnum, |
|
||||||
IntPtr pUnkReserved, |
|
||||||
IAssemblyName pName, |
|
||||||
ASM_CACHE_FLAGS dwFlags, |
|
||||||
IntPtr pvReserved); |
|
||||||
|
|
||||||
[DllImport("fusion.dll", CharSet=CharSet.Unicode, PreserveSig=false)] |
|
||||||
public static extern void CreateAssemblyNameObject( |
|
||||||
out IAssemblyName ppName, |
|
||||||
string szAssemblyName, |
|
||||||
uint dwFlags, |
|
||||||
IntPtr pvReserved); |
|
||||||
|
|
||||||
[DllImport("fusion.dll", PreserveSig=false)] |
|
||||||
public static extern void CreateInstallReferenceEnum( |
|
||||||
out IInstallReferenceEnum ppRefEnum, |
|
||||||
IAssemblyName pName, |
|
||||||
uint dwFlags, |
|
||||||
IntPtr pvReserved); |
|
||||||
|
|
||||||
|
|
||||||
[DllImport("fusion.dll", CharSet=CharSet.Unicode, PreserveSig=false)] |
|
||||||
public static extern void CreateHistoryReader( |
|
||||||
string wzFilePath, |
|
||||||
out IHistoryReader ppHistReader); |
|
||||||
|
|
||||||
// Retrieves the path of the ApplicationHistory folder, typically
|
|
||||||
// Documents and Settings\<user>\Local Settings\Application Data\ApplicationHistory
|
|
||||||
// containing .ini files that can be read with IHistoryReader.
|
|
||||||
// pwdSize appears to be the offset of the last backslash in the returned
|
|
||||||
// string after the call.
|
|
||||||
[DllImport("fusion.dll", CharSet=CharSet.Unicode, PreserveSig=false)] |
|
||||||
public static extern void GetHistoryFileDirectory( |
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDir, |
|
||||||
ref uint pdwSize); |
|
||||||
|
|
||||||
[DllImport("fusion.dll", CharSet=CharSet.Unicode, PreserveSig=false)] |
|
||||||
public static extern void LookupHistoryAssembly( |
|
||||||
string pwzFilePath, |
|
||||||
ref FILETIME pftActivationDate, |
|
||||||
string pwzAsmName, |
|
||||||
string pwzPublicKeyToken, |
|
||||||
string wzCulture, |
|
||||||
string pwzVerRef, |
|
||||||
out IntPtr pHistAsm); // IHistoryAssembly
|
|
||||||
|
|
||||||
[DllImport("fusion.dll", PreserveSig=false)] |
|
||||||
public static extern void NukeDownloadedCache(); |
|
||||||
|
|
||||||
[DllImport("fusion.dll", PreserveSig=false)] |
|
||||||
public static extern void CreateApplicationContext( |
|
||||||
IAssemblyName pName, |
|
||||||
out IntPtr ppCtx); // IApplicationContext
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Brings up the .NET Applicaion Restore wizard
|
|
||||||
// Returns S_OK, 0x80131075 (App not run) or 0x80131087 (Fix failed)
|
|
||||||
//
|
|
||||||
[DllImport("shfusion.dll", CharSet=CharSet.Unicode)] |
|
||||||
public static extern uint PolicyManager( |
|
||||||
IntPtr hWndParent, |
|
||||||
string pwzFullyQualifiedAppPath, |
|
||||||
string pwzAppName, |
|
||||||
int dwFlags); |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -1,32 +0,0 @@ |
|||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
||||||
<PropertyGroup> |
|
||||||
<OutputType>Exe</OutputType> |
|
||||||
<RootNamespace>GacUtil2</RootNamespace> |
|
||||||
<AssemblyName>GacUtil2</AssemblyName> |
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
||||||
<ProjectGuid>{938FAB27-5DE2-4980-B8AA-1B892F959C63}</ProjectGuid> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
||||||
<OutputPath>bin\Debug\</OutputPath> |
|
||||||
<Optimize>false</Optimize> |
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
||||||
<OutputPath>bin\Release\</OutputPath> |
|
||||||
<Optimize>true</Optimize> |
|
||||||
<DefineConstants>TRACE</DefineConstants> |
|
||||||
</PropertyGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Reference Include="System" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Compile Include="Main.cs" /> |
|
||||||
<Compile Include="AssemblyInfo.cs" /> |
|
||||||
<Compile Include="FusionNative.cs" /> |
|
||||||
<Compile Include="CommandLineSwitchAttribute.cs" /> |
|
||||||
<Compile Include="AssemblyCache.cs" /> |
|
||||||
<Compile Include="Parser.cs" /> |
|
||||||
</ItemGroup> |
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
|
||||||
</Project> |
|
Binary file not shown.
@ -1,6 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<configuration> |
|
||||||
<startup> |
|
||||||
<supportedRuntime version="v2.0.50727" /> |
|
||||||
</startup> |
|
||||||
</configuration> |
|
@ -1,6 +0,0 @@ |
|||||||
Microsoft Visual Studio Solution File, Format Version 9.00 |
|
||||||
# SharpDevelop 2.0.0.339 |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GacUtil2", "GacUtil2.csproj", "{938FAB27-5DE2-4980-B8AA-1B892F959C63}" |
|
||||||
EndProject |
|
||||||
Global |
|
||||||
EndGlobal |
|
@ -1,116 +0,0 @@ |
|||||||
// GacUtil2
|
|
||||||
// Copyright (c) 2004, Christoph Wille
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
|
||||||
// permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// - Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
// of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// - Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
|
||||||
// provided with the distribution.
|
|
||||||
//
|
|
||||||
// - Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to
|
|
||||||
// endorse or promote products derived from this software without specific prior written
|
|
||||||
// permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
|
|
||||||
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
||||||
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
|
||||||
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
||||||
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Text; |
|
||||||
using RJH.CommandLineHelper; // http://www.codeproject.com/csharp/commandlineparser.asp
|
|
||||||
|
|
||||||
namespace GacUtil2 |
|
||||||
{ |
|
||||||
public class GacUtil2Switches |
|
||||||
{ |
|
||||||
private string _Install = ""; |
|
||||||
private string _Remove = ""; |
|
||||||
private bool _ShowHelp = false; |
|
||||||
|
|
||||||
[CommandLineSwitch("i","/i <assembly name>")] |
|
||||||
public string Install |
|
||||||
{ |
|
||||||
get { return _Install; } |
|
||||||
set { _Install = value; } |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
[CommandLineSwitch("u","/u <assembly name>")] |
|
||||||
public string Remove |
|
||||||
{ |
|
||||||
get { return _Remove; } |
|
||||||
set { _Remove = value; } |
|
||||||
} |
|
||||||
|
|
||||||
[CommandLineSwitch("?","/?")] |
|
||||||
public bool ShowHelp |
|
||||||
{ |
|
||||||
get { return _ShowHelp; } |
|
||||||
set { _ShowHelp = value; } |
|
||||||
} |
|
||||||
|
|
||||||
public void PrintHelp() |
|
||||||
{ |
|
||||||
StringBuilder stb = new StringBuilder(); |
|
||||||
stb.Append(Environment.NewLine); |
|
||||||
|
|
||||||
// TODO: implement the help text for this application
|
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
class MainClass |
|
||||||
{ |
|
||||||
// NOTE: Only switches /i and /u are supported
|
|
||||||
public static void Main(string[] args) |
|
||||||
{ |
|
||||||
GacUtil2Switches switches = new GacUtil2Switches(); |
|
||||||
Parser parser = new Parser( System.Environment.CommandLine, switches); |
|
||||||
parser.Parse(); |
|
||||||
|
|
||||||
if (switches.ShowHelp) |
|
||||||
{ |
|
||||||
switches.PrintHelp(); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
if (switches.Install != "") |
|
||||||
{ |
|
||||||
try |
|
||||||
{ |
|
||||||
AssemblyCache.Install(switches.Install); |
|
||||||
Console.WriteLine("Assembly installed successfully"); |
|
||||||
} |
|
||||||
catch(Exception e) |
|
||||||
{ |
|
||||||
Console.WriteLine("Error during install: " + e.Message); |
|
||||||
} |
|
||||||
} |
|
||||||
else if (switches.Remove != "") |
|
||||||
{ |
|
||||||
try |
|
||||||
{ |
|
||||||
AssemblyCache.Uninstall(switches.Remove); |
|
||||||
Console.WriteLine("Assembly removed successfully"); |
|
||||||
} |
|
||||||
catch(Exception e) |
|
||||||
{ |
|
||||||
Console.WriteLine("Error during removal of assembly from GAC: " + e.Message); |
|
||||||
} |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
Console.WriteLine("No valid parameters specified"); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,535 +0,0 @@ |
|||||||
using System; |
|
||||||
using System.Text.RegularExpressions; |
|
||||||
|
|
||||||
namespace RJH.CommandLineHelper |
|
||||||
{ |
|
||||||
/// <summary>Implementation of a command-line parsing class. Is capable of
|
|
||||||
/// having switches registered with it directly or can examine a registered
|
|
||||||
/// class for any properties with the appropriate attributes appended to
|
|
||||||
/// them.</summary>
|
|
||||||
public class Parser |
|
||||||
{ |
|
||||||
/// <summary>A simple internal class for passing back to the caller
|
|
||||||
/// some information about the switch. The internals/implementation
|
|
||||||
/// of this class has privillaged access to the contents of the
|
|
||||||
/// SwitchRecord class.</summary>
|
|
||||||
public class SwitchInfo |
|
||||||
{ |
|
||||||
#region Private Variables
|
|
||||||
private object m_Switch = null; |
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public Properties
|
|
||||||
public string Name { get { return (m_Switch as SwitchRecord).Name; } } |
|
||||||
public string Description { get { return (m_Switch as SwitchRecord).Description; } } |
|
||||||
public string[] Aliases { get { return (m_Switch as SwitchRecord).Aliases; } } |
|
||||||
public System.Type Type { get { return (m_Switch as SwitchRecord).Type; } } |
|
||||||
public object Value { get { return (m_Switch as SwitchRecord).Value; } } |
|
||||||
public object InternalValue { get { return (m_Switch as SwitchRecord).InternalValue; } } |
|
||||||
public bool IsEnum { get { return (m_Switch as SwitchRecord).Type.IsEnum; } } |
|
||||||
public string[] Enumerations { get { return (m_Switch as SwitchRecord).Enumerations; } } |
|
||||||
#endregion
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor for the SwitchInfo class. Note, in order to hide to the outside world
|
|
||||||
/// information not necessary to know, the constructor takes a System.Object (aka
|
|
||||||
/// object) as it's registering type. If the type isn't of the correct type, an exception
|
|
||||||
/// is thrown.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="rec">The SwitchRecord for which this class store information.</param>
|
|
||||||
/// <exception cref="ArgumentException">Thrown if the rec parameter is not of
|
|
||||||
/// the type SwitchRecord.</exception>
|
|
||||||
public SwitchInfo( object rec ) |
|
||||||
{ |
|
||||||
if ( rec is SwitchRecord ) |
|
||||||
m_Switch = rec; |
|
||||||
else |
|
||||||
throw new ArgumentException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The SwitchRecord is stored within the parser's collection of registered
|
|
||||||
/// switches. This class is private to the outside world.
|
|
||||||
/// </summary>
|
|
||||||
private class SwitchRecord |
|
||||||
{ |
|
||||||
#region Private Variables
|
|
||||||
private string m_name = ""; |
|
||||||
private string m_description = ""; |
|
||||||
private object m_value = null; |
|
||||||
private System.Type m_switchType = typeof(bool); |
|
||||||
private System.Collections.ArrayList m_Aliases = null; |
|
||||||
private string m_Pattern = ""; |
|
||||||
|
|
||||||
// The following advanced functions allow for callbacks to be
|
|
||||||
// made to manipulate the associated data type.
|
|
||||||
private System.Reflection.MethodInfo m_SetMethod = null; |
|
||||||
private System.Reflection.MethodInfo m_GetMethod = null; |
|
||||||
private object m_PropertyOwner = null; |
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Private Utility Functions
|
|
||||||
private void Initialize( string name, string description ) |
|
||||||
{ |
|
||||||
m_name = name; |
|
||||||
m_description = description; |
|
||||||
|
|
||||||
BuildPattern(); |
|
||||||
} |
|
||||||
|
|
||||||
private void BuildPattern() |
|
||||||
{ |
|
||||||
string matchString = Name; |
|
||||||
|
|
||||||
if ( Aliases != null && Aliases.Length > 0 ) |
|
||||||
foreach( string s in Aliases ) |
|
||||||
matchString += "|" + s; |
|
||||||
|
|
||||||
string strPatternStart = @"(\s|^)(?<match>(-{1,2}|/)("; |
|
||||||
string strPatternEnd; // To be defined below.
|
|
||||||
|
|
||||||
// The common suffix ensures that the switches are followed by
|
|
||||||
// a white-space OR the end of the string. This will stop
|
|
||||||
// switches such as /help matching /helpme
|
|
||||||
//
|
|
||||||
string strCommonSuffix = @"(?=(\s|$))"; |
|
||||||
|
|
||||||
if ( Type == typeof(bool) ) |
|
||||||
strPatternEnd = @")(?<value>(\+|-){0,1}))"; |
|
||||||
else if ( Type == typeof(string) ) |
|
||||||
strPatternEnd = @")(?::|\s+))((?:"")(?<value>.+)(?:"")|(?<value>\S+))"; |
|
||||||
else if ( Type == typeof(int) ) |
|
||||||
strPatternEnd = @")(?::|\s+))((?<value>(-|\+)[0-9]+)|(?<value>[0-9]+))"; |
|
||||||
else if ( Type.IsEnum ) |
|
||||||
{ |
|
||||||
string[] enumNames = Enumerations; |
|
||||||
string e_str = enumNames[0]; |
|
||||||
for ( int e=1; e<enumNames.Length; e++ ) |
|
||||||
e_str += "|" + enumNames[e]; |
|
||||||
strPatternEnd = @")(?::|\s+))(?<value>" + e_str + @")"; |
|
||||||
} |
|
||||||
else |
|
||||||
throw new System.ArgumentException(); |
|
||||||
|
|
||||||
// Set the internal regular expression pattern.
|
|
||||||
m_Pattern = strPatternStart + matchString + strPatternEnd + strCommonSuffix; |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public Properties
|
|
||||||
public object Value |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if ( ReadValue != null ) |
|
||||||
return ReadValue; |
|
||||||
else |
|
||||||
return m_value; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public object InternalValue |
|
||||||
{ |
|
||||||
get { return m_value; } |
|
||||||
} |
|
||||||
|
|
||||||
public string Name |
|
||||||
{ |
|
||||||
get { return m_name; } |
|
||||||
set { m_name = value; } |
|
||||||
} |
|
||||||
|
|
||||||
public string Description |
|
||||||
{ |
|
||||||
get { return m_description; } |
|
||||||
set { m_description = value; } |
|
||||||
} |
|
||||||
|
|
||||||
public System.Type Type |
|
||||||
{ |
|
||||||
get { return m_switchType; } |
|
||||||
} |
|
||||||
|
|
||||||
public string[] Aliases |
|
||||||
{ |
|
||||||
get { return (m_Aliases != null) ? (string[])m_Aliases.ToArray(typeof(string)): null; } |
|
||||||
} |
|
||||||
|
|
||||||
public string Pattern |
|
||||||
{ |
|
||||||
get { return m_Pattern; } |
|
||||||
} |
|
||||||
|
|
||||||
public System.Reflection.MethodInfo SetMethod |
|
||||||
{ |
|
||||||
set { m_SetMethod = value; } |
|
||||||
} |
|
||||||
|
|
||||||
public System.Reflection.MethodInfo GetMethod |
|
||||||
{ |
|
||||||
set { m_GetMethod = value; } |
|
||||||
} |
|
||||||
|
|
||||||
public object PropertyOwner |
|
||||||
{ |
|
||||||
set { m_PropertyOwner = value; } |
|
||||||
} |
|
||||||
|
|
||||||
public object ReadValue |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
object o = null; |
|
||||||
if ( m_PropertyOwner != null && m_GetMethod != null ) |
|
||||||
o = m_GetMethod.Invoke( m_PropertyOwner, null ); |
|
||||||
return o; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string[] Enumerations |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if ( m_switchType.IsEnum ) |
|
||||||
return System.Enum.GetNames( m_switchType ); |
|
||||||
else |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
public SwitchRecord( string name, string description ) |
|
||||||
{ |
|
||||||
Initialize( name, description ); |
|
||||||
} |
|
||||||
|
|
||||||
public SwitchRecord( string name, string description, System.Type type ) |
|
||||||
{ |
|
||||||
if ( type == typeof(bool) || |
|
||||||
type == typeof(string) || |
|
||||||
type == typeof(int) || |
|
||||||
type.IsEnum ) |
|
||||||
{ |
|
||||||
m_switchType = type; |
|
||||||
Initialize( name, description ); |
|
||||||
} |
|
||||||
else |
|
||||||
throw new ArgumentException("Currently only Ints, Bool and Strings are supported"); |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public Methods
|
|
||||||
public void AddAlias( string alias ) |
|
||||||
{ |
|
||||||
if ( m_Aliases == null ) |
|
||||||
m_Aliases = new System.Collections.ArrayList(); |
|
||||||
m_Aliases.Add( alias ); |
|
||||||
|
|
||||||
BuildPattern(); |
|
||||||
} |
|
||||||
|
|
||||||
public void Notify( object value ) |
|
||||||
{ |
|
||||||
if ( m_PropertyOwner != null && m_SetMethod != null ) |
|
||||||
{ |
|
||||||
object[] parameters = new object[1]; |
|
||||||
parameters[0] = value; |
|
||||||
m_SetMethod.Invoke( m_PropertyOwner, parameters ); |
|
||||||
} |
|
||||||
m_value = value; |
|
||||||
} |
|
||||||
|
|
||||||
#endregion
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
#region Private Variables
|
|
||||||
private string m_commandLine = ""; |
|
||||||
private string m_workingString = ""; |
|
||||||
private string m_applicationName = ""; |
|
||||||
private string[] m_splitParameters = null; |
|
||||||
private System.Collections.ArrayList m_switches = null; |
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Private Utility Functions
|
|
||||||
private void ExtractApplicationName() |
|
||||||
{ |
|
||||||
Regex r = new Regex(@"^(?<commandLine>("".+""|(\S)+))(?<remainder>.+)", |
|
||||||
RegexOptions.ExplicitCapture); |
|
||||||
Match m = r.Match(m_commandLine); |
|
||||||
if ( m != null && m.Groups["commandLine"] != null ) |
|
||||||
{ |
|
||||||
m_applicationName = m.Groups["commandLine"].Value; |
|
||||||
m_workingString = m.Groups["remainder"].Value; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private void SplitParameters() |
|
||||||
{ |
|
||||||
// Populate the split parameters array with the remaining parameters.
|
|
||||||
// Note that if quotes are used, the quotes are removed.
|
|
||||||
// e.g. one two three "four five six"
|
|
||||||
// 0 - one
|
|
||||||
// 1 - two
|
|
||||||
// 2 - three
|
|
||||||
// 3 - four five six
|
|
||||||
// (e.g. 3 is not in quotes).
|
|
||||||
Regex r = new Regex(@"((\s*(""(?<param>.+?)""|(?<param>\S+))))", |
|
||||||
RegexOptions.ExplicitCapture); |
|
||||||
MatchCollection m = r.Matches( m_workingString ); |
|
||||||
|
|
||||||
if ( m != null ) |
|
||||||
{ |
|
||||||
m_splitParameters = new string[ m.Count ]; |
|
||||||
for ( int i=0; i < m.Count; i++ ) |
|
||||||
m_splitParameters[i] = m[i].Groups["param"].Value; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private void HandleSwitches() |
|
||||||
{ |
|
||||||
if ( m_switches != null ) |
|
||||||
{ |
|
||||||
foreach ( SwitchRecord s in m_switches ) |
|
||||||
{ |
|
||||||
Regex r = new Regex( s.Pattern, |
|
||||||
RegexOptions.ExplicitCapture |
|
||||||
| RegexOptions.IgnoreCase ); |
|
||||||
MatchCollection m = r.Matches( m_workingString ); |
|
||||||
if ( m != null ) |
|
||||||
{ |
|
||||||
for ( int i=0; i < m.Count; i++ ) |
|
||||||
{ |
|
||||||
string value = null; |
|
||||||
if ( m[i].Groups != null && m[i].Groups["value"] != null ) |
|
||||||
value = m[i].Groups["value"].Value; |
|
||||||
|
|
||||||
if ( s.Type == typeof(bool)) |
|
||||||
{ |
|
||||||
bool state = true; |
|
||||||
// The value string may indicate what value we want.
|
|
||||||
if ( m[i].Groups != null && m[i].Groups["value"] != null ) |
|
||||||
{ |
|
||||||
switch ( value ) |
|
||||||
{ |
|
||||||
case "+": state = true; |
|
||||||
break; |
|
||||||
case "-": state = false; |
|
||||||
break; |
|
||||||
case "": if ( s.ReadValue != null ) |
|
||||||
state = !(bool)s.ReadValue; |
|
||||||
break; |
|
||||||
default: break; |
|
||||||
} |
|
||||||
} |
|
||||||
s.Notify( state ); |
|
||||||
break; |
|
||||||
} |
|
||||||
else if ( s.Type == typeof(string) ) |
|
||||||
s.Notify( value ); |
|
||||||
else if ( s.Type == typeof(int) ) |
|
||||||
s.Notify( int.Parse( value ) ); |
|
||||||
else if ( s.Type.IsEnum ) |
|
||||||
s.Notify( System.Enum.Parse(s.Type,value,true) ); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
m_workingString = r.Replace(m_workingString, " "); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public Properties
|
|
||||||
public string ApplicationName |
|
||||||
{ |
|
||||||
get { return m_applicationName; } |
|
||||||
} |
|
||||||
|
|
||||||
public string[] Parameters |
|
||||||
{ |
|
||||||
get { return m_splitParameters; } |
|
||||||
} |
|
||||||
|
|
||||||
public SwitchInfo[] Switches |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if ( m_switches == null ) |
|
||||||
return null; |
|
||||||
else |
|
||||||
{ |
|
||||||
SwitchInfo[] si = new SwitchInfo[ m_switches.Count ]; |
|
||||||
for ( int i=0; i<m_switches.Count; i++ ) |
|
||||||
si[i] = new SwitchInfo( m_switches[i] ); |
|
||||||
return si; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public object this[string name] |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if ( m_switches != null ) |
|
||||||
for ( int i=0; i<m_switches.Count; i++ ) |
|
||||||
if ( string.Compare( (m_switches[i] as SwitchRecord).Name, name, true )==0 ) |
|
||||||
return (m_switches[i] as SwitchRecord).Value; |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>This function returns a list of the unhandled switches
|
|
||||||
/// that the parser has seen, but not processed.</summary>
|
|
||||||
/// <remark>The unhandled switches are not removed from the remainder
|
|
||||||
/// of the command-line.</remark>
|
|
||||||
public string[] UnhandledSwitches |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
string switchPattern = @"(\s|^)(?<match>(-{1,2}|/)(.+?))(?=(\s|$))"; |
|
||||||
Regex r = new Regex( switchPattern, |
|
||||||
RegexOptions.ExplicitCapture |
|
||||||
| RegexOptions.IgnoreCase ); |
|
||||||
MatchCollection m = r.Matches( m_workingString ); |
|
||||||
|
|
||||||
if ( m != null ) |
|
||||||
{ |
|
||||||
string[] unhandled = new string[ m.Count ]; |
|
||||||
for ( int i=0; i < m.Count; i++ ) |
|
||||||
unhandled[i] = m[i].Groups["match"].Value; |
|
||||||
return unhandled; |
|
||||||
} |
|
||||||
else |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public Methods
|
|
||||||
public void AddSwitch( string name, string description ) |
|
||||||
{ |
|
||||||
if ( m_switches == null ) |
|
||||||
m_switches = new System.Collections.ArrayList(); |
|
||||||
|
|
||||||
SwitchRecord rec = new SwitchRecord( name, description ); |
|
||||||
m_switches.Add( rec ); |
|
||||||
} |
|
||||||
|
|
||||||
public void AddSwitch( string[] names, string description ) |
|
||||||
{ |
|
||||||
if ( m_switches == null ) |
|
||||||
m_switches = new System.Collections.ArrayList(); |
|
||||||
SwitchRecord rec = new SwitchRecord( names[0], description ); |
|
||||||
for ( int s=1; s<names.Length; s++ ) |
|
||||||
rec.AddAlias( names[s] ); |
|
||||||
m_switches.Add( rec ); |
|
||||||
} |
|
||||||
|
|
||||||
public bool Parse() |
|
||||||
{ |
|
||||||
ExtractApplicationName(); |
|
||||||
|
|
||||||
// Remove switches and associated info.
|
|
||||||
HandleSwitches(); |
|
||||||
|
|
||||||
// Split parameters.
|
|
||||||
SplitParameters(); |
|
||||||
|
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
public object InternalValue(string name) |
|
||||||
{ |
|
||||||
if ( m_switches != null ) |
|
||||||
for ( int i=0; i<m_switches.Count; i++ ) |
|
||||||
if ( string.Compare( (m_switches[i] as SwitchRecord).Name, name, true )==0 ) |
|
||||||
return (m_switches[i] as SwitchRecord).InternalValue; |
|
||||||
return null; |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
public Parser( string commandLine ) |
|
||||||
{ |
|
||||||
m_commandLine = commandLine; |
|
||||||
} |
|
||||||
|
|
||||||
public Parser( string commandLine, |
|
||||||
object classForAutoAttributes ) |
|
||||||
{ |
|
||||||
m_commandLine = commandLine; |
|
||||||
|
|
||||||
Type type = classForAutoAttributes.GetType(); |
|
||||||
System.Reflection.MemberInfo[] members = type.GetMembers(); |
|
||||||
|
|
||||||
for(int i=0; i<members.Length; i++) |
|
||||||
{ |
|
||||||
object[] attributes = members[i].GetCustomAttributes(false); |
|
||||||
if(attributes.Length > 0) |
|
||||||
{ |
|
||||||
SwitchRecord rec = null; |
|
||||||
|
|
||||||
foreach ( Attribute attribute in attributes ) |
|
||||||
{ |
|
||||||
if ( attribute is CommandLineSwitchAttribute ) |
|
||||||
{ |
|
||||||
CommandLineSwitchAttribute switchAttrib = |
|
||||||
(CommandLineSwitchAttribute) attribute; |
|
||||||
|
|
||||||
// Get the property information. We're only handling
|
|
||||||
// properties at the moment!
|
|
||||||
if ( members[i] is System.Reflection.PropertyInfo ) |
|
||||||
{ |
|
||||||
System.Reflection.PropertyInfo pi = (System.Reflection.PropertyInfo) members[i]; |
|
||||||
|
|
||||||
rec = new SwitchRecord( switchAttrib.Name, |
|
||||||
switchAttrib.Description, |
|
||||||
pi.PropertyType ); |
|
||||||
|
|
||||||
// Map in the Get/Set methods.
|
|
||||||
rec.SetMethod = pi.GetSetMethod(); |
|
||||||
rec.GetMethod = pi.GetGetMethod(); |
|
||||||
rec.PropertyOwner = classForAutoAttributes; |
|
||||||
|
|
||||||
// Can only handle a single switch for each property
|
|
||||||
// (otherwise the parsing of aliases gets silly...)
|
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// See if any aliases are required. We can only do this after
|
|
||||||
// a switch has been registered and the framework doesn't make
|
|
||||||
// any guarantees about the order of attributes, so we have to
|
|
||||||
// walk the collection a second time.
|
|
||||||
if ( rec != null ) |
|
||||||
{ |
|
||||||
foreach ( Attribute attribute in attributes ) |
|
||||||
{ |
|
||||||
if ( attribute is CommandLineAliasAttribute ) |
|
||||||
{ |
|
||||||
CommandLineAliasAttribute aliasAttrib = |
|
||||||
(CommandLineAliasAttribute) attribute; |
|
||||||
rec.AddAlias( aliasAttrib.Alias ); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// Assuming we have a switch record (that may or may not have
|
|
||||||
// aliases), add it to the collection of switches.
|
|
||||||
if ( rec != null ) |
|
||||||
{ |
|
||||||
if ( m_switches == null ) |
|
||||||
m_switches = new System.Collections.ArrayList(); |
|
||||||
m_switches.Add( rec ); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue