BO4E/BoMapper.cs
/// <summary>
///     Returns a Type for given Business Object name. This method is useful to avoid stringified code.
/// </summary>
/// <param name="businessObjectName">name of a business object; is lenient regarding upper/lower case</param>
/// <returns>a BusinessObjectType or null if no matching type was found</returns>
/// <exception cref="ArgumentNullException">if argument is null</exception>
/// <example>
///     <code>
/// BoMapper.GetTypeForBoName("Energiemenge"); // returns typeof(BO4E.BO.Energiemenge)
/// BoMapper.GetTypeForBoName("eNeRgIeMENgE"); // returns typeof(BO4E.BO.Energiemenge)
/// BoMapper.GetTypeForBoName("non existent BO"); // returns null
/// </code>
/// </example>
Returns a Type for given Business Object name. This method is useful to avoid stringified code.
Returns a Type for given Business Object name . This method is useful to avoid stringified code .
public static Type GetTypeForBoName(string businessObjectName)
        {
            if (businessObjectName == null) throw new ArgumentNullException(nameof(businessObjectName));
            var clazz = Assembly.GetExecutingAssembly().GetType(PackagePrefix + "." + businessObjectName);
            return clazz != null
                ? clazz
                : (from boName in GetValidBoNames()
                   where string.Equals(boName, businessObjectName, StringComparison.CurrentCultureIgnoreCase)
                   select Assembly.GetExecutingAssembly().GetType(PackagePrefix + "." + boName)).FirstOrDefault();
        }
public static Type GetTypeForBoName ( string businessObjectName ) { if ( businessObjectName == null ) throw new ArgumentNullException ( nameof ( businessObjectName ) ) ; var clazz = Assembly . GetExecutingAssembly ( ) . GetType ( PackagePrefix + " " + businessObjectName ) ; return clazz != null ? clazz : ( from boName in GetValidBoNames ( ) where string . Equals ( boName , businessObjectName , StringComparison . CurrentCultureIgnoreCase ) select Assembly . GetExecutingAssembly ( ) . GetType ( PackagePrefix + " " + boName ) ) . FirstOrDefault ( ) ; }
Returns a Type for given Business Object name.
Returns a Type for given Business Object name .
//Type[] types = Assembly.GetExecutingAssembly().GetTypes(); //throw new ArgumentException($"No implemented BusinessObject type matches the name '{businessObjectName}'.");
a BusinessObjectType or null if no matching type was found
a BusinessObjectType or null if no matching type was found
if argument is null
if argument is null
businessObjectName
string
name of a business object; is lenient regarding upper/lower case
name of a business object ; is lenient regarding upper / lower case
example
BoMapper.GetTypeForBoName("Energiemenge"); // returns typeof(BO4E.BO.Energiemenge)
BoMapper.GetTypeForBoName("eNeRgIeMENgE"); // returns typeof(BO4E.BO.Energiemenge)
BoMapper.GetTypeForBoName("non existent BO"); // returns null
BoMapper . GetTypeForBoName ( " Energiemenge " ) ; // returns typeof ( BO4E . BO . Energiemenge ) BoMapper . GetTypeForBoName ( " eNeRgIeMENgE " ) ; // returns typeof ( BO4E . BO . Energiemenge ) BoMapper . GetTypeForBoName ( " non existent BO " ) ; // returns null