private static object GetMemberValue(object dataSourceObject, MemberInfo memberInfo, string path, Type targetType)
 {
     if (((memberInfo is FieldInfo) || (memberInfo is PropertyInfo)) || (memberInfo is EventInfo))
     {
         return(MemberBind.GetValue(memberInfo, dataSourceObject, path));
     }
     if ((targetType == null) || !(memberInfo is MethodInfo))
     {
         throw new InvalidOperationException(SR.GetString("Error_MemberNotFound"));
     }
     return(Delegate.CreateDelegate(targetType, dataSourceObject, (MethodInfo)memberInfo));
 }
        private static ActivityBind GetContextBind(ActivityBind activityBind, Activity activity, out Activity contextActivity)
        {
            if (activityBind == null)
            {
                throw new ArgumentNullException("activityBind");
            }
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }
            BindRecursionContext context = new BindRecursionContext();
            ActivityBind         bind    = activityBind;

            contextActivity = activity;
            while (bind != null)
            {
                Activity activity2 = Helpers.ParseActivityForBind(contextActivity, bind.Name);
                if (activity2 == null)
                {
                    return(null);
                }
                object     dataContext = activity2;
                MemberInfo memberInfo  = GetMemberInfo(dataContext.GetType(), bind.Path, null);
                if (memberInfo == null)
                {
                    contextActivity = activity2;
                    return(bind);
                }
                if (memberInfo is FieldInfo)
                {
                    contextActivity = activity2;
                    return(bind);
                }
                if ((!(memberInfo is PropertyInfo) || !((memberInfo as PropertyInfo).PropertyType == typeof(ActivityBind))) || (dataContext == null))
                {
                    return(null);
                }
                object obj3 = MemberBind.GetValue(memberInfo, dataContext, bind.Path);
                if (!(obj3 is ActivityBind))
                {
                    return(null);
                }
                if (context.Contains(contextActivity, bind))
                {
                    return(null);
                }
                context.Add(contextActivity, bind);
                contextActivity = activity2;
                bind            = obj3 as ActivityBind;
            }
            return(bind);
        }