protected internal virtual object InstantiateDelegateClass(IActivityExecution execution)
        {
            object @delegate = null;

            if (Expression != null)
            {
                @delegate = Expression.GetValue(execution);
            }
            else if (!ReferenceEquals(ClassName, null))
            {
                @delegate = ClassDelegateUtil.InstantiateDelegate(ClassName, null);
            }
            return(@delegate);
        }
        protected internal virtual IActivityBehavior GetActivityBehaviorInstance(IActivityExecution execution)
        {
            var delegateInstance = ClassDelegateUtil.InstantiateDelegate(ClassName, FieldDeclarations);

            if (delegateInstance is IActivityBehavior)
            {
                return(new CustomActivityBehavior((IActivityBehavior)delegateInstance));
            }
            if (delegateInstance is IJavaDelegate)
            {
                return(new ServiceTaskJavaDelegateActivityBehavior((IJavaDelegate)delegateInstance));
            }
            throw Log.MissingDelegateParentClassException(delegateInstance.GetType()
                                                          .FullName, typeof(IJavaDelegate).FullName, typeof(IActivityBehavior).FullName);
        }