internal override RegisterConditionResult GetExchangeDiagnosticsInfoData(DiagnosableParameters argument) { ConditionalRegistration registration = ConditionalRegistration.CreateFromArgument(argument); ConditionalRegistrationCache.Singleton.Register(registration); return(new RegisterConditionResult(registration)); }
// Token: 0x06000900 RID: 2304 RVA: 0x000238E4 File Offset: 0x00021AE4 internal List <ConditionalResults> Evaluate(IReadOnlyPropertyBag propertyBag) { List <BaseConditionalRegistration> values = this.cache.Values; if (values == null || values.Count == 0) { return(null); } List <ConditionalResults> list = null; foreach (BaseConditionalRegistration baseConditionalRegistration in values) { ConditionalResults conditionalResults = baseConditionalRegistration.Evaluate(propertyBag); if (conditionalResults != null) { if (list == null) { list = new List <ConditionalResults>(); } list.Add(conditionalResults); ConditionalRegistration conditionalRegistration = baseConditionalRegistration as ConditionalRegistration; if (conditionalRegistration != null) { int currentHits = conditionalRegistration.CurrentHits; if (currentHits >= conditionalRegistration.MaxHits) { ExTraceGlobals.DiagnosticHandlersTracer.TraceDebug <string, int, int>((long)this.GetHashCode(), "[ConditionalRegistrationCache.Evaluate] Removing entry '{0}' because current hits {1} exceeds MaxHits {2}.", conditionalRegistration.Cookie, currentHits, conditionalRegistration.MaxHits); this.cache.Remove(baseConditionalRegistration.Cookie); } } } } return(list); }
internal void HydrateNonPersistentRegistrations() { string conditionalRegistrationsDirectory = ConditionalRegistrationLog.GetConditionalRegistrationsDirectory(); if (!string.IsNullOrEmpty(conditionalRegistrationsDirectory)) { DirectoryInfo directoryInfo = new DirectoryInfo(conditionalRegistrationsDirectory); FileInfo[] files = directoryInfo.GetFiles("*.xml"); foreach (FileInfo fileInfo in files) { try { ConditionalRegistration conditionalRegistration; using (StreamReader streamReader = fileInfo.OpenText()) { conditionalRegistration = ConditionalRegistration.DeserializeFromStreamReader(streamReader); } if (conditionalRegistration != null) { ConditionalRegistrationCache.Singleton.Register(conditionalRegistration); } else { File.Delete(fileInfo.FullName); } } catch (Exception exception) { ConditionalRegistrationLog.LogFailedHydration(new XElement(string.Format("Failed to hydrate registration with cookie:{0}", fileInfo.Name)), exception); } } } }
internal RegisterConditionResult(ConditionalRegistration registration) { this.Cookie = registration.Cookie; this.ParsedFilter = registration.QueryFilter.ToString(); this.MaxHits = registration.MaxHits; this.TimeToLive = registration.TimeToLive.ToString(); }
// Token: 0x06000936 RID: 2358 RVA: 0x00024AB8 File Offset: 0x00022CB8 private GetConditionMetadataResult GetAllMetadata(string userIdentity = "") { GetConditionMetadataResult getConditionMetadataResult = new GetConditionMetadataResult(); List <ActiveConditionalMetadataResult> list = new List <ActiveConditionalMetadataResult>(); List <ConditionalMetadataResult> list2 = new List <ConditionalMetadataResult>(); List <BaseConditionalRegistration> list3; List <ConditionalRegistrationLog.ConditionalRegistrationHitMetadata> list4; ConditionalRegistrationCache.Singleton.GetRegistrationMetadata(userIdentity, out list3, out list4); List <string> list5 = new List <string>(); if (list4 != null) { foreach (ConditionalRegistrationLog.ConditionalRegistrationHitMetadata conditionalRegistrationHitMetadata in list4) { ConditionalRegistration reg = null; foreach (BaseConditionalRegistration baseConditionalRegistration in list3) { ConditionalRegistration conditionalRegistration = (ConditionalRegistration)baseConditionalRegistration; if (conditionalRegistration.Cookie == conditionalRegistrationHitMetadata.Cookie) { reg = conditionalRegistration; list5.Add(conditionalRegistration.Cookie); break; } } ActiveConditionalMetadataResult activeConditionalMetadataResult; ConditionalMetadataResult conditionalMetadataResult; this.FillCorrectResultType(reg, conditionalRegistrationHitMetadata, out activeConditionalMetadataResult, out conditionalMetadataResult); if (activeConditionalMetadataResult != null) { list.Add(activeConditionalMetadataResult); } else if (conditionalMetadataResult != null) { list2.Add(conditionalMetadataResult); } } } foreach (BaseConditionalRegistration baseConditionalRegistration2 in list3) { if (!list5.Contains(baseConditionalRegistration2.Cookie)) { ActiveConditionalMetadataResult activeConditionalMetadataResult2; ConditionalMetadataResult conditionalMetadataResult2; this.FillCorrectResultType(baseConditionalRegistration2, null, out activeConditionalMetadataResult2, out conditionalMetadataResult2); activeConditionalMetadataResult2.Cookie = baseConditionalRegistration2.Cookie; list.Add(activeConditionalMetadataResult2); } } getConditionMetadataResult.ActiveConditions = list.ToArray(); getConditionMetadataResult.CompletedConditions = list2.ToArray(); return(getConditionMetadataResult); }
public static string Save(ConditionalRegistration registration) { string text = Path.Combine(ConditionalRegistrationLog.GetConditionalRegistrationsDirectory(), string.Format("{0}.{1}", registration.Cookie, "xml")); ExTraceGlobals.DiagnosticHandlersTracer.TraceDebug <string, string>(0L, "[ConditionalRegistrationLog.Save] Logging registration for '{0}' of user '{1}'", registration.Cookie, registration.User); using (XmlWriter xmlWriter = XmlWriter.Create(text, ConditionalRegistrationLog.writerSettings)) { XElement xelement = new XElement("ConditionalRegistration"); XElement content = new XElement("Description") { Value = registration.Description }; xelement.Add(content); XElement content2 = new XElement("CreatedTime") { Value = registration.Created.ToString() }; xelement.Add(content2); XElement content3 = new XElement("User") { Value = registration.User }; xelement.Add(content3); XElement content4 = new XElement("Cookie") { Value = registration.Cookie }; xelement.Add(content4); XElement content5 = new XElement("PropertiesToFetch") { Value = registration.OriginalPropertiesToFetch }; xelement.Add(content5); XElement content6 = new XElement("Filter") { Value = registration.OriginalFilter }; xelement.Add(content6); XElement content7 = new XElement("TimeToLive") { Value = registration.TimeToLive.ToString() }; xelement.Add(content7); XElement content8 = new XElement("MaxHits") { Value = registration.MaxHits.ToString() }; xelement.Add(content8); xelement.WriteTo(xmlWriter); xmlWriter.Flush(); } return(text); }
// Token: 0x06000982 RID: 2434 RVA: 0x00025698 File Offset: 0x00023898 internal RemoveConditionResult GetRemove(string argument) { int num = argument.IndexOf('='); string cookie = argument.Substring(num + 1); ConditionalRegistration conditionalRegistration = ConditionalRegistrationCache.Singleton.GetRegistration(cookie) as ConditionalRegistration; bool removed = false; if (conditionalRegistration != null) { removed = ConditionalRegistrationCache.Singleton.Remove(cookie); } return(new RemoveConditionResult(cookie, removed)); }
// Token: 0x06000901 RID: 2305 RVA: 0x000239C0 File Offset: 0x00021BC0 internal void Register(ConditionalRegistration registration) { TimeSpan expiration = (ConditionalRegistrationCache.MaxActiveRegistrationTimeEntry.Value < registration.TimeToLive) ? ConditionalRegistrationCache.MaxActiveRegistrationTimeEntry.Value : registration.TimeToLive; if (this.cache.TryAddAbsolute(registration.Cookie, registration, expiration)) { this.UpdateActiveProperties(registration, true); if (ConditionalRegistrationCache.TESTHOOK_PersistRegistration == null) { ConditionalRegistrationLog.Save(registration); return; } ConditionalRegistrationCache.TESTHOOK_PersistRegistration(registration); } }
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)); }
// Token: 0x06000983 RID: 2435 RVA: 0x000256E4 File Offset: 0x000238E4 internal RemoveConditionResult GetAllRemove() { List <string> allKeys = ConditionalRegistrationCache.Singleton.GetAllKeys(); for (int i = allKeys.Count - 1; i >= 0; i--) { string cookie = allKeys[i]; ConditionalRegistration conditionalRegistration = ConditionalRegistrationCache.Singleton.GetRegistration(cookie) as ConditionalRegistration; if (conditionalRegistration != null) { ConditionalRegistrationCache.Singleton.Remove(cookie); } else { allKeys.RemoveAt(i); } } return(new RemoveConditionResult(allKeys)); }
// 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; } }
public XElement GetXmlResults() { XElement xelement = new XElement("Registration"); XElement xelement2 = new XElement("CreationDate"); xelement.Add(xelement2); xelement2.Add(new XText(this.Registration.Created.ToString())); XElement xelement3 = new XElement("Description"); xelement.Add(xelement3); ConditionalRegistration conditionalRegistration = this.Registration as ConditionalRegistration; if (conditionalRegistration != null) { xelement3.Add(new XCData(conditionalRegistration.Description)); } else { xelement3.Add(new XCData((this.Registration as PersistentConditionalRegistration).Cookie)); } XElement xelement4 = new XElement("OriginalFilter"); xelement.Add(xelement4); xelement4.Add(new XCData(this.Registration.OriginalFilter)); XElement xelement5 = new XElement("ParsedFilter"); xelement.Add(xelement5); xelement5.Add(new XCData(this.Registration.QueryFilter.ToString())); XElement xelement6 = new XElement("Fetch"); xelement.Add(xelement6); xelement6.Add(new XText(this.Registration.OriginalPropertiesToFetch)); ConditionalRegistration conditionalRegistration2 = this.Registration as ConditionalRegistration; if (conditionalRegistration2 != null) { XElement xelement7 = new XElement("MaxHits"); xelement.Add(xelement7); xelement7.Add(new XText(conditionalRegistration2.MaxHits.ToString())); } XElement xelement8 = new XElement("Results"); xelement.Add(xelement8); xelement8.Add(new XText(this.Result.ToString())); XElement xelement9 = new XElement("CompleteDate"); xelement.Add(xelement9); xelement9.Add(new XText(this.Completed.ToString())); XElement xelement10 = new XElement("Data"); xelement.Add(xelement10); if (this.Data == null) { xelement10.Add(new XCData("NO DATA")); } else { foreach (KeyValuePair <PropertyDefinition, object> keyValuePair in this.Data) { XElement xelement11 = new XElement(keyValuePair.Key.Name); xelement10.Add(xelement11); if (keyValuePair.Value is string || keyValuePair.Value.GetType().IsValueType) { xelement11.Add(new XCData(keyValuePair.Value.ToString())); } else { XmlSerializer xmlSerializer = new XmlSerializer(keyValuePair.Value.GetType()); using (MemoryStream memoryStream = new MemoryStream()) { xmlSerializer.Serialize(memoryStream, keyValuePair.Value); memoryStream.Position = 0L; StreamReader streamReader = new StreamReader(memoryStream); xelement11.Add(new XCData(streamReader.ReadToEnd())); streamReader.Close(); } } } } return(xelement); }