public override void UpdateBindings() { base.UpdateBindings(); if (_dstView != null) { var props = _dstView.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); DstProps = props.Where(prop => prop.GetSetMethod(false) != null && prop.GetSetMethod(false) != null && !prop.GetCustomAttributes(typeof(ObsoleteAttribute), true).Any() ).Select(e => new BindablePropertyInfo { PropertyName = e.Name, PropertyType = e.PropertyType.Name }).ToList(); } if (!string.IsNullOrEmpty(ViewModelName)) { var props = ViewModelProvider.GetViewModelProperties(ViewModelName); // SrcProps = props.Where(prop => // prop.PropertyType.IsAssignableToGenericType(typeof(Reactive.ReactiveProperty<>)) // && !prop.GetCustomAttributes(typeof(ObsoleteAttribute), true) // .Any()) SrcProps = SrcPropsSearch(props).Select(e => new BindablePropertyInfo(e.Name, e.PropertyType.IsGenericType ? e.PropertyType.GetGenericArguments()[0].Name : e.PropertyType.BaseType.GetGenericArguments()[0].Name)).ToList(); SrcProps.AddRange(GetExtraViewModelProperties(props)); } }
public void UpdateBindings() { try { ViewModels = ViewModelProvider.Viewmodels; if (_srcView != null) { var props = _srcView.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); SrcEvents = props .Where(p => p.PropertyType.IsSubclassOf(typeof(UnityEventBase)) && !p.GetCustomAttributes(typeof(ObsoleteAttribute), true).Any()) .Select(p => p.Name).ToList(); if (!string.IsNullOrEmpty(SrcEventName)) { _srcEventProp = _srcView.GetType().GetProperty(SrcEventName); } } if (!string.IsNullOrEmpty(ViewModelName)) { var props = ViewModelProvider.GetViewModelProperties(ViewModelName, BindingFlags.Instance | BindingFlags.Public); DstProps = props.Where(prop => prop.GetSetMethod(false) != null && !prop.GetCustomAttributes(typeof(ObsoleteAttribute), true).Any() ).Select(e => e.Name).ToList(); } if (!string.IsNullOrEmpty(DstPropName)) { _method = this.GetType().GetMethod(nameof(SetProp)); } } catch (Exception exc) { Debug.LogErrorFormat("Error creating bindings in {0}. Exception: {1}", gameObject.name, exc.Message); if (exc.InnerException != null) { Debug.LogErrorFormat("InnerException: {0}" + exc.InnerException.Message); } } }