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

            return(value * ((Decimal)from / (Decimal)to));
        }
Esempio n. 3
0
        public static UInt64 ConvertInformation(UInt64 value, InformationSize from, InformationSize to)
        {
            if (from == to)
            {
                return(value);
            }

            return(value * ((UInt64)from / (UInt64)to));
        }
Esempio n. 4
0
        public static Double ConvertInformation(Double value, InformationSize from, InformationSize to)
        {
            if (from == to)
            {
                return(value);
            }

            return(value * ((Double)from / (Double)to));
        }
Esempio n. 5
0
 public static Decimal ConvertToBit(this InformationSize from, Decimal value)
 {
     return(ConvertToBit(value, from));
 }
Esempio n. 6
0
 public static Decimal ConvertToBit(Decimal value, InformationSize from)
 {
     return(ConvertToBytes(value, from) * BitInBytes);
 }
Esempio n. 7
0
 public static Double ConvertToBit(this InformationSize from, Double value)
 {
     return(ConvertToBit(value, from));
 }
Esempio n. 8
0
 public static Double ConvertInformation(this InformationSize from, Double value, InformationSize to)
 {
     return(ConvertInformation(value, from, to));
 }
Esempio n. 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));
        }
Esempio n. 10
0
 public BandwidthStream(Stream stream, UInt64 speed, InformationSize size)
     : base(stream, speed, size)
 {
 }
Esempio n. 11
0
 public static UInt64 ConvertInformation(this InformationSize from, UInt64 value, InformationSize to)
 {
     return(ConvertInformation(value, from, to));
 }
Esempio n. 12
0
 public static UInt64 ConvertInformation(Int64 value, InformationSize from, InformationSize to)
 {
     return(value > 0 ? ConvertInformation(from, (UInt64)value, to) : 0);
 }
Esempio n. 13
0
 public static UInt64 ConvertInformation(UInt32 value, InformationSize from, InformationSize to)
 {
     return(ConvertInformation((UInt64)value, from, to));
 }
Esempio n. 14
0
 public static Decimal ConvertInformation(this InformationSize from, Decimal value, InformationSize to)
 {
     return(ConvertInformation(value, from, to));
 }
Esempio n. 15
0
 public static UInt64 ConvertToBytes(Int64 value, InformationSize from)
 {
     return(value > 0 ? ConvertToBytes(from, (UInt64)value) : 0);
 }
Esempio n. 16
0
 public static UInt64 ConvertToBytes(this InformationSize from, Int64 value)
 {
     return(ConvertToBytes(value, from));
 }
Esempio n. 17
0
 public static UInt64 ConvertToBit(this InformationSize from, UInt32 value)
 {
     return(ConvertToBit(value, from));
 }
Esempio n. 18
0
 public BandwidthStream(Stream stream, Int32 speed, InformationSize size, IScheduler scheduler)
     : base(stream, speed, size, scheduler)
 {
 }
Esempio n. 19
0
 public static UInt64 ConvertToBit(Int64 value, InformationSize from)
 {
     return(value > 0 ? ConvertToBit((UInt64)value, from) : 0);
 }
Esempio n. 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));
        }
Esempio n. 21
0
 public static UInt64 ConvertToBit(UInt64 value, InformationSize from)
 {
     return(ConvertToBytes(value, from) * BitInBytes);
 }
Esempio n. 22
0
 public static FileStream Reserve([NotNull] this FileStream stream, Int32 count, InformationSize type)
 {
     return(Reserve(stream, (Int64)type.ConvertToBytes(count)));
 }
Esempio n. 23
0
 public static Double ConvertToBit(Double value, InformationSize from)
 {
     return(ConvertToBytes(value, from) * BitInBytes);
 }