/// <summary> /// Creates an <see cref="BasicGetter"/> to <c>get</c> the value from the Property. /// </summary> /// <param name="type">The <see cref="System.Type"/> to find the Property in.</param> /// <param name="propertyName">The name of the mapped Property to get.</param> /// <returns> /// The <see cref="BasicGetter"/> to use to get the value of the Property from an /// instance of the <see cref="System.Type"/>.</returns> /// <exception cref="PropertyNotFoundException" > /// Thrown when a Property specified by the <c>propertyName</c> could not /// be found in the <see cref="System.Type"/>. /// </exception> public IGetter GetGetter(System.Type type, string propertyName) { BasicGetter result = BasicPropertyAccessor.GetGetterOrNull(type, propertyName); if (result == null) { throw new PropertyNotFoundException(type, propertyName, "getter"); } return(result); }
/// <summary> /// Initializes the static members in <see cref="PropertyAccessorFactory"/>. /// </summary> static PropertyAccessorFactory() { accessors = new Hashtable(13); accessors["property"] = new BasicPropertyAccessor(); accessors["field"] = new FieldAccessor(); accessors["field.camelcase"] = new FieldAccessor(new CamelCaseStrategy()); accessors["field.camelcase-underscore"] = new FieldAccessor(new CamelCaseUnderscoreStrategy()); accessors["field.lowercase"] = new FieldAccessor(new LowerCaseStrategy()); accessors["field.lowercase-underscore"] = new FieldAccessor(new LowerCaseUnderscoreStrategy()); accessors["field.pascalcase-underscore"] = new FieldAccessor(new PascalCaseUnderscoreStrategy()); accessors["field.pascalcase-m-underscore"] = new FieldAccessor(new PascalCaseMUnderscoreStrategy()); accessors["nosetter.camelcase"] = new NoSetterAccessor(new CamelCaseStrategy()); accessors["nosetter.camelcase-underscore"] = new NoSetterAccessor(new CamelCaseUnderscoreStrategy()); accessors["nosetter.lowercase"] = new NoSetterAccessor(new LowerCaseStrategy()); accessors["nosetter.lowercase-underscore"] = new NoSetterAccessor(new LowerCaseUnderscoreStrategy()); accessors["nosetter.pascalcase-underscore"] = new NoSetterAccessor(new PascalCaseUnderscoreStrategy()); accessors["nosetter.pascalcase-m-underscore"] = new NoSetterAccessor(new PascalCaseMUnderscoreStrategy()); }
/// <summary> /// Initializes the static members in <see cref="PropertyAccessorFactory"/>. /// </summary> static PropertyAccessorFactory() { accessors = new Hashtable( 13 ); accessors[ "property" ] = new BasicPropertyAccessor(); accessors[ "field" ] = new FieldAccessor(); accessors[ "field.camelcase" ] = new FieldAccessor( new CamelCaseStrategy() ); accessors[ "field.camelcase-underscore" ] = new FieldAccessor( new CamelCaseUnderscoreStrategy() ); accessors[ "field.lowercase" ] = new FieldAccessor( new LowerCaseStrategy() ); accessors[ "field.lowercase-underscore" ] = new FieldAccessor( new LowerCaseUnderscoreStrategy() ); accessors[ "field.pascalcase-underscore" ] = new FieldAccessor( new PascalCaseUnderscoreStrategy() ); accessors[ "field.pascalcase-m-underscore" ] = new FieldAccessor( new PascalCaseMUnderscoreStrategy() ); accessors[ "nosetter.camelcase" ] = new NoSetterAccessor( new CamelCaseStrategy() ); accessors[ "nosetter.camelcase-underscore" ] = new NoSetterAccessor( new CamelCaseUnderscoreStrategy() ); accessors[ "nosetter.lowercase" ] = new NoSetterAccessor( new LowerCaseStrategy() ); accessors[ "nosetter.lowercase-underscore" ] = new NoSetterAccessor( new LowerCaseUnderscoreStrategy() ); accessors[ "nosetter.pascalcase-underscore" ] = new NoSetterAccessor( new PascalCaseUnderscoreStrategy() ); accessors[ "nosetter.pascalcase-m-underscore" ] = new NoSetterAccessor( new PascalCaseMUnderscoreStrategy() ); }