Exemplo n.º 1
0
        private bool IsActivityAllowed(MethodInfo method, ActivityType activityType)
        {
            ActivityAttribute activityAttribute =
                System.Attribute.GetCustomAttribute(method, typeof(ActivityAttribute)) as ActivityAttribute;

            return(activityAttribute != null && activityAttribute.ActivityType == activityType && InUse > 0);
        }
Exemplo n.º 2
0
    private void SetActivityType(MemberInfo method)
    {
        ActivityAttribute activityAttribute =
            System.Attribute.GetCustomAttribute(method, typeof(ActivityAttribute)) as ActivityAttribute;

        if (activityAttribute == null)
        {
            Debug.Log("Method's activity type is missing!");
            return;
        }

        ActivityType = activityAttribute.ActivityType;
    }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the Cadence activity type name to be used for a activity interface or
        /// implementation class.
        /// </summary>
        /// <param name="activityType">The activity interface or implementation type.</param>
        /// <param name="activityAttribute">Specifies the <see cref="ActivityAttribute"/>.</param>
        /// <returns>The type name.</returns>
        /// <remarks>
        /// <para>
        /// If <paramref name="activityAttribute"/> is passed and <see cref="ActivityAttribute.Name"/>
        /// is not <c>null</c> or empty, then the name specified in the attribute is returned.
        /// </para>
        /// <para>
        /// Otherwise, we'll return the fully qualified name of the activity interface
        /// with the leadting "I" removed.
        /// </para>
        /// </remarks>
        internal static string GetActivityTypeName(Type activityType, ActivityAttribute activityAttribute)
        {
            Covenant.Requires <ArgumentNullException>(activityType != null, nameof(activityType));

            if (activityAttribute != null && !string.IsNullOrEmpty(activityAttribute.Name))
            {
                return(activityAttribute.Name);
            }

            if (activityType.IsClass)
            {
                CadenceHelper.ValidateActivityImplementation(activityType);

                activityType = CadenceHelper.GetActivityInterface(activityType);
            }
            else
            {
                CadenceHelper.ValidateActivityInterface(activityType);
            }

            var fullName = activityType.FullName;
            var name     = activityType.Name;

            if (name.StartsWith("I") && name != "I")
            {
                // We're going to strip the leading "I" from the unqualified
                // type name (unless that's the only character).

                fullName  = fullName.Substring(0, fullName.Length - name.Length);
                fullName += name.Substring(1);
            }

            // We need to replace the "+" characters .NET uses for nested types into
            // "." so the result will be a valid C# type identifier.

            return(fullName.Replace('+', '.'));
        }