• Articles
  • Api Documentation
Show / Hide Table of Contents
  • Estrelica
    • Core
    • CoreConfig
    • CoreConfig.Settings
  • Estrelica.Archer.AccessControl
    • AccessControlEdit
    • AccountStatus
    • ContactSubType
    • ContactType
    • IArcherGroup
    • IArcherGroupEdit
    • IArcherRole
    • IArcherRoleEdit
    • IArcherUser
    • IArcherUserEdit
    • ISecurityParameter
    • IUserContact
    • IUserProvider
    • UserType
  • Estrelica.Archer.Content
    • ArcherContentExtensions
    • ContentFilterHelper
    • ContentReportOptions
    • ContentSearchOptions
    • ContentSource
    • ContentType
    • CurrentDateOperator
    • DatafeedHistoryStatus
    • DatafeedStatus
    • DatafeedType
    • DateOffsetOperator
    • DateValueOperator
    • DisplayFieldExtensions
    • EqualityOperator
    • FieldHistoryAuditType
    • HistoryAuditType
    • IAdvancedWorkflowAudit
    • IArcherContent
    • IArcherContentAccess
    • IArcherContentEdit
    • IArcherContentIdQuery
    • IArcherDateFieldQuery
    • IArcherDocument
    • IArcherMembershipQuery<T>
    • IArcherNumericFieldQuery
    • IArcherRecord
    • IArcherRecordQuery
    • IArcherReport
    • IArcherTextFieldQuery
    • IArcherUserGroupFieldQuery
    • IArcherValuesListQuery
    • IContentHistory
    • IContentInformation
    • IContentReport
    • IContentReportOptions
    • IContentUpdateInformation
    • ICrossReferencedRecordsSelectionEdit
    • IDatafeed
    • IDatafeedHistory
    • IDatafeedHistoryMessage
    • IDatafeedRecordCount
    • IDateValueEdit
    • IDisplayField
    • IDocumentSelectionEdit
    • IEditableField
    • IExternalLink
    • IExternalLinkEdit
    • IExternalLinksSelectionEdit
    • IFieldAudit
    • IFieldHistory
    • IFieldHistoryEx
    • IFieldQuery
    • IFieldValueEdit<T>
    • IHistoryAudit
    • INumericValueEdit
    • IObjectValue
    • IReferencedRecordsSelection
    • IReferencedRecordsSelectionEdit
    • ISearchDisplayFieldOptions
    • ISearchOptions
    • ISignatureAudit
    • IStatisticsReport
    • ISubEditableField
    • ISystemUpdateInformation
    • ITextValueEdit
    • IUserGroupListSelection
    • IUserGroupListSelectionEdit
    • IValuesListBaseSelection
    • IValuesListBaseSelectionEdit
    • IValuesListSelection
    • IValuesListSelectionEdit
    • IValuesListSingleSelection
    • IValuesListSingleSelectionEdit
    • IWorkflowAction
    • IWorkflowNode
    • LastUpdatedPreference
    • NumericRangeOperator
    • RecordCountType
    • RecordStatus
    • ReportSource
    • SortField
    • SortType
    • ValueOperator
    • ValuesOperator
    • WorkflowAuditActionType
  • Estrelica.Archer.Entity
    • ArcherEntityExtensions
    • ASOStatus
    • EntityType
    • IArcherAliasableEntity
    • IArcherAliasedEntity
    • IArcherASOEntity
    • IArcherASONamedEntity
    • IArcherBase
    • IArcherContentUpdateInfoEntity
    • IArcherDescribableEntity
    • IArcherDescribedEntity
    • IArcherEntity
    • IArcherEntityBase
    • IArcherGuidEntity
    • IArcherNameableEntity
    • IArcherNamedEntity
    • IArcherUpdateInfoEntity
    • IEditableArcherEntity
    • IUpdateInformation
    • SourceAttribute
    • UpstreamPropertyAttribute
  • Estrelica.Archer.Events
    • EventActionLayoutType
    • EventActionType
    • EventDateActionType
    • EventItemActionType
    • EventSectionActionType
    • IEventAction
    • IEventRule
    • ISetDateOption
  • Estrelica.Archer.Layouts
    • ILayout
    • ILayoutEntity
    • ILayoutItem
    • ILayoutSection
    • ILayoutTab
    • LayoutItemType
    • LayoutMemberType
    • LayoutSectionType
    • LayoutTabType
  • Estrelica.Archer.Metadata
    • ArcherMetadataExtensions
    • FilterConditionType
    • FilterCriteriaOperatorType
    • IArcherApplication
    • IArcherLevel
    • IArcherModule
    • IArcherQuestionnaire
    • IArcherSolution
    • IArcherSubForm
    • IArcherValuesList
    • IArcherValuesListValue
    • IFilterCondition
    • IFilterCriteria
    • ILevelFilter
    • ILevelFilterValue
    • IModuleOwner
    • IModuleOwnerGroup
    • IModuleOwnerUser
    • IModuleReference
    • INumericRange
    • INumericRangeValue
    • IQuestionnaireRule
    • ModuleClass
    • ModuleStatus
    • ModuleType
    • QuestionnaireRuleType
    • ReportType
    • Timezone
    • ValuesListType
    • ValueSortType
  • Estrelica.Archer.Metadata.Field
    • ArcherFieldExtensions
    • DefaultDateType
    • ExternalLinkProtocol
    • FieldEncryptionState
    • FieldType
    • IArcherField
    • IAssetResponsibilitiesField
    • IAttachmentField
    • IAvailableUserGroupSelections
    • IBaseDateField
    • ICalculatedValuesListField
    • IContentAccessHistoryField
    • ICrossApplicationStatusTrackingField
    • ICrossModuleStatusTrackingField
    • ICrossReferenceField
    • IDateField
    • IDiscussionField
    • IDocumentField
    • IExternalLinksField
    • IFirstPublishedField
    • IGroupPermission
    • IHistoryLogField
    • IImageField
    • IIPAddressField
    • ILastUpdatedField
    • IMatrixField
    • ImplementsAPIKey
    • ImplementsFieldTypeAttribute
    • IMultipleReferenceDisplayField
    • INumericField
    • IPermissionInheritance
    • IQuestionnaireReferenceField
    • IRecordStatusField
    • IReferenceField
    • IRelatedRecordsField
    • IRiskAssessmentField
    • ISchedulerField
    • ISubformField
    • ITechnologiesListField
    • ITechnologyVersionsListField
    • ITextField
    • ITrackingIDField
    • IUserGroupListField
    • IUserPermission
    • IValuesListField
    • IVotingField
    • SystemFieldType
    • UserGroupType
    • VotingType
  • Estrelica.Archer.Metadata.Field.Properties
    • DisplayControl
    • FieldLayoutFormat
    • IAdvancedDisplayOption
    • IAdvancedDisplayProperty
    • IAllowLookupProperty
    • IAllowSortingProperty
    • IColumnCountProperty
    • IDisplayControlProperty
    • IDisplayInHeaderProperty
    • IEncryptionStateProperty
    • IFieldValidationTypeProperty
    • IHeightWidthProperty
    • IIncludeTimeInformationProperty
    • IIncludeUserInformationProperty
    • IIsAuditEnabledProperty
    • IIsBulkCreateEnabledProperty
    • IIsBulkUpdateEnabledProperty
    • IIsCalculatedProperty
    • IIsEditableGridDisplayProperty
    • IIsEditableInSearchProperty
    • IIsEncryptedProperty
    • IIsFindEnabledProperty
    • IIsKeyProperty
    • IIsQuestionProperty
    • IIsRequiredProperty
    • IIsRestrictedToLevelProperty
    • IIsSupressedProperty
    • IIsTrendingEnabledProperty
    • IIsUniqueProperty
    • ILinkProperty
    • ILookupReportProperty
    • IMaxAttachmentsAllowedProperty
    • IMaxFileSizeProperty
    • IMaximumSelectionProperty
    • IMaxIntValueProperty
    • IMaxLongValueProperty
    • IMinAttachmentsAllowedProperty
    • IMinimumSelectionProperty
    • IMinIntValueProperty
    • IMinLongValueProperty
    • IMinMaxSelectionProperty
    • IPrefixProperty
    • ISuffixProperty
    • ITrendingDurationProperty
    • ITrendingDurationTypeProperty
    • MatrixAxis
    • NegativeDisplayType
  • Estrelica.Archer.Metadata.Properties
    • IIsDeprecatedProperty
    • IIsDirectToEditEnabledProperty
    • IIsMobileEnabledProperty
    • IIsNotificationProperty
    • IIsTaskManagementEnabledProperty
    • IIsWaveEnabledProperty
    • IKeepLicensedProperty
    • ISearchViewProperty
  • Estrelica.Archer.Utility
    • APIExceptionExtensions
    • APIPreference
    • APISource
    • ArcherAPIException
    • ArcherEntitySerializer
    • BaseDataWrapper<K>
    • CachedResolver
    • DictionaryDataWrapper<K>
    • DomainFormat
    • EditUtilities
    • ExtensionsUnavailableException
    • FilterCriteriaHelper
    • IAccessResolver
    • IAPIFacade
    • IArcherRestAPI
    • IArcherSoapAPI
    • IArcherUndocumentedAPI
    • ICastleHillExtendedAPI
    • IContentResolver
    • ILayoutResolver
    • IMetadataResolver
    • IReportResolver
    • IValueAccessor
    • ObjectDataWrapper<T, K>
    • ObjectKeyAttribute
    • ValuesListChangeEvent
    • ValuesListChangeEventArgs
  • Estrelica.Interfaces
    • IArcherAuthProvider
    • ICacheProvider
    • IClearable
    • IDatabaseAuthProvider
    • IEditable
    • IEditable<V>
    • IEditableCollection<V>
    • IEditableEnumerable<V>
    • IEditableFieldSelection<V>
    • IEditableInterface<I>
    • IEntityResolver
    • IExtendedAPIAuthProvider
    • IHttpClientAccessor
    • ILogCleanup
    • ILogSubscriber
    • InvalidateEntity<K>
    • InvalidateEntityEventArgs<K>
    • IRecordAccess
    • IRecordAccess<T>
    • IResolverProvider
    • ISessionProvider
    • ISystemUpdateable
    • ITrafficCounter
    • LogLevel
  • Estrelica.Logging
    • BaseLogger
    • ConsoleLogger
    • FileLogger
    • FileLogger.TimestampFormat
    • Logger
    • TraceLogger
  • Estrelica.Utility
    • Arguments
    • BaseRecordAccess
    • DataReaderExtensions
    • DateTimeExtensions
    • Debouncer
    • DebugLog
    • DeferEnumerable<T>
    • DeferValue<V>
    • DictionaryExtensions
    • EnumHelper
    • ExceptionExtensions
    • GuidUtility
    • HandledException
    • HashSetExtensions
    • ICacheHandler
    • ICollectionExtensions
    • IDeferrable
    • IDeferredValue
    • IEnumerableExtensions
    • IgnoreDefaultValuesDictionary<K, V>
    • JsonDictionary<V>
    • OperationExtensions
    • Resource
    • SqlConnectionExtensions
    • SqlUtilities
    • StreamExtensions
    • StringExtensions
    • TableMapper
    • TimeoutDictionary<K, V>
    • TypeExtensions
    • XElementExtensions

