public static string ToAppropriateUnitFormatString(this ByteQuantifiedSize size, string valueFormat)
 {
     if (size.ToTB() > 0UL)
     {
         return(string.Format(OwaOptionStrings.MailboxUsageUnitTB, string.Format(CultureInfo.InvariantCulture, valueFormat, new object[]
         {
             size.ToBytes() / 1099511627776.0
         })));
     }
     if (size.ToGB() > 0UL)
     {
         return(string.Format(OwaOptionStrings.MailboxUsageUnitGB, string.Format(CultureInfo.InvariantCulture, valueFormat, new object[]
         {
             size.ToBytes() / 1073741824.0
         })));
     }
     if (size.ToMB() > 0UL)
     {
         return(string.Format(OwaOptionStrings.MailboxUsageUnitMB, string.Format(CultureInfo.InvariantCulture, valueFormat, new object[]
         {
             size.ToBytes() / 1048576.0
         })));
     }
     if (size.ToKB() > 0UL)
     {
         return(string.Format(OwaOptionStrings.MailboxUsageUnitKB, string.Format(CultureInfo.InvariantCulture, valueFormat, new object[]
         {
             size.ToBytes() / 1024.0
         })));
     }
     return(string.Format(CultureInfo.InvariantCulture, OwaOptionStrings.MailboxUsageUnitB, new object[]
     {
         size.ToBytes()
     }));
 }
Esempio n. 2
0
        protected override string FormatObject(string format, object arg, IFormatProvider formatProvider)
        {
            ByteQuantifiedSize byteQuantifiedSize = (ByteQuantifiedSize)arg;

            if (byteQuantifiedSize.ToGB() > 0UL)
            {
                return(Strings.ByteQuantifiedSizeAsGB(byteQuantifiedSize.ToGB()));
            }
            if (byteQuantifiedSize.ToMB() > 0UL)
            {
                return(Strings.ByteQuantifiedSizeAsMB(byteQuantifiedSize.ToMB()));
            }
            return(Strings.ByteQuantifiedSizeAsKB(byteQuantifiedSize.ToKB()));
        }
        internal static byte[] PackAndValidateCompressedRulePackage(byte[] uncompressedSerializedRulePackageData, ValidationContext validationContext)
        {
            byte[] array;
            if (!ClassificationDefinitionUtils.TryCompressXmlBytes(uncompressedSerializedRulePackageData, out array))
            {
                throw new ClassificationRuleCollectionStorageException();
            }
            ByteQuantifiedSize value = (ByteQuantifiedSize)DataClassificationConfigSchema.MaxRulePackageSize.DefaultValue;

            if (validationContext != null && validationContext.DcValidationConfig != null)
            {
                value = validationContext.DcValidationConfig.MaxRulePackageSize;
            }
            ByteQuantifiedSize value2 = ByteQuantifiedSize.FromBytes((ulong)((long)array.Length));

            if (value2 > value)
            {
                throw new ClassificationRuleCollectionPayloadSizeExceededLimitException(value2.ToKB(), value.ToKB());
            }
            return(array);
        }