Exemple #1
0
        private static void ValidateItemIsRule(XmlNode xmlNode)
        {
            XmlAttribute xmlAttribute = xmlNode.Attributes["ItemClass"];

            if (xmlAttribute != null)
            {
                string value = xmlAttribute.Value;
                if (ObjectClass.IsSmime(value) || ObjectClass.IsRightsManagedContentClass(value))
                {
                    throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonItemTypeInvalid));
                }
                XmlAttribute xmlAttribute2 = xmlNode.Attributes["IncludeSubClasses"];
                if (string.Equals(value, "IPM", StringComparison.OrdinalIgnoreCase) && xmlAttribute2 != null && ExtensionDataHelper.ConvertXmlStringToBoolean(xmlAttribute2.Value))
                {
                    throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonItemTypeAllTypes));
                }
            }
            XmlAttribute       xmlAttribute3 = xmlNode.Attributes["FormType"];
            ItemIsRuleFormType itemIsRuleFormType;

            if (xmlAttribute3 != null && EnumValidator.TryParse <ItemIsRuleFormType>(xmlAttribute3.Value, EnumParseOptions.Default, out itemIsRuleFormType) && (itemIsRuleFormType == ItemIsRuleFormType.Edit || itemIsRuleFormType == ItemIsRuleFormType.ReadOrEdit))
            {
                XmlAttribute xmlAttribute4 = xmlNode.Attributes["IncludeSubClasses"];
                if (xmlAttribute != null || xmlAttribute4 != null)
                {
                    throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonItemIsRuleAttributesNotValidForEdit));
                }
            }
        }
Exemple #2
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);
        }
Exemple #3
0
        private InternalGetMessageTrackingReportResponse(string domain, Microsoft.Exchange.InfoWorker.Common.Availability.Proxy.GetMessageTrackingReportResponseMessageType dispatcherResponse)
        {
            this.Response             = new Microsoft.Exchange.SoapWebClient.EWS.GetMessageTrackingReportResponseMessageType();
            this.Response.Diagnostics = dispatcherResponse.Diagnostics;
            Microsoft.Exchange.InfoWorker.Common.Availability.Proxy.MessageTrackingReportType messageTrackingReport = dispatcherResponse.MessageTrackingReport;
            Microsoft.Exchange.SoapWebClient.EWS.MessageTrackingReportType messageTrackingReportType = new Microsoft.Exchange.SoapWebClient.EWS.MessageTrackingReportType();
            messageTrackingReportType.OriginalRecipients  = MessageConverter.CopyEmailAddressArray(messageTrackingReport.OriginalRecipients);
            messageTrackingReportType.PurportedSender     = MessageConverter.CopyEmailAddress(messageTrackingReport.PurportedSender);
            messageTrackingReportType.Sender              = MessageConverter.CopyEmailAddress(messageTrackingReport.Sender);
            messageTrackingReportType.Subject             = messageTrackingReport.Subject;
            messageTrackingReportType.SubmitTime          = messageTrackingReport.SubmitTime;
            messageTrackingReportType.SubmitTimeSpecified = messageTrackingReport.SubmitTimeSpecified;
            messageTrackingReportType.Properties          = MessageConverter.CopyTrackingProperties(dispatcherResponse.Properties);
            this.Response.MessageTrackingReport           = messageTrackingReportType;
            this.Response.Properties = MessageConverter.CopyTrackingProperties(dispatcherResponse.Properties);
            this.Response.Errors     = MessageConverter.CopyErrors(dispatcherResponse.Errors);
            Microsoft.Exchange.SoapWebClient.EWS.ResponseCodeType responseCode;
            if (EnumValidator <Microsoft.Exchange.SoapWebClient.EWS.ResponseCodeType> .TryParse(dispatcherResponse.ResponseCode, EnumParseOptions.Default, out responseCode))
            {
                this.Response.ResponseCode = responseCode;
            }
            else
            {
                TraceWrapper.SearchLibraryTracer.TraceError <string>(0, "{0} cannot be converted to a valid ResponseCodeType, mapping to ErrorMessageTrackingPermanentError", dispatcherResponse.ResponseCode);
                this.Response.ResponseCode = Microsoft.Exchange.SoapWebClient.EWS.ResponseCodeType.ErrorMessageTrackingPermanentError;
            }
            this.Response.ResponseClass = EnumConverter <Microsoft.Exchange.SoapWebClient.EWS.ResponseClassType, Microsoft.Exchange.InfoWorker.Common.Availability.Proxy.ResponseClassType> .Convert(dispatcherResponse.ResponseClass);

            this.Response.MessageText = dispatcherResponse.MessageText;
            messageTrackingReportType.RecipientTrackingEvents = null;
            this.RecipientTrackingEvents = InternalGetMessageTrackingReportResponse.CreateEventList <Microsoft.Exchange.InfoWorker.Common.Availability.Proxy.RecipientTrackingEventType>(domain, messageTrackingReport.RecipientTrackingEvents, InternalGetMessageTrackingReportResponse.dispatcherConversionDelegate);
        }
