ControlTypecontains the values in the reference.EntityControlAttributederives from Attribute and its constructors assignControlTypeandDescription.- The required product properties are decorated with appropriate control metadata.
11.2 Assignment
Attributes
Work through the stories in order. Use the acceptance criteria to check each feature, and complete the nested tasks using the specified names, values, and scenarios.
ControlType contains the values in the reference.EntityControlAttribute derives from Attribute and its constructors assign ControlType and Description.11.2 Assignment Start.zip
ReflectionScenario project:EntityControlAttribute constructors, assign the corresponding properties to the passed in parameters.EntityControlAttribute to each…Go through each of the classes in the Products folder and add custom attributes of type EntityControlAttribute to each property. Pass in a ControlType and a description (if the name can be cleaned up) for each one.
memberListBox should be populated with properties of that type with a EntityControlAttribute.HasAttribute returns whether the requested attribute exists.GetAttributePropertyValue returns the requested property value when the attribute and property are present, otherwise null.GetAttributePropertyValueAsString exposes the string representation used by the UI.ReflectionUtil class:GetAttributePropertyValue method:null.memberInfo by calling GetCustomAttributes. Pass in the…Read all of the attributes of the specified type from the passed in memberInfo by calling GetCustomAttributes. Pass in the attributeType and false as arguments. Store the result in an array of attributes.
Assign an attribute variable to the first attribute.
Get the property from the attribute and store it in a variable.
If the property is found, get the value from the property and store it in the result variable.
HasAttribute method:GetCustomAttributes on the passed in memberInfo. Pass in the attributeType and false as arguments. Store the result in an array.GetAttributePropertyValueAsString method:GetAttributePropertyValue method as a string.EntityControlAttribute control type.MainWindow: typeListBox and memberListBox.Assembly.GetExecutingAssembly().GetTypes.typeListBox.SelectionChanged event for the typeListBox:memberListBox items.typeListBox and cast it as a type.GetProperties. Store it in a variable named properties.PropertyInfo objects in the properties array:Using ReflectionUtil.HasAttribute, check if the current property has an attribute of type EntityControlAttribute. If it does:
Use ReflectionUtil.GetAttributePropertyValueAsString to get the value of the ControlType property of the EntityControlAttribute on the current property. Store it in a string variable named controlType.
Repeat the step above but get the value of the Description property of the EntityControlAttribute. Store the result in a variable named description.
Add the name of the property and the attribute value to the memberListBox's items.
$"{p.Name} - {description} - {controlType}"typeListBoxmemberListBox. This is because none of the properties in the classes have the…Click on a type. Nothing should show up in the memberListBox. This is because none of the properties in the classes have the EntityControlAttribute on them.
Return to each story and verify its acceptance criteria. Preserve the submission format and destination stated in the activity; a reading, setup guide, lab, video demonstration, and oral final may require different evidence.
Describe editable properties with attributes Read attribute values with reusable reflection helpers Explore type and property metadata in the window