Ejemplo n.º 1
0
        internal static object InternalHeaderPromotionModeGetter(IPropertyBag bag)
        {
            TransportSettingFlags transportSettingFlags = (TransportSettingFlags)bag[ADAMTransportConfigContainerSchema.Flags];
            HeaderPromotionMode   headerPromotionMode   = (HeaderPromotionMode)((transportSettingFlags & TransportSettingFlags.HeaderPromotionModeSetting) >> 21);

            return(EnumValidator.IsValidValue <HeaderPromotionMode>(headerPromotionMode) ? headerPromotionMode : HeaderPromotionMode.NoCreate);
        }
Ejemplo n.º 2
0
 public void UpdateWorkingPeriod(DaysOfWeek daysOfWeek, int startTimeInMinutes, int endTimeInMinutes)
 {
     EnumValidator.ThrowIfInvalid <DaysOfWeek>(daysOfWeek, "daysOfWeek");
     this.startTimeInMinutes = startTimeInMinutes;
     this.endTimeInMinutes   = endTimeInMinutes;
     this.daysOfWeek         = daysOfWeek;
 }
Ejemplo n.º 3
0
        public ExchangePrincipal(IGenericADUser adUser, IEnumerable <IMailboxInfo> allMailboxes, Func <IMailboxInfo, bool> mailboxSelector, RemotingOptions remotingOptions)
        {
            ArgumentValidator.ThrowIfNull("adUser", adUser);
            ArgumentValidator.ThrowIfNull("mailboxes", allMailboxes);
            ArgumentValidator.ThrowIfNull("mailboxSelector", mailboxSelector);
            EnumValidator <RemotingOptions> .ThrowIfInvalid(remotingOptions);

            this.MailboxInfo = allMailboxes.FirstOrDefault(mailboxSelector);
            if (this.MailboxInfo == null && (remotingOptions & RemotingOptions.AllowHybridAccess) != RemotingOptions.AllowHybridAccess)
            {
                throw new UserHasNoMailboxException();
            }
            this.AllMailboxes = allMailboxes;
            this.ObjectId     = adUser.ObjectId;
            this.LegacyDn     = adUser.LegacyDn;
            this.Alias        = (adUser.Alias ?? string.Empty);
            this.DefaultPublicFolderMailbox = adUser.DefaultPublicFolderMailbox;
            this.Sid = adUser.Sid;
            this.MasterAccountSid = adUser.MasterAccountSid;
            this.SidHistory       = adUser.SidHistory;
            this.Delegates        = from delegateUser in adUser.GrantSendOnBehalfTo
                                    where delegateUser != null
                                    select delegateUser;

            this.PreferredCultures         = ((adUser.Languages == null) ? Enumerable.Empty <CultureInfo>() : new PreferredCultures(adUser.Languages));
            this.RecipientType             = adUser.RecipientType;
            this.RecipientTypeDetails      = adUser.RecipientTypeDetails;
            this.IsResource                = adUser.IsResource;
            this.ModernGroupType           = adUser.ModernGroupType;
            this.PublicToGroupSids         = adUser.PublicToGroupSids;
            this.ExternalDirectoryObjectId = adUser.ExternalDirectoryObjectId;
            this.AggregatedMailboxGuids    = (adUser.AggregatedMailboxGuids ?? ((IEnumerable <Guid>)Array <Guid> .Empty));
            this.remotingOptions           = remotingOptions;
        }
Ejemplo n.º 4
0
        internal static object InternalShadowMessagePreferenceGetter(IPropertyBag bag)
        {
            TransportSettingFlags   transportSettingFlags   = (TransportSettingFlags)bag[ADAMTransportConfigContainerSchema.Flags];
            ShadowMessagePreference shadowMessagePreference = (ShadowMessagePreference)((transportSettingFlags & TransportSettingFlags.ShadowMessagePreferenceSetting) >> 27);

            return(EnumValidator.IsValidValue <ShadowMessagePreference>(shadowMessagePreference) ? shadowMessagePreference : ShadowMessagePreference.PreferRemote);
        }
        internal override StoreObjectValidationError Validate(ValidationContext context, IValidatablePropertyBag validatablePropertyBag)
        {
            string text = validatablePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string;

            if (!string.IsNullOrEmpty(text) && (ObjectClass.IsCalendarItem(text) || ObjectClass.IsRecurrenceException(text) || ObjectClass.IsMeetingMessage(text)) && validatablePropertyBag.IsPropertyDirty(InternalSchema.AppointmentStateInternal))
            {
                object obj = validatablePropertyBag.TryGetProperty(InternalSchema.AppointmentStateInternal);
                if (obj is int)
                {
                    AppointmentStateFlags appointmentStateFlags = (AppointmentStateFlags)obj;
                    if (EnumValidator <AppointmentStateFlags> .IsValidValue(appointmentStateFlags))
                    {
                        PropertyValueTrackingData originalPropertyInformation = validatablePropertyBag.GetOriginalPropertyInformation(InternalSchema.AppointmentStateInternal);
                        if (originalPropertyInformation.PropertyValueState == PropertyTrackingInformation.Modified && originalPropertyInformation.OriginalPropertyValue != null && !PropertyError.IsPropertyNotFound(originalPropertyInformation.OriginalPropertyValue))
                        {
                            AppointmentStateFlags appointmentStateFlags2 = (AppointmentStateFlags)originalPropertyInformation.OriginalPropertyValue;
                            bool flag  = (appointmentStateFlags2 & AppointmentStateFlags.Received) == AppointmentStateFlags.None;
                            bool flag2 = (appointmentStateFlags & AppointmentStateFlags.Received) == AppointmentStateFlags.None;
                            if (flag != flag2)
                            {
                                return(new StoreObjectValidationError(context, InternalSchema.AppointmentStateInternal, obj, this));
                            }
                        }
                    }
                }
            }
            return(null);
        }
        public void SetLocationIdentifier(uint id, LastChangeAction action)
        {
            EnumValidator.ThrowIfInvalid <LastChangeAction>(action);
            LocationIdentifier locationIdentifier = new LocationIdentifier(id, action);

            this.SetLocationIdentifier(locationIdentifier);
        }
Ejemplo n.º 7
0
 internal static void AppendKeywordOrClause(StringBuilder query, PropertyKeyword keyword, ICollection <string> valuesToQuery)
 {
     EnumValidator.ThrowIfInvalid <PropertyKeyword>(keyword);
     if (valuesToQuery != null && valuesToQuery.Count > 0)
     {
         bool flag = false;
         foreach (string value in valuesToQuery)
         {
             if (!string.IsNullOrEmpty(value))
             {
                 if (!flag)
                 {
                     flag = true;
                     AqsQueryBuilder.AppendLeadingSpaceIfNecessary(query);
                     query.Append(keyword.ToString().ToLower()).Append(":(");
                 }
                 else
                 {
                     query.Append(AqsQueryBuilder.AqsQueryORSeparator);
                 }
                 query.Append("\"").Append(value).Append("\"");
             }
         }
         if (flag)
         {
             query.Append(")");
         }
     }
 }
