public AliasedPrefixedUnitInfo(
     string fieldName,
     UnitShortCodeSource unitShortCode,
     string scaleFactor,
     string fromMethodNameSufix,
     TypeCodeAliases aliases)
     : base(fieldName, unitShortCode, scaleFactor, fromMethodNameSufix)
 {
     Aliases = aliases;
 }
Exemplo n.º 2
0
        public RelatedUnit WithPrefixedUnit(string unitShortName, string fieldName,
                                            decimal multiplicator, string fromMethodNameSufix = null, TypeCodeAliases aliases = null,
                                            Action <AliasedPrefixedUnitInfo> extraSettings    = null)
        {
            if (aliases != null)
            {
                if (string.IsNullOrWhiteSpace(fieldName))
                {
                    if (!string.IsNullOrWhiteSpace(aliases.NameSingular))
                    {
                        fieldName = aliases.NameSingular.FirstUpper();
                    }
                }
                if (string.IsNullOrWhiteSpace(fromMethodNameSufix))
                {
                    if (!string.IsNullOrWhiteSpace(aliases.NamePlural))
                    {
                        fromMethodNameSufix = aliases.NamePlural.FirstUpper();
                    }
                }
            }

            AliasedPrefixedUnitInfo info = new AliasedPrefixedUnitInfo(fieldName,
                                                                       UnitShortCodeSource.MakeDirect(unitShortName), multiplicator.CsEncode(),
                                                                       fromMethodNameSufix, aliases);

            if (extraSettings != null)
            {
                extraSettings(info);
            }
            Units.Add(info);
            return(this);
        }