private string FormatPropertyParagraph(string propName, object value)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(propName + ": ");
            StringBuilder stringBuilder2 = new StringBuilder();

            if (value == null)
            {
                stringBuilder2.Append(string.Empty);
            }
            else if (value is Enum)
            {
                stringBuilder2.Append(LocalizedDescriptionAttribute.FromEnum(value.GetType(), value));
            }
            else
            {
                if (value is Array)
                {
                    using (IEnumerator enumerator = ((Array)value).GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            object obj = enumerator.Current;
                            stringBuilder2.Append(" " + obj.ToString());
                        }
                        goto IL_AB;
                    }
                }
                stringBuilder2.Append(value.ToString());
            }
IL_AB:
            stringBuilder.Append(stringBuilder2.ToString());
            return(stringBuilder.ToString());
        }
        private static string AtomToString(object item)
        {
            string text = string.Empty;

            if (item != null)
            {
                if (item is Enum)
                {
                    text = LocalizedDescriptionAttribute.FromEnum(item.GetType(), item);
                }
                else if (item is ADObjectId)
                {
                    ADObjectId adobjectId = (ADObjectId)item;
                    text = ((!string.IsNullOrEmpty(adobjectId.Name)) ? adobjectId.Name : adobjectId.ToString());
                }
                else if (item is CultureInfo)
                {
                    text = ((CultureInfo)item).DisplayName;
                }
                else if (item is DateTime)
                {
                    text = ((DateTime)item).ToLongDateString();
                }
                else
                {
                    text = item.ToString();
                }
                if (string.IsNullOrEmpty(text))
                {
                    text = string.Empty;
                }
            }
            return(text);
        }
Beispiel #3
0
        private string GetLocalizedString(string[] elements)
        {
            StringBuilder stringBuilder = new StringBuilder();

            foreach (string text in elements)
            {
                if (text.Length > 1 && text[0] == '<' && text[text.Length - 1] == '>')
                {
                    string value = text.Substring(1, text.Length - 2);
                    if (Enum.IsDefined(typeof(GroupNamingPolicyAttributeEnum), value))
                    {
                        GroupNamingPolicyAttributeEnum groupNamingPolicyAttributeEnum = (GroupNamingPolicyAttributeEnum)Enum.Parse(typeof(GroupNamingPolicyAttributeEnum), value);
                        stringBuilder.AppendFormat("<{0}>", LocalizedDescriptionAttribute.FromEnum(typeof(GroupNamingPolicyAttributeEnum), groupNamingPolicyAttributeEnum));
                    }
                    else
                    {
                        stringBuilder.Append(DistributionGroupNamingPolicy.UnescapeText(text));
                    }
                }
                else
                {
                    stringBuilder.Append(DistributionGroupNamingPolicy.UnescapeText(text));
                }
            }
            return(stringBuilder.ToString());
        }