Class JsonDictionary<V>

This class is intended to wrap Dictionary<string,V> objects that are to be serialized, specifically with the Newtonsoft Json serializer (this may apply to other serializers too, but I haven't tested any others to see how they behave).

The reason this is needed is because the Newtonsoft serializer emits its JSON based on the order that the KVPs of a dictionary are returned via the dictionary's GetEnumerator() method. This order is typically the same as the order in which objects were added to the dictionary, but that order may change as values are updated or removed, when the GC runs, etc. Regardless, the point is that the order is unpredictable and entirely non-deterministic.

This means that two dictionaries having exactly the same key/value pairs added to them may not get serialized identically, making it impossible to compare their JSON representations for object equality later (e.g. if they're stored in a db somewhere).

This class addresses this problem by ensuring that every call to GetEnumerator() receives the KVPs ordered by the string key. It will also detect if any of the values in those KVPs are IDictionary<string,V>, and if so, will wrap them with another JsonDictionary<V> before returning, so that sub-dictionaries will also be serialized consistently.

Inheritance
object
JsonDictionary<V>
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Estrelica.Utility
Assembly: Estrelica.Utility.dll
Syntax
[DoNotObfuscateType]
public class JsonDictionary<V> : IDictionary<string, V>, ICollection<KeyValuePair<string, V>>, IEnumerable<KeyValuePair<string, V>>, IEnumerable
Type Parameters
V

Constructors

JsonDictionary(IDictionary<string, V>)

Declaration
public JsonDictionary(IDictionary<string, V> wrappedDictionary = null)
Parameters
IDictionary<string, V> wrappedDictionary

Properties

Count

Declaration
public int Count { get; }
Property Value
int

IsReadOnly

Declaration
public bool IsReadOnly { get; }
Property Value
bool

this[string]

Declaration
public V this[string key] { get; set; }
Parameters
string key

Property Value
V

Keys

Declaration
public ICollection<string> Keys { get; }
Property Value
ICollection<string>

Values

Declaration
public ICollection<V> Values { get; }
Property Value
ICollection<V>

Methods

Add(KeyValuePair<string, V>)

Declaration
public void Add(KeyValuePair<string, V> item)
Parameters
KeyValuePair<string, V> item

Add(string, V)

Declaration
public void Add(string key, V value)
Parameters
string key

V value

Clear()

Declaration
public void Clear()

Contains(KeyValuePair<string, V>)

Declaration
public bool Contains(KeyValuePair<string, V> item)
Parameters
KeyValuePair<string, V> item

Returns
bool

ContainsKey(string)

Declaration
public bool ContainsKey(string key)
Parameters
string key

Returns
bool

CopyTo(KeyValuePair<string, V>[], int)

Declaration
public void CopyTo(KeyValuePair<string, V>[] array, int arrayIndex)
Parameters
KeyValuePair<string, V>[] array

int arrayIndex

GetEnumerator()

Declaration
public IEnumerator<KeyValuePair<string, V>> GetEnumerator()
Returns
IEnumerator<KeyValuePair<string, V>>

Remove(KeyValuePair<string, V>)

Declaration
public bool Remove(KeyValuePair<string, V> item)
Parameters
KeyValuePair<string, V> item

Returns
bool

Remove(string)

Declaration
public bool Remove(string key)
Parameters
string key

Returns
bool

TryGetValue(string, out V)

Declaration
public bool TryGetValue(string key, out V value)
Parameters
string key

V value

Returns
bool

Extension Methods

EnumHelper.In<TEnum>(TEnum, params TEnum[])
IEnumerableExtensions.ToEnumerable<T>(T)
StringExtensions.AssertNotNull<T>(T, string)
TypeExtensions.WithDispose<T, V>(T, Func<T, V>)
ICollectionExtensions.AddAll<V>(ICollection<V>, IEnumerable<V>)
ICollectionExtensions.RemoveAll<V>(ICollection<V>, IEnumerable<V>)
DictionaryExtensions.AddAll<K, V>(IDictionary<K, V>, IEnumerable<V>, Func<V, K>)
DictionaryExtensions.AddAll<K, V>(IDictionary<K, V>, IEnumerable<KeyValuePair<K, V>>, Func<K, V, V, bool>)
DictionaryExtensions.IsNullOrEmpty<K, V>(IDictionary<K, V>)
DictionaryExtensions.LoadFromQuery<K, V>(IDictionary<K, V>, string, string, Action<SqlCommand>)
DictionaryExtensions.LoadFromQuery<K, V>(IDictionary<K, V>, string, string, K, V, Action<SqlCommand>)
DictionaryExtensions.MergeFrom<K, V>(IDictionary<K, V>, IDictionary<K, V>, bool)
DictionaryExtensions.Set<K, V>(IDictionary<K, V>, K, V, bool)
DictionaryExtensions.SetAll<K, V>(IDictionary<K, V>, IEnumerable<KeyValuePair<K, V>>)
DictionaryExtensions.ValueOrCreate<K, V>(IDictionary<K, V>, K, Func<V>)
DictionaryExtensions.ValueOrCreateAsync<K, V>(IDictionary<K, V>, K, Func<V>)
DictionaryExtensions.ValueOrCreateAsync<K, V>(IDictionary<K, V>, K, Func<Task<V>>)
DictionaryExtensions.ValueOrCreateAsync<K, V>(IDictionary<K, V>, K, Task<V>)
DictionaryExtensions.ValueOrDefault<K, V>(IDictionary<K, V>, K)
DictionaryExtensions.ValueOrDefault<K, V>(IDictionary<K, V>, K, V)
DictionaryExtensions.AsArray<V>(IEnumerable<V>, bool)
DictionaryExtensions.ContainsAll<T>(IEnumerable<T>, IEnumerable<T>, IEqualityComparer<T>)
DictionaryExtensions.ContainsAny<T>(IEnumerable<T>, IEnumerable<T>, IEqualityComparer<T>)
DictionaryExtensions.ForEach<T>(IEnumerable<T>, Action<T>)
DictionaryExtensions.ToDictionary<K, V>(IEnumerable<KeyValuePair<K, V>>)
IEnumerableExtensions.Distinct<T, K>(IEnumerable<T>, Func<T, K>)
IEnumerableExtensions.Matches<T>(IEnumerable<T>, IEnumerable<T>, bool, bool, bool)
StringExtensions.Conjoin(IEnumerable, string, bool)
EnumHelper.CastNullable<TEnum>(object)
TypeExtensions.ConvertTo<V>(object)
TypeExtensions.TryConvert<V>(object, out V)
Back to top Copyright 2019-2023 by CastleHill Software LLC