Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

Attribute instances

Interface member access | Fully qualified interface member names | Explicit interface member implementations | Interface mapping | Enum modifiers | The System.Enum type | Delegate declarations | Delegate invocation | Common Exception Classes | Attribute usage |


Читайте также:
  1. Aristarchic attributes
  2. Attribute specification
  3. Attribute usage
  4. AttributeUsage
  5. Defining attributes of objects
  6. Democratic attributes

An attribute instance is an instance that represents an attribute at run-time. An attribute is defined with an attribute class, positional arguments, and named arguments. An attribute instance is an instance of the attribute class that is initialized with the positional and named arguments.

Retrieval of an attribute instance involves both compile-time and run-time processing, as described in the following sections.

Compilation of an attribute

The compilation of an attribute with attribute class T, positional-argument-list P and named-argument-list N, consists of the following steps:

· Follow the compile-time processing steps for compiling an object-creation-expression of the form new T(P). These steps either result in a compile-time error, or determine an instance constructor C on T that can be invoked at run-time.

· If C does not have public accessibility, then a compile-time error occurs.

· For each named-argument Arg in N:

o Let Name be the identifier of the named-argument Arg.

o Name must identify a non-static read-write public field or property on T. If T has no such field or property, then a compile-time error occurs.

· Keep the following information for run-time instantiation of the attribute: the attribute class T, the instance constructor C on T, the positional-argument-list P and the named-argument-list N.

Run-time retrieval of an attribute instance

Compilation of an attribute yields an attribute class T, an instance constructor C on T, a positional-argument-list P, and a named-argument-list N. Given this information, an attribute instance can be retrieved at run-time using the following steps:

· Follow the run-time processing steps for executing an object-creation-expression of the form new T(P), using the instance constructor C as determined at compile-time. These steps either result in an exception, or produce an instance O of T.

· For each named-argument Arg in N, in order:

o Let Name be the identifier of the named-argument Arg. If Name does not identify a non-static public read-write field or property on O, then an exception is thrown.

o Let Value be the result of evaluating the attribute-argument-expression of Arg.

o If Name identifies a field on O, then set this field to Value.

o Otherwise, Name identifies a property on O. Set this property to Value.

o The result is O, an instance of the attribute class T that has been initialized with the positional-argument-list P and the named-argument-list N.


Дата добавления: 2015-11-16; просмотров: 63 | Нарушение авторских прав


<== предыдущая страница | следующая страница ==>
Attribute specification| Conditional methods

mybiblioteka.su - 2015-2024 год. (0.005 сек.)