Beispiel #4
0
        public void TestWhetherAttributesAreBeingLocalizedProperly(string testCulture)
        {
            //choose culture based on given test case
            ICultureInfoProvider _cultureProvider = new CustomCultureProvider(string.IsNullOrEmpty(testCulture)
          ? CultureInfo.CurrentCulture
          : CultureInfo.GetCultureInfo(testCulture));
            IAppResourcesProxy _resourceProxy = new AppResourcesProxy(_cultureProvider);

            LocalizedDescriptionAttribute.ResourcesProxy = _resourceProxy;

            //obtain properties
            PropertyInfo firstPropertyInfo =
                typeof(TestInstrumentation).GetProperty(nameof(TestInstrumentation.MyFirstTestProperty));
            PropertyInfo secondPropertyInfo =
                typeof(TestInstrumentation).GetProperty(nameof(TestInstrumentation.MySecondTestProperty));

            //obtain attributes
            LocalizedDescriptionAttribute _firstAttribute =
                firstPropertyInfo.GetCustomAttribute <LocalizedDescriptionAttribute>();
            LocalizedDescriptionAttribute _secondAttribute =
                secondPropertyInfo.GetCustomAttribute <LocalizedDescriptionAttribute>();

            //asserts
            Assert.AreEqual(_firstAttribute.Description, _resourceProxy.GetString(_firstAttribute.LocalizationKey));
            Assert.AreEqual(_secondAttribute.Description, _resourceProxy.GetString(_secondAttribute.LocalizationKey));
        }
        protected virtual string FormatObject(string format, object arg, IFormatProvider formatProvider)
        {
            string result = this.NullValueText;
            Type   type   = arg.GetType();

            if (type == typeof(DateTime) && format == null)
            {
                format = "F";
            }
            if (type.IsEnum)
            {
                result = LocalizedDescriptionAttribute.FromEnum(arg.GetType(), arg);
            }
            else if (typeof(IFormattable).IsAssignableFrom(type))
            {
                result = ((IFormattable)arg).ToString(format, formatProvider);
            }
            else if (type == typeof(bool))
            {
                result = (((bool)arg) ? Strings.TrueString : Strings.FalseString);
            }
            else if (type == typeof(double) || type == typeof(float))
            {
                result = ((double)arg).ToString(TextConverter.DoubleFormatString);
            }
            else
            {
                result = arg.ToString();
            }
            return(result);
        }
Beispiel #6
0
        private string GetDescription(Type resourcesType, Type enumType, string name)
        {
            FieldInfo field = enumType.GetField(name);

            if (field == (FieldInfo)null)
            {
                return(string.Empty);
            }
            LocalizedDescriptionAttribute descriptionAttribute = field.GetCustomAttributes(false).OfType <LocalizedDescriptionAttribute>().FirstOrDefault <LocalizedDescriptionAttribute>();

            if (descriptionAttribute != null)
            {
                return(descriptionAttribute.Description);
            }
            if (resourcesType != (Type)null)
            {
                ResourceManager resourceManager = new ResourceManager(resourcesType);
                string          name1           = enumType.Name + name;
                string          str             = resourceManager.GetString(name1, ResourceHelper.CurrentUICulture) ?? resourceManager.GetString(name, ResourceHelper.CurrentCulture);
                if (str != null)
                {
                    return(str);
                }
            }
            return(name);
        }
        public static void GetObjectPostAction(DataRow inputRow, DataTable dataTable, DataObjectStore store)
        {
            DataRow dataRow = dataTable.Rows[0];
            string  value   = string.Empty;

            dataRow["IsPrecannedRecipientFilterType"] = (dataRow["IsCustomRecipientFilterType"] = (dataRow["IsOtherRecipientFilterType"] = false));
            if (dataRow["RecipientFilterType"] != DBNull.Value)
            {
                switch ((WellKnownRecipientFilterType)dataRow["RecipientFilterType"])
                {
                case WellKnownRecipientFilterType.Unknown:
                case WellKnownRecipientFilterType.Legacy:
                    dataRow["IsOtherRecipientFilterType"] = true;
                    value = Strings.CustomFilterDescription((string)dataRow["LdapRecipientFilter"]);
                    break;

                case WellKnownRecipientFilterType.Custom:
                    dataRow["IsCustomRecipientFilterType"] = true;
                    value = Strings.CustomFilterDescription((string)dataRow["RecipientFilter"]);
                    break;

                case WellKnownRecipientFilterType.Precanned:
                    dataRow["IsPrecannedRecipientFilterType"] = true;
                    value = LocalizedDescriptionAttribute.FromEnum(typeof(WellKnownRecipientType), dataRow["IncludedRecipients"]);
                    break;

                default:
                    throw new NotSupportedException("Unkown WellKnownRecipientFilterType: " + dataRow["RecipientFilterType"].ToStringWithNull());
                }
                dataRow["IncludeRecipientDescription"] = value;
            }
        }
