=======================
**classMember** element
=======================
The **classMember** element is used to reference class member values (i.e., class variables, constant values, properties, method call results) in configuration file.
This element uses attribute **class** (and optional attribute **assembly**), or alternatively, an attribute **classRef** to specify the class, as well as attribute **memberName**, to specify the class member name.
The element **classMember** can be used to reference enum values as well. Example: .
Referencing non-static and non-constant class members
=====================================================
If the class member is non-static, and non-constant, **IoC.Configuration** will get the class member value by first resolving the class instance from the dependency injection container.
If the class is non-interface, non-abstract, and has a public constructor, **IoC.Configuration** will generate a self-binding for the class.
Otherwise, a binding should be provided either in configuration file, or in one of dependency injection modules.
.. note::
Refer to :doc:`../../sample-files/IoCConfiguration_classMember.generated` for more examples on **classMember** element.
Example 1: Using **classMember** to provide a service implementation
====================================================================
.. code-block:: xml
:linenos:
Example 2: Using **classMember** in **collection** element
==========================================================
.. code-block:: xml
:linenos:
Example 3: Using **classMember** to specify a returned value in **autoProperty** element
========================================================================================
.. code-block:: xml
:linenos:
Example 3: Referencing class member in **if** element under **autoMethod** element
==================================================================================
To reference class members in **if** element attributes in **autoMethod**, use **_classMember:** prefix followed by class full name (or type alias name, for a type declared in **typeDefinition** element), period, and the class member name.
.. note::
Refer to :doc:`../autogenerated-services/index` and :doc:`../autogenerated-services/auto-method` for more details on **autoMethod** element.
In the example below, we reference a class member **IoC.Configuration.Tests.ClassMember.Services.IAppIds.DefaultAppId** (it is assumed that the configuration has a **typeDefinition** element for a type **IoC.Configuration.Tests.ClassMember.Services.IAppIds**, that has an alias **IAppIds**)
.. code-block:: xml
:linenos:
Example 3: Using **classMember** to call methods with parameters
================================================================
If the class member is a method, we can use **parameters** child element to specify parameter values when the method is called.
See the usage of **classMember** elements in the example below.
.. code-block:: xml
:linenos: