Skip to content

Commit

Permalink
Merge pull request #1476 from PrismLibrary/module-minor
Browse files Browse the repository at this point in the history
Modularity Alignment
  • Loading branch information
dansiegel authored Jun 14, 2018
2 parents 859fc9e + 9e9eca6 commit 7356b9c
Show file tree
Hide file tree
Showing 35 changed files with 128 additions and 174 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ public interface IModuleManager
/// Loads and initializes the module on the <see cref="ModuleCatalog"/> with the name <paramref name="moduleName"/>.
/// </summary>
/// <param name="moduleName">Name of the module requested for initialization.</param>
void LoadModule(string moduleName);
void LoadModule(string moduleName);

#if NET45
/// <summary>
/// Raised repeatedly to provide progress as modules are downloaded.
/// </summary>
event EventHandler<ModuleDownloadProgressChangedEventArgs> ModuleDownloadProgressChanged;
#endif

/// <summary>
/// Raised when a module is loaded or fails to load.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#if NET45

using System;
using System.ComponentModel;
Expand Down Expand Up @@ -58,3 +58,4 @@ private static int CalculateProgressPercentage(long bytesReceived, long totalByt
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,33 @@ public ModuleInfo(string name, string type, params string[] dependsOn)
{
}

/// <summary>
/// Initializes a new instance of <see cref="ModuleInfo"/>.
/// </summary>
/// <param name="moduleType">The module's type.</param>
public ModuleInfo(Type moduleType)
: this(moduleType, moduleType.Name) { }

/// <summary>
/// Initializes a new instance of <see cref="ModuleInfo"/>.
/// </summary>
/// <param name="moduleType">The module's type.</param>
/// <param name="moduleName">The module's name.</param>
public ModuleInfo(Type moduleType, string moduleName)
: this(moduleType, moduleName, InitializationMode.WhenAvailable) { }

/// <summary>
/// Initializes a new instance of <see cref="ModuleInfo"/>.
/// </summary>
/// <param name="moduleType">The module's type.</param>
/// <param name="moduleName">The module's name.</param>
/// <param name="initializationMode">The module's <see cref="InitializationMode"/>.</param>
public ModuleInfo(Type moduleType, string moduleName, InitializationMode initializationMode)
: this(moduleName, moduleType.AssemblyQualifiedName)
{
InitializationMode = initializationMode;
}

/// <summary>
/// Gets or sets the name of the module.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions Source/Prism/Prism.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
<PackageReference Condition=" '$(TargetFramework)' == 'netstandard1.0' " Include="System.Resources.ResourceManager" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.0' Or $(TargetFramework.StartsWith('uap10.0')) ">
<Compile Remove="**\*.Desktop.cs" />
<None Include="**\*.Desktop.cs" />
</ItemGroup>

<ItemGroup>
<Compile Condition=" '$(TargetFramework)' == 'net45' " Remove="Navigation/**" />
<Compile Update="Properties\Resources.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="Resources.resx" />
Expand Down
39 changes: 37 additions & 2 deletions Source/Prism/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions Source/Prism/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@
<data name="EventAggregatorNotConstructedOnUIThread" xml:space="preserve">
<value>To use the UIThread option for subscribing, the EventAggregator must be constructed on the UI thread.</value>
</data>
<data name="FailedToLoadModule" xml:space="preserve">
<value>An exception occurred while initializing module '{0}'.
- The exception message was: {2}
- The Assembly that the module was trying to be loaded from was:{1}
Check the InnerException property of the exception for more information. If the exception occurred while creating an object in a DI container, you can exception.GetRootException() to help locate the root cause of the problem.</value>
</data>
<data name="FailedToLoadModuleNoAssemblyInfo" xml:space="preserve">
<value>An exception occurred while initializing module '{0}'.
- The exception message was: {1}
Check the InnerException property of the exception for more information. If the exception occurred
while creating an object in a DI container, you can exception.GetRootException() to help locate the
root cause of the problem.</value>
</data>
<data name="FailedToRetrieveModule" xml:space="preserve">
<value>Failed to load type for module {0}.
Error was: {1}.</value>
</data>
<data name="InvalidDelegateRerefenceTypeException" xml:space="preserve">
<value>Invalid Delegate Reference Type Exception</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<Modularity:ModuleCatalog xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:Modularity="clr-namespace:Prism.Modularity;assembly=Prism.Wpf">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:coreModularity="clr-namespace:Prism.Modularity;assembly=Prism"
xmlns:Modularity="clr-namespace:Prism.Modularity;assembly=Prism.Wpf">
<Modularity:ModuleInfoGroup Ref="ModuleGroup1" InitializationMode="OnDemand">
<Modularity:ModuleInfo ModuleName="Module1" ModuleType="Module1Type" />
<coreModularity:ModuleInfo ModuleName="Module1" ModuleType="Module1Type" />
</Modularity:ModuleInfoGroup>
<Modularity:ModuleInfoGroup Ref="ModuleGroup2" InitializationMode="WhenAvailable">
<Modularity:ModuleInfo ModuleName="Module2InModuleGroup2" ModuleType="Module2Type">
<Modularity:ModuleInfo.DependsOn>
<coreModularity:ModuleInfo ModuleName="Module2InModuleGroup2" ModuleType="Module2Type">
<coreModularity:ModuleInfo.DependsOn>
<sys:String>ModuleW</sys:String>
</Modularity:ModuleInfo.DependsOn>
</Modularity:ModuleInfo>
<Modularity:ModuleInfo ModuleName="Module3InModuleGroup2" ModuleType="ModuleType">
</Modularity:ModuleInfo>
</coreModularity:ModuleInfo.DependsOn>
</coreModularity:ModuleInfo>
<coreModularity:ModuleInfo ModuleName="Module3InModuleGroup2" ModuleType="ModuleType">
</coreModularity:ModuleInfo>
</Modularity:ModuleInfoGroup>
<Modularity:ModuleInfo Ref="Module3" ModuleName="Module3" ModuleType="Module3Type" />
<coreModularity:ModuleInfo Ref="Module3" ModuleName="Module3" ModuleType="Module3Type" />
</Modularity:ModuleCatalog>

36 changes: 0 additions & 36 deletions Source/Wpf/Prism.Wpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions Source/Wpf/Prism.Wpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -171,24 +171,6 @@
<data name="FailedToGetType" xml:space="preserve">
<value>Unable to retrieve the module type {0} from the loaded assemblies. You may need to specify a more fully-qualified type name.</value>
</data>
<data name="FailedToLoadModule" xml:space="preserve">
<value>An exception occurred while initializing module '{0}'.
- The exception message was: {2}
- The Assembly that the module was trying to be loaded from was:{1}
Check the InnerException property of the exception for more information. If the exception occurred while creating an object in a DI container, you can exception.GetRootException() to help locate the root cause of the problem.
</value>
</data>
<data name="FailedToLoadModuleNoAssemblyInfo" xml:space="preserve">
<value>An exception occurred while initializing module '{0}'.
- The exception message was: {1}
Check the InnerException property of the exception for more information. If the exception occurred
while creating an object in a DI container, you can exception.GetRootException() to help locate the
root cause of the problem. </value>
</data>
<data name="FailedToRetrieveModule" xml:space="preserve">
<value>Failed to load type for module {0}.
Error was: {1}.</value>
</data>
<data name="HostControlCannotBeNull" xml:space="preserve">
<value>HostControl cannot have null value when behavior attaches. </value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static IModuleCatalog AddModule<T>(this IModuleCatalog catalog, string na
/// <typeparam name="T">The <see cref="IModule"/> to check for.</typeparam>
public static bool Exists<T>(this IModuleCatalog catalog)
where T : IModule =>
catalog.Modules.Any(mi => mi.ModuleType == typeof(T));
catalog.Modules.Any(mi => mi.ModuleType == typeof(T).AssemblyQualifiedName);

/// <summary>
/// Exists the specified catalog and name.
Expand All @@ -57,7 +57,7 @@ public static bool Exists(this IModuleCatalog catalog, string name) =>
/// <typeparam name="T">The <see cref="IModule"/> to check.</typeparam>
public static bool IsInitialized<T>(this IModuleCatalog catalog)
where T : IModule =>
catalog.Modules.FirstOrDefault(mi => mi.ModuleType == typeof(T))?.State == ModuleState.Initialized;
catalog.Modules.FirstOrDefault(mi => mi.ModuleType == typeof(T).AssemblyQualifiedName)?.State == ModuleState.Initialized;

/// <summary>
/// Checks to see if the <see cref="IModule"/> is already initialized.
Expand Down
14 changes: 0 additions & 14 deletions Source/Xamarin/Prism.Forms/Modularity/IModuleInitializer.cs

This file was deleted.

21 changes: 0 additions & 21 deletions Source/Xamarin/Prism.Forms/Modularity/IModuleManager.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Source/Xamarin/Prism.Forms/Modularity/ModuleCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public IModuleCatalog AddModule(ModuleInfo moduleInfo)
throw new Exception($"A duplicated module with name {moduleInfo.ModuleName} has already been added.");

if (_items.Any(mi => mi.ModuleType == moduleInfo.ModuleType))
throw new Exception($"A duplicate module of type {moduleInfo.ModuleType.Name} has already been added.");
throw new Exception($"A duplicate module of type {moduleInfo.ModuleType} has already been added.");

_items.Add(moduleInfo);
return this;
Expand Down
57 changes: 0 additions & 57 deletions Source/Xamarin/Prism.Forms/Modularity/ModuleInfo.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Source/Xamarin/Prism.Forms/Modularity/ModuleInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public ModuleInitializer(IContainerExtension container)

public void Initialize(ModuleInfo moduleInfo)
{
var module = CreateModule(moduleInfo.ModuleType);
var module = CreateModule(Type.GetType(moduleInfo.ModuleType, true));
if (module != null)
{
module.RegisterTypes(_container);
Expand Down
Loading

0 comments on commit 7356b9c

Please sign in to comment.