/// <summary> /// Creates new instance of the indexer /// </summary> /// <param name="getter">Delegate to the getter function.</param> /// <param name="enumerator"> /// Delegate which returns inumerator for the indexer, or null, /// if enumeration is not supported for this indexer. /// </param> public ReadOnlyNamedIndexer( Func <TParam, TType> getter, Func <IEnumerator <TType> > enumerator = null) : base(enumerator) { NamedIndexer.Validate("getter", getter); this.getter = getter; }
public ExampleObject() { TheNumbers = new NamedIndexer <int, int>(i => _numbers[i], (i, x) => { _numbers[i] = x; }); Typesetter = new NamedIndexer <int, char>(i => _letters[i], (i, x) => { _letters[i] = x; }); Double = new NamedGetter <int, long>(x => 2 * x); }
public UsingIndexers() { Indexer = new NamedIndexer<int, int>(Get, Set); Getter = new NamedIndexerGetter<int, int>(Get); Setter = new NamedIndexerSetter<int, int>(Set); }
/// <summary> /// Creates new instance of the indexer /// </summary> /// <param name="setter">Delegate to the setter function.</param> public WriteOnlyNamedIndexer(Action <TParam, TType> setter) : base(param => NamedIndexer.FailGet <TType>(), setter) { }