예제 #1
0
        public static IDictionary <string, CancellableOperationDescription> ExtractCancellableOperations(ContractDescription contract)
        {
            var indexByOperation = new Dictionary <string, CancellableOperationDescription>(StringComparer.OrdinalIgnoreCase);

            foreach (var operation in contract.Operations)
            {
                var part = operation
                           .Messages
                           .FirstOrDefault(i => i.Direction == MessageDirection.Input)
                           ?.Body
                           .Parts
                           .FirstOrDefault(i => IsTokenOrProxy(i.Type));

                if (part != null)
                {
                    var description = new CancellableOperationDescription(
                        part.Index,
                        part.Type,
                        "{0}.{1}".FormatWith(contract.Name, operation.Name));

                    indexByOperation.Add(operation.Name, description);

                    if (IsToken(part.Type))
                    {
                        operation.KnownTypes.Add(typeof(CancellationTokenProxy?));
                    }
                }
            }

            return(indexByOperation);
        }
예제 #2
0
        public void PassTokenIntoService(Type tokenType, CancellationTokenProxy?valueToSet, object expected)
        {
            var operation = new CancellableOperationDescription(1, tokenType, null);

            var args = new object[3];

            operation.PassTokenIntoService(args, valueToSet);

            Assert.AreEqual(expected, args[1]);
        }
예제 #3
0
        public void GetToken(object inputValue, object expected)
        {
            var operation = new CancellableOperationDescription(1, null, null);

            var args = new object[3];

            args[1] = inputValue;

            Assert.AreEqual(expected, operation.GetToken(args));
        }