示例#1
0
 public static UInt64 ConvertToBytes(UInt64 value, InformationSize from)
 {
     return(from switch
     {
         InformationSize.Bit => value / BitInBytes,
         InformationSize.Byte => value,
         _ => value * ((UInt64)from / BitInBytes)
     });
示例#2
0
        public static Decimal ConvertInformation(Decimal value, InformationSize from, InformationSize to)
        {
            if (from == to)
            {
                return(value);
            }

            return(value * ((Decimal)from / (Decimal)to));
        }
示例#3
0
        public static UInt64 ConvertInformation(UInt64 value, InformationSize from, InformationSize to)
        {
            if (from == to)
            {
                return(value);
            }

            return(value * ((UInt64)from / (UInt64)to));
        }
示例#4
0
        public static Double ConvertInformation(Double value, InformationSize from, InformationSize to)
        {
            if (from == to)
            {
                return(value);
            }

            return(value * ((Double)from / (Double)to));
        }
示例#5
0
 public static Decimal ConvertToBit(this InformationSize from, Decimal value)
 {
     return(ConvertToBit(value, from));
 }
示例#6
0
 public static Decimal ConvertToBit(Decimal value, InformationSize from)
 {
     return(ConvertToBytes(value, from) * BitInBytes);
 }
示例#7
0
 public static Double ConvertToBit(this InformationSize from, Double value)
 {
     return(ConvertToBit(value, from));
 }
示例#8
0
 public static Double ConvertInformation(this InformationSize from, Double value, InformationSize to)
 {
     return(ConvertInformation(value, from, to));
 }
示例#9
0
        public static BandwidthStream <T> Bandwidth <T>([NotNull] this T stream, UInt64 speed = UInt64.MaxValue, InformationSize size = InformationSize.Byte) where T : Stream
        {
            if (stream is null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            return(new BandwidthStream <T>(stream, speed, size));
        }
示例#10
0
 public BandwidthStream(Stream stream, UInt64 speed, InformationSize size)
     : base(stream, speed, size)
 {
 }
示例#11
0
 public static UInt64 ConvertInformation(this InformationSize from, UInt64 value, InformationSize to)
 {
     return(ConvertInformation(value, from, to));
 }
示例#12
0
 public static UInt64 ConvertInformation(Int64 value, InformationSize from, InformationSize to)
 {
     return(value > 0 ? ConvertInformation(from, (UInt64)value, to) : 0);
 }
示例#13
0
 public static UInt64 ConvertInformation(UInt32 value, InformationSize from, InformationSize to)
 {
     return(ConvertInformation((UInt64)value, from, to));
 }
示例#14
0
 public static Decimal ConvertInformation(this InformationSize from, Decimal value, InformationSize to)
 {
     return(ConvertInformation(value, from, to));
 }
示例#15
0
 public static UInt64 ConvertToBytes(Int64 value, InformationSize from)
 {
     return(value > 0 ? ConvertToBytes(from, (UInt64)value) : 0);
 }
示例#16
0
 public static UInt64 ConvertToBytes(this InformationSize from, Int64 value)
 {
     return(ConvertToBytes(value, from));
 }
示例#17
0
 public static UInt64 ConvertToBit(this InformationSize from, UInt32 value)
 {
     return(ConvertToBit(value, from));
 }
示例#18
0
 public BandwidthStream(Stream stream, Int32 speed, InformationSize size, IScheduler scheduler)
     : base(stream, speed, size, scheduler)
 {
 }
示例#19
0
 public static UInt64 ConvertToBit(Int64 value, InformationSize from)
 {
     return(value > 0 ? ConvertToBit((UInt64)value, from) : 0);
 }
示例#20
0
        public static BandwidthStream Bandwidth([NotNull] this Stream stream, Int32 speed, InformationSize size)
        {
            if (stream is null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            return(new BandwidthStream(stream, speed, size));
        }
示例#21
0
 public static UInt64 ConvertToBit(UInt64 value, InformationSize from)
 {
     return(ConvertToBytes(value, from) * BitInBytes);
 }
示例#22
0
 public static FileStream Reserve([NotNull] this FileStream stream, Int32 count, InformationSize type)
 {
     return(Reserve(stream, (Int64)type.ConvertToBytes(count)));
 }
示例#23
0
 public static Double ConvertToBit(Double value, InformationSize from)
 {
     return(ConvertToBytes(value, from) * BitInBytes);
 }