Skip to content

Commit

Permalink
added SilverlightActivator project (for Windows Phone)
Browse files Browse the repository at this point in the history
added SilverlightActivator.NuGet project to build the NuGet package
  • Loading branch information
Mariano Gabriel Converti committed Nov 6, 2011
1 parent 4d6c567 commit ac392f1
Show file tree
Hide file tree
Showing 16 changed files with 854 additions and 0 deletions.
48 changes: 48 additions & 0 deletions SilverlightActivator.NuGet/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// <copyright file="AssemblyInfo.cs" company="open-source">
// No rights reserved. Copyright (c) 2011 by Mariano Converti, Damian Martinez, and Nico Bello
//
// Redistribution and use in source and binary forms, with or without modification, are permitted.
//
// The names of its contributors may not 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.
// </copyright>

using System;
using System.Reflection;
using System.Resources;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SilverlightActivator.NuGet")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SilverlightActivator.NuGet")]
[assembly: AssemblyCopyright("Copyright © 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f9fc135d-a42f-4d42-b935-a2c199c9646d")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: CLSCompliant(true)]
[assembly: NeutralResourcesLanguageAttribute("en-US")]
88 changes: 88 additions & 0 deletions SilverlightActivator.NuGet/SilverlightActivator.NuGet.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.20506</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C052C0D7-F6CB-40C0-85BF-2B44EA13081C}</ProjectGuid>
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SilverlightActivator.NuGet</RootNamespace>
<AssemblyName>SilverlightActivator.NuGet</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
<TargetFrameworkProfile>WindowsPhone71</TargetFrameworkProfile>
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
<SilverlightApplication>false</SilverlightApplication>
<ValidateXaml>true</ValidateXaml>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Bin\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Bin\Release</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Windows" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="System.Net" />
<Reference Include="mscorlib.extensions" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="content\App.xaml.transform">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SilverlightActivator.nuspec">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SilverlightActivator_WP\SilverlightActivator_WP.csproj">
<Project>{5406D531-ECF1-4458-B5A1-B8781495EF2A}</Project>
<Name>SilverlightActivator_WP</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
<ProjectExtensions />
<PropertyGroup>
<PostBuildEvent>md $(TargetDir)\lib
md $(TargetDir)\lib\sl4-wp71
copy SilverlightActivator.dll $(TargetDir)\lib\sl4-wp71\
del SilverlightActivator.pdb
del SilverlightActivator.dll
del SilverlightActivator.NuGet.dll
del SilverlightActivator.NuGet.pdb
$(SolutionDir)Tools\NuGet.exe pack $(TargetDir)SilverlightActivator.nuspec</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
15 changes: 15 additions & 0 deletions SilverlightActivator.NuGet/SilverlightActivator.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>SilverlightActivator</id>
<version>1.0.0</version>
<title>Silverlight Activator for Windows Phone</title>
<authors>Mariano Converti, Damian Martinez, and Nico Bello</authors>
<owners>Mariano Converti, Damian Martinez, and Nico Bello</owners>
<projectUrl>https://github.com/mconverti/silverlightactivator</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A NuGet package that allows other packages to execute some startup code in Silverlight for Windows Phone applications</description>
<language>en-US</language>
<tags>windowsphone</tags>
</metadata>
</package>
10 changes: 10 additions & 0 deletions SilverlightActivator.NuGet/content/App.xaml.transform
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:silverlightactivator="clr-namespace:SilverlightActivator;assembly=SilverlightActivator">

<Application.Resources>
<silverlightactivator:ActivationManager x:Name="SilverlightActivator" />
</Application.Resources>

