public int ByteSize() { var size = ByteSizes.Size(FirstObjectNumber); size += ByteSizes.Size(ObjectCount); size += 3; // 1 space + CR LF size += ObjectCount * 20; return(size); }
/// <summary> /// Write a <see cref="long"/> to the stream /// </summary> /// <param name="value">The long to write</param> /// <returns>The calling <see cref="PdfStream"/> to support chaining operations.</returns> public PdfStream Write(long value) { var intSize = ByteSizes.Size(value); for (int i = intSize - 1; i >= 0; i--) { var result = (byte)('0' + ((int)(value / Math.Pow(10, i)) % 10)); InnerStream.WriteByte(result); } return(this); }
/// <summary> /// Convierte un cantidad de un tamaño a otro /// </summary> /// <param name="units">Cantidad a convertir</param> /// <param name="currentUnit">Unidad de origen</param> /// <param name="destinationUnit">Unidad a la que se quiere convertir</param> /// <returns>Cantidad convertida</returns> public static double ConvertToByteUnit(this double units, ByteSizes currentUnit, ByteSizes destinationUnit) { int diff = (int)destinationUnit - (int)currentUnit; bool negative = diff < 0; diff = Math.Abs(diff); if (diff == 0) { return(units); } if (negative) { return(units * Math.Pow(1024L, diff)); } return(units / Math.Pow(1024L, diff)); }
/// <summary> /// Convierte un cantidad de un tamaño a otro /// </summary> /// <param name="units">Cantidad a convertir</param> /// <param name="currentUnit">Unidad de origen</param> /// <param name="destinationUnit">Unidad a la que se quiere convertir</param> /// <returns>Cantidad convertida</returns> public static double ConvertToByteUnit(this float units, ByteSizes currentUnit, ByteSizes destinationUnit) { var unitsConverted = Convert.ToDouble(units); return(unitsConverted.ConvertToByteUnit(currentUnit, destinationUnit)); }