Ejemplo n.º 8
0
        private static bool IsPartnerManagedGroup(ExSearchResultEntry searchEntry, EdgeSyncDiag diagSession)
        {
            DirectoryAttribute directoryAttribute;

            if (!searchEntry.Attributes.TryGetValue("msExchCapabilityIdentifiers", out directoryAttribute) || directoryAttribute == null)
            {
                return(false);
            }
            foreach (object obj in directoryAttribute.GetValues(typeof(string)))
            {
                string text = obj as string;
                if (!string.IsNullOrEmpty(text))
                {
                    Capability capability;
                    if (EnumValidator.TryParse <Capability>(text, EnumParseOptions.AllowNumericConstants | EnumParseOptions.IgnoreCase, out capability))
                    {
                        if (capability == Capability.Partner_Managed)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        diagSession.LogAndTraceError("Capability value '{0}' is not in the expected format on the object '{1}'", new object[]
                        {
                            text,
                            searchEntry.DistinguishedName
                        });
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 9
0
 private UserConfiguration(UserConfigurationName configurationName, UserConfigurationTypes type, IStorePropertyBag queryPropertyBag)
 {
     EnumValidator.AssertValid <UserConfigurationTypes>(type);
     this.queryPropertyBag = queryPropertyBag;
     StorageGlobals.TraceConstructIDisposable(this);
     this.disposeTracker = this.GetDisposeTracker();
 }
Ejemplo n.º 10
0
        internal static void AppendDateClause(StringBuilder query, PropertyKeyword keyword, DateRangeQueryOperation operation, DateTime date)
        {
            EnumValidator.ThrowIfInvalid <PropertyKeyword>(keyword, AqsQueryBuilder.ValidDateKeywords);
            EnumValidator.ThrowIfInvalid <DateRangeQueryOperation>(operation);
            AqsQueryBuilder.AppendLeadingSpaceIfNecessary(query);
            query.Append(keyword.ToString().ToLower()).Append(":(");
            switch (operation)
            {
            case DateRangeQueryOperation.Equal:
                query.Append("=");
                break;

            case DateRangeQueryOperation.GreaterThan:
                query.Append(">");
                break;

            case DateRangeQueryOperation.GreaterThanOrEqual:
                query.Append(">=");
                break;

            case DateRangeQueryOperation.LessThan:
                query.Append("<");
                break;

            case DateRangeQueryOperation.LessThanOrEqual:
                query.Append("<=");
                break;
            }
            query.Append(date.ToLocalTime().ToString(AqsQueryBuilder.AqsDateTimeFormat, CultureInfo.InvariantCulture));
            query.Append(")");
        }
Ejemplo n.º 11
0
        internal static void Delete(Folder folder, string searchString, UserConfigurationSearchFlags searchFlags)
        {
            EnumValidator.AssertValid <UserConfigurationSearchFlags>(searchFlags);
            if (searchFlags != UserConfigurationSearchFlags.SubString && searchFlags != UserConfigurationSearchFlags.FullString && searchFlags != UserConfigurationSearchFlags.Prefix)
            {
                ExTraceGlobals.StorageTracer.TraceError <UserConfigurationSearchFlags>(0L, "UserConfiguration::FindItems. The search flag is not supported. searchFlags = {0}.", searchFlags);
                throw new NotSupportedException();
            }
            IList <IStorePropertyBag> list = null;

            try
            {
                list = UserConfiguration.QueryConfigurations(folder, null, new UserConfigurationName(searchString, ConfigurationNameKind.PartialName), searchFlags, StorageLimits.Instance.UserConfigurationMaxSearched, new PropertyDefinition[0]);
            }
            catch (InvalidOperationException innerException)
            {
                throw new InvalidOperationException(ServerStrings.ExCannotQueryAssociatedTable, innerException);
            }
            List <VersionedId> list2 = new List <VersionedId>();

            for (int i = 0; i < list.Count; i++)
            {
                list2.Add((VersionedId)list[i][InternalSchema.ItemId]);
                if (i == list.Count - 1 || list2.Count > 100)
                {
                    AggregateOperationResult result = folder.Session.Delete(DeleteItemFlags.SoftDelete, list2.ToArray());
                    UserConfiguration.CheckOperationResults(result, "Delete");
                    list2.Clear();
                }
            }
        }
Ejemplo n.º 12
0
        internal static ICollection <UserConfiguration> Find(Folder folder, string searchString, UserConfigurationSearchFlags searchFlags)
        {
            EnumValidator.AssertValid <UserConfigurationSearchFlags>(searchFlags);
            List <UserConfiguration> list = new List <UserConfiguration>();

            if (searchFlags != UserConfigurationSearchFlags.SubString && searchFlags != UserConfigurationSearchFlags.FullString && searchFlags != UserConfigurationSearchFlags.Prefix)
            {
                ExTraceGlobals.StorageTracer.TraceError <UserConfigurationSearchFlags>(0L, "UserConfiguration::FindItems. The search flag is not supported. searchFlags = {0}.", searchFlags);
                throw new NotSupportedException(ServerStrings.ExNotSupportedConfigurationSearchFlags(searchFlags.ToString()));
            }
            IList <IStorePropertyBag> list2 = null;

            try
            {
                list2 = UserConfiguration.QueryConfigurations(folder, null, new UserConfigurationName(searchString, ConfigurationNameKind.PartialName), searchFlags, StorageLimits.Instance.UserConfigurationMaxSearched + 1, new PropertyDefinition[0]);
            }
            catch (InvalidOperationException innerException)
            {
                throw new InvalidOperationException(ServerStrings.ExCannotQueryAssociatedTable, innerException);
            }
            if (list2.Count > StorageLimits.Instance.UserConfigurationMaxSearched)
            {
                ExTraceGlobals.StorageTracer.TraceError <int, int>(0L, "UserConfiguration::FindItems. There are too many user configuration objects created with the same name. Max. = {0}, Find = {1}.", StorageLimits.Instance.UserConfigurationMaxSearched, list2.Count);
                throw new TooManyConfigurationObjectsException(ServerStrings.ExTooManyObjects(searchString, list2.Count, StorageLimits.Instance.UserConfigurationMaxSearched));
            }
            if (list2.Count > 0)
            {
                UserConfiguration.BuildConfigurationsFromFilterQuery(list2, folder, list);
            }
            return(list);
        }
Ejemplo n.º 13
0
 public RestrictionInfo(ContentRight usageRights, ExDateTime expiryTime, string owner)
 {
     EnumValidator.ThrowIfInvalid <ContentRight>(usageRights, "usageRights");
     this.usageRights       = usageRights;
     this.expiryTime        = expiryTime;
     this.conversationOwner = owner;
 }
Ejemplo n.º 14
0
        internal static COWTriggerAction GetTriggerAction(FolderChangeOperation operation)
        {
            EnumValidator.ThrowIfInvalid <FolderChangeOperation>(operation, "operation");
            switch (operation)
            {
            case FolderChangeOperation.Copy:
                return(COWTriggerAction.Copy);

            case FolderChangeOperation.Move:
                return(COWTriggerAction.Move);

            case FolderChangeOperation.MoveToDeletedItems:
                return(COWTriggerAction.MoveToDeletedItems);

            case FolderChangeOperation.SoftDelete:
                return(COWTriggerAction.SoftDelete);

            case FolderChangeOperation.HardDelete:
                return(COWTriggerAction.HardDelete);

            case FolderChangeOperation.DoneWithMessageDelete:
                return(COWTriggerAction.DoneWithMessageDelete);

            default:
                throw new NotSupportedException("Invalid folder change operation");
            }
        }
Ejemplo n.º 15
0
        // Token: 0x060071F5 RID: 29173 RVA: 0x00179D78 File Offset: 0x00177F78
        private static object ConvertValueFromString(object valueToConvert, Type resultType)
        {
            string text = valueToConvert as string;
            bool   flag;

            if (resultType == typeof(bool) && bool.TryParse(text, out flag))
            {
                return(flag);
            }
            object result;

            if (resultType.IsEnum && EnumValidator.TryParse(resultType, text, EnumParseOptions.Default, out result))
            {
                return(result);
            }
            if (resultType.IsGenericType && resultType.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                bool flag2 = text == null || "null".Equals(text, StringComparison.OrdinalIgnoreCase) || "$null".Equals(text, StringComparison.OrdinalIgnoreCase);
                if (flag2)
                {
                    return(null);
                }
            }
            return(LanguagePrimitives.ConvertTo(text, resultType));
        }
Ejemplo n.º 16
0
 public static SharingMessageType GetSharingMessageType(SharingFlavor sharingFlavor)
 {
     EnumValidator.ThrowIfInvalid <SharingFlavor>(sharingFlavor, "sharingFlavor");
     if ((sharingFlavor & SharingFlavor.SharingMessageInvitation) == SharingFlavor.SharingMessageInvitation && (sharingFlavor & SharingFlavor.SharingMessageRequest) == SharingFlavor.SharingMessageRequest)
     {
         return(SharingMessageType.InvitationAndRequest);
     }
     if ((sharingFlavor & SharingFlavor.SharingMessageAccept) == SharingFlavor.SharingMessageAccept)
     {
         return(SharingMessageType.AcceptOfRequest);
     }
     if ((sharingFlavor & SharingFlavor.SharingMessageInvitation) == SharingFlavor.SharingMessageInvitation)
     {
         return(SharingMessageType.Invitation);
     }
     if ((sharingFlavor & SharingFlavor.SharingMessageRequest) == SharingFlavor.SharingMessageRequest)
     {
         return(SharingMessageType.Request);
     }
     if ((sharingFlavor & SharingFlavor.SharingMessageDeny) == SharingFlavor.SharingMessageDeny)
     {
         return(SharingMessageType.DenyOfRequest);
     }
     return(SharingMessageType.Unknown);
 }
Ejemplo n.º 17
0
 public EwsConnectionManager(ExchangePrincipal principal, OpenAsAdminOrSystemServiceBudgetTypeType budgetType, Trace tracer)
 {
     EnumValidator.AssertValid <OpenAsAdminOrSystemServiceBudgetTypeType>(budgetType);
     this.budgetType = budgetType;
     this.currentExchangePrincipal = principal;
     this.Tracer = tracer;
 }
 public ExchangePrincipal FromADUser(ADSessionSettings adSettings, IGenericADUser user, RemotingOptions remotingOptions, string domainController = null)
 {
     Util.ThrowOnNullArgument(adSettings, "adSettings");
     EnumValidator.ThrowIfInvalid <RemotingOptions>(remotingOptions, "remotingOptions");
     Util.ThrowOnNullArgument(user, "user");
     return(this.InternalFromADUser(user, remotingOptions));
 }
 public ExchangePrincipal FromWindowsIdentity(ADSessionSettings adSettings, WindowsIdentity windowsIdentity, RemotingOptions remotingOptions)
 {
     EnumValidator.ThrowIfInvalid <RemotingOptions>(remotingOptions, "remotingOptions");
     Util.ThrowOnNullArgument(adSettings, "adSettings");
     Util.ThrowOnNullArgument(windowsIdentity, "windowsIdentity");
     return(this.FromUserSid(adSettings, windowsIdentity.User, remotingOptions));
 }
        public ExchangePrincipal FromLegacyDNByMiniRecipient(IRecipientSession recipientSession, string legacyDN, RemotingOptions remotingOptions, PropertyDefinition[] miniRecipientProperties, out StorageMiniRecipient miniRecipient)
        {
            Util.ThrowOnNullArgument(recipientSession, "recipientSession");
            Util.ThrowOnNullArgument(legacyDN, "legacyDN");
            EnumValidator.ThrowIfInvalid <RemotingOptions>(remotingOptions, "remotingOptions");
            if (legacyDN.Length == 0)
            {
                throw new ArgumentException("legacyDN has zero length", "legacyDN");
            }
            Guid mbxGuid;

            legacyDN = this.TryToExtractArchiveOrAggregatedMailboxGuid(legacyDN, out mbxGuid);
            IGenericADUser genericADUser = this.directoryAccessor.FindMiniRecipientByProxyAddress(recipientSession, ProxyAddressPrefix.LegacyDN.GetProxyAddress(legacyDN, true), miniRecipientProperties, out miniRecipient);

            if (genericADUser == null)
            {
                throw new ObjectNotFoundException(ServerStrings.ADUserNotFound);
            }
            ADObjectId mdb;
            bool       asArchive             = this.UpdateArchiveStatus(mbxGuid, genericADUser, out mdb);
            Guid?      aggregatedMailboxGuid = null;

            if (genericADUser.AggregatedMailboxGuids != null)
            {
                aggregatedMailboxGuid = (genericADUser.AggregatedMailboxGuids.Any((Guid mailbox) => mailbox == mbxGuid) ? new Guid?(mbxGuid) : null);
            }
            IMailboxLocation  mailboxLocation   = new OnDemandMailboxLocation(() => new MailboxDatabaseLocation(this.databaseLocationProvider.GetLocationInfo(mdb.ObjectGuid, false, (remotingOptions & RemotingOptions.AllowCrossSite) == RemotingOptions.AllowCrossSite)));
            ExchangePrincipal exchangePrincipal = this.InternalFromMiniRecipient(genericADUser, mdb, mailboxLocation, remotingOptions, asArchive, aggregatedMailboxGuid);

            if (mbxGuid != Guid.Empty && !exchangePrincipal.MailboxInfo.IsAggregated && !exchangePrincipal.MailboxInfo.IsArchive)
            {
                throw new ObjectNotFoundException(ServerStrings.AggregatedMailboxNotFound(mbxGuid.ToString()));
            }
            return(exchangePrincipal);
        }
Ejemplo n.º 21
0
        public static SearchFolder Bind(MailboxSession session, DefaultFolderType defaultFolderType, ICollection <PropertyDefinition> propsToReturn)
        {
            EnumValidator.ThrowIfInvalid <DefaultFolderType>(defaultFolderType, "defaultFolderType");
            DefaultFolder defaultFolder = session.InternalGetDefaultFolder(defaultFolderType);

            if (defaultFolder.StoreObjectType != StoreObjectType.OutlookSearchFolder && defaultFolder.StoreObjectType != StoreObjectType.SearchFolder)
            {
                throw new ArgumentOutOfRangeException("defaultFolderType");
            }
            StoreObjectId           folderId = session.SafeGetDefaultFolderId(defaultFolderType);
            ObjectNotFoundException ex       = null;

            for (int i = 0; i < 2; i++)
            {
                try
                {
                    return(SearchFolder.Bind(session, folderId, propsToReturn));
                }
                catch (ObjectNotFoundException ex2)
                {
                    ex = ex2;
                    ExTraceGlobals.StorageTracer.Information <DefaultFolderType>(0L, "SearchFolder::Bind(defaultFolderType): attempting to recreate {0}.", defaultFolderType);
                    if (!session.TryFixDefaultFolderId(defaultFolderType, out folderId))
                    {
                        throw;
                    }
                }
            }
            throw ex;
        }
Ejemplo n.º 22
0
        private static SetSearchCriteriaFlags CalculateSearchCriteriaFlags(bool deepTraversal, bool useCiForComplexQueries, SetSearchCriteriaFlags statisticsOnly, bool failNonContentIndexedSearch, SearchFolder.SearchType searchType)
        {
            EnumValidator.ThrowIfInvalid <SearchFolder.SearchType>(searchType, "searchType");
            SetSearchCriteriaFlags setSearchCriteriaFlags = SetSearchCriteriaFlags.None;

            if (deepTraversal)
            {
                setSearchCriteriaFlags |= SetSearchCriteriaFlags.Recursive;
            }
            else
            {
                setSearchCriteriaFlags |= SetSearchCriteriaFlags.Shallow;
            }
            if (useCiForComplexQueries)
            {
                setSearchCriteriaFlags |= SetSearchCriteriaFlags.UseCiForComplexQueries;
            }
            setSearchCriteriaFlags |= statisticsOnly;
            if (failNonContentIndexedSearch)
            {
                setSearchCriteriaFlags |= SetSearchCriteriaFlags.FailNonContentIndexedSearch;
            }
            switch (searchType)
            {
            case SearchFolder.SearchType.RunOnce:
                setSearchCriteriaFlags |= (SetSearchCriteriaFlags.ContentIndexed | SetSearchCriteriaFlags.Static);
                break;

            case SearchFolder.SearchType.ContinousUpdate:
                setSearchCriteriaFlags |= SetSearchCriteriaFlags.NonContentIndexed;
                break;
            }
            return(setSearchCriteriaFlags | SetSearchCriteriaFlags.Restart);
        }
Ejemplo n.º 23
0
        public static AggregateOperationResult DeleteOutlookSearchFolder(DeleteItemFlags deleteItemFlags, MailboxSession session, StoreId outlookSearchFolderId)
        {
            EnumValidator.ThrowIfInvalid <DeleteItemFlags>(deleteItemFlags);
            VersionedId versionedId;

            using (OutlookSearchFolder outlookSearchFolder = OutlookSearchFolder.Bind(session, outlookSearchFolderId))
            {
                versionedId = OutlookSearchFolder.FindAssociatedMessageId((MailboxSession)outlookSearchFolder.Session, (Guid)outlookSearchFolder[InternalSchema.OutlookSearchFolderClsId]);
            }
            StoreId[] ids;
            if (versionedId != null)
            {
                ids = new StoreId[]
                {
                    outlookSearchFolderId,
                    versionedId
                };
            }
            else
            {
                ids = new StoreId[]
                {
                    outlookSearchFolderId
                };
            }
            return(session.Delete(deleteItemFlags, ids));
        }
Ejemplo n.º 24
0
        public bool SkipItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, bool onBeforeNotification, bool onDumpster, bool success, CallbackContext callbackContext)
        {
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            Util.ThrowOnNullArgument(callbackContext, "callbackContext");
            if (!WorkingSetPublisher.IsGroupWSPublishingEnabled())
            {
                COWGroupMessageWSPublishing.Tracer.Information((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: skipping group message working set publishing as the feature is disabled.");
                return(true);
            }
            switch (callbackContext.COWGroupMessageWSPublishingState)
            {
            case COWProcessorState.Unknown:
                callbackContext.COWGroupMessageWSPublishingState = this.InspectNotification(operation, session, item, onBeforeNotification, onDumpster);
                COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId, COWProcessorState>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: inspected item {0} and result is {1}.", itemId, callbackContext.COWGroupMessageWSPublishingState);
                return(true);

            case COWProcessorState.DoNotProcess:
                COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: skipping notification for item {0} because it should not be processed.", itemId);
                return(true);

            case COWProcessorState.ProcessAfterSave:
                return(onBeforeNotification);

            case COWProcessorState.Processed:
                COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: skipping notification for item {0} because it has already been processed.", itemId);
                return(true);

            default:
                return(true);
            }
        }
Ejemplo n.º 25
0
        public static void PerformActionOnNativePropertyDefinitions <T>(PropertyDependencyType targetDependencyType, ICollection <T> propertyDefinitions, Action <NativeStorePropertyDefinition> action) where T : PropertyDefinition
        {
            EnumValidator.AssertValid <PropertyDependencyType>(targetDependencyType);
            if (propertyDefinitions == null)
            {
                return;
            }
            int actualDependencyCount = 0;

            foreach (T t in propertyDefinitions)
            {
                PropertyDefinition      propertyDefinition      = t;
                StorePropertyDefinition storePropertyDefinition = InternalSchema.ToStorePropertyDefinition(propertyDefinition);
                storePropertyDefinition.ForEachMatch(targetDependencyType, delegate(NativeStorePropertyDefinition item)
                {
                    action(item);
                    actualDependencyCount++;
                });
            }
            int num = (propertyDefinitions.Count >= StorePropertyDefinition.dependencyEstimates.Length) ? propertyDefinitions.Count : StorePropertyDefinition.dependencyEstimates[propertyDefinitions.Count];

            if (actualDependencyCount != num && propertyDefinitions.Count < StorePropertyDefinition.dependencyEstimates.Length)
            {
                Interlocked.Exchange(ref StorePropertyDefinition.dependencyEstimates[propertyDefinitions.Count], actualDependencyCount);
            }
        }
Ejemplo n.º 26
0
        public override Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode)
        {
            base.CheckDisposed("OpenPropertyStream");
            EnumValidator.AssertValid <PropertyOpenMode>(openMode);
            NativeStorePropertyDefinition nativeStorePropertyDefinition = propertyDefinition as NativeStorePropertyDefinition;

            if (nativeStorePropertyDefinition == null)
            {
                throw new InvalidOperationException(ServerStrings.ExPropertyNotStreamable(propertyDefinition.ToString()));
            }
            Stream result;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                StoreObjectStream storeObjectStream = new StoreObjectStream(this, nativeStorePropertyDefinition, openMode);
                disposeGuard.Add <StoreObjectStream>(storeObjectStream);
                this.listOfStreams.Add(storeObjectStream);
                disposeGuard.Success();
                if (openMode == PropertyOpenMode.Create || openMode == PropertyOpenMode.Modify)
                {
                    this.TrackProperty(nativeStorePropertyDefinition, true);
                }
                result = storeObjectStream;
            }
            return(result);
        }
        public override void Init()
        {
            base.Init();
            validators    = new MenuInputValidator[widgets.Length];
            defaultValues = new string[widgets.Length];

            validators       = new MenuInputValidator[widgets.Length];
            validators[0]    = new HexColValidator();
            defaultValues[0] = WorldEnv.DefaultCloudsColHex;
            validators[1]    = new HexColValidator();
            defaultValues[1] = WorldEnv.DefaultSkyColHex;
            validators[2]    = new HexColValidator();
            defaultValues[2] = WorldEnv.DefaultFogColHex;
            validators[3]    = new RealValidator(0, 1000);
            defaultValues[3] = "1";
            validators[4]    = new IntegerValidator(-10000, 10000);
            defaultValues[4] = (game.World.Height + 2).ToString();

            validators[5]    = new HexColValidator();
            defaultValues[5] = WorldEnv.DefaultSunlightHex;
            validators[6]    = new HexColValidator();
            defaultValues[6] = WorldEnv.DefaultShadowlightHex;
            validators[7]    = new EnumValidator(typeof(Weather));
            validators[8]    = new RealValidator(-100, 100);
            defaultValues[8] = "1";
            validators[9]    = new IntegerValidator(-2048, 2048);
            defaultValues[9] = (game.World.Height / 2).ToString();
        }
Ejemplo n.º 28
0
        public static Subscription Create(StoreSession session, NotificationHandler handler, NotificationType notificationType, StoreId id, bool isSyncCallback, bool passthruCallback)
        {
            EnumValidator.ThrowIfInvalid <NotificationType>(notificationType, "notificationType");
            if (session == null)
            {
                ExTraceGlobals.StorageTracer.TraceError <string>(0L, "Subscription::Create. {0} should not be null.", "session");
                throw new ArgumentNullException("session");
            }
            if (handler == null)
            {
                ExTraceGlobals.StorageTracer.TraceError <string>(0L, "Subscription::Create. {0} should not be null.", "handler");
                throw new ArgumentNullException("handler");
            }
            if (id == null)
            {
                ExTraceGlobals.StorageTracer.TraceError <string>(0L, "Subscription::Create. {0} should not be null.", "id");
                throw new ArgumentNullException("id");
            }
            if ((notificationType & NotificationType.ConnectionDropped) == NotificationType.ConnectionDropped)
            {
                ExTraceGlobals.StorageTracer.TraceError(0L, "Subscription::Create. ConnectionDropped not valid on object notifications.");
                throw new InvalidOperationException("ConnectionDropped not valid on object notifications.");
            }
            StoreObjectId            storeObjectId = StoreId.GetStoreObjectId(id);
            NotificationCallbackMode callbackMode  = isSyncCallback ? NotificationCallbackMode.Sync : NotificationCallbackMode.Async;

            return(Subscription.InternalCreate(session, handler, notificationType, storeObjectId, callbackMode, passthruCallback));
        }
 public WeeklyRecurrencePattern(DaysOfWeek daysOfWeek, int recurrenceInterval, DayOfWeek firstDayOfWeek)
 {
     EnumValidator.ThrowIfInvalid <DayOfWeek>(firstDayOfWeek);
     this.DaysOfWeek         = daysOfWeek;
     base.RecurrenceInterval = recurrenceInterval;
     this.firstDayOfWeek     = firstDayOfWeek;
 }
        private UserConfiguration GetMessageConfiguration(UserConfigurationName configurationName, UserConfigurationTypes freefetchDataTypes, StoreObjectId messageId)
        {
            UserConfiguration result            = null;
            ConfigurationItem configurationItem = null;

            EnumValidator.ThrowIfInvalid <UserConfigurationTypes>(freefetchDataTypes, "freefetchDataTypes");
            try
            {
                configurationItem = ConfigurationItem.Bind(this.mailboxSession, messageId);
                result            = new UserConfiguration(configurationItem, (StoreObjectId)configurationItem.TryGetProperty(StoreObjectSchema.ParentItemId), configurationName, freefetchDataTypes, true);
            }
            catch (ObjectNotFoundException arg)
            {
                result = null;
                if (configurationItem != null)
                {
                    configurationItem.Dispose();
                }
                ExTraceGlobals.StorageTracer.TraceError <ObjectNotFoundException>(0L, "UserConfigurationManager::GetMessageConfiguration. Message object not found. Exception = {0}.", arg);
            }
            catch (Exception arg2)
            {
                result = null;
                if (configurationItem != null)
                {
                    configurationItem.Dispose();
                }
                ExTraceGlobals.StorageTracer.TraceError <Exception>(0L, "UserConfigurationManager::GetMessageConfiguration. Unable to create user configuration. Exception = {0}.", arg2);
            }
            return(result);
        }
 public ReleaseTypeValidationAttribute(params ReleaseType[] allowedTypes)
 {
     validator = new EnumValidator<ReleaseType>(allowedTypes);
 }
 public ProjectTypeValidationAttribute(params ProjectType[] allowedTypes)
 {
     validator = new EnumValidator<ProjectType>(allowedTypes);
 }