Beispiel #8
0
 protected override void OnLoad(EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.EnumType))
     {
         Type type = Type.GetType(this.EnumType);
         Enum.GetUnderlyingType(type);
         foreach (object obj in Enum.GetValues(type))
         {
             string value = obj.ToString();
             if (string.IsNullOrEmpty(this.AvailabeValues) || this.AvailabeValues.Split(new char[]
             {
                 ','
             }).Any((string each) => each.Equals(value, StringComparison.InvariantCultureIgnoreCase)))
             {
                 string   value2 = this.localizedText ? LocalizedDescriptionAttribute.FromEnum(type, obj) : obj.ToString();
                 ListItem item   = new ListItem(RtlUtil.ConvertToDecodedBidiString(value2, RtlUtil.IsRtl), value);
                 this.Items.Add(item);
                 if (this.DefaultValue != null && value == this.DefaultValue)
                 {
                     this.SelectedValue = value;
                 }
             }
         }
     }
     base.OnLoad(e);
 }
Beispiel #9
0
        public string ToString(bool handleCustomNames)
        {
            if (this.mode == ScheduleMode.Never)
            {
                return(LocalizedDescriptionAttribute.FromEnum(typeof(ScheduleMode), ScheduleMode.Never));
            }
            if (this.mode == ScheduleMode.Always)
            {
                return(LocalizedDescriptionAttribute.FromEnum(typeof(ScheduleMode), ScheduleMode.Always));
            }
            if (handleCustomNames && this.scheduleName != null)
            {
                return(this.scheduleName);
            }
            StringBuilder stringBuilder = new StringBuilder();

            foreach (ScheduleInterval scheduleInterval in this.intervals)
            {
                stringBuilder.Append(scheduleInterval.ToString());
                stringBuilder.Append(", ");
            }
            if (stringBuilder.Length > 0)
            {
                stringBuilder.Remove(stringBuilder.Length - 2, 2);
            }
            return(stringBuilder.ToString());
        }
Beispiel #10
0
        /// <summary>
        /// Filter the currently selected property sheet according to the text on the filter box
        /// </summary>
        private void FilterPropertySheet()
        {
            LocalizedDescriptionAttribute lda = null;
            Object settingsObj = this.itemPropertyGrid.SelectedObject;
            String text        = this.filterText.Text;

            if (settingsObj != null)
            {
                Int32          i          = 0;
                String[]       browsables = { "" };
                PropertyInfo[] props      = settingsObj.GetType().GetProperties();
                foreach (PropertyInfo prop in props)
                {
                    var atts = prop.GetCustomAttributes(typeof(LocalizedDescriptionAttribute), true);
                    if (atts.Length > 0)
                    {
                        lda = atts[0] as LocalizedDescriptionAttribute;
                    }
                    if (prop.Name.ToLower().ToLower().Contains(text.ToLower()) || lda != null && lda.Description.ToLower().Contains(text.ToLower()))
                    {
                        Array.Resize(ref browsables, i + 1);
                        browsables.SetValue(prop.Name, i);
                        i++;
                    }
                }
                itemPropertyGrid.BrowsableProperties = browsables;
                itemPropertyGrid.SelectedObject      = settingsObj;
                itemPropertyGrid.Refresh();
            }
        }
Beispiel #11
0
 public static string EnumToLocalizedString(object value)
 {
     if (value.GetType().Equals(typeof(DBNull)))
     {
         return(string.Empty);
     }
     return(LocalizedDescriptionAttribute.FromEnum(value.GetType(), value));
 }
Beispiel #12
0
        public static string GetRepairUrgencyDisplayString(RepairUrgency urgency)
        {
            string text = LocalizedDescriptionAttribute.FromEnum(typeof(RepairUrgency), urgency);

            if (!string.IsNullOrWhiteSpace(text))
            {
                return(text);
            }
            return(urgency.ToString());
        }
Beispiel #13
0
        private static string GetTransitionStateString(TransitionState state)
        {
            string text = LocalizedDescriptionAttribute.FromEnum(typeof(TransitionState), state);

            if (!string.IsNullOrWhiteSpace(text))
            {
                return(text);
            }
            return(state.ToString());
        }
 protected override void CreateChildControls()
 {
     base.CreateChildControls();
     this.checkBoxList    = new EnumCheckBoxList();
     this.checkBoxList.ID = "checklist";
     this.checkBoxList.Items.AddRange((from e in Enum.GetNames(typeof(IncidentReportContent))
                                       select new ListItem(LocalizedDescriptionAttribute.FromEnum(typeof(IncidentReportContent), Enum.Parse(typeof(IncidentReportContent), e)), e.ToString())).ToArray <ListItem>());
     this.checkBoxList.CellSpacing = 2;
     this.Controls.Add(this.checkBoxList);
 }
        protected override string GetValueText(object objectValue)
        {
            string result = string.Empty;

            if (this.enumType.IsInstanceOfType(objectValue))
            {
                result = LocalizedDescriptionAttribute.FromEnum(this.enumType, objectValue);
            }
            return(result);
        }
Beispiel #16
0
        /// <summary>
        /// Checks if the property matches in any property infos
        /// </summary>
        private Boolean PropertyMatches(PropertyInfo prop, String text)
        {
            LocalizedDescriptionAttribute lda = null;
            var atts = prop.GetCustomAttributes(typeof(LocalizedDescriptionAttribute), true);

            if (atts.Length > 0)
            {
                lda = atts[0] as LocalizedDescriptionAttribute;
            }
            return(prop.Name.ToLower().Contains(text.ToLower()) || lda != null && lda.Description.ToLower().Contains(text.ToLower()));
        }
 protected override string FormatObject(string format, object arg, IFormatProvider formatProvider)
 {
     if (Enum.IsDefined(typeof(PublicFolderPermissionRole), (int)arg))
     {
         return(LocalizedDescriptionAttribute.FromEnum(typeof(PublicFolderPermissionRole), (int)arg));
     }
     if (PublicFolderPermission.None.Equals(arg))
     {
         return(Strings.PublicFolderPermissionRoleNone);
     }
     return(Strings.PublicFolderPermissionRoleCustom);
 }
Beispiel #18
0
        private static string GetDisplayName(FieldInfo field)
        {
            LocalizedDescriptionAttribute customAttribute = field.GetCustomAttribute <LocalizedDescriptionAttribute>(false);

            if (customAttribute != null)
            {
                string name = customAttribute.Description;
                if (!string.IsNullOrEmpty(name))
                {
                    return(name);
                }
            }
            return(field.Name);
        }
Beispiel #19
0
        public static FlaggedForActionCondition Create(Rule rule, string action)
        {
            Condition.CheckParams(new object[]
            {
                rule
            });
            RequestedAction requestedAction;

            if (!RequestedAction.Any.ToString().Equals(action, StringComparison.OrdinalIgnoreCase) && EnumValidator.TryParse <RequestedAction>(action, EnumParseOptions.IgnoreCase, out requestedAction))
            {
                return(new FlaggedForActionCondition(rule, LocalizedDescriptionAttribute.FromEnum(FlaggedForActionCondition.RequestedActionType, requestedAction)));
            }
            return(new FlaggedForActionCondition(rule, action));
        }
Beispiel #20
0
        public static int GetRequestedActionLocalizedStringEnumIndex(string actionString, CultureInfo culture)
        {
            Array values = Enum.GetValues(FlaggedForActionCondition.RequestedActionType);

            for (int i = 0; i < values.Length; i++)
            {
                string a = (culture != null) ? LocalizedDescriptionAttribute.FromEnum(FlaggedForActionCondition.RequestedActionType, values.GetValue(i), culture) : LocalizedDescriptionAttribute.FromEnum(FlaggedForActionCondition.RequestedActionType, values.GetValue(i));
                if (string.Equals(a, actionString, StringComparison.OrdinalIgnoreCase))
                {
                    return(i);
                }
            }
            return(-1);
        }
Beispiel #21
0
        public static string AuthenticationMethodsToText(object authen)
        {
            ADMultiValuedProperty <AuthenticationMethod> admultiValuedProperty = (ADMultiValuedProperty <AuthenticationMethod>)authen;
            StringBuilder stringBuilder = new StringBuilder();

            foreach (AuthenticationMethod authenticationMethod in admultiValuedProperty)
            {
                stringBuilder.AppendFormat("{0}, ", LocalizedDescriptionAttribute.FromEnum(typeof(AuthenticationMethod), authenticationMethod));
            }
            return(stringBuilder.ToString().TrimEnd(new char[]
            {
                ',',
                ' '
            }));
        }
Beispiel #22
0
        public static string GetLocalizedEnumDescription(this Enum @enum)
        {
            System.Reflection.FieldInfo field = @enum.GetType().GetField(@enum.ToString());

            LocalizedDescriptionAttribute customAttribute = field.GetCustomAttribute <LocalizedDescriptionAttribute>(false);

            if (customAttribute != null)
            {
                string name = customAttribute.Description;
                if (!string.IsNullOrEmpty(name))
                {
                    return(name);
                }
            }
            return(field.Name);
        }
        private static string GetLocalizedRetentionAction(bool retentionEnabled, RetentionActionType retentionActionType)
        {
            string result = LocalizedDescriptionAttribute.FromEnum(typeof(RetentionActionType), retentionActionType);
            bool   flag   = retentionActionType == RetentionActionType.MoveToArchive;

            if (retentionActionType == RetentionActionType.DeleteAndAllowRecovery)
            {
                result = Strings.RetentionActionDeleteAndAllowRecovery;
            }
            if (!retentionEnabled)
            {
                if (flag)
                {
                    result = Strings.RetentionActionNeverMove;
                }
                else
                {
                    result = Strings.RetentionActionNeverDelete;
                }
            }
            return(result);
        }
Beispiel #24
0
        public WordTypesWindow()
        {
            InitializeComponent();

            foreach (grammatical field in Enum.GetValues(typeof(grammatical)))
            {
                Type typeField = field.GetType();

                foreach (FieldInfo fi in typeField.GetFields())
                {
                    if (fi.FieldType != typeof(grammatical))
                    {
                        continue;
                    }

                    if (fi.Name != field.ToString())
                    {
                        continue;
                    }

                    LocalizedDescriptionAttribute attr = fi.GetCustomAttributes(typeof(LocalizedDescriptionAttribute), true).SingleOrDefault() as LocalizedDescriptionAttribute;
                    if (attr != null)
                    {
                        AddGrammaticalMenu(buttonGrammatical.DropDownItems, field, attr.Description);
                        AddGrammaticalMenu(menuGrammatical.DropDownItems, field, attr.Description);
                    }

                    if (field == grammatical.none)
                    {
                        buttonGrammatical.DropDownItems.Add(new ToolStripSeparator());
                        menuGrammatical.DropDownItems.Add(new ToolStripSeparator());
                    }

                    break;
                }
            }
        }
Beispiel #25
0
 public static string EnumToLocalizedStringForOwaOption(object value)
 {
     return(LocalizedDescriptionAttribute.FromEnumForOwaOption(value.GetType(), value));
 }
 protected static string GetScenarioDescription(WebServicesTestOutcome.TestScenario scenario)
 {
     return(LocalizedDescriptionAttribute.FromEnum(typeof(WebServicesTestOutcome.TestScenario), scenario));
 }
        // Token: 0x0600106A RID: 4202 RVA: 0x000320D0 File Offset: 0x000302D0
        public override object GetValue(int ordinal)
        {
            ExTraceGlobals.DataTracer.Information <int>((long)this.GetHashCode(), "-->MonadDataReader.GetValue({0})", ordinal);
            this.AssertReaderIsOpen();
            object result;

            try
            {
                object obj = null;
                if (this.HasSchema && this.currentRecord != null)
                {
                    if (this.useBaseObject)
                    {
                        if (ordinal == 0)
                        {
                            obj = this.currentRecord.BaseObject;
                        }
                    }
                    else
                    {
                        COPropertyInfo copropertyInfo = this.properties[ordinal];
                        if (copropertyInfo != null)
                        {
                            if (string.Equals(copropertyInfo.Name, this.preservedObjectProperty))
                            {
                                obj = this.currentRecord.BaseObject;
                            }
                            else
                            {
                                PSPropertyInfo pspropertyInfo = this.currentRecord.Properties[copropertyInfo.Name];
                                if (pspropertyInfo != null)
                                {
                                    obj = pspropertyInfo.Value;
                                    if (obj is PSObject)
                                    {
                                        object obj2 = this.UnWrappPSObject(obj as PSObject);
                                        if (obj2 is ArrayList)
                                        {
                                            obj = obj2;
                                        }
                                    }
                                    if (copropertyInfo.Type == typeof(string) && obj is IList)
                                    {
                                        obj = this.FormatListToString((IList)obj);
                                    }
                                    else if (copropertyInfo.Type == typeof(string) && obj != null && obj.GetType().IsEnum)
                                    {
                                        obj = LocalizedDescriptionAttribute.FromEnum(obj.GetType(), obj);
                                    }
                                    else if (copropertyInfo.Type == typeof(EnumObject))
                                    {
                                        obj = new EnumObject(obj as Enum);
                                    }
                                    else if (copropertyInfo.Type == typeof(string) && obj != null && obj.GetType() == typeof(bool))
                                    {
                                        bool flag = (bool)obj;
                                        if (flag)
                                        {
                                            obj = Strings.TrueString;
                                        }
                                        else
                                        {
                                            obj = Strings.FalseString;
                                        }
                                    }
                                    else if (obj != null && obj.GetType() == typeof(string))
                                    {
                                        if (copropertyInfo.Type.IsEnum)
                                        {
                                            obj = Enum.Parse(copropertyInfo.Type, obj as string);
                                        }
                                        else if (copropertyInfo.Type == typeof(Guid))
                                        {
                                            obj = new Guid(obj as string);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                ExTraceGlobals.DataTracer.Information((long)this.GetHashCode(), "<--MonadDataReader.GetValue(), {0}", new object[]
                {
                    obj
                });
                result = obj;
            }
            catch (GetValueException ex)
            {
                Exception innerException = ex.InnerException;
                while (innerException is TargetInvocationException)
                {
                    innerException = innerException.InnerException;
                }
                if (innerException != null)
                {
                    result = innerException.Message;
                }
                else
                {
                    result = ex.Message;
                }
            }
            return(result);
        }
Beispiel #28
0
 private static void ReplaceLogFieldTags(StringBuilder sb, Globals.LogFields logField, object value)
 {
     sb = sb.Replace(logField.ToLabelTag(), LocalizedDescriptionAttribute.FromEnum(typeof(Globals.LogFields), logField) + ":");
     sb = sb.Replace(logField.ToValueTag(), string.Format("{0}", value));
 }
Beispiel #29
0
        private static string CreateMailBody(string templateName, MailboxDiscoverySearch searchObject, string[] statusMailRecipients, List <string> successfulMailboxes, List <string> unsuccessfulMailboxes, IList <ISource> srcMailboxes)
        {
            Util.ThrowIfNullOrEmpty(templateName, "templateName");
            Util.ThrowIfNull(searchObject, "searchObject");
            StringBuilder stringBuilder = new StringBuilder();

            using (StreamReader streamReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(templateName)))
            {
                stringBuilder.Append(streamReader.ReadToEnd());
            }
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.Identity, searchObject.Identity.ToString());
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.LastStartTime, searchObject.LastStartTime);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.LastEndTime, searchObject.LastEndTime);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.CreatedBy, searchObject.CreatedBy);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.Name, searchObject.Name);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.SearchQuery, searchObject.Query);
            string text = searchObject.Senders.AggregateOfDefault((string s, string x) => s + ", " + x);

            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.Senders, text.ValueOrDefault(Strings.LogMailAll));
            text = searchObject.Recipients.AggregateOfDefault((string s, string x) => s + ", " + x);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.Recipients, text.ValueOrDefault(Strings.LogMailAll));
            text = ((searchObject.StartDate != null) ? string.Format("{0}, {0:%z}", searchObject.StartDate.Value) : Strings.LogMailBlank);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.StartDate, text);
            text = ((searchObject.EndDate != null) ? string.Format("{0}, {0:%z}", searchObject.EndDate.Value) : Strings.LogMailBlank);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.EndDate, text);
            text = (from x in searchObject.MessageTypes
                    select x.ToString()).AggregateOfDefault((string s, string x) => s + ", " + x);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.MessageTypes, text.ValueOrDefault(Strings.LogMailAll));
            if (searchObject.StatisticsOnly)
            {
                Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.TargetMailbox, Strings.LogMailNone);
            }
            else
            {
                Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.TargetMailbox, searchObject.Target);
            }
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.LogLevel, searchObject.LogLevel);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.ExcludeDuplicateMessages, searchObject.ExcludeDuplicateMessages);
            StringBuilder sb = stringBuilder;

            Globals.LogFields logField = Globals.LogFields.SourceRecipients;
            object            value;

            if (srcMailboxes != null)
            {
                value = string.Join(", ", (from src in srcMailboxes
                                           select src.Id).ToArray <string>());
            }
            else
            {
                value = null;
            }
            Util.ReplaceLogFieldTags(sb, logField, value);
            text = statusMailRecipients.AggregateOfDefault((string s, string x) => s + ", " + x);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.StatusMailRecipients, text.ValueOrDefault(Strings.LogMailNone));
            text = (from x in searchObject.ManagedBy
                    select x.ToString()).AggregateOfDefault((string s, string x) => s + ", " + x);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.ManagedBy, text.ValueOrDefault(Strings.LogMailNone));
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.LastRunBy, searchObject.LastModifiedBy);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.NumberMailboxesToSearch, searchObject.NumberOfMailboxes);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.NumberSuccessfulMailboxes, (successfulMailboxes == null) ? 0 : successfulMailboxes.Count);
            text = null;
            if (successfulMailboxes != null && successfulMailboxes.Count > 0)
            {
                text = (from x in successfulMailboxes
                        select x).AggregateOfDefault((string s, string x) => s + ", " + x);
            }
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.SuccessfulMailboxes, string.IsNullOrEmpty(text) ? Strings.LogMailNone : text);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.NumberUnsuccessfulMailboxes, (unsuccessfulMailboxes == null) ? 0 : unsuccessfulMailboxes.Count);
            text = null;
            if (unsuccessfulMailboxes != null && unsuccessfulMailboxes.Count > 0)
            {
                text = (from x in unsuccessfulMailboxes
                        select x).AggregateOfDefault((string s, string x) => s + ", " + x);
            }
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.UnsuccessfulMailboxes, string.IsNullOrEmpty(text) ? Strings.LogMailNone : text);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.Resume, searchObject.Resume);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.IncludeKeywordStatistics, searchObject.IncludeKeywordStatistics);
            if (searchObject.Status == SearchState.Stopped || searchObject.Status == SearchState.EstimateStopped)
            {
                Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.StoppedBy, searchObject.LastModifiedBy);
            }
            else
            {
                Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.StoppedBy, Strings.LogMailNotApplicable);
            }
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.PercentComplete, string.Format("{0}%", searchObject.PercentComplete));
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.ResultSize, new ByteQuantifiedSize((ulong)searchObject.ResultSizeCopied));
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.ResultSizeEstimate, searchObject.ResultSizeEstimate);
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.ResultSizeCopied, new ByteQuantifiedSize((ulong)searchObject.ResultSizeCopied));
            if (searchObject.StatisticsOnly)
            {
                Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.ResultsLink, string.Empty);
            }
            else
            {
                Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.ResultsLink, searchObject.ResultsLink);
            }
            int           num            = Math.Min(Util.MaxNumberOfErrorsInStatusMessage, searchObject.Errors.Count);
            StringBuilder stringBuilder2 = new StringBuilder();

            for (int i = 0; i < num; i++)
            {
                stringBuilder2.Append(searchObject.Errors[i]);
            }
            text = stringBuilder2.ToString();
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.Errors, text.ValueOrDefault(Strings.LogMailNone));
            KeywordHit    unsearchableHit = null;
            StringBuilder stringBuilder3  = new StringBuilder();

            if (searchObject.KeywordHits != null && searchObject.KeywordHits.Count > 0)
            {
                stringBuilder3.AppendLine("<table style=\"width: 100%\" cellspacing=\"0\">");
                stringBuilder3.AppendFormat("<tr> <td class=\"lefttd\"><strong>{0}</strong>&nbsp;</td><td class=\"lefttd\"><strong>{1}</strong>&nbsp;</td><td class=\"rightttd\"><strong>{2}</strong></td></tr>", Strings.LogFieldsKeywordKeyword, Strings.LogFieldsKeywordHitCount, Strings.LogFieldsKeywordMbxs);
                foreach (KeywordHit keywordHit in searchObject.KeywordHits)
                {
                    if (keywordHit.Phrase != "652beee2-75f7-4ca0-8a02-0698a3919cb9")
                    {
                        stringBuilder3.AppendFormat("<tr><td class=\"lefttd\">{0}&nbsp;</td><td class=\"lefttd\">{1}&nbsp;</td><td class=\"rightttd\">{2}</td></tr>", keywordHit.Phrase, keywordHit.Count, keywordHit.MailboxCount);
                    }
                    else
                    {
                        unsearchableHit = keywordHit;
                    }
                }
                stringBuilder3.Append("</table>");
            }
            else if (!searchObject.StatisticsOnly)
            {
                stringBuilder3.Append(Strings.NoKeywordStatsForCopySearch);
            }
            else if (string.IsNullOrEmpty(searchObject.Query))
            {
                stringBuilder3.Append(Strings.KeywordHitEmptyQuery);
            }
            else
            {
                stringBuilder3.Append(Strings.KeywordStatsNotRequested);
            }
            Util.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.KeywordHits, stringBuilder3.ToString());
            Util.BuildResultNumbers(stringBuilder, searchObject, unsearchableHit);
            stringBuilder = stringBuilder.Replace(Globals.LogFields.LogMailHeader.ToLabelTag(), Strings.LogMailHeader(searchObject.Name, LocalizedDescriptionAttribute.FromEnum(typeof(SearchState), searchObject.Status)));
            if (!searchObject.StatisticsOnly)
            {
                stringBuilder = stringBuilder.Replace(Globals.LogFields.LogMailHeaderInstructions.ToLabelTag(), Strings.LogMailHeaderInstructions(searchObject.Name));
            }
            else
            {
                stringBuilder.Replace(Globals.LogFields.LogMailHeaderInstructions.ToLabelTag(), string.Empty);
            }
            stringBuilder = stringBuilder.Replace(Globals.LogFields.LogMailSeeAttachment.ToLabelTag(), Strings.LogMailSeeAttachment);
            stringBuilder = stringBuilder.Replace(Globals.LogFields.LogMailFooter.ToLabelTag(), Strings.LogMailFooter);
            return(stringBuilder.ToString());
        }
 public NotAllowedPublishingByPolicyException(DetailLevelEnumType detailLevel, DetailLevelEnumType maxAllowedDetailLevel) : base(ServerStrings.DetailLevelNotAllowedByPolicy(LocalizedDescriptionAttribute.FromEnum(typeof(DetailLevelEnumType), detailLevel)))
 {
     EnumValidator.ThrowIfInvalid <DetailLevelEnumType>(detailLevel, "detailLevel");
     EnumValidator.ThrowIfInvalid <DetailLevelEnumType>(maxAllowedDetailLevel, "maxAllowedDetailLevel");
     this.MaxAllowedDetailLevel = (int)maxAllowedDetailLevel;
 }