get { return descriptionImporter.CodeGenerationOptions; }
}
- internal ICodeGenerator CodeGenerator {
+ internal CodeDomProvider CodeGenerator {
get { return descriptionImporter.CodeGenerator; }
}
}
}
}
+
+ if (!found)
+ {
+ // Looks like MS.NET generates classes for all bindings if
+ // no services are present
+
+ foreach (ImportInfo info in importInfo)
+ {
+ this.iinfo = info;
+ foreach (Binding b in info.ServiceDescription.Bindings)
+ {
+ this.binding = b;
+ this.service = null;
+ this.port = null;
+ if (!IsBindingSupported ()) continue;
+ found = true;
+ ImportPortBinding (true);
+ }
+ }
+ }
EndNamespace ();
void ImportPortBinding (bool multipleBindings)
{
- if (multipleBindings) className = port.Name;
- else className = service.Name;
+ if (port != null) {
+ if (multipleBindings) className = port.Name;
+ else className = service.Name;
+ }
+ else
+ className = binding.Name;
className = classNames.AddUnique (CodeIdentifier.MakeValid (className), port);
className = className.Replace ("_x0020_", ""); // MS.NET seems to do this
CodeTypeDeclaration codeClass = BeginClass ();
codeTypeDeclaration = codeClass;
- AddCodeType (codeClass, port.Documentation);
+ AddCodeType (codeClass, port != null ? port.Documentation : null);
codeClass.Attributes = MemberAttributes.Public;
-
- if (service.Documentation != null && service.Documentation != "")
+
+ if (service != null && service.Documentation != null && service.Documentation != "")
AddComments (codeClass, service.Documentation);
if (Style == ServiceDescriptionImportStyle.Client) {
{
operationBinding = oper;
operation = FindPortOperation ();
- if (operation == null) throw new Exception ("Operation " + operationBinding.Name + " not found in portType " + PortType.Name);
+ if (operation == null)
+ throw new Exception ("Operation " + operationBinding.Name + " not found in portType " + PortType.Name);
+
+ inputMessage = null;
+ outputMessage = null;
foreach (OperationMessage omsg in operation.Messages)
{
else return msg.Name;
}
- internal string GetServiceUrl (string location)
+ internal void GenerateServiceUrl (string location, CodeStatementCollection stms)
{
- if (ImportInfo.AppSettingUrlKey == null || ImportInfo.AppSettingUrlKey == string.Empty)
- return location;
+ if (ImportInfo.AppSettingUrlKey == null || ImportInfo.AppSettingUrlKey == string.Empty) {
+ if (location != null) {
+ CodeExpression ce = new CodeFieldReferenceExpression (new CodeThisReferenceExpression(), "Url");
+ CodeAssignStatement cas = new CodeAssignStatement (ce, new CodePrimitiveExpression (location));
+ stms.Add (cas);
+ }
+ }
else
{
- string url;
- if (Style == ServiceDescriptionImportStyle.Server) throw new InvalidOperationException ("Cannot set appSettingUrlKey if Style is Server");
- url = ConfigurationSettings.AppSettings [ImportInfo.AppSettingUrlKey];
- if (ImportInfo.AppSettingBaseUrl != null && ImportInfo.AppSettingBaseUrl != string.Empty)
- url += "/" + ImportInfo.AppSettingBaseUrl + "/" + location;
- return url;
+ CodeExpression prop = new CodePropertyReferenceExpression (new CodeTypeReferenceExpression ("System.Configuration.ConfigurationSettings"), "AppSettings");
+ prop = new CodeIndexerExpression (prop, new CodePrimitiveExpression (ImportInfo.AppSettingUrlKey));
+ stms.Add (new CodeVariableDeclarationStatement (typeof(string), "urlSetting", prop));
+
+ CodeExpression urlSetting = new CodeVariableReferenceExpression ("urlSetting");
+ CodeExpression thisUrl = new CodeFieldReferenceExpression (new CodeThisReferenceExpression(), "Url");
+
+ CodeStatement[] trueStms = new CodeStatement [1];
+ CodeExpression ce = urlSetting;
+ CodeExpression cond = new CodeBinaryOperatorExpression (urlSetting, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression (null));
+
+ if (ImportInfo.AppSettingBaseUrl != null)
+ ce = new CodeMethodInvokeExpression (new CodeTypeReferenceExpression (typeof(string)), "Concat", ce, new CodePrimitiveExpression (ImportInfo.AppSettingBaseUrl));
+ trueStms [0] = new CodeAssignStatement (thisUrl, ce);
+
+ if (location != null) {
+ CodeStatement[] falseStms = new CodeStatement [1];
+ falseStms [0] = new CodeAssignStatement (thisUrl, new CodePrimitiveExpression (location));
+ stms.Add (new CodeConditionStatement (cond, trueStms, falseStms));
+ }
+ else
+ stms.Add (new CodeConditionStatement (cond, trueStms));
}
}
-
+
void ClasifySchemas (ArrayList importInfo)
{
// I don't like this, but I could not find any other way of clasifying
foreach (XmlSchemaObject ob in sc.Includes)
{
XmlSchemaImport import = ob as XmlSchemaImport;
- if (import.Namespace == SoapProtocolReflector.EncodingNamespace) return true;
+ if (import != null && import.Namespace == SoapProtocolReflector.EncodingNamespace) return true;
}
return false;
}