示例#1
0
        /// <summary>
        /// Returns a short string representation for given <see cref="ResourceSizeUnit"/>
        /// </summary>
        /// <param name="unit">
        /// <see cref="ResourceSizeUnit"/>
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public static string RenderableForUnit(ResourceSizeUnit unit)
        {
            string unitString = null;

            switch (unit)
            {
            case ResourceSizeUnit.KiloBytes:
                unitString = "KB";
                break;

            case ResourceSizeUnit.MegaBytes:
                unitString = "MB";
                break;

            case ResourceSizeUnit.GigaBytes:
                unitString = "GB";
                break;

            default:
                unitString = string.Empty;
                break;
            }

            return(unitString);
        }
示例#2
0
        /// <summary>
        /// Returns converted size value for given <see cref="ResourceSizeUnit"/>
        /// </summary>
        /// <param name="unit">
        /// <see cref="ResourceSizeUnit"/>
        /// </param>
        /// <returns>
        /// The <see cref="float"/>.
        /// </returns>
        public float ValueConvertedTo(ResourceSizeUnit unit)
        {
            switch (unit)
            {
            case ResourceSizeUnit.Bytes:
                return(this.Bytes);

            case ResourceSizeUnit.KiloBytes:
                return(this.KiloBytes);

            case ResourceSizeUnit.MegaBytes:
                return(this.MegaBytes);

            case ResourceSizeUnit.GigaBytes:
                return(this.GigaBytes);
            }

            return(0.0f);
        }