| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | using System.ComponentModel; |
| | | 7 | | using System.Text.Json.Serialization; |
| | | 8 | | |
| | | 9 | | namespace Azure.Data.AppConfiguration |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// A setting, defined by a unique combination of a key and label. |
| | | 13 | | /// </summary> |
| | | 14 | | [JsonConverter(typeof(ConfigurationSettingJsonConverter))] |
| | | 15 | | public sealed class ConfigurationSetting |
| | | 16 | | { |
| | | 17 | | private IDictionary<string, string> _tags; |
| | | 18 | | |
| | 4540 | 19 | | internal ConfigurationSetting() |
| | | 20 | | { |
| | 4540 | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Creates a configuration setting and sets the values from the passed in parameter to this setting. |
| | | 25 | | /// </summary> |
| | | 26 | | /// <param name="key">The primary identifier of the configuration setting.</param> |
| | | 27 | | /// <param name="value">The configuration setting's value.</param> |
| | | 28 | | /// <param name="label">A label used to group this configuration setting with others.</param> |
| | 202 | 29 | | public ConfigurationSetting(string key, string value, string label = null) |
| | | 30 | | { |
| | 202 | 31 | | Key = key; |
| | 202 | 32 | | Value = value; |
| | 202 | 33 | | Label = label; |
| | 202 | 34 | | } |
| | | 35 | | |
| | | 36 | | #region Snippet:SettingProperties |
| | | 37 | | /// <summary> |
| | | 38 | | /// The primary identifier of the configuration setting. |
| | | 39 | | /// A <see cref="Key"/> is used together with a <see cref="Label"/> to uniquely identify a configuration setting |
| | | 40 | | /// </summary> |
| | 6728 | 41 | | public string Key { get; set; } |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// A value used to group configuration settings. |
| | | 45 | | /// A <see cref="Label"/> is used together with a <see cref="Key"/> to uniquely identify a configuration setting |
| | | 46 | | /// </summary> |
| | 5956 | 47 | | public string Label { get; set; } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// The configuration setting's value. |
| | | 51 | | /// </summary> |
| | 5944 | 52 | | public string Value { get; set; } |
| | | 53 | | |
| | | 54 | | /// <summary> |
| | | 55 | | /// The content type of the configuration setting's value. |
| | | 56 | | /// Providing a proper content-type can enable transformations of values when they are retrieved by applications |
| | | 57 | | /// </summary> |
| | 5400 | 58 | | public string ContentType { get; set; } |
| | | 59 | | |
| | | 60 | | /// <summary> |
| | | 61 | | /// An ETag indicating the state of a configuration setting within a configuration store. |
| | | 62 | | /// </summary> |
| | 5124 | 63 | | public ETag ETag { get; internal set; } |
| | | 64 | | |
| | | 65 | | /// <summary> |
| | | 66 | | /// The last time a modifying operation was performed on the given configuration setting. |
| | | 67 | | /// </summary> |
| | 4470 | 68 | | public DateTimeOffset? LastModified { get; internal set; } |
| | | 69 | | |
| | | 70 | | /// <summary> |
| | | 71 | | /// A value indicating whether the configuration setting is read only. |
| | | 72 | | /// A read only configuration setting may not be modified until it is made writable. |
| | | 73 | | /// </summary> |
| | 4530 | 74 | | public bool? IsReadOnly { get; internal set; } |
| | | 75 | | |
| | | 76 | | /// <summary> |
| | | 77 | | /// A dictionary of tags used to assign additional properties to a configuration setting. |
| | | 78 | | /// These can be used to indicate how a configuration setting may be applied. |
| | | 79 | | /// </summary> |
| | | 80 | | public IDictionary<string, string> Tags |
| | | 81 | | #endregion Setting:Properties |
| | | 82 | | { |
| | 2362 | 83 | | get => _tags ?? (_tags = new Dictionary<string, string>()); |
| | 246 | 84 | | internal set => _tags = value; |
| | | 85 | | } |
| | | 86 | | |
| | | 87 | | /// <summary> |
| | | 88 | | /// Check if two ConfigurationSetting instances are equal. |
| | | 89 | | /// </summary> |
| | | 90 | | /// <param name="obj">The instance to compare to.</param> |
| | | 91 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 0 | 92 | | public override bool Equals(object obj) => base.Equals(obj); |
| | | 93 | | |
| | | 94 | | /// <summary> |
| | | 95 | | /// Get a hash code for the ConfigurationSetting. |
| | | 96 | | /// </summary> |
| | | 97 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 0 | 98 | | public override int GetHashCode() => base.GetHashCode(); |
| | | 99 | | |
| | | 100 | | /// <summary> |
| | | 101 | | /// Creates a (Key,Value) string in reference to the ConfigurationSetting. |
| | | 102 | | /// </summary> |
| | | 103 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | | 104 | | public override string ToString() |
| | 0 | 105 | | => $"({Key},{Value})"; |
| | | 106 | | } |
| | | 107 | | } |