/// <summary> /// Gets the specified feature. This is the preferred way. /// </summary> /// <param name="featureDescriptor"></param> /// <returns>The casted feature object</returns> public T GetFeature <T>(FeatureDescriptor <T> featureDescriptor) { return((T)features[featureDescriptor.Key]); }
public bool HasFeature(FeatureDescriptor featureDescriptor) { return(features.ContainsKey(featureDescriptor.Key)); }
/*public T GetFeature<T>() * { * return (T)features[FeatureDescriptor.GetKey<T>()]; * }*/ /*public T GetFeature<T>(int index) * { * return ((List<T>)features[FeatureDescriptor.GetKey<T>()])[index]; * }*/ /// <summary> /// Gets a collection of <see cref="FeatureDescriptor"/>s that are used in this signature. /// </summary> /// <returns>A collection of <see cref="FeatureDescriptor"/>s.</returns> public IEnumerable <FeatureDescriptor> GetFeatureDescriptors() { return(features.Keys.Select(k => FeatureDescriptor.GetDescriptor(k))); }
/*/// <summary> * /// Gets a list of <see cref="FeatureDescriptor"/>s of given type <typeparamref name="T"/> that are used in this signature. * /// </summary> * /// <returns>A list of <see cref="FeatureDescriptor"/>s.</returns> * public List<T> GetFeatures<T>() * { * return (features.TryGetValue(FeatureDescriptor.GetKey<T>(), out var result)) ? result as List<T> : null; * }*/ /*public void SetFeature<T>(T feature) * { * features[FeatureDescriptor.GetKey(feature.GetType())] = feature; * }*/ /*public void SetFeatures<T>(List<T> feature) * { * features[FeatureDescriptor.GetKey<T>()] = feature; * }*/ /// <summary> /// Sets the specified feature. This is the preferred way. /// </summary> /// <param name="featureDescriptor">The feature to put the new value in.</param> /// <param name="feature">The value to set.</param> public void SetFeature <T>(FeatureDescriptor featureDescriptor, T feature) { features[featureDescriptor.Key] = feature; }
/// <summary> /// Gets the specified feature. This is the preferred way. /// </summary> /// <param name="featureDescriptor"></param> /// <returns>The casted feature object</returns> public T GetFeature <T>(FeatureDescriptor featureDescriptor) { //TODO: try cast, catch log return((T)features[featureDescriptor.Key]); }