コード例 #1
0
        public static string ToString <T>(Activity <T> activity)
        {
            var literal = activity as Literal <T>;

            if (literal != null && CSharpConvert.IsCodePrimitive(literal.Value))
            {
                // TODO : P2 : Handle literals according to the expression language

                return(CSharpConvert.ToString(literal.Value));
            }

            var serializableExpression = activity as IValueSerializableExpression;

            if (serializableExpression != null && serializableExpression.CanConvertToString(null))
            {
                return(serializableExpression.ConvertToString(null));
            }

            var textExpression = activity as ITextExpression;

            if (textExpression != null)
            {
                return(textExpression.ExpressionText);
            }

            return(null);
        }
コード例 #2
0
        public static string ToString(ActivityWithResult activity)
        {
            if (activity == null)
            {
                return(null);
            }

            if (activity.GetType().IsConstructedGenericTypeOf(typeof(Literal <>)) && CSharpConvert.IsCodePrimitive(activity.ResultType))
            {
                return(CSharpConvert.ToString(((dynamic)activity).Value));
            }

            var serializableExpression = activity as IValueSerializableExpression;

            if (serializableExpression != null && serializableExpression.CanConvertToString(null))
            {
                return(serializableExpression.ConvertToString(null));
            }

            var textExpression = activity as ITextExpression;

            if (textExpression != null)
            {
                return(textExpression.ExpressionText);
            }

            return(null);
        }