Ejemplo n.º 1
0
        // Token: 0x060008E2 RID: 2274 RVA: 0x00023118 File Offset: 0x00021318
        private static string[] ExpandPropertyGroups(string properties)
        {
            List <string> list = new List <string>();

            foreach (string text in properties.Split(new char[]
            {
                ','
            }))
            {
                if (BaseConditionalRegistration.IsPropertyGroup(text))
                {
                    list.AddRange(BaseConditionalRegistration.GetPropertiesForPropertyGroup(text.ToLower().Trim(new char[]
                    {
                        '[',
                        ']'
                    })).Split(new char[]
                    {
                        ','
                    }));
                }
                else
                {
                    list.Add(text);
                }
            }
            return(list.ToArray());
        }
Ejemplo n.º 2
0
 // Token: 0x060008BF RID: 2239 RVA: 0x00022C3C File Offset: 0x00020E3C
 public static void Initialize(string protocolName, ObjectSchema fetchSchema, ObjectSchema querySchema, Dictionary <string, string> customPropertyGroups = null)
 {
     if (BaseConditionalRegistration.Initialized)
     {
         return;
     }
     BaseConditionalRegistration.FetchSchema = fetchSchema;
     BaseConditionalRegistration.QuerySchema = querySchema;
     ConditionalRegistrationLog.ProtocolName = protocolName;
     if (BaseConditionalRegistration.PropertyGroups == null)
     {
         BaseConditionalRegistration.PropertyGroups = new Dictionary <string, string>();
     }
     BaseConditionalRegistration.PropertyGroups.Add("user", BaseConditionalRegistration.GetConfigurationValue("UserPropertyGroup") ?? "SmtpAddress,DisplayName,TenantName,WindowsLiveId,MailboxServer,MailboxDatabase,MailboxServerVersion,IsMonitoringUser");
     BaseConditionalRegistration.PropertyGroups.Add("wlm", BaseConditionalRegistration.GetConfigurationValue("WlmPropertyGroup") ?? "IsOverBudgetAtStart,IsOverBudgetAtEnd,BudgetBalanceStart,BudgetBalanceEnd,BudgetDelay,BudgetUsed,BudgetLockedOut,BudgetLockedUntil");
     BaseConditionalRegistration.PropertyGroups.Add("policy", BaseConditionalRegistration.GetConfigurationValue("PolicyPropertyGroup") ?? "ThrottlingPolicyName,MaxConcurrency,MaxBurst,RechargeRate,CutoffBalance,ThrottlingPolicyScope,ConcurrencyStart,ConcurrencyEnd");
     BaseConditionalRegistration.PropertyGroups.Add("error", BaseConditionalRegistration.GetConfigurationValue("ErrorPropertyGroup") ?? "Exception");
     if (customPropertyGroups != null)
     {
         foreach (string key in customPropertyGroups.Keys)
         {
             if (!BaseConditionalRegistration.PropertyGroups.ContainsKey(key))
             {
                 BaseConditionalRegistration.PropertyGroups.Add(key, customPropertyGroups[key]);
             }
         }
     }
     BaseConditionalRegistration.Initialized = true;
     RegisterConditionHandler.GetInstance().HydratePersistentHandlers();
     RegisterConditionHandler.GetInstance().HydrateNonPersistentRegistrations();
 }
Ejemplo n.º 3
0
 // Token: 0x06000902 RID: 2306 RVA: 0x00023A30 File Offset: 0x00021C30
 private void UpdateActiveProperties(BaseConditionalRegistration newRegistration, bool adding)
 {
     lock (this.activePropertiesLock)
     {
         foreach (PropertyDefinition key in newRegistration.PropertiesToFetch)
         {
             int num;
             this.activeProperties.TryGetValue(key, out num);
             num += (adding ? 1 : -1);
             if (num <= 0)
             {
                 num = 0;
             }
             this.activeProperties[key] = num;
         }
         foreach (PropertyDefinition key2 in newRegistration.QueryFilter.FilterProperties())
         {
             int num2;
             this.activeProperties.TryGetValue(key2, out num2);
             num2 += (adding ? 1 : -1);
             if (num2 <= 0)
             {
                 num2 = 0;
             }
             this.activeProperties[key2] = num2;
         }
     }
 }
Ejemplo n.º 4
0
        // Token: 0x060008DF RID: 2271 RVA: 0x00023038 File Offset: 0x00021238
        internal static PropertyDefinition[] ParsePropertiesToFetch(string propertiesToFetch)
        {
            if (string.IsNullOrEmpty(propertiesToFetch))
            {
                throw new ArgumentException("propertiesToFetch cannot be null or empty.");
            }
            string[] array = BaseConditionalRegistration.ExpandPropertyGroups(propertiesToFetch);
            if (array.Length > 100)
            {
                throw new ArgumentException(string.Format("A maximum of {0} properties can be requested", 100));
            }
            PropertyDefinition[] array2 = new PropertyDefinition[array.Length];
            int num = 0;

            foreach (string text in array)
            {
                PropertyDefinition propertyDefinition = BaseConditionalRegistration.FetchSchema[text.Trim()];
                if (propertyDefinition == null)
                {
                    throw new ArgumentException("Undefined property in properties to fetch: " + text);
                }
                array2[num++] = propertyDefinition;
            }
            return(array2);
        }
Ejemplo n.º 5
0
 public ConditionalResults(BaseConditionalRegistration registration, RegistrationResult result, Dictionary <PropertyDefinition, object> data)
 {
     this.Completed    = (ExDateTime)TimeProvider.UtcNow;
     this.Registration = registration;
     this.Result       = result;
     this.Data         = data;
 }
Ejemplo n.º 6
0
        private static void ParseOptions(string argument, out string description, out uint maxHits, out TimeSpan timeToLive)
        {
            string text  = argument.Trim();
            string text2 = text.ToLower();

            maxHits     = 0U;
            timeToLive  = TimeSpan.Zero;
            description = string.Empty;
            int num = text2.IndexOf(" options ");

            if (num != -1)
            {
                string   text3 = text.Substring(num + " options ".Length);
                string[] array = text3.Split(new char[]
                {
                    ','
                });
                foreach (string text4 in array)
                {
                    string text5 = text4.Trim().ToLower();
                    if (text5.StartsWith("maxhits", StringComparison.OrdinalIgnoreCase))
                    {
                        string rightHand = BaseConditionalRegistration.GetRightHand(text5);
                        if (!uint.TryParse(rightHand, out maxHits))
                        {
                            throw new ArgumentException("Invalid value for MaxHits: " + rightHand);
                        }
                    }
                    else if (text5.StartsWith("timetolive", StringComparison.OrdinalIgnoreCase))
                    {
                        string rightHand2 = BaseConditionalRegistration.GetRightHand(text5);
                        if (!TimeSpan.TryParse(rightHand2, out timeToLive))
                        {
                            throw new ArgumentException("Invalid value for TimeToLive: " + rightHand2);
                        }
                        if (timeToLive <= TimeSpan.Zero)
                        {
                            throw new ArgumentOutOfRangeException("TimeToLive must be > TimeSpan.Zero.  Actual: " + timeToLive);
                        }
                    }
                    else
                    {
                        if (!text5.StartsWith("description", StringComparison.OrdinalIgnoreCase))
                        {
                            throw new ArgumentException(string.Format("Unknown option: '{0}'", text5));
                        }
                        description = BaseConditionalRegistration.GetRightHand(text5);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public static ConditionalRegistration CreateFromArgument(DiagnosableParameters argument)
        {
            if (BaseConditionalRegistration.FetchSchema == null || BaseConditionalRegistration.QuerySchema == null || string.IsNullOrEmpty(ConditionalRegistrationLog.ProtocolName))
            {
                throw new InvalidOperationException("Can not use Conditional Diagnostics Handlers without proper initialization. Call 'BaseConditionalRegistration.Initialize' to initialize pre-requisites.");
            }
            string propertiesToFetch;
            string whereClause;

            BaseConditionalRegistration.ParseArgument(argument.Argument, out propertiesToFetch, out whereClause);
            string   arg;
            uint     num;
            TimeSpan timeSpan;

            ConditionalRegistration.ParseOptions(argument.Argument, out arg, out num, out timeSpan);
            return(new ConditionalRegistration(string.Format("[{0}] {1}", argument.UserIdentity, arg), argument.UserIdentity.Replace("/", "-"), Guid.NewGuid().ToString(), propertiesToFetch, whereClause, (int)((num == 0U) ? 10U : num), (timeSpan <= TimeSpan.Zero) ? ConditionalRegistration.DefaultTimeToLive : timeSpan));
        }
Ejemplo n.º 8
0
 // Token: 0x0600090B RID: 2315 RVA: 0x00023C9C File Offset: 0x00021E9C
 private void HandleRemoveRegistration(string key, BaseConditionalRegistration value, RemoveReason reason)
 {
     ExTraceGlobals.DiagnosticHandlersTracer.TraceDebug <string, RemoveReason, string>((long)this.GetHashCode(), "[ConditionalRegistrationCache.HandleRemoveRegistration] Cookie: {0} was removed for reason {1}.  Description: '{2}'", key, reason, value.Description ?? "<NULL>");
     if (ConditionalRegistrationCache.TESTHOOK_DeleteRegistration == null)
     {
         ConditionalRegistrationLog.DeleteRegistration(key);
     }
     else
     {
         ConditionalRegistrationCache.TESTHOOK_DeleteRegistration(key);
     }
     this.UpdateActiveProperties(value, false);
     if (value.OnExpired != null)
     {
         value.OnExpired(value, reason);
     }
 }
Ejemplo n.º 9
0
        // Token: 0x06000907 RID: 2311 RVA: 0x00023C10 File Offset: 0x00021E10
        internal bool Remove(string cookie)
        {
            if (ConditionalRegistrationCache.TESTHOOK_DeleteRegistration == null)
            {
                ConditionalRegistrationLog.DeleteRegistration(cookie);
            }
            else
            {
                ConditionalRegistrationCache.TESTHOOK_DeleteRegistration(cookie);
            }
            BaseConditionalRegistration baseConditionalRegistration = this.cache.Remove(cookie.ToString());

            if (baseConditionalRegistration != null)
            {
                this.UpdateActiveProperties(baseConditionalRegistration, false);
            }
            return(baseConditionalRegistration != null);
        }
        public static PersistentConditionalRegistration CreateFromXml(XElement element)
        {
            if (BaseConditionalRegistration.FetchSchema == null || BaseConditionalRegistration.QuerySchema == null || string.IsNullOrEmpty(ConditionalRegistrationLog.ProtocolName))
            {
                throw new InvalidOperationException("Can not use Conditional Diagnostics Handlers without proper initialization. Call 'BaseConditionalRegistration.Initialize' to initialize pre-requisites.");
            }
            XAttribute xattribute  = element.Attribute(XName.Get("Name"));
            XAttribute xattribute2 = element.Attribute(XName.Get("Registration"));

            if (xattribute == null || xattribute2 == null)
            {
                throw new ArgumentException("[PersistentConditionalRegistration.CreateFromXml] app.config persistent registrations must have both 'Name' and 'Registration' attributes.");
            }
            string propertiesToFetch;
            string whereClause;

            BaseConditionalRegistration.ParseArgument(xattribute2.Value, out propertiesToFetch, out whereClause);
            return(new PersistentConditionalRegistration(xattribute.Value, propertiesToFetch, whereClause));
        }
 // Token: 0x06000937 RID: 2359 RVA: 0x00024C4C File Offset: 0x00022E4C
 private void FillCorrectResultType(BaseConditionalRegistration reg, ConditionalRegistrationLog.ConditionalRegistrationHitMetadata hit, out ActiveConditionalMetadataResult active, out ConditionalMetadataResult expired)
 {
     if (reg != null)
     {
         expired = null;
         active  = new ActiveConditionalMetadataResult();
         if (hit != null)
         {
             GetConditionMetadataHandler.FillHitData(active, hit);
         }
         active.Created      = (DateTime)reg.Created;
         active.Cookie       = reg.Cookie;
         active.Description  = reg.Description;
         active.SelectClause = reg.OriginalPropertiesToFetch;
         active.WhereClause  = reg.OriginalFilter;
         ConditionalRegistration conditionalRegistration = reg as ConditionalRegistration;
         if (conditionalRegistration != null)
         {
             active.MaxHits       = conditionalRegistration.MaxHits;
             active.TimeRemaining = ((DateTime)reg.Created.Add(conditionalRegistration.TimeToLive) - DateTime.UtcNow).ToString();
             return;
         }
         active.MaxHits       = int.MaxValue;
         active.TimeRemaining = "Persistent";
         return;
     }
     else
     {
         if (hit != null)
         {
             active  = null;
             expired = new ConditionalMetadataResult();
             GetConditionMetadataHandler.FillHitData(expired, hit);
             return;
         }
         active  = null;
         expired = null;
         return;
     }
 }
Ejemplo n.º 12
0
 // Token: 0x060008C2 RID: 2242 RVA: 0x00022E68 File Offset: 0x00021068
 protected BaseConditionalRegistration(string cookie, string user, string propertiesToFetch, string whereClause)
 {
     this.User                      = user;
     this.OriginalFilter            = whereClause;
     this.OriginalPropertiesToFetch = propertiesToFetch;
     this.PropertiesToFetch         = BaseConditionalRegistration.ParsePropertiesToFetch(propertiesToFetch);
     this.QueryFilter               = BaseConditionalRegistration.ParseWhereClause(whereClause);
     this.Created                   = (ExDateTime)TimeProvider.UtcNow;
     this.Cookie                    = cookie;
     if (BaseConditionalRegistration.GetHitCountForCookie == null)
     {
         ConditionalRegistrationLog.ConditionalRegistrationHitMetadata hitsForCookie = ConditionalRegistrationLog.GetHitsForCookie(user, cookie);
         if (hitsForCookie != null)
         {
             this.hits = hitsForCookie.HitFiles.Length;
             return;
         }
     }
     else
     {
         this.hits = BaseConditionalRegistration.GetHitCountForCookie();
     }
 }
Ejemplo n.º 13
0
 // Token: 0x06000905 RID: 2309 RVA: 0x00023BE0 File Offset: 0x00021DE0
 internal void GetRegistrationMetadata(string userIdentity, string cookie, out BaseConditionalRegistration reg, out ConditionalRegistrationLog.ConditionalRegistrationHitMetadata hit)
 {
     reg = this.GetRegistration(cookie);
     hit = ConditionalRegistrationLog.GetHitsForCookie(userIdentity, cookie);
 }