MonoMobile.Views.BindingExpression.BindingExpression C# (CSharp) Method

BindingExpression() public method

Initializes a new instance of the MonoMobile.Views.BindingExpression class.
/// Is thrown when an argument passed to a method is invalid because it is . ///
public BindingExpression ( Binding binding, MemberInfo targetProperty, object target ) : System
binding Binding /// Binding. ///
targetProperty System.Reflection.MemberInfo /// ViewModel.. ///
target object /// ViewModel to hock into. ///
return System
        public BindingExpression(Binding binding, MemberInfo targetProperty, object target)
        {
            if (binding == null)
                throw new ArgumentNullException("binding");

            if (targetProperty == null)
                throw new ArgumentNullException("targetProperty");

            if (target == null)
                throw new ArgumentNullException("target");

            Binding = binding;
            Binding.Target = target;
            TargetProperty = targetProperty;
            if(string.IsNullOrEmpty(binding.TargetPath))
            {
                binding.TargetPath = targetProperty.Name;
            }

            object viewSource = Binding.Source;
            _ViewProperty = viewSource.GetType().GetNestedMember(ref viewSource, Binding.SourcePath, true);
            Binding.ViewSource = viewSource;
            SourceProperty = _ViewProperty;

            var dataContext = viewSource as IDataContext;
            if (dataContext != null && dataContext.DataContext != null)
            {
                var source = dataContext.DataContext;

                SourceProperty = source.GetType().GetNestedMember(ref source, Binding.SourcePath, true);
                Binding.Source = source;
            }
        }