本文整理汇总了C#中SettingsDictionary.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# SettingsDictionary.ContainsKey方法的具体用法?C# SettingsDictionary.ContainsKey怎么用?C# SettingsDictionary.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SettingsDictionary
的用法示例。
在下文中一共展示了SettingsDictionary.ContainsKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EventProcessingAsync
public override Task EventProcessingAsync(EventContext context) {
if (!context.Event.IsError())
return Task.CompletedTask;
Error error = context.Event.GetError();
if (error == null)
return Task.CompletedTask;
if (String.IsNullOrWhiteSpace(context.Event.Message))
context.Event.Message = error.Message;
string[] commonUserMethods = { "DataContext.SubmitChanges", "Entities.SaveChanges" };
if (context.HasProperty("CommonMethods"))
commonUserMethods = context.GetProperty<string>("CommonMethods").SplitAndTrim(',');
string[] userNamespaces = null;
if (context.HasProperty("UserNamespaces"))
userNamespaces = context.GetProperty<string>("UserNamespaces").SplitAndTrim(',');
var signature = new ErrorSignature(error, userCommonMethods: commonUserMethods, userNamespaces: userNamespaces);
if (signature.SignatureInfo.Count <= 0)
return Task.CompletedTask;
var targetInfo = new SettingsDictionary(signature.SignatureInfo);
var stackingTarget = error.GetStackingTarget();
if (stackingTarget?.Error?.StackTrace != null && stackingTarget.Error.StackTrace.Count > 0 && !targetInfo.ContainsKey("Message"))
targetInfo["Message"] = stackingTarget.Error.Message;
error.Data[Error.KnownDataKeys.TargetInfo] = targetInfo;
foreach (var key in signature.SignatureInfo.Keys)
context.StackSignatureData.Add(key, signature.SignatureInfo[key]);
return Task.CompletedTask;
}
示例2: BuildDiff
private static void BuildDiff(DiffDictionary<string, string> dictionary, SettingsDictionary settingsA, SettingsDictionary settingsB) {
foreach (var settingA in settingsA) {
string oldValue, newValue;
if (settingsB.ContainsKey(settingA.Key)) {
oldValue = settingA.Value;
newValue = settingsB[settingA.Key];
}
else {
oldValue = settingA.Value;
newValue = settingsB[settingA.Key] = default(string);
}
if (oldValue != newValue) {
dictionary[settingA.Key] = new Diff<string> {
NewValue = newValue,
OldValue = oldValue
};
}
}
}
示例3: RunInternalAsync
//.........这里部分代码省略.........
if (!String.Equals(info.UserAgent.Family, "Other")) {
request.Data[RequestInfo.KnownDataKeys.Browser] = info.UserAgent.Family;
if (!String.IsNullOrEmpty(info.UserAgent.Major)) {
request.Data[RequestInfo.KnownDataKeys.BrowserVersion] = String.Join(".", new[] { info.UserAgent.Major, info.UserAgent.Minor, info.UserAgent.Patch }.Where(v => !String.IsNullOrEmpty(v)));
request.Data[RequestInfo.KnownDataKeys.BrowserMajorVersion] = info.UserAgent.Major;
}
}
if (!String.Equals(info.Device.Family, "Other"))
request.Data[RequestInfo.KnownDataKeys.Device] = info.Device.Family;
if (!String.Equals(info.OS.Family, "Other")) {
request.Data[RequestInfo.KnownDataKeys.OS] = info.OS.Family;
if (!String.IsNullOrEmpty(info.OS.Major)) {
request.Data[RequestInfo.KnownDataKeys.OSVersion] = String.Join(".", new[] { info.OS.Major, info.OS.Minor, info.OS.Patch }.Where(v => !String.IsNullOrEmpty(v)));
request.Data[RequestInfo.KnownDataKeys.OSMajorVersion] = info.OS.Major;
}
}
request.Data[RequestInfo.KnownDataKeys.IsBot] = info.Device.IsSpider;
} catch (Exception ex) {
Log.Warn().Project(e.ProjectId).Message("Unable to parse user agent {0}. Exception: {1}", request.UserAgent, ex.Message).Write();
}
}
e.AddRequestInfo(request);
}
foreach (var ip in GetIpAddresses(e, request)) {
var location = await _geoIpResolver.ResolveIpAsync(ip, token);
if (location == null || !location.IsValid())
continue;
e.Geo = location.ToString();
break;
}
if (e.Type == Event.KnownTypes.NotFound && request != null) {
if (String.IsNullOrWhiteSpace(e.Source)) {
e.Message = null;
e.Source = request.GetFullPath(includeHttpMethod: true, includeHost: false, includeQueryString: false);
}
return;
}
var error = e.GetError();
if (error == null) {
Debugger.Break();
Log.Error().Project(e.ProjectId).Message("Unable to get parse error model: {0}", e.Id).Write();
return;
}
var stackingTarget = error.GetStackingTarget();
if (stackingTarget != null && stackingTarget.Method != null && !String.IsNullOrEmpty(stackingTarget.Method.GetDeclaringTypeFullName()))
e.Source = stackingTarget.Method.GetDeclaringTypeFullName().Truncate(2000);
var signature = new ErrorSignature(error);
if (signature.SignatureInfo.Count <= 0)
return;
var targetInfo = new SettingsDictionary(signature.SignatureInfo);
if (stackingTarget != null && stackingTarget.Error != null && !targetInfo.ContainsKey("Message"))
targetInfo["Message"] = stackingTarget.Error.Message;
error.Data[Error.KnownDataKeys.TargetInfo] = targetInfo;
});
Log.Info().Message("Saving events {0}-{1} {2:N0} total", errors.First().Id, errors.Last().Id, upgradedEvents.Count).Write();
try {
_eventRepository.Add(upgradedEvents, sendNotification: false);
} catch (Exception) {
foreach (var persistentEvent in upgradedEvents) {
try {
_eventRepository.Add(persistentEvent, sendNotification: false);
} catch (Exception ex) {
//Debugger.Break();
Log.Error().Exception(ex).Project(persistentEvent.ProjectId).Message("An error occurred while migrating event '{0}': {1}", persistentEvent.Id, ex.Message).Write();
}
}
}
batch++;
total += upgradedEvents.Count;
Log.Info().Message("Getting next batch of events").Write();
var sw = new Stopwatch();
sw.Start();
errors = errorCollection.Find(query).SetSortOrder(SortBy.Ascending(ErrorFieldNames.OccurrenceDate_UTC)).SetLimit(_batchSize).SetSkip(_batchSize * batch).ToList();
sw.Stop();
Log.Info().Message("Finished getting next batch of events in {0}ms", sw.ElapsedMilliseconds).Write();
}
Log.Info().Message("Finished processing event migration jobs for date range: {0}-{1}", new DateTimeOffset(queueEntry.Value.StartTicks, TimeSpan.Zero).ToString("O"), new DateTimeOffset(queueEntry.Value.EndTicks, TimeSpan.Zero).ToString("O")).Write();
_cache.Set("migration-completedperiod", queueEntry.Value.EndTicks);
queueEntry.Complete();
return JobResult.Success;
}