</Application>
48 changes: 48 additions & 0 deletions SilverlightActivator.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightActivator.NuGet", "SilverlightActivator.NuGet\SilverlightActivator.NuGet.csproj", "{C052C0D7-F6CB-40C0-85BF-2B44EA13081C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightActivator_WP", "SilverlightActivator_WP\SilverlightActivator_WP.csproj", "{5406D531-ECF1-4458-B5A1-B8781495EF2A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Windows Phone = Debug|Windows Phone
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Windows Phone = Release|Windows Phone
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C052C0D7-F6CB-40C0-85BF-2B44EA13081C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C052C0D7-F6CB-40C0-85BF-2B44EA13081C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C052C0D7-F6CB-40C0-85BF-2B44EA13081C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{C052C0D7-F6CB-40C0-85BF-2B44EA13081C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{C052C0D7-F6CB-40C0-85BF-2B44EA13081C}.Debug|Windows Phone.ActiveCfg = Debug|Any CPU
{C052C0D7-F6CB-40C0-85BF-2B44EA13081C}.Debug|x86.ActiveCfg = Debug|Any CPU
{C052C0D7-F6CB-40C0-85BF-2B44EA13081C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C052C0D7-F6CB-40C0-85BF-2B44EA13081C}.Release|Any CPU.Build.0 = Release|Any CPU
{C052C0D7-F6CB-40C0-85BF-2B44EA13081C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C052C0D7-F6CB-40C0-85BF-2B44EA13081C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C052C0D7-F6CB-40C0-85BF-2B44EA13081C}.Release|Windows Phone.ActiveCfg = Release|Any CPU
{C052C0D7-F6CB-40C0-85BF-2B44EA13081C}.Release|x86.ActiveCfg = Release|Any CPU
{5406D531-ECF1-4458-B5A1-B8781495EF2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5406D531-ECF1-4458-B5A1-B8781495EF2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5406D531-ECF1-4458-B5A1-B8781495EF2A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{5406D531-ECF1-4458-B5A1-B8781495EF2A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{5406D531-ECF1-4458-B5A1-B8781495EF2A}.Debug|Windows Phone.ActiveCfg = Debug|Any CPU
{5406D531-ECF1-4458-B5A1-B8781495EF2A}.Debug|x86.ActiveCfg = Debug|Any CPU
{5406D531-ECF1-4458-B5A1-B8781495EF2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5406D531-ECF1-4458-B5A1-B8781495EF2A}.Release|Any CPU.Build.0 = Release|Any CPU
{5406D531-ECF1-4458-B5A1-B8781495EF2A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{5406D531-ECF1-4458-B5A1-B8781495EF2A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{5406D531-ECF1-4458-B5A1-B8781495EF2A}.Release|Windows Phone.ActiveCfg = Release|Any CPU
{5406D531-ECF1-4458-B5A1-B8781495EF2A}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
65 changes: 65 additions & 0 deletions SilverlightActivator_WP/ActivationManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// <copyright file="ActivationManager.cs" company="open-source">
// No rights reserved. Copyright (c) 2011 by Mariano Converti, Damian Martinez, and Nico Bello
//
// Redistribution and use in source and binary forms, with or without modification, are permitted.
//
// The names of its contributors may not 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.
// </copyright>

namespace SilverlightActivator
{
using System;
using System.Linq;
using System.Windows;

/// <summary>
/// Represents the activation entry point.
/// </summary>
public class ActivationManager
{
private static bool initialized = false;

/// <summary>
/// Initializes a new instance of the SilverlightActivator.ActivationManager class, containing the activation mechanisms.
/// </summary>
public ActivationManager()
{
if (!initialized)
{
Init();
initialized = true;
}
}

private static void Init()
{
Application.Current.Startup += OnStartup;
Application.Current.Exit += OnApplicationExit;
}

private static void OnStartup(object sender, StartupEventArgs e)
{
RunActivationMethods<ApplicationStartupMethodAttribute>();
}

private static void OnApplicationExit(object sender, EventArgs e)
{
RunActivationMethods<ApplicationExitMethodAttribute>();
}

private static void RunActivationMethods<T>() where T : BaseActivationMethodAttribute
{
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
// The activation methods are executed according to the specified order
var activationAttributes = assembly.GetActivationAttributes<T>().OrderBy(at => at.Order);
foreach (var attribute in activationAttributes)
{
attribute.InvokeMethod();
}
}
}
}
}
31 changes: 31 additions & 0 deletions SilverlightActivator_WP/ApplicationExitMethodAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// <copyright file="ApplicationExitMethodAttribute.cs" company="open-source">
// No rights reserved. Copyright (c) 2011 by Mariano Converti, Damian Martinez, and Nico Bello
//
// Redistribution and use in source and binary forms, with or without modification, are permitted.
//
// The names of its contributors may not 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.
// </copyright>

namespace SilverlightActivator
{
using System;

/// <summary>
/// Identifies activation methods that run while the application is exiting.
/// </summary>
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class ApplicationExitMethodAttribute : BaseActivationMethodAttribute
{
/// <summary>
/// Initializes a new instance of the ApplicationExitMethodAttribute class with the specified parameters.
/// </summary>
/// <param name="activationType">The activation type.</param>
/// <param name="methodName">The activation method name.</param>
public ApplicationExitMethodAttribute(Type activationType, string methodName)
: base(activationType, methodName)
{
}
}
}
31 changes: 31 additions & 0 deletions SilverlightActivator_WP/ApplicationStartupMethodAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// <copyright file="ApplicationStartupMethodAttribute.cs" company="open-source">
// No rights reserved. Copyright (c) 2011 by Mariano Converti, Damian Martinez, and Nico Bello
//
// Redistribution and use in source and binary forms, with or without modification, are permitted.
//
// The names of its contributors may not 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.
// </copyright>

namespace SilverlightActivator
{
using System;

/// <summary>
/// Identifies activation methods that run during the application starup.
/// </summary>
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class ApplicationStartupMethodAttribute : BaseActivationMethodAttribute
{
/// <summary>
/// Initializes a new instance of the ApplicationStartupMethodAttribute class with the specified parameters.
/// </summary>
/// <param name="activationType">The activation type.</param>
/// <param name="methodName">The activation method name.</param>
public ApplicationStartupMethodAttribute(Type activationType, string methodName)
: base(activationType, methodName)
{
}
}
}
Loading

0 comments on commit ac392f1

Please sign in to comment.