Пример #1
0
        public static string Bonuses(int periodTypeID, int bonusID, CommonResourceFormat format = CommonResourceFormat.Default)
        {
            var resourceKeyPrefix = "Bonus";
            var padding           = 3;

            // Build our resource key
            var resourceKey = "{0}_{1}_{2}".FormatWith(resourceKeyPrefix, periodTypeID, bonusID.ToString().PadLeft(padding, '0'));

            if (format != CommonResourceFormat.Default)
            {
                resourceKey += "_{0}".FormatWith(format.ToString());
            }

            // Get the resource
            var resource = GetGlobalResource("Common", resourceKey, "{0} {1} {2}".FormatWith(resourceKeyPrefix, periodTypeID, bonusID));

            // If the resource is null and we asked for a specific format, get the default format instead.
            if (resource.IsNullOrEmpty() && format != CommonResourceFormat.Default)
            {
                return(Bonuses(periodTypeID, bonusID, CommonResourceFormat.Default));
            }
            else
            {
                return(resource);
            }
        }
        private static string GetCommonResource(object id, int padding, string resourceKeyPrefix, string classKey, CommonResourceFormat format = CommonResourceFormat.Default, string defaultDescription = "")
        {
            if (id == null)
            {
                id = string.Empty;
            }

            // Build our resource key
            var resourceKey = "{0}_{1}".FormatWith(resourceKeyPrefix, id.ToString().PadLeft(padding, '0'));

            if (format != CommonResourceFormat.Default)
            {
                resourceKey += "_{0}".FormatWith(format.ToString());
            }

            // Get the resource
            var fallback = (!defaultDescription.IsNullOrEmpty()) ? defaultDescription : (format == CommonResourceFormat.Default) ? "{0} {1}".FormatWith(resourceKeyPrefix, id) : string.Empty;
            var resource = GetGlobalResource("Common", resourceKey, fallback);

            // If the resource is null and we asked for a specific format, get the default format instead.
            if (resource.IsNullOrEmpty() && format != CommonResourceFormat.Default)
            {
                return(GetCommonResource(id, padding, resourceKeyPrefix, "Common"));
            }
            else
            {
                return(resource);
            }
        }
        public static string Bonuses(int periodTypeID, int bonusID, CommonResourceFormat format = CommonResourceFormat.Default)
        {
            var resourceKeyPrefix = "Bonus";
            var padding = 3;

            // Build our resource key
            var resourceKey = "{0}_{1}_{2}".FormatWith(resourceKeyPrefix, periodTypeID, bonusID.ToString().PadLeft(padding, '0'));
            if (format != CommonResourceFormat.Default) resourceKey += "_{0}".FormatWith(format.ToString());

            // Get the resource
            var resource = GetGlobalResource("Common", resourceKey, "{0} {1} {2}".FormatWith(resourceKeyPrefix, periodTypeID, bonusID));

            // If the resource is null and we asked for a specific format, get the default format instead.
            if (resource.IsNullOrEmpty() && format != CommonResourceFormat.Default)
            {
                return Bonuses(periodTypeID, bonusID, CommonResourceFormat.Default);
            }
            else
            {
                return resource;
            }
        }
Пример #4
0
        private static string GetCommonResource(int id, int padding, string resourceKeyPrefix, string classKey, CommonResourceFormat format = CommonResourceFormat.Default)
        {
            // Build our resource key
            var resourceKey = "{0}_{1}".FormatWith(resourceKeyPrefix, id.ToString().PadLeft(padding, '0'));

            if (format != CommonResourceFormat.Default)
            {
                resourceKey += "_{0}".FormatWith(format.ToString());
            }

            // Get the resource
            var resource = GetGlobalResource("Common", resourceKey, "{0} {1}".FormatWith(resourceKeyPrefix, id));

            // If the resource is null and we asked for a specific format, get the default format instead.
            if (resource.IsNullOrEmpty() && format != CommonResourceFormat.Default)
            {
                return(GetCommonResource(id, padding, resourceKeyPrefix, "Common"));
            }
            else
            {
                return(resource);
            }
        }
        private static string GetCommonResource(int id, int padding, string resourceKeyPrefix, string classKey, CommonResourceFormat format = CommonResourceFormat.Default)
        {
            // Build our resource key
            var resourceKey = "{0}_{1}".FormatWith(resourceKeyPrefix, id.ToString().PadLeft(padding, '0'));
            if (format != CommonResourceFormat.Default) resourceKey += "_{0}".FormatWith(format.ToString());

            // Get the resource
            var resource = GetGlobalResource("Common", resourceKey, "{0} {1}".FormatWith(resourceKeyPrefix, id));

            // If the resource is null and we asked for a specific format, get the default format instead.
            if (resource.IsNullOrEmpty() && format != CommonResourceFormat.Default)
            {
                return GetCommonResource(id, padding, resourceKeyPrefix, "Common");
            }
            else
            {
                return resource;
            }
        }