diff options
Diffstat (limited to 'Samples/HelloWorldWithManifest')
8 files changed, 180 insertions, 0 deletions
diff --git a/Samples/HelloWorldWithManifest/HelloWorld/HelloWorld.addin.xml b/Samples/HelloWorldWithManifest/HelloWorld/HelloWorld.addin.xml new file mode 100644 index 0000000..5fe9ca1 --- /dev/null +++ b/Samples/HelloWorldWithManifest/HelloWorld/HelloWorld.addin.xml @@ -0,0 +1,8 @@ +<Addin id="HelloWorld" version="1.0" isroot="true"> + + <!-- Declare a new extension point. This extension points will have elements with the name "Command" --> + <ExtensionPoint path = "/Commands"> + <ExtensionNode name="Command" /> + </ExtensionPoint> + +</Addin> diff --git a/Samples/HelloWorldWithManifest/HelloWorld/HelloWorld.csproj b/Samples/HelloWorldWithManifest/HelloWorld/HelloWorld.csproj new file mode 100644 index 0000000..df864d0 --- /dev/null +++ b/Samples/HelloWorldWithManifest/HelloWorld/HelloWorld.csproj @@ -0,0 +1 @@ +<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5F813963-DE40-433A-ABE3-71EACDF19412}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>HelloWorld</RootNamespace>
<AssemblyName>HelloWorld</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Mono.Addins, Version=0.5.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\bin\Mono.Addins.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="ICommand.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="HelloWorld.addin.xml">
<LogicalName>HelloWorld.addin.xml</LogicalName>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file diff --git a/Samples/HelloWorldWithManifest/HelloWorld/ICommand.cs b/Samples/HelloWorldWithManifest/HelloWorld/ICommand.cs new file mode 100644 index 0000000..6048538 --- /dev/null +++ b/Samples/HelloWorldWithManifest/HelloWorld/ICommand.cs @@ -0,0 +1,39 @@ +// +// ICommand.cs +// +// Author: +// Lluis Sanchez Gual <lluis@novell.com> +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using Mono.Addins; + +namespace HelloWorld +{ + // This is an interface which can be implemented by add-ins. + + public interface ICommand + { + void Run (); + } +} + diff --git a/Samples/HelloWorldWithManifest/HelloWorld/Main.cs b/Samples/HelloWorldWithManifest/HelloWorld/Main.cs new file mode 100644 index 0000000..7c9f219 --- /dev/null +++ b/Samples/HelloWorldWithManifest/HelloWorld/Main.cs @@ -0,0 +1,48 @@ +// +// Main.cs +// +// Author: +// Lluis Sanchez Gual <lluis@novell.com> +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using Mono.Addins; + +namespace HelloWorld +{ + class MainClass + { + public static void Main (string[] args) + { + // Initializes the add-in engine + AddinManager.Initialize (); + + // Looks for new add-ins and updates the add-in registry. + AddinManager.Registry.Update (null); + + // Gets all commands implemented in add-ins. + foreach (ICommand cmd in AddinManager.GetExtensionObjects ("/Commands")) + cmd.Run (); + } + } +} + diff --git a/Samples/HelloWorldWithManifest/HelloWorldAddin/HelloCommand.cs b/Samples/HelloWorldWithManifest/HelloWorldAddin/HelloCommand.cs new file mode 100644 index 0000000..ad97a6e --- /dev/null +++ b/Samples/HelloWorldWithManifest/HelloWorldAddin/HelloCommand.cs @@ -0,0 +1,40 @@ +// +// HelloCommand.cs +// +// Author: +// Lluis Sanchez Gual <lluis@novell.com> +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using HelloWorld; + +namespace HelloWorldAddin +{ + public class HelloCommand: ICommand + { + public void Run () + { + Console.WriteLine ("Hello World!"); + } + } +} + diff --git a/Samples/HelloWorldWithManifest/HelloWorldAddin/HelloWorldAddin.addin.xml b/Samples/HelloWorldWithManifest/HelloWorldAddin/HelloWorldAddin.addin.xml new file mode 100644 index 0000000..865ae4a --- /dev/null +++ b/Samples/HelloWorldWithManifest/HelloWorldAddin/HelloWorldAddin.addin.xml @@ -0,0 +1,13 @@ +<Addin> + + <!-- This add-in depends on the HelloWorld v1.0 add-in root --> + <Dependencies> + <Addin id="HelloWorld" version="1.0" /> + </Dependencies> + + <!-- Register an extension for the /Commands extension point --> + <Extension path = "/Commands"> + <Command class="HelloWorldAddin.HelloCommand" /> + </Extension> + +</Addin> diff --git a/Samples/HelloWorldWithManifest/HelloWorldAddin/HelloWorldAddin.csproj b/Samples/HelloWorldWithManifest/HelloWorldAddin/HelloWorldAddin.csproj new file mode 100644 index 0000000..c5fe307 --- /dev/null +++ b/Samples/HelloWorldWithManifest/HelloWorldAddin/HelloWorldAddin.csproj @@ -0,0 +1 @@ +<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{26C85FBC-0A97-4650-807F-E889C6D1F32F}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>HelloWorldAddin</RootNamespace>
<AssemblyName>HelloWorldAddin</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="HelloWorldAddin.addin.xml">
<LogicalName>HelloWorldAddin.addin.xml</LogicalName>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Compile Include="HelloCommand.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HelloWorld\HelloWorld.csproj">
<Project>{5F813963-DE40-433A-ABE3-71EACDF19412}</Project>
<Name>HelloWorld</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file diff --git a/Samples/HelloWorldWithManifest/HelloWorldWithManifest.sln b/Samples/HelloWorldWithManifest/HelloWorldWithManifest.sln new file mode 100644 index 0000000..b9084f1 --- /dev/null +++ b/Samples/HelloWorldWithManifest/HelloWorldWithManifest.sln @@ -0,0 +1,30 @@ +
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "HelloWorld\HelloWorld.csproj", "{5F813963-DE40-433A-ABE3-71EACDF19412}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorldAddin", "HelloWorldAddin\HelloWorldAddin.csproj", "{26C85FBC-0A97-4650-807F-E889C6D1F32F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x86 = Debug|x86
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {26C85FBC-0A97-4650-807F-E889C6D1F32F}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {26C85FBC-0A97-4650-807F-E889C6D1F32F}.Debug|x86.Build.0 = Debug|Any CPU
+ {26C85FBC-0A97-4650-807F-E889C6D1F32F}.Release|x86.ActiveCfg = Release|Any CPU
+ {26C85FBC-0A97-4650-807F-E889C6D1F32F}.Release|x86.Build.0 = Release|Any CPU
+ {5F813963-DE40-433A-ABE3-71EACDF19412}.Debug|x86.ActiveCfg = Debug|x86
+ {5F813963-DE40-433A-ABE3-71EACDF19412}.Debug|x86.Build.0 = Debug|x86
+ {5F813963-DE40-433A-ABE3-71EACDF19412}.Release|x86.ActiveCfg = Release|x86
+ {5F813963-DE40-433A-ABE3-71EACDF19412}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = HelloWorld\HelloWorld.csproj
+ Policies = $0
+ $0.ChangeLogPolicy = $1
+ $1.UpdateMode = Nearest
+ $1.inheritsSet = Mono
+ EndGlobalSection
+EndGlobal
|