Exemple #4
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));
        }
        private static RecipientTrackingEvent Create(string domain, string recipientEmail, string recipientDisplayName, string deliveryStatusString, string eventDescriptionString, string[] eventData, string server, DateTime date, string internalIdString, string uniquePathId, bool hiddenRecipient, bool?bccRecipient, string rootAddress, Microsoft.Exchange.SoapWebClient.EWS.TrackingPropertyType[] properties)
        {
            if (string.IsNullOrEmpty(recipientEmail))
            {
                TraceWrapper.SearchLibraryTracer.TraceError <string>(0, "Null recipient address in WS-RecipientTrackingEvent: {0}", recipientEmail);
                TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "Null recipient in WS-response", new object[0]);
            }
            SmtpAddress smtpAddress = new SmtpAddress(recipientEmail);

            if (!smtpAddress.IsValidAddress)
            {
                TraceWrapper.SearchLibraryTracer.TraceError <SmtpAddress>(0, "Corrupt recipient address in RD-RecipientTrackingEvent: {0}", smtpAddress);
                TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "Invalid recipient address {0} in WS-response", new object[]
                {
                    smtpAddress
                });
            }
            recipientDisplayName = (recipientDisplayName ?? smtpAddress.ToString());
            DeliveryStatus deliveryStatus;

            if (!EnumValidator <DeliveryStatus> .TryParse(deliveryStatusString, EnumParseOptions.Default, out deliveryStatus))
            {
                TraceWrapper.SearchLibraryTracer.TraceDebug <string>(0, "Skipping event because of unknown delivery-status value in WS-RecipientTrackingEvent: {0}", deliveryStatusString);
                return(null);
            }
            EventDescription eventDescription;

            if (!EnumValidator <EventDescription> .TryParse(eventDescriptionString, EnumParseOptions.Default, out eventDescription))
            {
                TraceWrapper.SearchLibraryTracer.TraceDebug <string>(0, "Skipping event because of unknown event-description in WS-RecipientTrackingEvent: {0}", eventDescriptionString);
                return(null);
            }
            if (string.IsNullOrEmpty(internalIdString))
            {
                TraceWrapper.SearchLibraryTracer.TraceError <string>(0, "Null or empty internalIdString in RD-RecipientTrackingEvent: {0}", internalIdString);
                TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "No InternalId {0} in WS-response", new object[0]);
            }
            long num = 0L;

            if (!long.TryParse(internalIdString, out num) || num < 0L)
            {
                TraceWrapper.SearchLibraryTracer.TraceError <string>(0, "Non-numeric or negative internalIdString in RD-RecipientTrackingEvent: {0}", internalIdString);
                TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "Invalid InternalId {0} in WS-response", new object[]
                {
                    internalIdString
                });
            }
            TrackingExtendedProperties trackingExtendedProperties = TrackingExtendedProperties.CreateFromTrackingPropertyArray(properties);

            if (eventDescription == EventDescription.PendingModeration && !string.IsNullOrEmpty(trackingExtendedProperties.ArbitrationMailboxAddress) && !SmtpAddress.IsValidSmtpAddress(trackingExtendedProperties.ArbitrationMailboxAddress))
            {
                TraceWrapper.SearchLibraryTracer.TraceDebug <string>(0, "Arbitration address is in the extended proprties but it's invalid: {0}", trackingExtendedProperties.ArbitrationMailboxAddress);
                TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "Invalid ArbitrationMailboxAddress property {0} in WS-response", new object[]
                {
                    trackingExtendedProperties.ArbitrationMailboxAddress
                });
            }
            return(new RecipientTrackingEvent(domain, smtpAddress, recipientDisplayName, deliveryStatus, EventType.Pending, eventDescription, eventData, server, date, num, uniquePathId, hiddenRecipient, bccRecipient, rootAddress, true, trackingExtendedProperties));
        }
