示例#1
0
        private void ConnectValidValuesProperty(object propertyInfoResolutionObject, ControllableAttribute controllableAttribute)
        {
            if (string.IsNullOrEmpty(controllableAttribute.ValidValuesListName))
            {
                return;
            }

            var foundProperty =
                propertyInfoResolutionObject.GetType()
                .GetProperty(controllableAttribute.ValidValuesListName,
                             BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

            if (foundProperty == null)
            {
                return;
            }


            TypeIndicatorTextComponent.ValidValuesCallback = () =>
            {
                var value = foundProperty.GetValue(propertyInfoResolutionObject, null) as List <string>;

                return(value);
            };
        }
        public void SetProperty(Object propertyResolutionObject, PropertyInfo propertyInfo)
        {
            if (Property != null)
            {
                throw new InvalidOperationException("Cannot reuse this view.");
            }

            PropertyResolutionObject = propertyResolutionObject;

            Property = propertyInfo;

            ControllableAttribute = (ControllableAttribute)Property.GetCustomAttributes(typeof(ControllableAttribute), true).First();


            PropertyNameTextComponent.text = String.IsNullOrEmpty(ControllableAttribute.LabelText) ? Property.Name : ControllableAttribute.LabelText;


            ValueInputField.text = Property.GetValue(PropertyResolutionObject, null).ToString();


            ConfigureConditionality();

            ConfigureObservation();
        }