9 public class PreserveSoapHttpClients : BaseSubStep {
11 public override SubStepTargets Targets {
12 get { return SubStepTargets.Type; }
15 public override bool IsActiveFor (AssemblyDefinition assembly)
17 return Annotations.GetAction (assembly) == AssemblyAction.Link && !Profile.IsSdkAssembly (assembly);
20 public override void ProcessType (TypeDefinition type)
22 if (IsWebServiceClient (type))
23 PreserveClient (type);
26 void PreserveClient (TypeDefinition type)
31 foreach (MethodDefinition method in type.Methods) {
33 if (!TryExtractSyncMethod (method, out sync_method))
36 AddPreservedMethod (method, sync_method);
40 void AddPreservedMethod (MethodDefinition target, string methodName)
42 foreach (MethodDefinition method in target.DeclaringType.Methods)
43 if (method.Name == methodName)
44 Annotations.AddPreservedMethod (target, method);
47 static bool TryExtractSyncMethod (MethodDefinition method, out string sync_method)
49 if (TryExtractPrefixedMethodName ("Begin", method.Name, out sync_method))
52 if (TryExtractPrefixedMethodName ("End", method.Name, out sync_method))
55 if (TryExtractSuffixedMethodName ("Async", method.Name, out sync_method))
61 static bool TryExtractPrefixedMethodName (string prefix, string fullName, out string methodName)
65 int pos = fullName.IndexOf (prefix, StringComparison.Ordinal);
69 methodName = fullName.Substring (prefix.Length);
73 static bool TryExtractSuffixedMethodName (string suffix, string fullName, out string methodName)
77 int pos = fullName.LastIndexOf (suffix, StringComparison.Ordinal);
81 methodName = fullName.Substring (0, pos);
85 static bool IsWebServiceClient (TypeDefinition type)
87 return type.Inherits ("System.Web.Services.Protocols", "SoapHttpClientProtocol");