//----------------------------------------------------------------------------- // // Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"). // You may not use this file except in compliance with the License. // A copy of the License is located at // // http://aws.amazon.com/apache2.0 // // or in the "license" file accompanying this file. This file is distributed // on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either // express or implied. See the License for the specific language governing // permissions and limitations under the License. // //----------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; namespace Amazon.XRay.Recorder.Core.Internal.Entities { /// /// key-value pairs that can be queried through GetTraceSummaries. /// [Serializable] public class Annotations : IEnumerable> { private readonly IDictionary _annotations; /// /// Initializes a new instance of the class. /// public Annotations() { _annotations = new ConcurrentDictionary(); } /// /// Gets the annotation value associated with the specified key. /// /// The key of the annotation value to get /// The value associated with the specified key public object this[string key] { get { return _annotations[key]; } } /// /// Add the specified key and string value as annotation /// /// The key of the annotation to add /// The string value of the annotation to add public void Add(string key, string value) { _annotations[key] = value; } /// /// Add the specified key and 32bit integer value as annotation /// /// The key of the annotation to add /// The 32bit integer value of the annotation to add public void Add(string key, int value) { _annotations[key] = value; } /// /// Add the specified key and double value as annotation /// /// The key of the annotation to add /// The double value of the annotation to add public void Add(string key, double value) { _annotations[key] = value; } /// /// Add the specified key and long value as annotation /// /// The key of the annotation to add /// The long value of the annotation to add public void Add(string key, long value) { _annotations[key] = value; } /// /// Add the specified key and boolean value as annotation /// /// The key of the annotation to add /// The boolean value of the annotation to add public void Add(string key, bool value) { _annotations[key] = value; } /// /// Returns an enumerator that iterates through annotations /// /// An enumerator structure for annotations. public IEnumerator> GetEnumerator() { return _annotations.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } }