|
2 | 2 | using System.Collections.Concurrent; |
3 | 3 | using System.Collections.Generic; |
4 | 4 | using System.ComponentModel; |
5 | | -using System.Linq; |
6 | 5 | using Sentry.Extensibility; |
| 6 | +using System.Linq; |
7 | 7 | using Sentry.Internal; |
8 | 8 | using Sentry.Protocol; |
9 | 9 | using Constants = Sentry.Protocol.Constants; |
@@ -354,39 +354,8 @@ public static void Apply(this IScope from, IScope to) |
354 | 354 | /// <param name="state">The state object to apply.</param> |
355 | 355 | public static void Apply(this IScope scope, object state) |
356 | 356 | { |
357 | | - switch (state) |
358 | | - { |
359 | | - case string scopeString: |
360 | | - // TODO: find unique key to support multiple single-string scopes |
361 | | - scope.SetTag("scope", scopeString); |
362 | | - break; |
363 | | - case IEnumerable<KeyValuePair<string, string>> keyValStringString: |
364 | | - scope.SetTags(keyValStringString |
365 | | - .Where(kv => !string.IsNullOrEmpty(kv.Value))); |
366 | | - break; |
367 | | - case IEnumerable<KeyValuePair<string, object>> keyValStringObject: |
368 | | - { |
369 | | - scope.SetTags(keyValStringObject |
370 | | - .Select(k => new KeyValuePair<string, string>( |
371 | | - k.Key, |
372 | | - k.Value?.ToString()!)) |
373 | | - .Where(kv => !string.IsNullOrEmpty(kv.Value))); |
374 | | - |
375 | | - break; |
376 | | - } |
377 | | -#if HAS_VALUE_TUPLE |
378 | | - case ValueTuple<string, string> tupleStringString: |
379 | | - if (!string.IsNullOrEmpty(tupleStringString.Item2)) |
380 | | - { |
381 | | - scope.SetTag(tupleStringString.Item1, tupleStringString.Item2); |
382 | | - } |
383 | | - |
384 | | - break; |
385 | | -#endif |
386 | | - default: |
387 | | - scope.SetExtra("state", state); |
388 | | - break; |
389 | | - } |
| 357 | + var processor = scope.ScopeOptions?.SentryScopeStateProcessor ?? new DefaultSentryScopeStateProcessor(); |
| 358 | + processor.Apply(scope, state); |
390 | 359 | } |
391 | 360 |
|
392 | 361 | /// <summary> |
|
0 commit comments