public string[] ResolveSet <T>(string matchIdentifier, T value, bool addIdentifierIfNotExists = false, Type associatedType = null) { CheckMatchIdentifier(matchIdentifier); MatchIdentifierRequestCacheEntry cacheEntry = GetOrCreateCacheEntry(matchIdentifier); string localIdentifier = matchIdentifier.Contains('.') ? matchIdentifier.Substring(matchIdentifier.LastIndexOf('.') + 1) : matchIdentifier; foreach (string fullIdentifier in cacheEntry.FullMatchedIdentifierArray) { IRegistry currentRegistry = cacheEntry.FullMatchedIdentifierRegistries[fullIdentifier]; associatedType = associatedType ?? currentRegistry.GetAssociatedType(localIdentifier); currentRegistry.Set(localIdentifier, value, associatedType); } if (addIdentifierIfNotExists) { foreach (string fullIdentifier in cacheEntry.LastUnmatchedIdentifierRegistries.Keys) { IRegistry currentRegistry = cacheEntry.LastUnmatchedIdentifierRegistries[fullIdentifier]; associatedType = associatedType ?? currentRegistry.GetAssociatedType(localIdentifier); currentRegistry.Set(localIdentifier, value, associatedType); } } return(cacheEntry.FullMatchedIdentifierArray); }
/// <summary> /// Get the parameter type for a certain registry entry. /// Note: This is just a convenience method which fetches the values and calls <see cref="IParameterisationManager.GetParameterType(string,System.Type,System.Type)"/> /// </summary> /// <param name="identifier">The direct identifier within the given registry.</param> /// <param name="registry">The registry to fetch the value from.</param> /// <returns>The parameter type the fetched value from the given registry should be parameterised as.</returns> public IParameterType GetParameterType(string identifier, IRegistry registry) { if (identifier == null) { throw new ArgumentNullException(nameof(identifier)); } if (registry == null) { throw new ArgumentNullException(nameof(registry)); } if (!registry.ContainsKey(identifier)) { throw new KeyNotFoundException($"Identifier {identifier} does not exist in given registry."); } return(GetParameterType(identifier, registry.GetAssociatedType(identifier), registry[identifier].GetType())); }