public object GetValue(ParameterCollection parameterCollection) { for (int i = 0; i < Keys.Length; ++i) { if (!parameterCollection.ContainsKey(Keys[i])) { return(null); } var value = parameterCollection.GetObject(Keys[i]); // Last key, returns result if (i == Keys.Length - 1) { return(value); } // Ohterwise, it should be a container if (!(value is ParameterCollection)) { return(null); } parameterCollection = (ParameterCollection)value; } return(null); }
public static void RegisterParameter(this ParameterCollection parameterCollection, ParameterKey parameterKey, bool addDependencies = true) { var metaData = parameterKey.Metadatas.OfType <ParameterKeyValueMetadata>().FirstOrDefault(); if (metaData == null) { throw new ArgumentException("ParameterKey must be declared with metadata", "parameterKey"); } if (!parameterCollection.ContainsKey(parameterKey)) { metaData.SetupDefaultValue(parameterCollection, parameterKey, addDependencies); } }
private static IEnumerable <ParameterCollection> ContainersInPath(ParameterCollection parameterCollection, IEnumerable <ParameterKey> keys) { yield return(parameterCollection); foreach (var key in keys) { if (!parameterCollection.ContainsKey(key)) { break; } var nextContainer = parameterCollection.GetObject(key) as ParameterCollection; if (nextContainer == null) { break; } yield return(nextContainer); parameterCollection = nextContainer; } }