internal static void ValidateRoles(Activity activity, string identity)
        {
            DependencyProperty dependencyProperty = DependencyProperty.FromName("Roles", activity.GetType().BaseType);

            if (dependencyProperty == null)
            {
                dependencyProperty = DependencyProperty.FromName("Roles", activity.GetType());
            }

            if (dependencyProperty == null)
            {
                return;
            }

            ActivityBind rolesBind = activity.GetBinding(dependencyProperty) as ActivityBind;

            if (rolesBind == null)
            {
                return;
            }

            WorkflowRoleCollection roles = rolesBind.GetRuntimeValue(activity) as WorkflowRoleCollection;

            if (roles == null)
            {
                return;
            }

            if (!roles.IncludesIdentity(identity))
            {
                throw new WorkflowAuthorizationException(activity.Name, identity);
            }
        }
        internal static void ValidateRoles(Activity activity, string identity)
        {
            DependencyProperty dependencyProperty = DependencyProperty.FromName("Roles", activity.GetType().BaseType);

            if (dependencyProperty == null)
            {
                dependencyProperty = DependencyProperty.FromName("Roles", activity.GetType());
            }
            if (dependencyProperty != null)
            {
                ActivityBind binding = activity.GetBinding(dependencyProperty);
                if (binding != null)
                {
                    WorkflowRoleCollection runtimeValue = binding.GetRuntimeValue(activity) as WorkflowRoleCollection;
                    if ((runtimeValue != null) && !runtimeValue.IncludesIdentity(identity))
                    {
                        throw new WorkflowAuthorizationException(activity.Name, identity);
                    }
                }
            }
        }