Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@327 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
35 changed files with 363 additions and 1678 deletions
@ -1,32 +0,0 @@
@@ -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("")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("")] |
||||
[assembly: AssemblyCopyright("")] |
||||
[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,45 +0,0 @@
@@ -1,45 +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.40607</ProductVersion> |
||||
<SchemaVersion>2.0</SchemaVersion> |
||||
<ProjectGuid>{861c68ac-5e3c-410b-942c-f813593c10ef}</ProjectGuid> |
||||
<RootNamespace>NewProject</RootNamespace> |
||||
<AssemblyName>BuildHelpIndex</AssemblyName> |
||||
<OutputTarget>Exe</OutputTarget> |
||||
<WarningLevel>4</WarningLevel> |
||||
<NoStdLib>False</NoStdLib> |
||||
<NoConfig>False</NoConfig> |
||||
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
<DebugSymbols>True</DebugSymbols> |
||||
<Optimize>True</Optimize> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<OutputPath>..\..\..\bin\setup\</OutputPath> |
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
<DebugSymbols>True</DebugSymbols> |
||||
<Optimize>True</Optimize> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<OutputPath>..\..\..\bin\</OutputPath> |
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xml" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="Main.cs" /> |
||||
<Compile Include="AssemblyInfo.cs" /> |
||||
<Compile Include="HelperFunctions.cs" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> |
||||
</Project> |
@ -1,4 +0,0 @@
@@ -1,4 +0,0 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> |
||||
</Project> |
@ -1,96 +0,0 @@
@@ -1,96 +0,0 @@
|
||||
using System; |
||||
using System.Collections; |
||||
using System.CodeDom.Compiler; |
||||
using System.Text; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
using System.Xml; |
||||
|
||||
public class HelperFunctions |
||||
{ |
||||
public static string ExecuteCmdLineApp(string strCmd) |
||||
{ |
||||
string output = ""; |
||||
string error = ""; |
||||
|
||||
TempFileCollection tf = new TempFileCollection(); |
||||
Executor.ExecWaitWithCapture(strCmd, tf, ref output, ref error); |
||||
|
||||
StreamReader sr = File.OpenText(output); |
||||
StringBuilder strBuilder = new StringBuilder(); |
||||
string strLine = null; |
||||
|
||||
while (null != (strLine = sr.ReadLine())) { |
||||
if ("" != strLine) { |
||||
strBuilder.Append(strLine); |
||||
strBuilder.Append("\r\n"); |
||||
} |
||||
} |
||||
sr.Close(); |
||||
|
||||
File.Delete(output); |
||||
File.Delete(error); |
||||
|
||||
return strBuilder.ToString(); |
||||
} |
||||
|
||||
public static bool GetHelpUpToDate() |
||||
{ |
||||
DateTime sourceDate, targetDate; |
||||
string basePath = Application.StartupPath + Path.DirectorySeparatorChar + |
||||
".." + Path.DirectorySeparatorChar + |
||||
".." + Path.DirectorySeparatorChar + |
||||
"doc" + Path.DirectorySeparatorChar + |
||||
"help"; |
||||
string filename = basePath + Path.DirectorySeparatorChar + "HelpDescription.xml"; |
||||
string targetname = basePath + Path.DirectorySeparatorChar + "SharpDevelopHelp.zip"; |
||||
if (!File.Exists(targetname)) return false; |
||||
if (!File.Exists(filename)) { |
||||
Console.WriteLine("HelpDescription.xml not found!"); |
||||
return false; |
||||
} |
||||
try { |
||||
sourceDate = File.GetLastWriteTime(filename); |
||||
targetDate = File.GetLastWriteTime(targetname); |
||||
if (sourceDate > targetDate) return false; |
||||
XmlDocument doc = new XmlDocument(); |
||||
doc.Load(filename); |
||||
return ParseTree(doc.DocumentElement, targetDate, basePath); |
||||
} catch (Exception ex) { |
||||
Console.WriteLine("Error checking if the help is up to date:"); |
||||
Console.WriteLine(ex.ToString()); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/// <remarks>
|
||||
/// Parses the xml tree and returns false if the target is out of date.
|
||||
/// </remarks>
|
||||
static bool ParseTree(XmlNode parentNode, DateTime targetDate, string basePath) |
||||
{ |
||||
try { |
||||
foreach (XmlNode node in parentNode.ChildNodes) { |
||||
switch (node.Name) { |
||||
case "Condition": // condition is always true...
|
||||
case "HelpFolder": |
||||
if (!ParseTree(node, targetDate, basePath)) |
||||
return false; |
||||
break; |
||||
case "HelpFile": |
||||
string filename = basePath + Path.DirectorySeparatorChar + node.Attributes["hhc"].InnerText; |
||||
if (File.Exists(filename)) { |
||||
if (File.GetLastWriteTime(filename) > targetDate) |
||||
return false; |
||||
} |
||||
break; |
||||
case "HelpAssemblies": |
||||
// ignore assemblies... they should be up to date
|
||||
break; |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
Console.Error.WriteLine("unexpected exception : " + e.ToString()); |
||||
} |
||||
return true; |
||||
} |
||||
} |
@ -1,36 +0,0 @@
@@ -1,36 +0,0 @@
|
||||
using System; |
||||
using System.Text; |
||||
using System.Reflection; |
||||
using System.IO; |
||||
|
||||
class MainClass |
||||
{ |
||||
public static void Main(string[] args) |
||||
{ |
||||
StringBuilder strOutput = new StringBuilder(); |
||||
|
||||
// find the current directory; note that we assume to be located in the \bin directory of
|
||||
// the SharpDevelop installation
|
||||
string strCurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); |
||||
|
||||
// generate our help system - we can do that only on the target system
|
||||
string strHelpGenApp = Path.Combine(strCurrentDirectory, @"..\tools\HelpConverter.exe"); |
||||
Console.WriteLine("Building SharpDevelop help index...\r\n"); |
||||
if (HelperFunctions.GetHelpUpToDate()) { |
||||
strOutput.Append("Help is already up to date.\r\n"); |
||||
Console.WriteLine("Help is already up to date.\r\n"); |
||||
} else { |
||||
Console.WriteLine("This might take a minute or two, please be patient\r\n\r\n\r\n"); |
||||
Console.WriteLine("Building SharpDevelop help index"); |
||||
Console.WriteLine("Building .NET Framework Reference help index"); |
||||
Console.WriteLine("Building DirectX 9 help index (if installed)"); |
||||
strOutput.Append(HelperFunctions.ExecuteCmdLineApp(strHelpGenApp)); |
||||
} |
||||
// write a setup log so the SharpDevelop team can investigate setup failures
|
||||
StreamWriter sw = File.CreateText("BuildHelpIndex.log"); |
||||
sw.Write(strOutput.ToString()); |
||||
sw.Flush(); |
||||
sw.Close(); |
||||
Console.WriteLine("\r\nHelp index has been built - details have been logged to BuildHelpIndex.log"); |
||||
} |
||||
} |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?> |
||||
<register> |
||||
<plugin parent="Corsavy"> |
||||
<child name="MS.NETFrameworkSDKv1.1.DE"/> |
||||
</plugin> |
||||
</register> |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
@"Help2Register.exe" /r register.xml |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<register> |
||||
<namespace name="Corsavy" description="SharpDevelop Help Collection" file="..\..\..\doc\help\sharpdevelop\fidalgo.HxC"> |
||||
<file Id="SharpMain" HxS="..\..\..\doc\help\sharpdevelop\SharpDevelop.HxS" HxI="..\..\..\doc\help\sharpdevelop\SharpDevelop.HxI" LangId="1033"/> |
||||
<file Id="SharpZipLib" HxS="..\..\..\doc\help\3rdparty\ICSharpCode.SharpZipLib.HxS" HxI="..\..\..\doc\help\3rdparty\ICSharpCode.SharpZipLib.HxI" LangId="1033"/> |
||||
<filter name="(no filter)"/> |
||||
<plugin> |
||||
<child name="MS.NETFrameworkSDKv1.1*"/> |
||||
</plugin> |
||||
</namespace> |
||||
</register> |
@ -0,0 +1,295 @@
@@ -0,0 +1,295 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?> |
||||
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
<xs:annotation><xs:documentation> |
||||
Help 2.0 Registration Validation Schema |
||||
Copyright (c) 2005 Mathias Simmack |
||||
</xs:documentation></xs:annotation> |
||||
|
||||
<xs:element name="register"> |
||||
<xs:annotation><xs:documentation> |
||||
This is the main node. You have to use this node! The node can include |
||||
a namespace registration, a plug-in registration, or both. But it must |
||||
not be empty. |
||||
</xs:documentation></xs:annotation> |
||||
<xs:complexType> |
||||
<xs:sequence minOccurs="1" maxOccurs="unbounded"> |
||||
<xs:choice> |
||||
<xs:element ref="namespace"/> |
||||
<xs:element ref="plugin"/> |
||||
</xs:choice> |
||||
</xs:sequence> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
|
||||
<xs:element name="namespace"> |
||||
<xs:annotation><xs:documentation> |
||||
This node is required to register Help 2.0 documents and filters. The |
||||
node can include a Help document registration, a filter registration, |
||||
or both. But it must not be empty. |
||||
</xs:documentation></xs:annotation> |
||||
<xs:complexType> |
||||
<xs:sequence minOccurs="1" maxOccurs="unbounded"> |
||||
<xs:choice> |
||||
<xs:element ref="file"/> |
||||
<xs:element ref="filter"/> |
||||
<xs:element name="plugin"> |
||||
<xs:annotation><xs:documentation> |
||||
This is a special node to register plug-ins. But it |
||||
just supports the child node (s. below). |
||||
</xs:documentation></xs:annotation> |
||||
<xs:complexType> |
||||
<xs:sequence minOccurs="1" maxOccurs="unbounded"> |
||||
<xs:element ref="child"/> |
||||
</xs:sequence> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
</xs:choice> |
||||
</xs:sequence> |
||||
<xs:attribute name="name" type="xs:string" use="required"> |
||||
<xs:annotation><xs:documentation> |
||||
The internal Namespace name of the Help 2.0 collection. This |
||||
attribute is required. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
<xs:attribute name="description" type="xs:string" use="required"> |
||||
<xs:annotation><xs:documentation> |
||||
The description of the Help 2.0 collection, you want to register. |
||||
This attribute is required. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
<xs:attribute name="file" use="required"> |
||||
<xs:annotation><xs:documentation> |
||||
The collection file (*.HxC/*.HxS) of the Help 2.0 collection, |
||||
you want to register. This attribute is required. |
||||
</xs:documentation></xs:annotation> |
||||
<xs:simpleType> |
||||
<xs:restriction base="xs:string"> |
||||
<xs:pattern value=".+\.[Hh][Xx][CcSs]"/> |
||||
</xs:restriction> |
||||
</xs:simpleType> |
||||
</xs:attribute> |
||||
<xs:attribute name="merge" default="yes" type="YesNoType"> |
||||
<xs:annotation><xs:documentation> |
||||
Set this attribute to "no" if you do not want to merge the collection |
||||
after registering it. The default value is "yes". The attribute is |
||||
optional. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
<xs:attribute name="update" default="no" type="YesNoType"> |
||||
<xs:annotation><xs:documentation> |
||||
Use this attribute if you want to add new files or filters to an |
||||
existing Help 2.0 namespace. The default value is "no". It means, |
||||
if the namespace does exist, it will be removed first and then it |
||||
will be re-registered. If you do not want to remove the namespace, |
||||
set the attribute to "yes". The attribute is optional. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
<xs:attribute name="noremove" default="no" type="YesNoType"> |
||||
<xs:annotation><xs:documentation> |
||||
Use this attribute if you want to remove files or filters without |
||||
removing the whole namespace. The default value is "no". It means, |
||||
if you are about to unregister, it will remove all files and filters, |
||||
listed in your XML file, and then it will also remove the namespace. |
||||
The attribute is optional. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
|
||||
<xs:element name="file"> |
||||
<xs:annotation><xs:documentation> |
||||
This node is required to register a Help 2.0 document. |
||||
</xs:documentation></xs:annotation> |
||||
<xs:complexType> |
||||
<xs:attribute name="Id" type="xs:string" use="required"> |
||||
<xs:annotation><xs:documentation> |
||||
The Help 2.0 document's internal name. This name is required to |
||||
identify the document. You can use the same name in different |
||||
namespaces, but the name has to be unique in a single namespace. |
||||
The attribute is required. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
<xs:attribute name="LangId" type="LangIdType" use="required"> |
||||
<xs:annotation><xs:documentation> |
||||
The document's language id. Typical values are 1033, 1031, ... |
||||
The attribute is required. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
<xs:attribute name="HxS" use="required"> |
||||
<xs:annotation><xs:documentation> |
||||
This attribute is required because it is the main Help document |
||||
(*.HxS). It's not possible to register a Help document without |
||||
this file. |
||||
</xs:documentation></xs:annotation> |
||||
<xs:simpleType> |
||||
<xs:restriction base="xs:string"> |
||||
<xs:pattern value=".+\.[Hh][Xx][Ss]"/> |
||||
</xs:restriction> |
||||
</xs:simpleType> |
||||
</xs:attribute> |
||||
<xs:attribute name="HxI"> |
||||
<xs:annotation><xs:documentation> |
||||
This attribute is optional. You need it if your index is in a |
||||
separate file (*.HxI). |
||||
</xs:documentation></xs:annotation> |
||||
<xs:simpleType> |
||||
<xs:restriction base="xs:string"> |
||||
<xs:pattern value=".+\.[Hh][Xx][IiSs]"/> |
||||
</xs:restriction> |
||||
</xs:simpleType> |
||||
</xs:attribute> |
||||
<xs:attribute name="HxQ"> |
||||
<xs:annotation><xs:documentation> |
||||
This attribute is optional. You just need it if you have a |
||||
combined full-text search file (*.HxQ) installed with your |
||||
Help 2.0 collection. |
||||
</xs:documentation></xs:annotation> |
||||
<xs:simpleType> |
||||
<xs:restriction base="xs:string"> |
||||
<xs:pattern value=".+\.[Hh][Xx][Qq]"/> |
||||
</xs:restriction> |
||||
</xs:simpleType> |
||||
</xs:attribute> |
||||
<xs:attribute name="HxR"> |
||||
<xs:annotation><xs:documentation> |
||||
This attribute is optional. You just need it if you have a combined |
||||
attributes file (*.HxR) installed with your Help 2.0 collection. |
||||
</xs:documentation></xs:annotation> |
||||
<xs:simpleType> |
||||
<xs:restriction base="xs:string"> |
||||
<xs:pattern value=".+\.[Hh][Xx][Rr]"/> |
||||
</xs:restriction> |
||||
</xs:simpleType> |
||||
</xs:attribute> |
||||
<xs:attribute name="HxSMediaId" type="xs:string"> |
||||
<xs:annotation><xs:documentation> |
||||
Because the Help 2.0 API is not documented, there is no real |
||||
explanation of this attribute. Sorry. My guess is that this |
||||
attribute specifies the ID of the disk medium (CD, Floppy, or |
||||
whatever) if the file is on a removable medium. So, if you try |
||||
to open the document, the viewer asks for the valid medium and |
||||
checks its ID with this given value. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
<xs:attribute name="HxQMediaId" type="xs:string"> |
||||
<xs:annotation><xs:documentation> |
||||
Because the Help 2.0 API is not documented, there is no real |
||||
explanation of this attribute. Sorry. My guess is that this |
||||
attribute specifies the ID of the disk medium (CD, Floppy, or |
||||
whatever) if the file is on a removable medium. So, if you try |
||||
to open the document, the viewer asks for the valid medium and |
||||
checks its ID with this given value. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
<xs:attribute name="HxRMediaId" type="xs:string"> |
||||
<xs:annotation><xs:documentation> |
||||
Because the Help 2.0 API is not documented, there is no real |
||||
explanation of this attribute. Sorry. My guess is that this |
||||
attribute specifies the ID of the disk medium (CD, Floppy, or |
||||
whatever) if the file is on a removable medium. So, if you try |
||||
to open the document, the viewer asks for the valid medium and |
||||
checks its ID with this given value. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
<xs:attribute name="SampleMediaId" type="xs:string"> |
||||
<xs:annotation><xs:documentation> |
||||
Because the Help 2.0 API is not documented, there is no real |
||||
explanation of this attribute. Sorry. My guess is that this |
||||
attribute specifies the ID of the disk medium (CD, Floppy, or |
||||
whatever) if the file is on a removable medium. So, if you try |
||||
to open the document, the viewer asks for the valid medium and |
||||
checks its ID with this given value. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
|
||||
<xs:element name="filter"> |
||||
<xs:annotation><xs:documentation> |
||||
This node is required to register a filter. |
||||
</xs:documentation></xs:annotation> |
||||
<xs:complexType> |
||||
<xs:simpleContent> |
||||
<xs:annotation><xs:documentation> |
||||
The content of this node is the filter query string. Please use |
||||
a CDATA block. If there is no content, an empty filter will be |
||||
created. |
||||
</xs:documentation></xs:annotation> |
||||
<xs:extension base="xs:string"> |
||||
<xs:attribute name="name" type="xs:string" use="required"> |
||||
<xs:annotation><xs:documentation> |
||||
This attribute specifies the filter name, you will see |
||||
in the viewer's combobox. Use a descriptive name here. |
||||
The attribute is required. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
</xs:extension> |
||||
</xs:simpleContent> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
|
||||
<xs:element name="plugin"> |
||||
<xs:annotation><xs:documentation> |
||||
This node is required to register a Help 2.0 plug-in. A plug-in |
||||
connects two different Help 2.0 namespaces together. But you can |
||||
connect real collections (registered *.HxC files) only! |
||||
</xs:documentation></xs:annotation> |
||||
<xs:complexType> |
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded"> |
||||
<xs:element ref="child"/> |
||||
</xs:sequence> |
||||
<xs:attribute name="parent" type="xs:string" use="required"> |
||||
<xs:annotation><xs:documentation> |
||||
This attribute specifies the parent namespace. The attribute |
||||
is required. The namespace must exist, of course. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
<xs:attribute name="child" type="xs:string"> |
||||
<xs:annotation><xs:documentation> |
||||
This attribute specifies the child namespace. The attribute |
||||
is required. The namespace must exist, of course. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
<xs:attribute name="merge" default="yes" type="YesNoType"> |
||||
<xs:annotation><xs:documentation> |
||||
Set this attribute to "no" if you do not want to merge the collection |
||||
after registering it. The default value is "yes". The attribute is |
||||
optional. |
||||
</xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
|
||||
<xs:element name="child"> |
||||
<xs:annotation><xs:documentation> |
||||
This node specifies a lower plug-in node. It's useful if you want to |
||||
register more than one plug-in for the same namespace. You can reduce |
||||
the time to merge the namespace using this way. |
||||
</xs:documentation></xs:annotation> |
||||
<xs:complexType> |
||||
<xs:attribute name="name" type="xs:string" use="required"> |
||||
<xs:annotation><xs:documentation></xs:documentation></xs:annotation> |
||||
</xs:attribute> |
||||
</xs:complexType> |
||||
</xs:element> |
||||
|
||||
<xs:simpleType name="LangIdType"> |
||||
<xs:annotation><xs:documentation> |
||||
Values of this type are languages identifiers. |
||||
</xs:documentation></xs:annotation> |
||||
<xs:restriction base="xs:string"> |
||||
<xs:pattern value="[0-9]{4}"/> |
||||
</xs:restriction> |
||||
</xs:simpleType> |
||||
|
||||
<xs:simpleType name="YesNoType"> |
||||
<xs:annotation><xs:documentation> |
||||
Values of this type will either be "yes" or "no". |
||||
</xs:documentation></xs:annotation> |
||||
<xs:restriction base='xs:NMTOKEN'> |
||||
<xs:enumeration value="no"/> |
||||
<xs:enumeration value="yes"/> |
||||
</xs:restriction> |
||||
</xs:simpleType> |
||||
</xs:schema> |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
@"Help2Register.exe" /u register.xml |
@ -1,32 +0,0 @@
@@ -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("")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("")] |
||||
[assembly: AssemblyCopyright("")] |
||||
[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,61 +0,0 @@
@@ -1,61 +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.40607</ProductVersion> |
||||
<SchemaVersion>2.0</SchemaVersion> |
||||
<ProjectGuid>{75dd61c0-b2a8-4232-bf99-8e86c484d5e7}</ProjectGuid> |
||||
<RootNamespace>NewProject</RootNamespace> |
||||
<AssemblyName>HelpBrowserApp</AssemblyName> |
||||
<OutputTarget>Exe</OutputTarget> |
||||
<WarningLevel>4</WarningLevel> |
||||
<NoStdLib>False</NoStdLib> |
||||
<NoConfig>False</NoConfig> |
||||
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
<DebugSymbols>True</DebugSymbols> |
||||
<Optimize>True</Optimize> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<OutputPath>..\..\..\bin\</OutputPath> |
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
<DebugSymbols>True</DebugSymbols> |
||||
<Optimize>True</Optimize> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<OutputPath>..\..\..\bin\</OutputPath> |
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="ICSharpCode.SharpZipLib.dll"> |
||||
<HintPath>..\..\..\bin\ICSharpCode.SharpZipLib.dll</HintPath> |
||||
<Private>True</Private> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="Main.cs" /> |
||||
<Compile Include="AssemblyInfo.cs" /> |
||||
<Compile Include="HhcFileParser.cs" /> |
||||
<Compile Include="HelpTreeBuilder\AssemblyLoader.cs" /> |
||||
<Compile Include="HelpTreeBuilder\TypeNodeFactory.cs" /> |
||||
<Compile Include="HelpTreeBuilder\ClassNodeBuilder.cs" /> |
||||
<Compile Include="HelpTreeBuilder\ITypeNodeBuilder.cs" /> |
||||
<Compile Include="HelpTreeBuilder\EnumNodeBuilder.cs" /> |
||||
<Compile Include="HelpTreeBuilder\DelegateNodeBuilder.cs" /> |
||||
<Compile Include="HelpTreeBuilder\InterfaceNodeBuilder.cs" /> |
||||
<Compile Include="HelpTreeBuilder\StructNodeBuilder.cs" /> |
||||
<Compile Include="HelpTreeBuilder\Generator.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Folder Include="HelpTreeBuilder\" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> |
||||
</Project> |
@ -1,4 +0,0 @@
@@ -1,4 +0,0 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> |
||||
</Project> |
@ -1,37 +0,0 @@
@@ -1,37 +0,0 @@
|
||||
using System; |
||||
using System.Reflection; |
||||
|
||||
namespace ICSharpCode.HelpConverter.HelpTreeBuilder |
||||
{ |
||||
public class AssemblyLoader |
||||
{ |
||||
// public AssemblyLoader()
|
||||
// {
|
||||
// AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(resolve);
|
||||
// }
|
||||
//
|
||||
// Assembly resolve(object sender, ResolveEventArgs e)
|
||||
// {
|
||||
// System.Console.WriteLine("warning: assembly " + e.Name + " couln't be loaded.");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
public Assembly[] LoadAssemblies(string[] names) |
||||
{ |
||||
Assembly[] assemblies = new Assembly[names.Length]; |
||||
int count = 0; |
||||
|
||||
foreach(string name in names) { |
||||
Console.WriteLine("Load assembly : >" + name + "<"); |
||||
Assembly assembly = Assembly.Load(name); |
||||
if(assembly != null) { |
||||
assemblies[count] = Assembly.Load(name); |
||||
count++; |
||||
} else { |
||||
throw new Exception("Unable to load assembly " + name + "."); |
||||
} |
||||
} |
||||
return assemblies; |
||||
} |
||||
} |
||||
} |
@ -1,415 +0,0 @@
@@ -1,415 +0,0 @@
|
||||
using System; |
||||
using System.Text.RegularExpressions; |
||||
using System.Xml; |
||||
using System.Threading; |
||||
using System.Reflection; |
||||
using System.Windows.Forms; |
||||
using Microsoft.Win32; |
||||
|
||||
// TODO: handle overloading (links)
|
||||
|
||||
namespace ICSharpCode.HelpConverter.HelpTreeBuilder |
||||
{ |
||||
public interface IHelpFileFormat |
||||
{ |
||||
bool NumerateConstructor { |
||||
get; |
||||
} |
||||
string NamespaceFormat { |
||||
get; |
||||
} |
||||
string ClassTopic { |
||||
get; |
||||
} |
||||
string MembersTopic { |
||||
get; |
||||
} |
||||
string MethodsTopic { |
||||
get; |
||||
} |
||||
string PropertiesTopic { |
||||
get; |
||||
} |
||||
string FieldsTopic { |
||||
get; |
||||
} |
||||
string EventsTopic { |
||||
get; |
||||
} |
||||
|
||||
string MemberFormat { |
||||
get; |
||||
} |
||||
} |
||||
|
||||
public class SDKHelpFileFormat : IHelpFileFormat |
||||
{ |
||||
string prefix = "ms-help://MS.NETFrameworkSDK"; |
||||
|
||||
public bool NumerateConstructor { |
||||
get { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
string Prefix { |
||||
get { |
||||
return prefix; |
||||
} |
||||
} |
||||
|
||||
public string NamespaceFormat { |
||||
get { |
||||
return String.Concat(Prefix, "/cpref/html/frlrf%NAMESPACEFLAT%.htm"); |
||||
} |
||||
} |
||||
|
||||
public string ClassTopic { |
||||
get { |
||||
return String.Concat(Prefix, "/cpref/html/frlrf%FULLFLATTYPENAME%ClassTopic.htm"); |
||||
} |
||||
} |
||||
|
||||
public string MembersTopic { |
||||
get { |
||||
return String.Concat(Prefix, "/cpref/html/frlrf%FULLFLATTYPENAME%MembersTopic.htm"); |
||||
} |
||||
} |
||||
|
||||
public string MethodsTopic { |
||||
get { |
||||
return String.Concat(Prefix, "/cpref/html/frlrf%FULLFLATTYPENAME%MethodsTopic.htm"); |
||||
} |
||||
} |
||||
|
||||
public string PropertiesTopic { |
||||
get { |
||||
return String.Concat(Prefix, "/cpref/html/frlrf%FULLFLATTYPENAME%PropertiesTopic.htm"); |
||||
} |
||||
} |
||||
public string FieldsTopic { |
||||
get { |
||||
return String.Concat(Prefix, "/cpref/html/frlrf%FULLFLATTYPENAME%FieldsTopic.htm"); |
||||
} |
||||
} |
||||
public string EventsTopic { |
||||
get { |
||||
return String.Concat(Prefix, "/cpref/html/frlrf%FULLFLATTYPENAME%EventsTopic.htm"); |
||||
} |
||||
} |
||||
|
||||
public string MemberFormat { |
||||
get { |
||||
return String.Concat(Prefix, "/cpref/html/frlrf%FULLFLATTYPENAME%class%MEMBERNAME%Topic%NUM%.htm"); |
||||
} |
||||
} |
||||
|
||||
string ScanSubKeys(RegistryKey key) |
||||
{ |
||||
string[] subKeys = key.GetSubKeyNames(); |
||||
foreach (string subKey in subKeys) { |
||||
RegistryKey sub = key.OpenSubKey(subKey); |
||||
if (sub.GetValue(null).ToString().StartsWith("Microsoft .NET Framework SDK")) { |
||||
return sub.GetValue("Filename").ToString(); |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public SDKHelpFileFormat() |
||||
{ |
||||
string localHelp = "0x" + Thread.CurrentThread.CurrentCulture.LCID.ToString("X4"); |
||||
RegistryKey helpKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MSDN\7.0\Help"); |
||||
|
||||
RegistryKey k = helpKey.OpenSubKey(localHelp); |
||||
bool found = false; |
||||
if (k != null) { |
||||
string v = ScanSubKeys(k); |
||||
if (v != null) { |
||||
prefix = v; |
||||
found = true; |
||||
} |
||||
} |
||||
if (!found) { |
||||
// use default english subkey
|
||||
k = helpKey.OpenSubKey("0x0409"); |
||||
string v = k != null ? ScanSubKeys(k) : null; |
||||
if (v != null) { |
||||
prefix = v; |
||||
} else { |
||||
string[] subKeys = helpKey.GetSubKeyNames(); |
||||
foreach (string subKey in subKeys) { |
||||
if (subKey.StartsWith("0x")) { |
||||
prefix = ScanSubKeys(helpKey.OpenSubKey(subKey)); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
public class DirectX9HelpFileFormat : IHelpFileFormat |
||||
{ |
||||
public bool NumerateConstructor { |
||||
get { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
public string NamespaceFormat { |
||||
get { |
||||
return "ms-help://MS.DirectX9.1033/DirectX9_m/directx/ref/ns/%NAMESPACE%.htm"; |
||||
} |
||||
} |
||||
|
||||
public string ClassTopic { |
||||
get { |
||||
return "ms-help://MS.DirectX9.1033/DirectX9_m/directx/ref/ns/%NAMESPACE%/%TYPESHORT%/%TYPENAME%/%TYPENAME%.htm"; |
||||
} |
||||
} |
||||
|
||||
public string MembersTopic { |
||||
get { |
||||
return "ms-help://MS.DirectX9.1033/DirectX9_m/directx/ref/ns/%NAMESPACE%/%TYPESHORT%/%TYPENAME%/%TYPENAME%.htm"; |
||||
} |
||||
} |
||||
public string MethodsTopic { |
||||
get { |
||||
return null; |
||||
} |
||||
} |
||||
public string PropertiesTopic { |
||||
get { |
||||
return null; |
||||
} |
||||
} |
||||
public string FieldsTopic { |
||||
get { |
||||
return null; |
||||
} |
||||
} |
||||
public string EventsTopic { |
||||
get { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public string MemberFormat { |
||||
get { |
||||
return "ms-help://MS.DirectX9.1033/DirectX9_m/directx/ref/ns/%NAMESPACE%/%TYPESHORT%/%TYPENAME%/%MEMBERSHORT%/%MEMBERNAME%%NUM%.htm"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
public class classNodeBuilder : ITypeNodeBuilder |
||||
{ |
||||
BindingFlags flags = BindingFlags.Instance | |
||||
BindingFlags.DeclaredOnly | |
||||
BindingFlags.Static | |
||||
BindingFlags.Public; |
||||
|
||||
public static IHelpFileFormat helpFileFormat = new SDKHelpFileFormat(); |
||||
|
||||
public virtual string Postfix { |
||||
get { |
||||
return " class"; |
||||
} |
||||
} |
||||
|
||||
public virtual string ShortType { |
||||
get { |
||||
return "c"; |
||||
} |
||||
} |
||||
|
||||
public void SetLink(XmlDocument doc, XmlNode node, string link) |
||||
{ |
||||
if (link != null) { |
||||
XmlAttribute attrib = doc.CreateAttribute("link"); |
||||
attrib.Value = link; |
||||
node.Attributes.Append(attrib); |
||||
|
||||
attrib = doc.CreateAttribute("ismsdn"); |
||||
attrib.Value = "true"; |
||||
node.Attributes.Append(attrib); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
public XmlNode createLinkNode(XmlDocument doc, string name, string link) |
||||
{ |
||||
XmlNode node = doc.CreateElement("HelpTopic"); |
||||
XmlAttribute attrib = doc.CreateAttribute("name"); |
||||
attrib.Value = name; |
||||
node.Attributes.Append(attrib); |
||||
SetLink(doc, node, link); |
||||
return node; |
||||
} |
||||
|
||||
public XmlNode createFolderNode(XmlDocument doc, string name) |
||||
{ |
||||
XmlNode node = doc.CreateElement("HelpFolder"); |
||||
XmlAttribute attrib = doc.CreateAttribute("name"); |
||||
attrib.Value = name; |
||||
node.Attributes.Append(attrib); |
||||
|
||||
return node; |
||||
} |
||||
|
||||
public string ConvertLink(string format, Type type) |
||||
{ |
||||
if (format == null) { |
||||
return null; |
||||
} |
||||
string output = Regex.Replace(format, "%FULLFLATTYPENAME%", (type.Namespace + type.Name).Replace(".", "").ToLower(), RegexOptions.None); |
||||
output = Regex.Replace(output, "%NAMESPACE%", type.Namespace, RegexOptions.None); |
||||
output = Regex.Replace(output, "%NAMESPACEFLAT%", type.Namespace.Replace(".", ""), RegexOptions.None); |
||||
output = Regex.Replace(output, "%TYPENAME%", type.Name, RegexOptions.None); |
||||
output = Regex.Replace(output, "%TYPESHORT%", ShortType, RegexOptions.None); |
||||
return output; |
||||
} |
||||
|
||||
public string ConvertLink(string format, Type type, string memberName, string memberShort, string memberNum) |
||||
{ |
||||
string output = ConvertLink(format, type); |
||||
|
||||
output = Regex.Replace(output, "%MEMBERNAME%", memberName, RegexOptions.None); |
||||
output = Regex.Replace(output, "%MEMBERSHORT%", memberShort, RegexOptions.None); |
||||
output = Regex.Replace(output, "%NUM%", memberNum, RegexOptions.None); |
||||
|
||||
return output; |
||||
} |
||||
|
||||
public virtual XmlNode buildNode(XmlDocument doc, Type type) |
||||
{ |
||||
XmlNode rootnode = createFolderNode(doc, type.Name + Postfix); |
||||
SetLink(doc, rootnode, ConvertLink(helpFileFormat.ClassTopic, type)); |
||||
|
||||
rootnode.AppendChild(createLinkNode(doc, type.Name + " members", ConvertLink(helpFileFormat.MembersTopic, type))); |
||||
|
||||
// search for constructors
|
||||
XmlNode constructorsNode = createFolderNode(doc, "Constructors"); |
||||
int constructorNum = 0; |
||||
ConstructorInfo[] constructorInfo = type.GetConstructors(flags); |
||||
if (constructorInfo.Length > 0) { |
||||
SetLink(doc, constructorsNode, ConvertLink(helpFileFormat.MemberFormat, type, "ctor", "m", "")); |
||||
} |
||||
foreach(ConstructorInfo constructor in constructorInfo) { |
||||
if(constructor.DeclaringType == type) { |
||||
string memberFormat = null; |
||||
if (constructorInfo.Length > 1) { |
||||
memberFormat = ConvertLink(helpFileFormat.MemberFormat, type, "ctor", "m", constructorNum == 0 && !helpFileFormat.NumerateConstructor ? (constructorNum + 1).ToString() : constructorNum.ToString()); |
||||
++constructorNum; |
||||
} else { |
||||
memberFormat = ConvertLink(helpFileFormat.MemberFormat, type, "ctor", "m", ""); |
||||
} |
||||
|
||||
constructorsNode.AppendChild(createLinkNode(doc, |
||||
constructor.Name + "(" + getMethodSignature(constructor) + ")", |
||||
memberFormat)); |
||||
} |
||||
} |
||||
if(constructorsNode.ChildNodes.Count > 0) { |
||||
rootnode.AppendChild(constructorsNode); |
||||
} |
||||
|
||||
// search for fields
|
||||
XmlNode fieldsNode = createFolderNode(doc, "Fields"); |
||||
SetLink(doc, fieldsNode, ConvertLink(helpFileFormat.FieldsTopic, type)); |
||||
|
||||
foreach(FieldInfo field in type.GetFields(flags)) { |
||||
if(field.DeclaringType == type) { |
||||
string memberFormat = ConvertLink(helpFileFormat.MemberFormat, type, field.Name, "f", ""); |
||||
fieldsNode.AppendChild(createLinkNode(doc, field.Name, memberFormat)); |
||||
} |
||||
} |
||||
if(fieldsNode.ChildNodes.Count > 0) { |
||||
rootnode.AppendChild(fieldsNode); |
||||
} |
||||
|
||||
|
||||
// search for methods
|
||||
XmlNode methodsNode = createFolderNode(doc, "Methods"); |
||||
SetLink(doc, methodsNode, ConvertLink(helpFileFormat.MethodsTopic, type)); |
||||
MethodInfo[] methodInfos = type.GetMethods(flags); |
||||
int methodNum = 0; |
||||
for (int i = 0; i < methodInfos.Length; ++i) { |
||||
MethodInfo method = methodInfos[i]; |
||||
if (!method.IsSpecialName && method.DeclaringType == type) { |
||||
// HACK: BUGFIX FOR DirectX.Direct3D.Device and other directx classes ...
|
||||
// for unknown reason add and remove methods are added to the non special name, public space
|
||||
// maybe because the directx assemblies are generated by a buggy internal MS compiler :)
|
||||
if (method.Name.StartsWith("add_") || method.Name.StartsWith("remove_")) { |
||||
continue; |
||||
} |
||||
string number = ""; |
||||
if (i > 0 && methodInfos[i - 1].Name != method.Name) { |
||||
methodNum = helpFileFormat.NumerateConstructor ? 0 : 1; |
||||
} |
||||
if (i > 0 && methodInfos[i - 1].Name == method.Name) { |
||||
number = methodNum++.ToString(); |
||||
} else if (i + 1 < methodInfos.Length && methodInfos[i + 1].Name == method.Name) { |
||||
number = methodNum++.ToString(); |
||||
} |
||||
|
||||
string memberFormat = ConvertLink(helpFileFormat.MemberFormat, type, method.Name, "m", number); |
||||
methodsNode.AppendChild(createLinkNode(doc, |
||||
method.Name + "(" + getMethodSignature(method) + ")", |
||||
memberFormat)); |
||||
} |
||||
} |
||||
|
||||
if(methodsNode.ChildNodes.Count > 0) { |
||||
rootnode.AppendChild(methodsNode); |
||||
} |
||||
|
||||
// search for properties
|
||||
XmlNode propertiesNode = createFolderNode(doc, "Properties"); |
||||
SetLink(doc, propertiesNode, ConvertLink(helpFileFormat.PropertiesTopic, type)); |
||||
|
||||
foreach(PropertyInfo property in type.GetProperties(flags)) |
||||
{ |
||||
if (property.DeclaringType == type) { |
||||
string memberFormat = ConvertLink(helpFileFormat.MemberFormat, type, property.Name, "p", ""); |
||||
propertiesNode.AppendChild(createLinkNode(doc, property.Name, memberFormat)); |
||||
} |
||||
} |
||||
|
||||
if(propertiesNode.ChildNodes.Count > 0) { |
||||
rootnode.AppendChild(propertiesNode); |
||||
} |
||||
|
||||
// search for events
|
||||
XmlNode eventsNode = createFolderNode(doc, "Events"); |
||||
SetLink(doc, eventsNode, ConvertLink(helpFileFormat.EventsTopic, type)); |
||||
|
||||
foreach(EventInfo ev in type.GetEvents(flags)) |
||||
{ |
||||
if(ev.DeclaringType == type) { |
||||
string memberFormat = ConvertLink(helpFileFormat.MemberFormat, type, ev.Name, "e", ""); |
||||
eventsNode.AppendChild(createLinkNode(doc, ev.Name, memberFormat)); |
||||
} |
||||
} |
||||
|
||||
if(eventsNode.ChildNodes.Count > 0) { |
||||
rootnode.AppendChild(eventsNode); |
||||
} |
||||
|
||||
return rootnode; |
||||
} |
||||
|
||||
string getMethodSignature(MethodBase method) |
||||
{ |
||||
string signature = ""; |
||||
foreach(ParameterInfo param in method.GetParameters()) |
||||
{ |
||||
if(signature != "") signature += ", "; |
||||
signature += param.ParameterType; |
||||
} |
||||
return signature; |
||||
} |
||||
} |
||||
} |
@ -1,26 +0,0 @@
@@ -1,26 +0,0 @@
|
||||
using System; |
||||
using System.Xml; |
||||
using System.Reflection; |
||||
|
||||
namespace ICSharpCode.HelpConverter.HelpTreeBuilder |
||||
{ |
||||
class delegateNodeBuilder : classNodeBuilder |
||||
{ |
||||
public override string Postfix { |
||||
get { |
||||
return " delegate"; |
||||
} |
||||
} |
||||
|
||||
public override string ShortType { |
||||
get { |
||||
return "d"; |
||||
} |
||||
} |
||||
|
||||
public override XmlNode buildNode(XmlDocument doc, Type type) |
||||
{ |
||||
return createLinkNode(doc, type.Name + Postfix, ConvertLink(helpFileFormat.ClassTopic, type)); |
||||
} |
||||
} |
||||
} |
@ -1,26 +0,0 @@
@@ -1,26 +0,0 @@
|
||||
using System; |
||||
using System.Xml; |
||||
using System.Reflection; |
||||
|
||||
namespace ICSharpCode.HelpConverter.HelpTreeBuilder |
||||
{ |
||||
public class enumNodeBuilder : classNodeBuilder |
||||
{ |
||||
public override string Postfix { |
||||
get { |
||||
return " enumeration"; |
||||
} |
||||
} |
||||
|
||||
public override string ShortType { |
||||
get { |
||||
return "e"; |
||||
} |
||||
} |
||||
|
||||
public override XmlNode buildNode(XmlDocument doc, Type type) |
||||
{ |
||||
return createLinkNode(doc, type.Name + Postfix, ConvertLink(helpFileFormat.ClassTopic, type)); |
||||
} |
||||
} |
||||
} |
@ -1,111 +0,0 @@
@@ -1,111 +0,0 @@
|
||||
using System; |
||||
using System.IO; |
||||
using System.Collections; |
||||
using System.Reflection; |
||||
using System.Windows.Forms; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.HelpConverter.HelpTreeBuilder |
||||
{ |
||||
public class Generator |
||||
{ |
||||
public Generator(XmlDocument doc, XmlNode rootNode, string[] args) |
||||
{ |
||||
AssemblyLoader loader = new AssemblyLoader(); |
||||
Assembly[] assemblies; |
||||
|
||||
try { |
||||
assemblies = loader.LoadAssemblies(args); |
||||
} catch(Exception e) { |
||||
throw e; |
||||
} |
||||
|
||||
Hashtable typesByNamespace = loadTypesByNamespace(assemblies); |
||||
|
||||
string[] namespacesSorted = new string[typesByNamespace.Keys.Count]; |
||||
int count = 0; |
||||
|
||||
foreach(string nspace in typesByNamespace.Keys) { |
||||
namespacesSorted[count] = nspace; |
||||
count++; |
||||
} |
||||
|
||||
Array.Sort(namespacesSorted); |
||||
|
||||
foreach(string nspace in namespacesSorted) { |
||||
// create folder node for namespace
|
||||
XmlNode namespaceNode = doc.CreateElement("HelpFolder"); |
||||
XmlAttribute attrib = doc.CreateAttribute("name"); |
||||
attrib.Value = nspace; |
||||
|
||||
|
||||
namespaceNode.Attributes.Append(attrib); |
||||
|
||||
string[] typesSorted = new string[((Hashtable)typesByNamespace[nspace]).Count]; |
||||
count = 0; |
||||
|
||||
foreach(string typeName in ((Hashtable)typesByNamespace[nspace]).Keys) { |
||||
typesSorted[count] = typeName; |
||||
count++; |
||||
} |
||||
|
||||
Array.Sort(typesSorted); |
||||
|
||||
// put the namespace in a separate file
|
||||
XmlDocument newDoc = new XmlDocument(); |
||||
newDoc.LoadXml("<HelpCollection/>"); |
||||
bool setNamespaceLink = false; |
||||
foreach(string typeName in typesSorted) { |
||||
Type type = (Type)((Hashtable)typesByNamespace[nspace])[typeName]; |
||||
try { |
||||
newDoc.DocumentElement.AppendChild(TypeNodeFactory.CreateNode(type, newDoc)); |
||||
// set link to namespace description
|
||||
if (!setNamespaceLink) { |
||||
classNodeBuilder cbn = new classNodeBuilder(); |
||||
cbn.SetLink(doc, namespaceNode, cbn.ConvertLink(classNodeBuilder.helpFileFormat.NamespaceFormat,type )); |
||||
setNamespaceLink = true; |
||||
} |
||||
} catch(Exception e) { |
||||
System.Console.WriteLine(e.Message); |
||||
} |
||||
} |
||||
string helpFileName = Application.StartupPath + Path.DirectorySeparatorChar + nspace + "Help.xml"; |
||||
HelpBrowserApp.HelpFiles.Add(helpFileName); |
||||
newDoc.Save(helpFileName); |
||||
|
||||
// create help reference
|
||||
XmlElement referenceNode = doc.CreateElement("HelpReference"); |
||||
attrib = doc.CreateAttribute("reference"); |
||||
attrib.Value = nspace + "Help.xml"; |
||||
referenceNode.Attributes.Append(attrib); |
||||
namespaceNode.AppendChild(referenceNode); |
||||
|
||||
// add the namespace + reference node to the document
|
||||
rootNode.AppendChild(namespaceNode); |
||||
} |
||||
} |
||||
|
||||
Hashtable loadTypesByNamespace(Assembly[] assemblies) |
||||
{ |
||||
Hashtable namespaces = new Hashtable(); |
||||
|
||||
foreach(Assembly assembly in assemblies) { |
||||
|
||||
foreach(Type type in assembly.GetTypes()) { |
||||
if(type.Namespace != null && type.IsPublic) { |
||||
|
||||
if(namespaces.Contains(type.Namespace) == false) { |
||||
namespaces.Add(type.Namespace, new Hashtable()); |
||||
} |
||||
|
||||
((Hashtable)namespaces[type.Namespace]).Add(type.Name, type); |
||||
|
||||
} else { |
||||
System.Console.WriteLine("no namespace, ignoring: " + type.Name); |
||||
} |
||||
} |
||||
} |
||||
return namespaces; |
||||
} |
||||
} |
||||
} |
@ -1,10 +0,0 @@
@@ -1,10 +0,0 @@
|
||||
using System; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.HelpConverter.HelpTreeBuilder |
||||
{ |
||||
public interface ITypeNodeBuilder |
||||
{ |
||||
XmlNode buildNode(XmlDocument doc, Type type); |
||||
} |
||||
} |
@ -1,22 +0,0 @@
@@ -1,22 +0,0 @@
|
||||
using System; |
||||
using System.Xml; |
||||
using System.Reflection; |
||||
|
||||
namespace ICSharpCode.HelpConverter.HelpTreeBuilder |
||||
{ |
||||
class interfaceNodeBuilder : classNodeBuilder |
||||
{ |
||||
public override string ShortType { |
||||
get { |
||||
return "i"; |
||||
} |
||||
} |
||||
|
||||
public override string Postfix |
||||
{ |
||||
get { |
||||
return " interface"; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,22 +0,0 @@
@@ -1,22 +0,0 @@
|
||||
using System; |
||||
using System.Xml; |
||||
using System.Reflection; |
||||
|
||||
namespace ICSharpCode.HelpConverter.HelpTreeBuilder |
||||
{ |
||||
class structNodeBuilder : classNodeBuilder |
||||
{ |
||||
public override string ShortType { |
||||
get { |
||||
return "s"; |
||||
} |
||||
} |
||||
|
||||
public override string Postfix |
||||
{ |
||||
get { |
||||
return " structure"; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,29 +0,0 @@
@@ -1,29 +0,0 @@
|
||||
using System; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.HelpConverter.HelpTreeBuilder |
||||
{ |
||||
public class TypeNodeFactory |
||||
{ |
||||
public static XmlNode CreateNode(Type type, XmlDocument doc) |
||||
{ |
||||
ITypeNodeBuilder builder; |
||||
|
||||
if(type.IsClass == true && type.IsSubclassOf(typeof(MulticastDelegate)) == false) { |
||||
builder = new classNodeBuilder(); |
||||
} else if(type.IsClass == true && type.IsSubclassOf(typeof(MulticastDelegate)) == true) { |
||||
builder = new delegateNodeBuilder(); |
||||
} else if(type.IsEnum) { |
||||
builder = new enumNodeBuilder(); |
||||
} else if(type.IsInterface) { |
||||
builder = new interfaceNodeBuilder(); |
||||
} else if(type.IsValueType == true) { |
||||
builder = new structNodeBuilder(); |
||||
} else { |
||||
throw new Exception("Generation for this type is currently not supported: " + type.Name); |
||||
} |
||||
|
||||
return builder.buildNode(doc, type); |
||||
} |
||||
} |
||||
} |
@ -1,197 +0,0 @@
@@ -1,197 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Christoph Wille" email="christophw@alphasierrapapa.com"/>
|
||||
// <version value="$version"/>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Text; |
||||
using System.Text.RegularExpressions; |
||||
using System.Collections; |
||||
using System.Windows.Forms; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.HelpConverter |
||||
{ |
||||
public class HhcFileParser |
||||
{ |
||||
string hhcFileContents; |
||||
string chmName; |
||||
string basePath; |
||||
|
||||
ArrayList rootTreeNodes = new ArrayList(); |
||||
XmlNode currentNode = null; |
||||
|
||||
public HhcFileParser(string basePath) |
||||
{ |
||||
this.basePath = basePath; |
||||
} |
||||
|
||||
void LoadHhcFile(string fileName) |
||||
{ |
||||
FileInfo fi = new FileInfo(basePath + Path.DirectorySeparatorChar + fileName); |
||||
StreamReader sr = fi.OpenText(); |
||||
hhcFileContents = sr.ReadToEnd(); |
||||
sr.Close(); |
||||
} |
||||
|
||||
void MakeXmlCompliant() |
||||
{ |
||||
StringBuilder strFixup = |
||||
new StringBuilder(Regex.Replace(hhcFileContents, |
||||
"(?'start'<param\\s[^>]*)(?'end'\"/?>)", |
||||
"${start}\"/>")); |
||||
|
||||
strFixup.Replace("</OBJECT></UL>", "</OBJECT></LI></UL>"); |
||||
strFixup.Replace("</OBJECT><LI>", "</OBJECT></LI><LI>"); |
||||
strFixup.Replace("</OBJECT><UL><LI>", "</OBJECT></LI><UL><LI>"); |
||||
hhcFileContents = strFixup.ToString(); |
||||
} |
||||
|
||||
void Load(string fileName) |
||||
{ |
||||
LoadHhcFile(fileName); |
||||
MakeXmlCompliant(); |
||||
} |
||||
|
||||
public void Parse(XmlDocument helpFileDocument, XmlNode currentNode, string hhcFileName, string chmName) |
||||
{ |
||||
this.chmName = chmName; |
||||
|
||||
Load(hhcFileName); |
||||
|
||||
XmlDocument doc = new XmlDocument(); |
||||
doc.LoadXml(hhcFileContents); |
||||
|
||||
XmlNode root = doc.ChildNodes[0]; |
||||
XmlNode outermostList = null; |
||||
|
||||
switch (root.Name.ToLower()) { |
||||
case "ul": |
||||
outermostList = root; |
||||
break; |
||||
case "html": // this would be well-formed HTML
|
||||
outermostList = root["BODY"]["UL"]; |
||||
break; |
||||
case "#comment": // this is NDoc malformed HTML
|
||||
outermostList = doc.ChildNodes[1]; |
||||
break; |
||||
default: |
||||
// this is nothing we can read; please send us the .hhc file
|
||||
break; |
||||
} |
||||
|
||||
if (null == outermostList) { |
||||
Console.WriteLine("Format of file not valid, cannot find root <UL> node"); |
||||
return; |
||||
} |
||||
|
||||
this.currentNode = currentNode; |
||||
EvaluateLevel(helpFileDocument, outermostList); |
||||
|
||||
// quick & dirty overview of the structure
|
||||
// Console.WriteLine("---------------------------");
|
||||
// DumpElement(root, 0);
|
||||
} |
||||
|
||||
void EvaluateLevel(XmlDocument helpFileDocument, XmlNode currentLevel) |
||||
{ |
||||
for (int i = 0; i < currentLevel.ChildNodes.Count; i++) { |
||||
XmlNode currentElement = currentLevel.ChildNodes[i]; |
||||
|
||||
// we need a lookup on the next node - is it a UL, then the current node
|
||||
// node needs to be displayed as a folder, otherwise it is a non-expandable
|
||||
// leaf node in our tree
|
||||
bool bIsFolderNode = false; |
||||
if (i < (currentLevel.ChildNodes.Count - 1)) { |
||||
XmlNode nextElement = currentLevel.ChildNodes[i + 1]; |
||||
if ("UL" == nextElement.Name) bIsFolderNode = true; |
||||
} |
||||
|
||||
string strNodeName, strNodeUrl; |
||||
if (bIsFolderNode) { |
||||
GetNodeInformation(currentElement["OBJECT"], out strNodeName, out strNodeUrl); |
||||
|
||||
// we need to create a folder and continue traversing
|
||||
XmlElement folderElement = helpFileDocument.CreateElement("HelpFolder"); |
||||
|
||||
XmlAttribute attrib = helpFileDocument.CreateAttribute("name"); |
||||
attrib.InnerText = strNodeName; |
||||
folderElement.Attributes.Append(attrib); |
||||
currentNode.AppendChild(folderElement); |
||||
|
||||
|
||||
XmlNode savedNode = currentNode; |
||||
currentNode = folderElement; |
||||
EvaluateLevel(helpFileDocument, currentLevel.ChildNodes[i + 1]); |
||||
currentNode = savedNode; |
||||
} else { |
||||
// we have a leaf node here, but we need to ignore UL's, those are handled by
|
||||
// their parents above
|
||||
if ("UL" == currentElement.Name) { |
||||
// we do nothing with this element
|
||||
} else { |
||||
GetNodeInformation(currentElement["OBJECT"], out strNodeName, out strNodeUrl); |
||||
|
||||
XmlElement helpTopic = helpFileDocument.CreateElement("HelpTopic"); |
||||
|
||||
XmlAttribute attrib = helpFileDocument.CreateAttribute("name"); |
||||
attrib.InnerText = strNodeName; |
||||
helpTopic.Attributes.Append(attrib); |
||||
attrib = helpFileDocument.CreateAttribute("link"); |
||||
attrib.InnerText = chmName + "::/" + strNodeUrl; |
||||
helpTopic.Attributes.Append(attrib); |
||||
currentNode.AppendChild(helpTopic); |
||||
|
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void GetNodeInformation(XmlNode theNode, out string NodeName, out string NodeUrl) |
||||
{ |
||||
// <param name="Name" value="name of node"/> and url are read from OBJECT node
|
||||
string strParamType, strParamValue; |
||||
strParamType = strParamValue = NodeName = NodeUrl = ""; |
||||
|
||||
for (int i = 0; i < theNode.ChildNodes.Count; i++) { |
||||
XmlNode currentParam = theNode.ChildNodes[i]; |
||||
// we work with param nodes only, anything else cannot be handled here
|
||||
if ("param" != currentParam.Name) { |
||||
return; |
||||
} |
||||
|
||||
// if any of the below two XmlAttribute objects is not available,
|
||||
// we will get a null ref exception
|
||||
try { |
||||
strParamType = currentParam.Attributes["name"].Value; |
||||
strParamValue = currentParam.Attributes["value"].Value; |
||||
} catch { |
||||
strParamType = ""; // because of the switch statement, we need a default value when it fails
|
||||
} |
||||
|
||||
switch (strParamType) { |
||||
case "Name": |
||||
NodeName = strParamValue; |
||||
break; |
||||
case "Local": |
||||
NodeUrl = strParamValue; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
// for internal use only - dump entire structure to the console.
|
||||
void DumpElement(XmlNode el, int nDepth) |
||||
{ |
||||
string strTree = new String(' ', nDepth); |
||||
|
||||
foreach(XmlNode subEl in el.ChildNodes) { |
||||
Console.WriteLine(strTree + subEl.Name); |
||||
DumpElement(subEl, nDepth+1); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,168 +0,0 @@
@@ -1,168 +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.Windows.Forms; |
||||
using System.Drawing; |
||||
using System.CodeDom.Compiler; |
||||
using System.IO; |
||||
using System.Reflection; |
||||
using System.Diagnostics; |
||||
using System.Xml; |
||||
using ICSharpCode.HelpConverter.HelpTreeBuilder; |
||||
|
||||
using ICSharpCode.SharpZipLib.Checksums; |
||||
using ICSharpCode.SharpZipLib.Zip; |
||||
using ICSharpCode.SharpZipLib.GZip; |
||||
|
||||
namespace ICSharpCode.HelpConverter |
||||
{ |
||||
public class HelpBrowserApp |
||||
{ |
||||
HhcFileParser hhcFileParser; |
||||
public static ArrayList HelpFiles = new ArrayList(); |
||||
|
||||
/// <remarks>
|
||||
/// Parses the xml tree and generates a TreeNode tree out of it.
|
||||
/// </remarks>
|
||||
void ParseTree(XmlDocument doc, XmlNode docParent, XmlNode parentNode) |
||||
{ |
||||
try { |
||||
foreach (XmlNode node in parentNode.ChildNodes) { |
||||
XmlNode importNode = doc.ImportNode(node, true); |
||||
switch (node.Name) { |
||||
case "Condition": |
||||
Console.WriteLine("trying to load : " + node.Attributes["canload"].InnerText); |
||||
Assembly assembly = Assembly.Load(node.Attributes["canload"].InnerText); |
||||
if(assembly != null) { |
||||
Console.WriteLine("Success"); |
||||
ParseTree(doc, docParent, node); |
||||
} else { |
||||
Console.WriteLine("Failure"); |
||||
} |
||||
break; |
||||
case "HelpFolder": |
||||
docParent.AppendChild(importNode); |
||||
ParseTree(doc, importNode, node); |
||||
break; |
||||
case "HelpFile": |
||||
Console.WriteLine("Parse hhc : " + node.Attributes["hhc"].InnerText); |
||||
hhcFileParser.Parse(doc, |
||||
docParent, |
||||
node.Attributes["hhc"].InnerText, |
||||
node.Attributes["chm"].InnerText); |
||||
break; |
||||
case "HelpAssemblies": |
||||
ArrayList assemblies = new ArrayList(); |
||||
foreach (XmlNode childNode in node.ChildNodes) { |
||||
assemblies.Add(childNode.InnerText); |
||||
} |
||||
if (node.Attributes["helpformat"].InnerText == "SDK") { |
||||
classNodeBuilder.helpFileFormat = new SDKHelpFileFormat(); |
||||
} else { |
||||
classNodeBuilder.helpFileFormat = new DirectX9HelpFileFormat(); |
||||
} |
||||
new Generator(doc, docParent, (string[])assemblies.ToArray(typeof(string))); |
||||
break; |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
Console.Error.WriteLine("unexpected exception : " + e.ToString()); |
||||
} |
||||
} |
||||
|
||||
void ConvertHelpfile() |
||||
{ |
||||
string basePath = Application.StartupPath + Path.DirectorySeparatorChar + |
||||
".." + Path.DirectorySeparatorChar + |
||||
".." + Path.DirectorySeparatorChar + |
||||
"doc" + Path.DirectorySeparatorChar + |
||||
"help"; |
||||
|
||||
if (!File.Exists(basePath + Path.DirectorySeparatorChar + @"HelpDescription.xml")) { |
||||
Console.WriteLine("HelpDescription.xml not found!"); |
||||
return; |
||||
} |
||||
|
||||
XmlDocument doc = new XmlDocument(); |
||||
doc.Load(basePath + Path.DirectorySeparatorChar + @"HelpDescription.xml"); |
||||
|
||||
XmlDocument newDoc = new XmlDocument(); |
||||
newDoc.LoadXml("<HelpCollection/>"); |
||||
hhcFileParser = new HhcFileParser(basePath); |
||||
ParseTree(newDoc, newDoc.DocumentElement, doc.DocumentElement); |
||||
|
||||
try { |
||||
newDoc.Save(basePath + Path.DirectorySeparatorChar + "HelpConv.xml"); |
||||
} catch (Exception e) { |
||||
Console.Error.WriteLine("Can't save HelpConv.xml (No write permission?) : " + e.ToString()); |
||||
} |
||||
|
||||
try { |
||||
ZipHelpFile(basePath); |
||||
} catch (Exception e) { |
||||
Console.Error.WriteLine("Error while zipping helpfile : " + e.ToString()); |
||||
} |
||||
} |
||||
|
||||
void ZipHelpFile(string basePath) |
||||
{ |
||||
Console.WriteLine("ZIP Help Contents"); |
||||
HelpFiles.Insert(0, basePath + Path.DirectorySeparatorChar + "HelpConv.xml"); |
||||
ZipOutputStream s = new ZipOutputStream(File.Create(basePath + Path.DirectorySeparatorChar + "SharpDevelopHelp.zip")); |
||||
try { |
||||
s.SetLevel(6); |
||||
Crc32 crc = new Crc32(); |
||||
foreach (string file in HelpFiles) { |
||||
Console.WriteLine("zip " + file); |
||||
|
||||
FileStream fs = null; |
||||
ZipEntry entry; |
||||
byte[] buffer; |
||||
|
||||
try { |
||||
fs = File.OpenRead(file); |
||||
buffer = new byte[fs.Length]; |
||||
fs.Read(buffer, 0, buffer.Length); |
||||
|
||||
entry = new ZipEntry(Path.GetFileName(file)); |
||||
entry.DateTime = DateTime.Now; |
||||
entry.Size = fs.Length; |
||||
crc.Reset(); |
||||
crc.Update(buffer); |
||||
entry.Crc = crc.Value; |
||||
} catch (Exception e) { |
||||
Console.Error.WriteLine("Error reading temp xml file : " + e.ToString()); |
||||
continue; |
||||
} finally { |
||||
if (fs != null) { |
||||
fs.Close(); |
||||
} |
||||
} |
||||
|
||||
s.PutNextEntry(entry); |
||||
s.Write(buffer, 0, buffer.Length); |
||||
|
||||
Console.WriteLine("remove " + file + " from disk"); |
||||
File.Delete(file); |
||||
} |
||||
} catch (Exception e) { |
||||
Console.Error.WriteLine("Error while zipping helpfile : " + e.ToString()); |
||||
} finally { |
||||
s.Finish(); |
||||
s.Close(); |
||||
Console.WriteLine("finished"); |
||||
} |
||||
} |
||||
|
||||
public static void Main(String[] args) |
||||
{ |
||||
new HelpBrowserApp().ConvertHelpfile(); |
||||
} |
||||
} |
||||
} |
@ -1,32 +0,0 @@
@@ -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("ResAsmTask")] |
||||
[assembly: AssemblyDescription("A nanttask for easy resource generation.")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("www.icsharpcode.net")] |
||||
[assembly: AssemblyProduct("")] |
||||
[assembly: AssemblyCopyright("(c) 2004 by Mike Krueger")] |
||||
[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,81 +0,0 @@
@@ -1,81 +0,0 @@
|
||||
using System; |
||||
using System.Drawing; |
||||
using System.IO; |
||||
using System.Resources; |
||||
|
||||
using NAnt.Core; |
||||
using NAnt.Core.Attributes; |
||||
using NAnt.Core.Tasks; |
||||
using NAnt.Core.Types; |
||||
using NAnt.Core.Util; |
||||
|
||||
namespace ResAsmTask |
||||
{ |
||||
[TaskName("resasm")] |
||||
public class ResAsmTask : Task |
||||
{ |
||||
string output; |
||||
string input = null; |
||||
FileSet files = new FileSet(); |
||||
|
||||
[TaskAttribute("output", Required=true)] |
||||
public string Output { |
||||
get { |
||||
return output; |
||||
} |
||||
set { |
||||
output = value; |
||||
} |
||||
} |
||||
|
||||
[TaskAttribute("input")] |
||||
public string Input { |
||||
get { |
||||
return input; |
||||
} |
||||
set { |
||||
input = value; |
||||
} |
||||
} |
||||
|
||||
[BuildElement("files")] |
||||
public FileSet Files { |
||||
get { |
||||
return files; |
||||
} |
||||
set { |
||||
files = value; |
||||
} |
||||
} |
||||
|
||||
protected override void ExecuteTask() |
||||
{ |
||||
if (Files.BaseDirectory == null) { |
||||
Files.BaseDirectory = new DirectoryInfo(Project.BaseDirectory); |
||||
} |
||||
|
||||
if (Files.FileNames.Count > 0) { |
||||
string outputDirectory; |
||||
if (Path.IsPathRooted(Output)) { |
||||
outputDirectory = Output; |
||||
} else { |
||||
outputDirectory = Path.Combine(Project.BaseDirectory, Output); |
||||
} |
||||
|
||||
if (!Directory.Exists(Path.GetDirectoryName(outputDirectory))) { |
||||
Directory.CreateDirectory(Path.GetDirectoryName(outputDirectory)); |
||||
} |
||||
|
||||
ResourceWriter rw = new ResourceWriter(outputDirectory); |
||||
foreach (string fileName in Files.FileNames) { |
||||
Bitmap bitmap = new Bitmap(Path.Combine(Files.BaseDirectory.FullName, fileName)); |
||||
rw.AddResource(Path.GetFileNameWithoutExtension(fileName), bitmap); |
||||
} |
||||
rw.Generate(); |
||||
rw.Close(); |
||||
} else if (Input != null) { |
||||
ResAsm.Assemble(Input, Output); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,178 +0,0 @@
@@ -1,178 +0,0 @@
|
||||
// ResAsm.cs
|
||||
// Copyright (c) 2001 Mike Krueger
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Drawing; |
||||
using System.Resources; |
||||
using System.IO; |
||||
using System.Text; |
||||
using System.Drawing.Imaging; |
||||
using System.Windows.Forms; |
||||
using System.Runtime.Serialization.Formatters.Binary; |
||||
|
||||
namespace ResAsmTask |
||||
{ |
||||
public class ResAsm |
||||
{ |
||||
static string ConvertIllegalChars(string str) |
||||
{ |
||||
StringBuilder newString = new StringBuilder(); |
||||
for (int i = 0; i < str.Length; ++i) { |
||||
switch (str[i]) { |
||||
case '\r': |
||||
break; |
||||
case '\n': |
||||
newString.Append("\\n"); |
||||
break; |
||||
case '"': |
||||
newString.Append("\\\""); |
||||
break; |
||||
case '\\': |
||||
newString.Append("\\\\"); |
||||
break; |
||||
default: |
||||
newString.Append(str[i]); |
||||
break; |
||||
} |
||||
} |
||||
return newString.ToString(); |
||||
} |
||||
|
||||
/// <remarks>
|
||||
/// Builds resource files out of the ResAsm format
|
||||
/// </remarks>
|
||||
public static void Assemble(string inputFileName, string outputFileName) |
||||
{ |
||||
int linenr = 0; |
||||
try { |
||||
StreamReader reader = new StreamReader(inputFileName, new UTF8Encoding()); |
||||
|
||||
ResourceWriter rw = new ResourceWriter(outputFileName); |
||||
linenr = 0; |
||||
while (true) { |
||||
string line = reader.ReadLine(); |
||||
linenr++; |
||||
if (line == null) { |
||||
break; |
||||
} |
||||
line = line.Trim(); |
||||
// skip empty or comment lines
|
||||
if (line.Length == 0 || line[0] == '#') { |
||||
continue; |
||||
} |
||||
|
||||
// search for a = char
|
||||
int idx = line.IndexOf('='); |
||||
if (idx < 0) { |
||||
Console.WriteLine("error in file " + inputFileName + " at line " + linenr); |
||||
continue; |
||||
} |
||||
string key = line.Substring(0, idx).Trim(); |
||||
string val = line.Substring(idx + 1).Trim(); |
||||
object entryval = null; |
||||
|
||||
if (val[0] == '"') { // case 1 : string value
|
||||
val = val.Trim(new char[] {'"'}); |
||||
StringBuilder tmp = new StringBuilder(); |
||||
for (int i = 0; i < val.Length; ++i) { |
||||
switch (val[i]) { // handle the \ char
|
||||
case '\\': |
||||
++i; |
||||
if (i < val.Length) |
||||
switch (val[i]) { |
||||
case '\\': |
||||
tmp.Append('\\'); |
||||
break; |
||||
case 'n': |
||||
tmp.Append('\n'); |
||||
break; |
||||
case '\"': |
||||
tmp.Append('\"'); |
||||
break; |
||||
} |
||||
break; |
||||
default: |
||||
tmp.Append(val[i]); |
||||
break; |
||||
} |
||||
} |
||||
entryval = tmp.ToString(); |
||||
} else { // case 2 : no string value -> load resource
|
||||
entryval = LoadResource(val); |
||||
} |
||||
rw.AddResource(key, entryval); |
||||
|
||||
} |
||||
rw.Generate(); |
||||
rw.Close(); |
||||
reader.Close(); |
||||
} catch (Exception e) { |
||||
Console.WriteLine("Error in line " + linenr); |
||||
Console.WriteLine("Error while processing " + inputFileName + " :"); |
||||
Console.WriteLine(e.ToString()); |
||||
} |
||||
} |
||||
|
||||
/// <remarks>
|
||||
/// Loads a file.
|
||||
/// </remarks>
|
||||
/// <returns>
|
||||
/// An object representation of the file (for a bitmap a Bitmap,
|
||||
/// for a Icon an Icon and so on), the fall back is a byte array
|
||||
/// </returns>
|
||||
static object LoadResource(string name) |
||||
{ |
||||
switch (Path.GetExtension(name).ToUpper()) { |
||||
case ".CUR": |
||||
return new Cursor(name); |
||||
case ".ICO": |
||||
return new Icon(name); |
||||
default: |
||||
// try to read a bitmap
|
||||
try { |
||||
return new Bitmap(name); |
||||
} catch {} |
||||
|
||||
// try to read a serialized object
|
||||
try { |
||||
Stream r = File.Open(name, FileMode.Open); |
||||
try { |
||||
BinaryFormatter c = new BinaryFormatter(); |
||||
object o = c.Deserialize(r); |
||||
r.Close(); |
||||
return o; |
||||
} catch { r.Close(); } |
||||
} catch { } |
||||
|
||||
// finally try to read a byte array
|
||||
try { |
||||
FileStream s = new FileStream(name, FileMode.Open); |
||||
BinaryReader r = new BinaryReader(s); |
||||
Byte[] d = new Byte[(int) s.Length]; |
||||
d = r.ReadBytes((int) s.Length); |
||||
s.Close(); |
||||
return d; |
||||
} catch (Exception e) { |
||||
MessageBox.Show(e.Message, "Can't load resource", MessageBoxButtons.OK); |
||||
} |
||||
break; |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTarget="Build"> |
||||
<ItemGroup> |
||||
<NDocFiles Include="ndoc\bin\*"/> |
||||
<WixFiles Include="wix\*"/> |
||||
<WixCaFiles Include="wix\ca\*"/> |
||||
<WixDocFiles Include="wix\doc\*"/> |
||||
<WixLibFiles Include="wix\doc\*"/> |
||||
<HelpToolFiles Include="Help\*"/> |
||||
</ItemGroup> |
||||
|
||||
<Target Name="Build"> |
||||
<Copy SourceFiles="@(NDocFiles)" DestinationFolder="..\..\bin\Tools\NDoc"/> |
||||
<Copy SourceFiles="@(WixFiles)" DestinationFolder="..\..\bin\Tools\Wix"/> |
||||
<Copy SourceFiles="@(WixCaFiles)" DestinationFolder="..\..\bin\Tools\Wix\ca"/> |
||||
<Copy SourceFiles="@(WixDocFiles)" DestinationFolder="..\..\bin\Tools\Wix\doc"/> |
||||
<Copy SourceFiles="@(WixLibFiles)" DestinationFolder="..\..\bin\Tools\Wix\lib"/> |
||||
<CreateProperty Condition = "!Exists('..\..\bin\setup\help\register.bat')" Value="yes"> |
||||
<Output TaskParameter="Value" PropertyName="NeedToRunRegister" /> |
||||
</CreateProperty> |
||||
<Copy SourceFiles="@(HelpToolFiles)" DestinationFolder="..\..\bin\setup\help"/> |
||||
<Exec Command="register.bat" WorkingDirectory = "..\..\bin\setup\help" Timeout = "60000" IgnoreExitCode = "true" Condition = "'$(NeedToRunRegister)' == 'yes'" /> |
||||
</Target> |
||||
|
||||
<Target Name="Rebuild" DependsOnTargets="Clean;Build"/> |
||||
|
||||
<Target Name="Publish" DependsOnTargets="Build"/> |
||||
|
||||
<Target Name="Clean"> |
||||
<Exec Command="unregister.bat" WorkingDirectory="..\..\bin\setup\help" IgnoreExitCode = "true" Condition = "Exists('..\..\bin\setup\help\unregister.bat')"/> |
||||
<RemoveDir Directories="..\..\bin\Tools" /> |
||||
<RemoveDir Directories="..\..\bin\setup\help" /> |
||||
</Target> |
||||
</Project> |
Loading…
Reference in new issue