Beispiel #1
0
        private static void VerifyTypeNameWithAssembly(
            TypeShortName typeName, Type expectedType, string expectedTypeString = null)
        {
            string name = expectedType.FullName;

            if (expectedType.IsConstructedGenericType)
            {
                name = name[..name.IndexOf('[')];
Beispiel #2
0
 /// <inheritdoc/>
 public override Task <T> CreateSubOrchestrationInstance <T>(Type orchestrationType, object input)
 {
     PreUpdateProperties();
     return(Wrap(CreateSubOrchestrationInstance <T>(
                     TypeShortName.ToString(orchestrationType, includeTopAssembly: false),
                     NameVersionHelper.GetDefaultVersion(orchestrationType),
                     input)));
 }
Beispiel #3
0
 /// <inheritdoc/>
 public override Task <TResult> ScheduleTask <TResult>(Type activityType, params object[] parameters)
 {
     PreUpdateProperties();
     return(Wrap(ScheduleTask <TResult>(
                     TypeShortName.ToString(activityType, includeTopAssembly: false),
                     NameVersionHelper.GetDefaultVersion(activityType),
                     parameters)));
 }
Beispiel #4
0
        public void Ctor_DefaultNameVersion(Type type)
        {
            var descriptor = new TaskOrchestrationDescriptor(type);

            descriptor.Should().NotBeNull();
            descriptor.Type.Should().Be(type);
            descriptor.Name.Should().Be(TypeShortName.ToString(type, false));
            descriptor.Version.Should().BeEmpty();
        }
        public void Ctor_Type_DefaultNameVersion(Type type)
        {
            var descriptor = new TaskActivityDescriptor(type);

            descriptor.Should().NotBeNull();
            descriptor.Method.Should().BeNull();
            descriptor.Type.Should().Be(type);
            descriptor.Name.Should().Be(TypeShortName.ToString(type, false));
            descriptor.Version.Should().BeEmpty();
        }
Beispiel #6
0
        public void Create_OpenGeneric_NotNull(Type type)
        {
            var manager = new GenericObjectManager <TaskActivity>();

            manager.Add(new ActivityObjectCreator(new TaskActivityDescriptor(typeof(TestActivity <>))));
            TaskActivity activity = manager.GetObject(TypeShortName.ToString(type, false), string.Empty);

            activity.Should().NotBeNull();
            activity.As <WrapperActivity>().Descriptor.Type.Should().Be(type);
        }
Beispiel #7
0
 /// <inheritdoc/>
 public override Task <T> ScheduleWithRetry <T>(
     Type taskActivityType, RetryOptions retryOptions, params object[] parameters)
 {
     PreUpdateProperties();
     return(Wrap(ScheduleWithRetry <T>(
                     TypeShortName.ToString(taskActivityType, includeTopAssembly: false),
                     NameVersionHelper.GetDefaultVersion(taskActivityType),
                     retryOptions,
                     parameters)));
 }
Beispiel #8
0
        public void Load_AssemblyNameProvided(Type type)
        {
            var  typeName1 = new TypeShortName(type);
            Type actual    = typeName1.Load(type.Assembly);

            actual.Should().Be(type);

            var typeName2 = new TypeShortName(typeName1.ToString(false));

            actual = typeName2.Load(type.Assembly);
            actual.Should().Be(type);
        }
Beispiel #9
0
        public void Load_AssemblyNameSet(Type type)
        {
            var  typeName1 = new TypeShortName(type);
            Type actual    = typeName1.Load();

            actual.Should().Be(type);

            var typeName2 = new TypeShortName(typeName1.ToString());

            actual = typeName2.Load();
            actual.Should().Be(type);
        }
Beispiel #10
0
        public void Ctor_NestedGenericString()
        {
            string typeNameString = "System.Collections.Generic.List`1[[DurableTask.Core.ObjectCreator`1[[DurableTask.Core.Task" +
                                    "Activity, DurableTask.Core]], DurableTask.Core]], System.Private.CoreLib";
            string genericTypeNameString = "DurableTask.Core.ObjectCreator`1[[DurableTask.Core.Task" +
                                           "Activity, DurableTask.Core]], DurableTask.Core";
            Type type        = typeof(List <ObjectCreator <TaskActivity> >);
            Type genericType = typeof(ObjectCreator <TaskActivity>);
            var  typeName    = new TypeShortName(typeNameString);

            VerifyTypeNameWithAssembly(typeName, type, typeNameString);
            VerifyTypeNameWithAssembly(typeName.GenericParams.First(), genericType, genericTypeNameString);
        }
        /// <inheritdoc/>
        public override TaskOrchestration Create(TypeShortName typeName)
        {
            if (_descriptor.Type?.IsGenericTypeDefinition != true)
            {
                throw new InvalidOperationException("This is not a generic type definition creator.");
            }

            Type closedType = typeName.Load(_descriptor.Type.Assembly);

            Check.Argument(closedType.IsConstructedGenericType, nameof(closedType), "Type must be closed");

            return(new WrapperOrchestration(new TaskOrchestrationDescriptor(closedType)));
        }
Beispiel #12
0
        public void Ctor_ClosedGenericString(string typeNameString, Type type)
        {
            var typeName = new TypeShortName(typeNameString);

            VerifyTypeNameWithAssembly(typeName, type, typeNameString);
        }
Beispiel #13
0
        public void Ctor_OpenGenericString_NoAssembly(string typeNameString, Type type)
        {
            var typeName = new TypeShortName(typeNameString);

            VerifyTypeNameWithoutAssembly(typeName, type);
        }
Beispiel #14
0
        public void Ctor_SimpleString(string typeNameString, Type type)
        {
            var typeName = new TypeShortName(typeNameString);

            VerifyTypeNameWithAssembly(typeName, type);
        }
Beispiel #15
0
        public void Ctor_OpenGenericType(Type type)
        {
            var typeName = new TypeShortName(type);

            VerifyTypeNameWithAssembly(typeName, type);
        }
Beispiel #16
0
        public void Ctor_SimpleType(Type type)
        {
            var typeName = new TypeShortName(type);

            VerifyTypeNameWithAssembly(typeName, type);
        }