public override Type?GetChildDataContextType(Type dataContext, DataContextStack controlContextStack, DotvvmBindableObject control, DotvvmProperty?property = null) { var controlType = control.GetType(); var controlPropertyField = controlType.GetField($"{PropertyName}Property", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); var controlProperty = (DotvvmProperty?)controlPropertyField?.GetValue(null); if (controlProperty == null) { throw new Exception($"The property '{PropertyName}' was not found on control '{controlType}'!"); } if (control.properties.Contains(controlProperty)) { return(control.GetValueBinding(controlProperty) is IValueBinding valueBinding ? valueBinding.ResultType : dataContext); } if (AllowMissingProperty) { return(dataContext); } throw new Exception($"Property '{PropertyName}' is required on '{controlType.Name}'."); }
public DotvvmControlException(DotvvmBindableObject control, string message, Exception innerException = null) : base(message, innerException) { ControlType = control.GetType(); LineNumber = (int?)Internal.MarkupLineNumberProperty.GetValue(control); FileName = (string)Internal.MarkupFileNameProperty.GetValue(control); }
public DotvvmControlException(DotvvmBindableObject control, string message, Exception innerException = null) : base(message, innerException) { ControlType = control.GetType(); LineNumber = (int?)Internal.MarkupLineNumberProperty.GetValue(control); if (control.Parent != null) control = control.Parent; FileName = (string)Internal.MarkupFileNameProperty.GetValue(control); }
public override Type GetChildDataContextType(Type dataContext, DataContextStack controlContextStack, DotvvmBindableObject control, DotvvmProperty property = null) { var controlType = control.GetType(); var controlPropertyField = controlType.GetField($"{PropertyName}Property", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); var controlProperty = (DotvvmProperty)controlPropertyField?.GetValue(null); if (controlProperty == null) { throw new Exception($"The property '{PropertyName}' was not found on control '{controlType}'!"); } if (control.Properties.ContainsKey(controlProperty) && control.HasValueBinding(controlProperty)) { return(control.GetValueBinding(controlProperty).ResultType); } return(controlProperty.PropertyType); }