Exemple #6
0
        // Token: 0x06001D3C RID: 7484 RVA: 0x00074854 File Offset: 0x00072A54
        private static MobileSpeechRecoResultType GetMobileSpeechResultType(string parsedResultType)
        {
            MobileSpeechRecoResultType result;

            if (!EnumValidator.TryParse <MobileSpeechRecoResultType>(parsedResultType, EnumParseOptions.IgnoreCase, out result))
            {
                result = MobileSpeechRecoResultType.None;
            }
            return(result);
        }
Exemple #7
0
        internal static CalendarType?CalendarTypeFromString(string value)
        {
            CalendarType value2;

            if (EnumValidator <CalendarType> .TryParse(value, EnumParseOptions.IgnoreCase, out value2))
            {
                return(new CalendarType?(value2));
            }
            return(null);
        }
        protected TrackingBaseException(TrackingError trackingError, Exception innerException, bool isAlreadyLogged) : base(trackingError.ToString(), innerException)
        {
            this.trackingError   = trackingError;
            this.IsAlreadyLogged = isAlreadyLogged;
            ErrorCode errorCode;

            if (EnumValidator <ErrorCode> .TryParse(trackingError.ErrorCode, EnumParseOptions.Default, out errorCode))
            {
                this.isOverBudgetError = (errorCode == ErrorCode.BudgetExceeded || errorCode == ErrorCode.TimeBudgetExceeded || errorCode == ErrorCode.TotalBudgetExceeded);
            }
        }
Exemple #9
0
        internal static Microsoft.Exchange.SoapWebClient.EWS.FindMessageTrackingReportResponseMessageType CopyDispatcherTypeToEWSType(Microsoft.Exchange.InfoWorker.Common.Availability.Proxy.FindMessageTrackingReportResponseMessageType dispatcherResponse)
        {
            if (dispatcherResponse == null)
            {
                return(null);
            }
            Microsoft.Exchange.SoapWebClient.EWS.FindMessageTrackingReportResponseMessageType findMessageTrackingReportResponseMessageType = new Microsoft.Exchange.SoapWebClient.EWS.FindMessageTrackingReportResponseMessageType();
            findMessageTrackingReportResponseMessageType.Diagnostics         = dispatcherResponse.Diagnostics;
            findMessageTrackingReportResponseMessageType.Properties          = MessageConverter.CopyTrackingProperties(dispatcherResponse.Properties);
            findMessageTrackingReportResponseMessageType.ExecutedSearchScope = dispatcherResponse.ExecutedSearchScope;
            findMessageTrackingReportResponseMessageType.Errors = MessageConverter.CopyErrors(dispatcherResponse.Errors);
            Microsoft.Exchange.SoapWebClient.EWS.ResponseCodeType responseCode;
            if (EnumValidator <Microsoft.Exchange.SoapWebClient.EWS.ResponseCodeType> .TryParse(dispatcherResponse.ResponseCode, EnumParseOptions.Default, out responseCode))
            {
                findMessageTrackingReportResponseMessageType.ResponseCode = responseCode;
            }
            else
            {
                TraceWrapper.SearchLibraryTracer.TraceError <string>(0, "{0} cannot be converted to a valid ResponseCodeType, mapping to ErrorMessageTrackingPermanentError", dispatcherResponse.ResponseCode);
                findMessageTrackingReportResponseMessageType.ResponseCode = Microsoft.Exchange.SoapWebClient.EWS.ResponseCodeType.ErrorMessageTrackingPermanentError;
            }
            findMessageTrackingReportResponseMessageType.ResponseClass = EnumConverter <Microsoft.Exchange.SoapWebClient.EWS.ResponseClassType, Microsoft.Exchange.InfoWorker.Common.Availability.Proxy.ResponseClassType> .Convert(dispatcherResponse.ResponseClass);

            findMessageTrackingReportResponseMessageType.MessageText = dispatcherResponse.MessageText;
            if (dispatcherResponse.MessageTrackingSearchResults == null)
            {
                return(findMessageTrackingReportResponseMessageType);
            }
            findMessageTrackingReportResponseMessageType.MessageTrackingSearchResults = new Microsoft.Exchange.SoapWebClient.EWS.FindMessageTrackingSearchResultType[dispatcherResponse.MessageTrackingSearchResults.Length];
            for (int i = 0; i < dispatcherResponse.MessageTrackingSearchResults.Length; i++)
            {
                Microsoft.Exchange.InfoWorker.Common.Availability.Proxy.FindMessageTrackingSearchResultType findMessageTrackingSearchResultType = dispatcherResponse.MessageTrackingSearchResults[i];
                Microsoft.Exchange.SoapWebClient.EWS.FindMessageTrackingSearchResultType findMessageTrackingSearchResultType2 = new Microsoft.Exchange.SoapWebClient.EWS.FindMessageTrackingSearchResultType();
                findMessageTrackingSearchResultType2.MessageTrackingReportId = findMessageTrackingSearchResultType.MessageTrackingReportId;
                findMessageTrackingSearchResultType2.PreviousHopServer       = findMessageTrackingSearchResultType.PreviousHopServer;
                findMessageTrackingSearchResultType2.PurportedSender         = MessageConverter.CopyEmailAddress(findMessageTrackingSearchResultType.PurportedSender);
                findMessageTrackingSearchResultType2.Recipients     = MessageConverter.CopyEmailAddressArray(findMessageTrackingSearchResultType.Recipients);
                findMessageTrackingSearchResultType2.Sender         = MessageConverter.CopyEmailAddress(findMessageTrackingSearchResultType.Sender);
                findMessageTrackingSearchResultType2.Subject        = findMessageTrackingSearchResultType.Subject;
                findMessageTrackingSearchResultType2.SubmittedTime  = findMessageTrackingSearchResultType.SubmittedTime;
                findMessageTrackingSearchResultType2.FirstHopServer = findMessageTrackingSearchResultType.FirstHopServer;
                findMessageTrackingSearchResultType2.Properties     = MessageConverter.CopyTrackingProperties(findMessageTrackingSearchResultType.Properties);
                findMessageTrackingReportResponseMessageType.MessageTrackingSearchResults[i] = findMessageTrackingSearchResultType2;
            }
            return(findMessageTrackingReportResponseMessageType);
        }
        public static object ConvertValueFromString(string valueToConvert, Type destinationType, string propName, object defaultValue)
        {
            if (string.IsNullOrEmpty(valueToConvert))
            {
                return(defaultValue);
            }
            bool flag;

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

            if (destinationType.IsEnum && EnumValidator.TryParse(destinationType, valueToConvert, EnumParseOptions.Default, out result))
            {
                return(result);
            }
            if (destinationType.IsGenericType && destinationType.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                bool flag2 = valueToConvert == null || "null".Equals(valueToConvert, StringComparison.OrdinalIgnoreCase) || "$null".Equals(valueToConvert, StringComparison.OrdinalIgnoreCase);
                if (flag2)
                {
                    return(null);
                }
            }
            object result2;

            try
            {
                result2 = LanguagePrimitives.ConvertTo(valueToConvert, destinationType);
            }
            catch (PSInvalidCastException)
            {
                AirSyncDiagnostics.LogEvent(AirSyncEventLogConstants.Tuple_GlobalValueNotParsable, new string[]
                {
                    propName,
                    destinationType.Name,
                    valueToConvert,
                    defaultValue.ToString()
                });
                result2 = defaultValue;
            }
            return(result2);
        }
Exemple #11
0
        // Token: 0x06001D59 RID: 7513 RVA: 0x00074FA0 File Offset: 0x000731A0
        private static void GetQueryStringParameters(HttpRequest request, out string tag, out MobileSpeechRecoRequestType requestType, out CultureInfo culture, out ExTimeZone timeZone)
        {
            ExTraceGlobals.SpeechRecognitionTracer.TraceDebug(0L, "Entering SpeechRecognitionProcessor.GetQueryStringParameters");
            NameValueCollection queryString = request.QueryString;
            string text  = queryString["tag"];
            string text2 = queryString["operation"];
            string text3 = queryString["culture"];
            string text4 = queryString["timezone"];

            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentOutOfRangeException("tag", "Parameter was not specified");
            }
            tag = text;
            if (string.IsNullOrEmpty(text4))
            {
                throw new ArgumentOutOfRangeException("timezone", "Parameter was not specified");
            }
            if (!ExTimeZoneEnumerator.Instance.TryGetTimeZoneByName(text4, out timeZone))
            {
                throw new ArgumentOutOfRangeException("timezone", text4, "Invalid parameter");
            }
            if (text2 == null)
            {
                throw new ArgumentOutOfRangeException("operation", "Parameter was not specified");
            }
            if (!EnumValidator.TryParse <MobileSpeechRecoRequestType>(text2, EnumParseOptions.IgnoreCase, out requestType))
            {
                throw new ArgumentOutOfRangeException("operation", text2, "Invalid parameter");
            }
            if (text3 == null)
            {
                throw new ArgumentOutOfRangeException("culture", "Parameter was not specified");
            }
            try
            {
                culture = new CultureInfo(text3);
            }
            catch (ArgumentException ex)
            {
                throw new ArgumentOutOfRangeException("culture", text3, ex.Message);
            }
        }
        internal string ToErrorMessage(bool isMultiMessageSearch, out ErrorCodeInformationAttribute errorCodeInfo, out ErrorCode errorCode)
        {
            errorCodeInfo = null;
            string result;

            if (!EnumValidator <Microsoft.Exchange.InfoWorker.Common.MessageTracking.ErrorCode> .TryParse(this.ErrorCode, EnumParseOptions.Default, out errorCode))
            {
                result = (isMultiMessageSearch ? Strings.TrackingTransientErrorMultiMessageSearch : Strings.TrackingTransientError);
            }
            else
            {
                if (!EnumAttributeInfo <Microsoft.Exchange.InfoWorker.Common.MessageTracking.ErrorCode, ErrorCodeInformationAttribute> .TryGetValue((int)errorCode, out errorCodeInfo))
                {
                    throw new InvalidOperationException(string.Format("{0} not annotated with ErrorCodeInformationAttribute", errorCode));
                }
                result = errorCodeInfo.ErrorFormatter(this, isMultiMessageSearch);
            }
            return(result);
        }
Exemple #13
0
 public static QueueViewerIncludesAndExcludes Parse(string s)
 {
     if (s == null)
     {
         throw new LocalizedException(DataStrings.IncludeExcludeInvalid(s));
     }
     int[]    array  = new int[QueueViewerIncludesAndExcludes.MaxFilterCount];
     string[] array2 = s.Split(new char[]
     {
         ','
     });
     foreach (string text in array2)
     {
         DeliveryType    deliveryType;
         NextHopCategory nextHopCategory;
         if (EnumValidator.TryParse <DeliveryType>(text, EnumParseOptions.IgnoreCase, out deliveryType))
         {
             array[(int)deliveryType] = 1;
         }
         else if (EnumValidator.TryParse <NextHopCategory>(text, EnumParseOptions.IgnoreCase, out nextHopCategory))
         {
             array[(int)(nextHopCategory + QueueViewerIncludesAndExcludes.NextHopCategoryBaseIndex)] = 1;
         }
         else if (StringComparer.OrdinalIgnoreCase.Compare("Empty", text.Trim()) == 0)
         {
             array[QueueViewerIncludesAndExcludes.EmptyIndex] = 1;
         }
         else
         {
             if (StringComparer.OrdinalIgnoreCase.Compare("SER", text.Trim()) != 0)
             {
                 throw new LocalizedException(DataStrings.IncludeExcludeInvalid(text));
             }
             array[10] = 1;
             array[QueueViewerIncludesAndExcludes.EmptyIndex]    = 1;
             array[QueueViewerIncludesAndExcludes.HighRiskIndex] = 1;
         }
     }
     return(new QueueViewerIncludesAndExcludes(array));
 }
        // Token: 0x06000386 RID: 902 RVA: 0x00015F04 File Offset: 0x00014104
        private static bool TryGetRequestVersion(out ExchangeVersion requestVersion)
        {
            requestVersion = ExchangeVersion.Exchange2010;
            bool result;

            try
            {
                MessageHeaders incomingMessageHeaders = OperationContext.Current.IncomingMessageHeaders;
                string         header = incomingMessageHeaders.GetHeader <string>("RequestedServerVersion", "http://schemas.microsoft.com/exchange/2010/Autodiscover");
                AutodiscoverRequestMessage.RemapEquivalentRequestedExchangeVersion(ref header);
                result = EnumValidator <ExchangeVersion> .TryParse(header, EnumParseOptions.Default, out requestVersion);
            }
            catch (MessageHeaderException)
            {
                result = false;
            }
            catch (SerializationException)
            {
                result = false;
            }
            return(result);
        }
 private static bool TryGetCapabilities(string capabilitiesPart, out SmtpReceiveCapabilities capabilities)
 {
     return(EnumValidator.TryParse <SmtpReceiveCapabilities>(capabilitiesPart, EnumParseOptions.AllowNumericConstants | EnumParseOptions.IgnoreCase, out capabilities));
 }
Exemple #16
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));
        }
        private static bool EnumerationValidator <T>(object value) where T : struct
        {
            T t;

            return(value != null && EnumValidator <T> .TryParse((string)value, EnumParseOptions.Default, out t));
        }
Exemple #18
0
        internal static bool TryCreateConditions(string filter, out List <InterceptorAgentCondition> conditions, out LocalizedString error)
        {
            error      = LocalizedString.Empty;
            conditions = new List <InterceptorAgentCondition>();
            if (filter.Trim().Contains(" -or "))
            {
                error = Strings.InterceptorErrorConditionConjunctionNotSupported("or");
                return(false);
            }
            bool   flag   = false;
            string header = null;
            InterceptorAgentConditionMatchType headerMatchType = InterceptorAgentConditionMatchType.CaseInsensitive;

            string[] array = filter.Trim().Split(new string[]
            {
                " -and "
            }, StringSplitOptions.RemoveEmptyEntries);
            string[] array2 = array;
            int      i      = 0;

            while (i < array2.Length)
            {
                string text = array2[i];
                string text2;
                string text3;
                string operand;
                bool   result;
                InterceptorAgentConditionType interceptorAgentConditionType;
                if (!InterceptorHelper.TryMatchCondition(text, out text2, out text3, out operand))
                {
                    error  = Strings.InterceptorErrorConditionInvalidFormat(text);
                    result = false;
                }
                else if (!EnumValidator <InterceptorAgentConditionType> .TryParse(text2, EnumParseOptions.IgnoreCase, out interceptorAgentConditionType) || interceptorAgentConditionType == InterceptorAgentConditionType.Invalid)
                {
                    error  = Strings.InterceptorErrorConditionInvalidProperty(text2);
                    result = false;
                }
                else if (!InterceptorHelper.CheckHeaderValue(flag, interceptorAgentConditionType, out error))
                {
                    result = false;
                }
                else
                {
                    InterceptorAgentConditionMatchType interceptorAgentConditionMatchType = InterceptorHelper.ParseMatchType(operand);
                    string error2;
                    if (!InterceptorAgentCondition.ValidateCondition(interceptorAgentConditionType, interceptorAgentConditionMatchType, out error2))
                    {
                        error  = Strings.InterceptorErrorInvalidConditionMatchTypePair(text, error2);
                        result = false;
                    }
                    else
                    {
                        if (InterceptorAgentCondition.ValidateConditionTypeValue(interceptorAgentConditionType, text3, out error2))
                        {
                            if (interceptorAgentConditionType == InterceptorAgentConditionType.HeaderName)
                            {
                                flag            = true;
                                header          = text3;
                                headerMatchType = interceptorAgentConditionMatchType;
                            }
                            else if (interceptorAgentConditionType == InterceptorAgentConditionType.HeaderValue)
                            {
                                try
                                {
                                    conditions.Add(new InterceptorAgentCondition(header, headerMatchType, text3, interceptorAgentConditionMatchType));
                                }
                                catch (ArgumentException error3)
                                {
                                    error = Strings.InterceptorErrorConditionInvalidRegex(text3, error3);
                                    return(false);
                                }
                                flag   = false;
                                header = null;
                            }
                            else
                            {
                                if (interceptorAgentConditionType == InterceptorAgentConditionType.ProcessRole)
                                {
                                    ProcessTransportRole[] processRoles;
                                    if (!InterceptorAgentCondition.ValidateProcessRole(interceptorAgentConditionMatchType, text3, out processRoles, out error2))
                                    {
                                        error = Strings.InterceptorErrorInvalidConditionMatchTypePair(text, error2);
                                        return(false);
                                    }
                                    try
                                    {
                                        conditions.Add(new InterceptorAgentCondition(processRoles, text3, interceptorAgentConditionMatchType));
                                        goto IL_259;
                                    }
                                    catch (ArgumentException ex)
                                    {
                                        error = Strings.InterceptorErrorInvalidConditionMatchTypePair(text, ex.Message);
                                        return(false);
                                    }
                                }
                                if (interceptorAgentConditionType == InterceptorAgentConditionType.ServerVersion)
                                {
                                    ServerVersion serverVersion;
                                    if (!InterceptorAgentCondition.ValidateServerVersion(interceptorAgentConditionMatchType, text3, out serverVersion, out error2))
                                    {
                                        error = Strings.InterceptorErrorInvalidConditionMatchTypePair(text, error2);
                                        return(false);
                                    }
                                    try
                                    {
                                        conditions.Add(new InterceptorAgentCondition(serverVersion, text3, interceptorAgentConditionMatchType));
                                        goto IL_259;
                                    }
                                    catch (ArgumentException ex2)
                                    {
                                        error = Strings.InterceptorErrorInvalidConditionMatchTypePair(text, ex2.Message);
                                        return(false);
                                    }
                                }
                                try
                                {
                                    conditions.Add(new InterceptorAgentCondition(interceptorAgentConditionType, text3, interceptorAgentConditionMatchType));
                                }
                                catch (ArgumentException error4)
                                {
                                    error = Strings.InterceptorErrorConditionInvalidRegex(text3, error4);
                                    return(false);
                                }
                            }
IL_259:
                            i++;
                            continue;
                        }
                        error  = Strings.InterceptorErrorInvalidConditionTypeValue(interceptorAgentConditionType.ToString(), text3, error2);
                        result = false;
                    }
                }
                return(result);
            }
            if (flag)
            {
                error = Strings.InterceptorErrorConditionHeaderValueMissing;
                conditions.Clear();
                return(false);
            }
            return(true);
        }
