120 lines
4.6 KiB
C#
120 lines
4.6 KiB
C#
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Base.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using static Sarand.BusinessMgr.Net.Standard.Base.App.SbmInstanceConfig;
|
|
|
|
namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
|
{
|
|
//=======================================================================
|
|
/// <summary>
|
|
/// Application configuration associated with an instance.
|
|
/// </summary>
|
|
public abstract class SbmInstanceConfig
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Definitions.
|
|
protected const String ParamContext_Config = "Config";
|
|
protected const String ParamContext_ConfigPrefix = "Config-";
|
|
protected const String ApplicationOptionValue_Allow = "Allow";
|
|
protected const String ApplicationOptionValue_Disallow = "Disallow";
|
|
protected const String ApplicationOptionValue_Default= "Default";
|
|
|
|
//-------------------------------------------------------------------
|
|
// Owner/Instance configuration parameters.
|
|
public enum ConfigParamType
|
|
{
|
|
// Affiliate types.
|
|
AllowedAffiliateTypes,
|
|
DisallowedAffiliateTypes,
|
|
// Association types.
|
|
AllowedAssociationTypes,
|
|
DisallowedAssociationTypes,
|
|
// Transaction types.
|
|
AllowedTransactionTypes,
|
|
DisallowedTransactionTypes,
|
|
// Application options.
|
|
ApplicationOption,
|
|
}
|
|
public class ConfigParamData
|
|
{
|
|
public ConfigParamType ConfigParam { get; set; }
|
|
public String Context { get; set; }
|
|
public String Name { get; set; }
|
|
public HashSet<String> Values { get; } = new HashSet<string>();
|
|
public bool Password { get; set; }
|
|
}
|
|
|
|
public bool IsConfigParamOfType(ConfigParamType configParam, SbmcItemParam itemParam)
|
|
{
|
|
switch (configParam)
|
|
{
|
|
// Affiliate types.
|
|
case ConfigParamType.AllowedAffiliateTypes:
|
|
case ConfigParamType.DisallowedAffiliateTypes:
|
|
// Association types.
|
|
case ConfigParamType.AllowedAssociationTypes:
|
|
case ConfigParamType.DisallowedAssociationTypes:
|
|
// Transaction types.
|
|
case ConfigParamType.AllowedTransactionTypes:
|
|
case ConfigParamType.DisallowedTransactionTypes:
|
|
return itemParam.Context.EqualsCI(ParamContext_Config) && itemParam.Name.EqualsCI(configParam.ToString());
|
|
// Application options.
|
|
case ConfigParamType.ApplicationOption:
|
|
return itemParam.Context.EqualsCI($"{ParamContext_ConfigPrefix}{ConfigParamType.ApplicationOption.ToString()}");
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public ConfigParamData GetConfigParamData(ConfigParamType configParam)
|
|
{
|
|
switch (configParam)
|
|
{
|
|
// Affiliate types.
|
|
case ConfigParamType.AllowedAffiliateTypes:
|
|
case ConfigParamType.DisallowedAffiliateTypes:
|
|
// Association types.
|
|
case ConfigParamType.AllowedAssociationTypes:
|
|
case ConfigParamType.DisallowedAssociationTypes:
|
|
// Transaction types.
|
|
case ConfigParamType.AllowedTransactionTypes:
|
|
case ConfigParamType.DisallowedTransactionTypes:
|
|
return new ConfigParamData() { ConfigParam = configParam, Context = ParamContext_Config, Name = configParam.ToString() };
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public ConfigParamData GetAllowOptionConfigParamData(Sbm.ConfigOption option)
|
|
{
|
|
ConfigParamData configParamData = new ConfigParamData() { ConfigParam = ConfigParamType.ApplicationOption, Context = $"{ParamContext_ConfigPrefix}{ConfigParamType.ApplicationOption.ToString()}", Name = option.ToString() };
|
|
configParamData.Values.UnionWith(new List<String>() { ApplicationOptionValue_Allow, ApplicationOptionValue_Disallow, ApplicationOptionValue_Default });
|
|
return configParamData;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Application options.
|
|
//-------------------------------------------------------------------
|
|
public abstract bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse);
|
|
|
|
//-------------------------------------------------------------------
|
|
// Allowed data component types.
|
|
//-------------------------------------------------------------------
|
|
// Supported affiliate types.
|
|
public abstract bool AllowAffiliateType(Sbm.AffiliateType type);
|
|
// Supported Association types.
|
|
public abstract bool AllowAssociationType(Sbm.AssociationType type);
|
|
// Supported Transaction types.
|
|
public abstract bool AllowTransactionType(Sbm.TransactionType type);
|
|
|
|
//-------------------------------------------------------------------
|
|
// Allow Option.
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|