Ejemplo n.º 1
0
 public static void RemovePortsWithoutOperations(this ServiceDescription sd)
 {
     foreach (var removePort in sd.GetPortTypes().Where(c => c.Operations.Count == 0).ToList())
     {
         sd.PortTypes.Remove(removePort);
     }
 }
Ejemplo n.º 2
0
        public static void RemoveAllOtherOperations(this ServiceDescription sd, IEnumerable <string> keepOperations)
        {
            foreach (var port in sd.GetPortTypes())
            {
                foreach (var rop in port.GetOperations().Where(op => !keepOperations.Contains(op.Name)).ToList())
                {
                    foreach (OperationMessage opmsg in rop.Messages)
                    {
                        // WARN: namespaces are ignored
                        foreach (var removeMsg in sd.GetMessages().Where(msg => msg.Name == opmsg.Message.Name).ToList())
                        {
                            sd.Messages.Remove(removeMsg);
                        }
                    }

                    foreach (var binding in sd.GetBindings())
                    {
                        foreach (var operationBinding in binding.Operations.Cast <OperationBinding>().Where(op => !keepOperations.Contains(op.Name)).ToList())
                        {
                            binding.Operations.Remove(operationBinding);
                        }
                    }
                    port.Operations.Remove(rop);
                }
            }
        }
Ejemplo n.º 3
0
        public static void RemovePortTypes(this ServiceDescription sd, IEnumerable <string> removePortTypes)
        {
            foreach (var removePort in sd.GetPortTypes().Where(c => removePortTypes.Contains(c.Name)).ToList())
            {
                foreach (var btr in sd.GetBindings().Where(c => c.Type.Name == removePort.Name).ToList())
                {
                    sd.Bindings.Remove(btr);
                }

                sd.PortTypes.Remove(removePort);
            }
        }
Ejemplo n.º 4
0
        public static void ConvertToFireAndForget(this ServiceDescription sd, IEnumerable <string> convertToFireAndForget)
        {
            foreach (var operation in sd.GetPortTypes().SelectMany(pt => pt.GetOperations().Where(op => convertToFireAndForget.Contains(op.Name))).Where(op => op.Messages.Flow != OperationFlow.OneWay).ToList())
            {
                // Remove output and faults, leaving only the input
                if (operation.Messages.Output != null)
                {
                    operation.Messages.Remove(operation.Messages.Output);
                }
                operation.Faults.Clear();

                foreach (var binding in sd.GetBindings())
                {
                    foreach (var operationBinding in binding.GetOperationBindings().Where(op => convertToFireAndForget.Contains(op.Name)).ToList())
                    {
                        operationBinding.Output = null;
                        operationBinding.Faults.Clear();
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public static void RemoveUnreferencesMessages(this ServiceDescription sd)
        {
            // Gather messages via bindings
            var operationBindings        = sd.GetBindings().SelectMany(c => c.GetOperationBindings()).ToList();
            var soapHeaderInputMessages  = operationBindings.Select(c => c.Input).SelectMany(c => c.GetExtensions().OfType <SoapHeaderBinding>()).Select(c => c.Message);
            var soapHeaderOutputMessages = operationBindings.Select(c => c.Output).SelectMany(c => c.GetExtensions().OfType <SoapHeaderBinding>()).Select(c => c.Message);

            // Gather messages via port type
            var portOperations = sd.GetPortTypes().SelectMany(c => c.GetOperations()).ToList();

            var operationMessages = portOperations.SelectMany(c => c.GetOperationMessages()).Select(c => c.Message);
            var operationFaults   = portOperations.SelectMany(c => c.GetOperationFaults()).Select(c => c.Message);

            var allMessagesOnAllPorts = operationMessages.Concat(soapHeaderInputMessages).Concat(soapHeaderOutputMessages).Concat(operationFaults).ToList();

            foreach (var messageElement in sd.GetMessages().ToList())
            {
                // WARN: namespaces are ignored
                if (!allMessagesOnAllPorts.Any(c => c.Name == messageElement.Name))
                {
                    sd.Messages.Remove(messageElement);
                }
            }
        }