@@ -3694,4 +3694,76 @@ SELECT SERVERPROPERTY('Edition') AS Edition,
36943694 var spReturnClassName = WriteStoredProcReturnModelName(sp);
36953695 return (returnModelCount == 1) ? string.Format("System.Collections.Generic.List<{0}>", spReturnClassName) : spReturnClassName;
36963696 };
3697+
3698+ /// <summary>
3699+ /// Helper class in making dynamic class definitions easier.
3700+ /// </summary>
3701+ public sealed class BaseClassMaker
3702+ {
3703+ private string _typeName;
3704+ private System.Text.StringBuilder _interfaces;
3705+
3706+ public BaseClassMaker(string baseClassName = null)
3707+ {
3708+ SetBaseClassName(baseClassName);
3709+ }
3710+
3711+ /// <summary>
3712+ /// Sets the base-class name.
3713+ /// </summary>
3714+ public void SetBaseClassName(string typeName)
3715+ {
3716+ _typeName = typeName;
3717+ }
3718+
3719+ /// <summary>
3720+ /// Appends additional implemented interface.
3721+ /// </summary>
3722+ public bool AddInterface(string typeName)
3723+ {
3724+ if (string.IsNullOrEmpty(typeName))
3725+ return false;
3726+
3727+ if (_interfaces == null)
3728+ {
3729+ _interfaces = new System.Text.StringBuilder();
3730+ }
3731+ else
3732+ {
3733+ if (_interfaces.Length > 0)
3734+ {
3735+ _interfaces.Append(", ");
3736+ }
3737+ }
3738+
3739+ _interfaces.Append(typeName);
3740+ return true;
3741+ }
3742+
3743+ /// <summary>
3744+ /// Conditionally appends additional implemented interface.
3745+ /// </summary>
3746+ public bool AddInterface(string interfaceName, bool condition)
3747+ {
3748+ if (condition)
3749+ {
3750+ return AddInterface(interfaceName);
3751+ }
3752+
3753+ return false;
3754+ }
3755+
3756+ public override string ToString()
3757+ {
3758+ var hasInterfaces = _interfaces != null && _interfaces.Length > 0;
3759+
3760+ if (string.IsNullOrEmpty(_typeName))
3761+ {
3762+ return hasInterfaces ? " : " + _interfaces : string.Empty;
3763+ }
3764+
3765+ return hasInterfaces ? string.Concat(" : ", _typeName, ", ", _interfaces) : " : " + _typeName;
3766+ }
3767+ }
3768+
36973769#>
0 commit comments