Exemple #19
0
        private bool TryCreateActivationRuleInternal(XmlNode node, out ActivationRule activationRule)
        {
            activationRule = null;
            if (node == null || node.Attributes == null)
            {
                return(false);
            }
            XmlAttribute xmlAttribute = node.Attributes["type", "http://www.w3.org/2001/XMLSchema-instance"];
            string       a;

            if (!ExtensionDataHelper.TryGetNameSpaceStrippedAttributeValue(xmlAttribute, out a))
            {
                return(false);
            }
            if (!string.Equals(a, "ItemIs", StringComparison.Ordinal))
            {
                if (string.Equals(a, "ItemHasKnownEntity", StringComparison.Ordinal))
                {
                    KnownEntityType entityType;
                    if (EnumValidator.TryParse <KnownEntityType>(node.Attributes["EntityType"].Value, EnumParseOptions.Default, out entityType))
                    {
                        XmlAttribute xmlAttribute2 = node.Attributes["FilterName"];
                        XmlAttribute xmlAttribute3 = node.Attributes["RegExFilter"];
                        bool         ignoreCase    = SchemaParser.ParseBoolFromXmlAttribute(node.Attributes["IgnoreCase"]);
                        activationRule = new ItemHasKnownEntityRule(entityType, (xmlAttribute2 != null) ? xmlAttribute2.Value : null, (xmlAttribute3 != null) ? xmlAttribute3.Value : null, ignoreCase);
                        return(true);
                    }
                }
                else if (string.Equals(a, "ItemHasRegularExpressionMatch", StringComparison.Ordinal))
                {
                    RegExPropertyName propertyName;
                    if (EnumValidator.TryParse <RegExPropertyName>(node.Attributes["PropertyName"].Value, EnumParseOptions.Default, out propertyName))
                    {
                        bool ignoreCase2 = SchemaParser.ParseBoolFromXmlAttribute(node.Attributes["IgnoreCase"]);
                        activationRule = new ItemHasRegularExpressionMatchRule(node.Attributes["RegExName"].Value, node.Attributes["RegExValue"].Value, propertyName, ignoreCase2);
                        return(true);
                    }
                }
                else
                {
                    if (string.Equals(a, "ItemHasAttachment", StringComparison.Ordinal))
                    {
                        activationRule = new ItemHasAttachmentRule();
                        return(true);
                    }
                    if (node.ChildNodes != null && 0 < node.ChildNodes.Count && string.Equals(a, "RuleCollection", StringComparison.Ordinal))
                    {
                        ActivationRule[] array = new ActivationRule[node.ChildNodes.Count];
                        int num = 0;
                        foreach (object obj in node.ChildNodes)
                        {
                            XmlNode        xmlNode = (XmlNode)obj;
                            ActivationRule activationRule2;
                            if (this.IsExpectedOweNamespace(xmlNode.NamespaceURI) && string.Equals(xmlNode.LocalName, "Rule", StringComparison.Ordinal) && this.TryCreateActivationRuleInternal(xmlNode, out activationRule2))
                            {
                                array[num++] = activationRule2;
                            }
                        }
                        xmlAttribute   = node.Attributes["Mode"];
                        activationRule = new CollectionRule((xmlAttribute == null) ? "Or" : xmlAttribute.Value, array);
                        return(true);
                    }
                }
                return(false);
            }
            ItemIsRuleItemType itemType;

            if (EnumValidator.TryParse <ItemIsRuleItemType>(node.Attributes["ItemType"].Value, EnumParseOptions.Default, out itemType))
            {
                XmlAttribute       xmlAttribute4 = node.Attributes["FormType"];
                ItemIsRuleFormType formType;
                if (xmlAttribute4 == null || !EnumValidator.TryParse <ItemIsRuleFormType>(xmlAttribute4.Value, EnumParseOptions.Default, out formType))
                {
                    formType = ItemIsRuleFormType.Read;
                }
                bool         includeSubClasses = SchemaParser.ParseBoolFromXmlAttribute(node.Attributes["IncludeSubClasses"]);
                XmlAttribute xmlAttribute5     = node.Attributes["ItemClass"];
                activationRule = new ItemIsRule(itemType, (xmlAttribute5 != null) ? xmlAttribute5.Value : null, includeSubClasses, formType);
                return(true);
            }
            return(false);
        }