/// <summary>
        /// Initializes a new instance of the <see cref="TaskOrchestrationDescriptor"/> class.
        /// </summary>
        /// <param name="type">The service type.</param>
        /// <param name="name">The name of the type.</param>
        /// <param name="version">The version of the type.</param>
        public TaskOrchestrationDescriptor(Type type, string name = null, string version = null)
        {
            Check.NotNull(type, nameof(type));
            Check.ConcreteType <TaskOrchestration>(type, nameof(type));

            Type    = type;
            Name    = name ?? TypeShortName.ToString(type, false);
            Version = version ?? NameVersionHelper.GetDefaultVersion(type);
        }
Esempio n. 2
0
        /// <summary>
        /// Tries to parse <paramref name="typeShortName"/> into a <see cref="TypeShortName"/>.
        /// </summary>
        /// <param name="typeShortName">The name to parse.</param>
        /// <param name="typeName">The parsed name.</param>
        /// <returns>True if successfully parsed, false otherwise.</returns>
        public static bool TryParse(string typeShortName, out TypeShortName typeName)
        {
            typeName = default;
            if (string.IsNullOrEmpty(typeShortName))
            {
                return(false);
            }

            try
            {
                typeName = new TypeShortName(typeShortName);
                return(true);
            }
            catch (Exception ex) when(ex is ArgumentException || ex is IndexOutOfRangeException)
            {
            }

            return(false);
        }
Esempio n. 3
0
 /// <summary>
 /// Creates an instance of <typeparamref name="T"/>, given the closed type name for T.
 /// </summary>
 /// <param name="typeName">The closed short name of T.</param>
 /// <returns>An instance of T.</returns>
 /// <remarks>
 /// This is called when this creator represents an open-generic version of T, with the provided type
 /// <paramref name="typeName"/> being the closed form to create.
 /// </remarks>
 public abstract T Create(TypeShortName typeName);