refactoring
This commit is contained in:
parent
8cec6d44e2
commit
7fc21f1056
25 changed files with 179 additions and 335 deletions
|
|
@ -1,60 +0,0 @@
|
|||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Yavsc.Model.WorkFlow.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// WF provider.
|
||||
/// </summary>
|
||||
public class WFProvider:ConfigurationElement
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
[ConfigurationProperty("name", IsKey=true, IsRequired=true)]
|
||||
public string Name {
|
||||
get {
|
||||
return (string) base ["name"];
|
||||
}
|
||||
set { base ["name"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type.
|
||||
/// </summary>
|
||||
/// <value>The type.</value>
|
||||
[ConfigurationProperty("type")]
|
||||
public string Type {
|
||||
get { return (string) this ["type"]; }
|
||||
set {
|
||||
this ["type"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the application.
|
||||
/// </summary>
|
||||
/// <value>The name of the application.</value>
|
||||
[ConfigurationProperty("applicationName")]
|
||||
public string ApplicationName {
|
||||
get {
|
||||
return (string)this ["applicationName"];
|
||||
}
|
||||
set {
|
||||
this ["applicationName"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the connection string.
|
||||
/// </summary>
|
||||
/// <value>The name of the connection string.</value>
|
||||
[ConfigurationProperty("connectionStringName")]
|
||||
public string ConnectionStringName {
|
||||
get { return (string)this ["connectionStringName"]; }
|
||||
set { this ["connectionStringName"] = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Yavsc.Model.WorkFlow.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// WF provider collection.
|
||||
/// </summary>
|
||||
public class WFProviderCollection : ConfigurationElementCollection
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the element key.
|
||||
/// </summary>
|
||||
/// <returns>The element key.</returns>
|
||||
/// <param name="element">Element.</param>
|
||||
protected override object GetElementKey (ConfigurationElement element)
|
||||
{
|
||||
return ((WFProvider) element).Name;
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates the new element.
|
||||
/// </summary>
|
||||
/// <returns>The new element.</returns>
|
||||
protected override ConfigurationElement CreateNewElement ()
|
||||
{
|
||||
return new WFProvider();
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the element.
|
||||
/// </summary>
|
||||
/// <returns>The element.</returns>
|
||||
/// <param name="name">Name.</param>
|
||||
public WFProvider GetElement (string name)
|
||||
{
|
||||
return this.BaseGet (name) as WFProvider;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Yavsc.Model.WorkFlow.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Workflow configuration.
|
||||
/// </summary>
|
||||
public class WorkflowConfiguration : ConfigurationSection
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the default provider.
|
||||
/// </summary>
|
||||
/// <value>The default provider.</value>
|
||||
[ConfigurationProperty("defaultProvider")]
|
||||
public string DefaultProvider {
|
||||
get { return (string)base ["defaultProvider"]; }
|
||||
set { base ["defaultProvider"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the providers.
|
||||
/// </summary>
|
||||
/// <value>The providers.</value>
|
||||
[ConfigurationProperty("providers")]
|
||||
[ConfigurationCollection(typeof(WFProvider),
|
||||
AddItemName = "add",
|
||||
ClearItemsName = "clear",
|
||||
RemoveItemName = "remove")]
|
||||
public WFProviderCollection Providers {
|
||||
get {
|
||||
return this["providers"] as WFProviderCollection;
|
||||
}
|
||||
|
||||
set {
|
||||
this["providers"]=value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using Yavsc.Model.WorkFlow;
|
||||
using System.Configuration;
|
||||
using Yavsc.Model.WorkFlow.Configuration;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace Yavsc.Model.WorkFlow
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
using System;
|
||||
using Yavsc.Model.WorkFlow;
|
||||
using System.Configuration;
|
||||
using Yavsc.Model.WorkFlow.Configuration;
|
||||
using System.Collections.Specialized;
|
||||
using Yavsc.Model.FrontOffice;
|
||||
using System.Configuration.Provider;
|
||||
|
||||
namespace Yavsc.Model.WorkFlow
|
||||
{
|
||||
|
|
@ -123,10 +123,10 @@ namespace Yavsc.Model.WorkFlow
|
|||
/// <value>The content provider.</value>
|
||||
public IContentProvider ContentProvider {
|
||||
get {
|
||||
WorkflowConfiguration c = (WorkflowConfiguration) ConfigurationManager.GetSection ("system.web/workflow");
|
||||
DataProviderConfigurationSection c = (DataProviderConfigurationSection) ConfigurationManager.GetSection ("system.web/workflow");
|
||||
if (c == null)
|
||||
throw new Exception ("No system.web/workflow configuration section found");
|
||||
WFProvider confprov = c.Providers.GetElement (c.DefaultProvider);
|
||||
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;
|
||||
|
|
@ -147,12 +147,7 @@ namespace Yavsc.Model.WorkFlow
|
|||
System.Reflection.ConstructorInfo ci =cpt.GetConstructor (System.Type.EmptyTypes);
|
||||
contentProvider = (IContentProvider)ci.Invoke (System.Type.EmptyTypes);
|
||||
}
|
||||
|
||||
NameValueCollection config = new NameValueCollection ();
|
||||
config.Add ("name", confprov.Name);
|
||||
config.Add ("connectionStringName", confprov.ConnectionStringName);
|
||||
config.Add ("applicationName", confprov.ApplicationName);
|
||||
contentProvider.Initialize (confprov.Name, config);
|
||||
contentProvider.Initialize (confprov.Name, confprov.Parameters);
|
||||
|
||||
return contentProvider;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue