private void DoPropertyBind(PropertyTreeMetaObject target, PropertyTreeNavigator navigator, PropertyDefinition property) { object ancestor = null; PropertyTreeMetaObject ancestorMeta = null; if (property.IsExtender) { var ancestorType = property.DeclaringTreeDefinition.SourceClrType; ancestorMeta = target.Ancestors.FirstOrDefault( t => ancestorType.IsAssignableFrom(t.ComponentType)); if (ancestorMeta != null) { ancestor = ancestorMeta.Component; } } var component = target.Component; PropertyTreeMetaObject propertyTarget = target.CreateChild(property, navigator.QualifiedName, ancestorMeta); var services = new PropertyBindContext( component, property, ServiceProvider.Compose(ServiceProvider.FromValue(navigator), this)) { LineNumber = navigator.LineNumber, LinePosition = navigator.LinePosition, }; try { propertyTarget = Bind(propertyTarget, navigator, services); target.BindSetMember(property, navigator.QualifiedName, propertyTarget, ancestorMeta, services); } catch (NullReferenceException nre) { // Normally a "critical" exception, consider it a conversion error _errors.BinderConversionError(property.Name, target.ComponentType, nre, navigator.FileLocation); } catch (ArgumentException a) { _errors.BinderConversionError(property.Name, target.ComponentType, a, navigator.FileLocation); } catch (PropertyTreeException) { throw; } catch (Exception ex) { if (ex.IsCriticalException()) { throw; } _errors.BinderConversionError(property.Name, target.ComponentType, ex, navigator.FileLocation); } }
private void DoPropertyBind(PropertyTreeBinderImpl parent, PropertyTreeMetaObject target, PropertyTreeNavigator navigator, PropertyDefinition property) { object ancestor = null; PropertyTreeMetaObject ancestorMeta = null; if (property.IsExtender) { var ancestorType = property.DeclaringTreeDefinition.SourceClrType; ancestorMeta = target.GetAncestors().Cast<PropertyTreeMetaObject>().FirstOrDefault( t => ancestorType.IsAssignableFrom(t.ComponentType)); if (ancestorMeta != null) ancestor = ancestorMeta.Component; } var component = target.Component; PropertyTreeMetaObject propertyTarget = target.CreateChild(property, navigator.QualifiedName, ancestorMeta); var services = new PropertyBindContext( component, property, ServiceProvider.Compose(ServiceProvider.FromValue(navigator), parent)) { LineNumber = navigator.LineNumber, LinePosition = navigator.LinePosition, }; propertyTarget = parent.Bind(propertyTarget, navigator, services); target.BindSetMember(property, navigator.QualifiedName, propertyTarget, ancestorMeta, services); }