/// <summary>
		/// Initializes the static members in <see cref="PropertyAccessorFactory"/>.
		/// </summary>
		static PropertyAccessorFactory()
		{
			accessors = new Dictionary<string, IPropertyAccessor>(19);
			accessors["property"] = new BasicPropertyAccessor();
			accessors["field"] = new FieldAccessor();
			accessors["backfield"] = new FieldAccessor(new BackFieldStrategy());
			accessors["readonly"] = new ReadOnlyAccessor();
			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["field.pascalcase-m"] = new FieldAccessor(new PascalCaseMStrategy());
			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());
			accessors["nosetter.pascalcase-m"] = new NoSetterAccessor(new PascalCaseMStrategy());
			accessors["embedded"] = new EmbeddedPropertyAccessor();
			accessors["noop"] = new NoopAccessor();
			accessors["none"] = new NoopAccessor();
		}
Example #2
0
 /// <summary>
 /// Initializes the static members in <see cref="PropertyAccessorFactory"/>.
 /// </summary>
 static PropertyAccessorFactory()
 {
     accessors                                     = new Dictionary <string, IPropertyAccessor>(19);
     accessors["property"]                         = new BasicPropertyAccessor();
     accessors["field"]                            = new FieldAccessor();
     accessors["backfield"]                        = new FieldAccessor(new BackFieldStrategy());
     accessors["readonly"]                         = new ReadOnlyAccessor();
     accessors["field.camelcase"]                  = new FieldAccessor(new CamelCaseStrategy());
     accessors["field.camelcase-underscore"]       = new FieldAccessor(new CamelCaseUnderscoreStrategy());
     accessors["field.camelcase-m-underscore"]     = new FieldAccessor(new CamelCaseMUnderscoreStrategy());
     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["field.pascalcase-m"]               = new FieldAccessor(new PascalCaseMStrategy());
     accessors["nosetter.camelcase"]               = new NoSetterAccessor(new CamelCaseStrategy());
     accessors["nosetter.camelcase-underscore"]    = new NoSetterAccessor(new CamelCaseUnderscoreStrategy());
     accessors["nosetter.camelcase-m-underscore"]  = new NoSetterAccessor(new CamelCaseMUnderscoreStrategy());
     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());
     accessors["nosetter.pascalcase-m"]            = new NoSetterAccessor(new PascalCaseMStrategy());
     accessors["embedded"]                         = new EmbeddedPropertyAccessor();
     accessors["noop"]                             = new NoopAccessor();
     accessors["none"]                             = new NoopAccessor();
 }
        /// <summary>
        /// Create a <see cref="FieldAccessor.FieldSetter"/> to <c>set</c> the value of the mapped Property
        /// through a <c>Field</c>.
        /// </summary>
        /// <param name="type">The <see cref="System.Type"/> to find the mapped Property in.</param>
        /// <param name="propertyName">The name of the mapped Property to set.</param>
        /// <returns>
        /// The <see cref="FieldAccessor.FieldSetter"/> to use to set the value of the Property on an
        /// instance of the <see cref="System.Type"/>.
        /// </returns>
        /// <exception cref="PropertyNotFoundException" >
        /// Thrown when a Field for the Property specified by the <c>propertyName</c> using the
        /// <see cref="IFieldNamingStrategy"/> could not be found in the <see cref="System.Type"/>.
        /// </exception>
        public ISetter GetSetter(System.Type type, string propertyName)
        {
            string fieldName = namingStrategy.GetFieldName(propertyName);

            return(new FieldAccessor.FieldSetter(FieldAccessor.GetField(type, fieldName), type, fieldName));
        }