Refactorisation de l'initialisation du workflow.
* Manager.cs: implémente la fonction de construction des fournisseurs définis par une interface (sans type, ni concret, ni abstrait, comme ceux du workflow). * WorkFlowManager.cs: refactorisation: utiliser le code commun pour instancier le fournisseur de données.
This commit is contained in:
parent
ca98af1611
commit
82b02b9c0c
3 changed files with 38 additions and 25 deletions
|
|
@ -1,3 +1,12 @@
|
||||||
|
2015-11-23 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
|
* Manager.cs: implémente la fonction de construction des
|
||||||
|
fournisseurs définis par une interface (sans type, ni concret,
|
||||||
|
ni abstrait, comme ceux du workflow).
|
||||||
|
|
||||||
|
* WorkFlowManager.cs: refactorisation: utiliser le code commun
|
||||||
|
pour instancier le fournisseur de données.
|
||||||
|
|
||||||
2015-11-23 Paul Schneider <paul@pschneider.fr>
|
2015-11-23 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
* ITitle.cs:
|
* ITitle.cs:
|
||||||
|
|
|
||||||
|
|
@ -59,5 +59,10 @@ namespace Yavsc.Model {
|
||||||
bp.Initialize (celt.Name, celt.Parameters);
|
bp.Initialize (celt.Name, celt.Parameters);
|
||||||
return bp as TProvider;
|
return bp as TProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ProviderBase GetDefaultProvider (string configSetion)
|
||||||
|
{
|
||||||
|
return GetDefaultProvider<ProviderBase>(configSetion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using System.Collections.Specialized;
|
||||||
using Yavsc.Model.FrontOffice;
|
using Yavsc.Model.FrontOffice;
|
||||||
using System.Configuration.Provider;
|
using System.Configuration.Provider;
|
||||||
using Yavsc.Model.FrontOffice.Catalog;
|
using Yavsc.Model.FrontOffice.Catalog;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Yavsc.Model.WorkFlow
|
namespace Yavsc.Model.WorkFlow
|
||||||
{
|
{
|
||||||
|
|
@ -15,6 +16,26 @@ namespace Yavsc.Model.WorkFlow
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class WorkFlowManager
|
public static class WorkFlowManager
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Finds the activity.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The activity.</returns>
|
||||||
|
/// <param name="pattern">Pattern.</param>
|
||||||
|
public static IEnumerable<Activity> FindActivity(string pattern = "%")
|
||||||
|
{
|
||||||
|
throw new NotImplementedException ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the activity.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The activity.</returns>
|
||||||
|
/// <param name="MAECode">MAE code.</param>
|
||||||
|
public static Activity GetActivity (string MAECode)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException ();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the catalog.
|
/// Gets or sets the catalog.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -123,33 +144,11 @@ namespace Yavsc.Model.WorkFlow
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The content provider.</value>
|
/// <value>The content provider.</value>
|
||||||
public static IContentProvider ContentProvider {
|
public static IContentProvider ContentProvider {
|
||||||
|
|
||||||
get {
|
get {
|
||||||
DataProviderConfigurationSection c = (DataProviderConfigurationSection) ConfigurationManager.GetSection ("system.web/workflow");
|
|
||||||
if (c == null)
|
|
||||||
throw new Exception ("No system.web/workflow configuration section found");
|
|
||||||
ProviderSettings confprov = c.Providers[c.DefaultProvider] as ProviderSettings;
|
|
||||||
if (confprov == null)
|
|
||||||
throw new Exception ("Default workflow provider not found (system.web/workflow@defaultProvider)");
|
|
||||||
string clsName = confprov.Type;
|
|
||||||
if (clsName == null)
|
|
||||||
throw new Exception ("Provider type not specified (system.web/workflow@type)");
|
|
||||||
|
|
||||||
if (contentProvider != null)
|
|
||||||
{
|
|
||||||
if (contentProvider.GetType ().Name != clsName)
|
|
||||||
contentProvider = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contentProvider == null)
|
if (contentProvider == null)
|
||||||
{
|
contentProvider = ManagerHelper.GetDefaultProvider
|
||||||
Type cpt = Type.GetType (clsName);
|
("system.web/workflow") as IContentProvider;
|
||||||
if (cpt == null)
|
|
||||||
throw new Exception (string.Format("Type not found : {0} (wrong name, or missing assembly reference?)",clsName));
|
|
||||||
System.Reflection.ConstructorInfo ci =cpt.GetConstructor (System.Type.EmptyTypes);
|
|
||||||
contentProvider = (IContentProvider)ci.Invoke (System.Type.EmptyTypes);
|
|
||||||
}
|
|
||||||
contentProvider.Initialize (confprov.Name, confprov.Parameters);
|
|
||||||
|
|
||||||
return contentProvider;
|
return contentProvider;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue