private static LegacyRecipientDisplayType GetLegacyRecipientDisplayType(RecipientDisplayType recipientDisplayType) { LegacyRecipientDisplayType legacyRecipientDisplayType = (LegacyRecipientDisplayType)(DisplayTypeExProperty.GetRecipientDisplayTypeInLocalForest(recipientDisplayType) & (RecipientDisplayType)255); if (EnumValidator.IsValidValue <LegacyRecipientDisplayType>(legacyRecipientDisplayType)) { return(legacyRecipientDisplayType); } if (legacyRecipientDisplayType != (LegacyRecipientDisplayType)9) { return(LegacyRecipientDisplayType.MailUser); } return(LegacyRecipientDisplayType.DistributionList); }
internal static TestActiveDirectoryConnectivityTask.ScenarioId EnsureFailureEventId(TestActiveDirectoryConnectivityTask.ScenarioId eventId) { if (eventId < TestActiveDirectoryConnectivityTask.ScenarioId.MachinePingFailed) { TestActiveDirectoryConnectivityTask.ScenarioId scenarioId = eventId + 1000; ExAssert.RetailAssert(EnumValidator.IsValidValue <TestActiveDirectoryConnectivityTask.ScenarioId>(scenarioId), "Corresponding failure eventId {0} is not defined for scenario {1}.", new object[] { (int)scenarioId, eventId }); return(scenarioId); } return(eventId); }
private UserConfiguration InternalCreateUserConfiguration(Folder folder, UserConfigurationName configurationName, UserConfigurationTypes dataTypes) { ExTraceGlobals.StorageTracer.Information <UserConfigurationName, UserConfigurationTypes>((long)this.GetHashCode(), "UserConfigurationManager::InternalCreateUserConfiguration. configurationName = {0}, dataTypes = {1}.", configurationName, dataTypes); if (folder == null) { throw new ArgumentNullException("folder"); } if (!EnumValidator.IsValidValue <UserConfigurationTypes>(dataTypes)) { ExTraceGlobals.StorageTracer.TraceError((long)this.GetHashCode(), "UserConfigurationManager::InternalCreateUserConfiguration. dataTypes is invalid."); throw new ArgumentException("dataTypes"); } return(UserConfiguration.Create(folder, configurationName, dataTypes)); }
private UserConfiguration InternalBindAndGetUserConfiguration(StoreId folderId, UserConfigurationName configurationName, UserConfigurationTypes freefetchDataType) { UserConfiguration result = null; using (Folder folder = Folder.Bind(this.mailboxSession, folderId)) { if (folder.IsNew) { ExTraceGlobals.StorageTracer.TraceError <string>((long)this.GetHashCode(), "UserConfigurationManager::InternalGetUserConfiguration. The folder Id is null maybe it is because the folder has not been saved yet. Id = {0}.", "null"); throw new InvalidOperationException(ServerStrings.ExFolderWithoutMapiProp); } if (!EnumValidator.IsValidValue <UserConfigurationTypes>(freefetchDataType)) { ExTraceGlobals.StorageTracer.TraceError <UserConfigurationTypes>((long)this.GetHashCode(), "UserConfigurationManager::InternalGetUserConfiguration. freefetchDataType is not allowed. freefetchDataType = {0}.", freefetchDataType); throw new ArgumentException("freefetchDataType"); } ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>((long)this.GetHashCode(), "UserConfigurationManager::InternalGetUserConfiguration. Hit code GetIgnoringCache. ConfigName = {0}.", configurationName); result = UserConfiguration.GetIgnoringCache(this, folder, configurationName, freefetchDataType); } return(result); }
private void SetObjectType(StoreObjectType objectType) { this.objectType = objectType; if (!EnumValidator.IsValidValue <StoreObjectType>(this.objectType)) { this.objectType = StoreObjectType.Unknown; } if (this.objectType == StoreObjectType.Unknown && this.IsFolderId) { this.objectType = StoreObjectType.Folder; return; } bool flag = StoreObjectTypeClassifier.IsFolderObjectType(this.objectType); if (flag && this.IsMessageId) { this.objectType = StoreObjectType.Message; return; } if (!flag && this.IsFolderId) { this.objectType = StoreObjectType.Folder; return; } if (!StoreObjectTypeExclusions.E12KnownObjectType(this.objectType)) { if (this.IsFolderId) { this.objectType = StoreObjectType.Folder; return; } if (!StoreObjectTypeClassifier.AlwaysReportRealType(this.objectType)) { this.objectType = StoreObjectType.Message; } } }
public static StorageWorkingHours Create(ExTimeZone timeZone, int daysOfWeek, int startTimeInMinutes, int endTimeInMinutes) { EnumValidator.IsValidValue <DaysOfWeek>((DaysOfWeek)daysOfWeek); return(new StorageWorkingHours(timeZone, (DaysOfWeek)daysOfWeek, startTimeInMinutes, endTimeInMinutes)); }
public void Validate() { bool flag = this.recurrenceType == TypeOfRecurrence.Calendar || (this.recurrenceType == TypeOfRecurrence.Task && !this.Regenerate); switch (this.Type) { case RecurrenceData.RecurrenceType.Daily: case RecurrenceData.RecurrenceType.Weekly: this.CheckNull("DayOfMonth"); this.CheckNull("WeekOfMonth"); this.CheckNull("MonthOfYear"); this.CheckNull("CalendarType"); this.CheckNull("IsLeapMonth"); if (!flag) { this.CheckNull("DayOfWeek"); return; } if (this.Type == RecurrenceData.RecurrenceType.Weekly) { this.CheckNotNull("DayOfWeek"); return; } return; case RecurrenceData.RecurrenceType.Monthly: this.CheckNull("DayOfWeek"); this.CheckNull("WeekOfMonth"); this.CheckNull("MonthOfYear"); this.CheckNull("IsLeapMonth"); if (flag) { this.CheckNotNull("DayOfMonth"); return; } this.CheckNull("DayOfMonth"); return; case RecurrenceData.RecurrenceType.MonthlyTh: this.CheckNull("DayOfMonth"); this.CheckNull("MonthOfYear"); this.CheckNull("IsLeapMonth"); if (flag) { this.CheckNotNull("WeekOfMonth"); this.CheckNotNull("DayOfWeek"); } else { this.CheckNull("WeekOfMonth"); this.CheckNull("DayOfWeek"); } if (!EnumValidator.IsValidValue <RecurrenceOrderType>(this.RecurrenceOrderType)) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "WeekOfMonth value {0} is invalid", new object[] { this.RecurrenceOrderType })); } return; case RecurrenceData.RecurrenceType.Yearly: this.CheckNull("DayOfWeek"); this.CheckNull("WeekOfMonth"); if (flag) { this.CheckNotNull("DayOfMonth"); this.CheckNotNull("MonthOfYear"); return; } this.CheckNull("WeekOfMonth"); this.CheckNull("MonthOfYear"); return; case RecurrenceData.RecurrenceType.YearlyTh: this.CheckNull("DayOfMonth"); if (!flag) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "Unsupported recurrence {0}, should have been caught in a higher validation layer", new object[] { this.Type })); } this.CheckNotNull("WeekOfMonth"); this.CheckNotNull("DayOfWeek"); this.CheckNotNull("MonthOfYear"); if (!EnumValidator.IsValidValue <RecurrenceOrderType>(this.RecurrenceOrderType)) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "WeekOfMonth value {0} is invalid", new object[] { this.RecurrenceOrderType })); } return; } throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "Unexpected recurrence type {0}, should have been caught in a higher validation layer", new object[] { this.Type })); }
private static RecurrencePattern CreateRecurrencePattern(TypeOfRecurrence recurrenceType, RecurrenceData recurrenceData, Recurrence oldRecurrence) { ushort recurrenceInterval = 1; RecurrenceData.RecurrenceType type = recurrenceData.Type; if (recurrenceData.HasInterval()) { recurrenceInterval = recurrenceData.Interval; } if (recurrenceData.HasWeekOfMonth()) { recurrenceData.WeekOfMonth = ((recurrenceData.WeekOfMonth == 5) ? byte.MaxValue : recurrenceData.WeekOfMonth); } if (recurrenceType == TypeOfRecurrence.Calendar || (recurrenceType == TypeOfRecurrence.Task && !recurrenceData.Regenerate)) { switch (type) { case RecurrenceData.RecurrenceType.Daily: if (recurrenceData.SubProperties["DayOfMonth"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null || recurrenceData.SubProperties["CalendarType"] != null || recurrenceData.SubProperties["IsLeapMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfMonth, WeekOfMonth, MonthOfYear, CalendarType, IsLeapMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } if (recurrenceData.SubProperties["DayOfWeek"] != null) { return(new WeeklyRecurrencePattern((DaysOfWeek)recurrenceData.DayOfWeek, (int)recurrenceInterval)); } return(new DailyRecurrencePattern((int)recurrenceInterval)); case RecurrenceData.RecurrenceType.Weekly: { if (recurrenceData.SubProperties["DayOfMonth"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null || recurrenceData.SubProperties["CalendarType"] != null || recurrenceData.SubProperties["IsLeapMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfMonth, WeekOfMonth, MonthOfYear, CalendarType, IsLeapMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } if (recurrenceData.SubProperties["DayOfWeek"] == null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfWeek is expected with recurrence type {0}", new object[] { type.ToString() })); } WeeklyRecurrencePattern weeklyRecurrencePattern = (oldRecurrence != null) ? (oldRecurrence.Pattern as WeeklyRecurrencePattern) : null; return(new WeeklyRecurrencePattern((DaysOfWeek)recurrenceData.DayOfWeek, (int)recurrenceInterval, (recurrenceData.ProtocolVersion < 141 && weeklyRecurrencePattern != null) ? weeklyRecurrencePattern.FirstDayOfWeek : recurrenceData.FirstDayOfWeek)); } case RecurrenceData.RecurrenceType.Monthly: if (recurrenceData.SubProperties["DayOfWeek"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null || recurrenceData.SubProperties["IsLeapMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfWeek, WeekOfMonth, MonthOfYear, IsLeapMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } if (recurrenceData.SubProperties["DayOfMonth"] == null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfMonth is expected with recurrence type {0}", new object[] { type.ToString() })); } return(new MonthlyRecurrencePattern((int)recurrenceData.DayOfMonth, (int)recurrenceInterval, recurrenceData.CalendarType)); case RecurrenceData.RecurrenceType.MonthlyTh: { if (recurrenceData.SubProperties["DayOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null || recurrenceData.SubProperties["IsLeapMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfMonth, MonthOfYear, IsLeapMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } if (recurrenceData.SubProperties["WeekOfMonth"] == null || recurrenceData.SubProperties["DayOfWeek"] == null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "WeekOfMonth, DayOfWeek is expected with recurrence type {0}", new object[] { type.ToString() })); } RecurrenceOrderType recurrenceOrderType = (recurrenceData.WeekOfMonth == byte.MaxValue) ? RecurrenceOrderType.Last : ((RecurrenceOrderType)recurrenceData.WeekOfMonth); if (!EnumValidator.IsValidValue <RecurrenceOrderType>(recurrenceOrderType)) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "WeekOfMonth value {0} is invalid", new object[] { recurrenceOrderType.ToString() })); } return(new MonthlyThRecurrencePattern((DaysOfWeek)recurrenceData.DayOfWeek, recurrenceOrderType, (int)recurrenceInterval, recurrenceData.CalendarType)); } case RecurrenceData.RecurrenceType.Yearly: if (recurrenceData.SubProperties["DayOfWeek"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfWeek, WeekOfMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } if (recurrenceData.SubProperties["DayOfMonth"] == null || recurrenceData.SubProperties["MonthOfYear"] == null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfMonth, MonthOfYear is expected with recurrence type {0}", new object[] { type.ToString() })); } return(new YearlyRecurrencePattern((int)recurrenceData.DayOfMonth, (int)recurrenceData.MonthOfYear, recurrenceData.IsLeapMonth, recurrenceData.CalendarType)); case RecurrenceData.RecurrenceType.YearlyTh: { if (recurrenceData.SubProperties["DayOfMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } if (recurrenceData.SubProperties["WeekOfMonth"] == null || recurrenceData.SubProperties["DayOfWeek"] == null || recurrenceData.SubProperties["MonthOfYear"] == null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "WeekOfMonth, DayOfWeek, MonthOfYear is expected with recurrence type {0}", new object[] { type.ToString() })); } RecurrenceOrderType recurrenceOrderType = (recurrenceData.WeekOfMonth == byte.MaxValue) ? RecurrenceOrderType.Last : ((RecurrenceOrderType)recurrenceData.WeekOfMonth); if (!EnumValidator.IsValidValue <RecurrenceOrderType>(recurrenceOrderType)) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "WeekOfMonth value {0} is invalid", new object[] { recurrenceOrderType.ToString() })); } return(new YearlyThRecurrencePattern((DaysOfWeek)recurrenceData.DayOfWeek, recurrenceOrderType, (int)recurrenceData.MonthOfYear, recurrenceData.IsLeapMonth, recurrenceData.CalendarType)); } } throw new ConversionException("Unexpected recurrence type, should have been caught in a higher validation layer"); } switch (type) { case RecurrenceData.RecurrenceType.Daily: if (recurrenceData.SubProperties["DayOfWeek"] != null || recurrenceData.SubProperties["DayOfMonth"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null || recurrenceData.SubProperties["CalendarType"] != null || recurrenceData.SubProperties["IsLeapMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfWeek, DayOfMonth, WeekOfMonth, MonthOfYear, CalendarType, IsLeapMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } return(new DailyRegeneratingPattern((int)recurrenceInterval)); case RecurrenceData.RecurrenceType.Weekly: if (recurrenceData.SubProperties["DayOfWeek"] != null || recurrenceData.SubProperties["DayOfMonth"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null || recurrenceData.SubProperties["CalendarType"] != null || recurrenceData.SubProperties["IsLeapMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfWeek, DayOfMonth, WeekOfMonth, MonthOfYear, CalendarType, IsLeapMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } return(new WeeklyRegeneratingPattern((int)recurrenceInterval)); case RecurrenceData.RecurrenceType.Monthly: if (recurrenceData.SubProperties["DayOfWeek"] != null || recurrenceData.SubProperties["DayOfMonth"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null || recurrenceData.SubProperties["IsLeapMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfWeek, DayOfMonth, WeekOfMonth, MonthOfYear, IsLeapMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } return(new MonthlyRegeneratingPattern((int)recurrenceInterval, recurrenceData.CalendarType)); case RecurrenceData.RecurrenceType.Yearly: if (recurrenceData.SubProperties["DayOfWeek"] != null || recurrenceData.SubProperties["DayOfMonth"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfWeek, DayOfMonth, WeekOfMonth, MonthOfYear is not expected with recurrence type {0}", new object[] { type.ToString() })); } return(new YearlyRegeneratingPattern((int)recurrenceInterval, recurrenceData.CalendarType)); } throw new ConversionException("Unexpected recurrence type '" + type + "', should have been caught in a higher validation layer"); }
private static RecipientDisplayType FixRecipientDisplayType(RecipientDisplayType recipientDisplayType) { if (!EnumValidator.IsValidValue <RecipientDisplayType>(recipientDisplayType) && EnumValidator.IsValidValue <RecipientDisplayType>(recipientDisplayType | RecipientDisplayType.ACLableMailboxUser)) { recipientDisplayType |= RecipientDisplayType.ACLableMailboxUser; } return(recipientDisplayType); }