static void Main() { // <Snippet1> // <Snippet2> // <Snippet3> ServiceDescription myServiceDescription = ServiceDescription.Read("MimeContentSample_cs.wsdl"); // Get the Binding. Binding myBinding = myServiceDescription.Bindings["b1"]; // Get the first OperationBinding. OperationBinding myOperationBinding = myBinding.Operations[0]; OutputBinding myOutputBinding = myOperationBinding.Output; ServiceDescriptionFormatExtensionCollection myServiceDescriptionFormatExtensionCollection = myOutputBinding.Extensions; // Find all MimeContentBinding objects in extensions. MimeContentBinding[] myMimeContentBindings = (MimeContentBinding[]) myServiceDescriptionFormatExtensionCollection.FindAll( typeof(MimeContentBinding)); // Enumerate the array and display MimeContentBinding properties. foreach (MimeContentBinding myMimeContentBinding in myMimeContentBindings) { Console.WriteLine("Type: " + myMimeContentBinding.Type); Console.WriteLine("Part: " + myMimeContentBinding.Part); } // </Snippet1> // </Snippet2> Console.WriteLine("Namespace: " + MimeContentBinding.Namespace); // </Snippet3> }
public void Add2() { ServiceDescriptionFormatExtensionCollection c = new ServiceDescriptionFormatExtensionCollection(new ServiceDescription()); c.Add(new XmlDocument().CreateElement("foo")); }
internal static void ConvertExtensions(ServiceDescriptionFormatExtensionCollection extensions, EnvelopeVersion version, ConvertExtension conversionMethod) { bool flag = false; for (int i = extensions.Count - 1; i >= 0; i--) { object src = extensions[i]; if (conversionMethod(ref src, version)) { if (src == null) { extensions.Remove(extensions[i]); } else { extensions[i] = src; } flag = true; } } if (!flag) { object obj3 = null; conversionMethod(ref obj3, version); if (obj3 != null) { extensions.Add(obj3); } } }
public void Add() { ServiceDescriptionFormatExtensionCollection c = new ServiceDescriptionFormatExtensionCollection(new ServiceDescription()); c.Add(0); }
private void ParseOperationBindingExtensions(ServiceDescriptionFormatExtensionCollection extensions, [CallerLineNumber] int callerLine = -1) { foreach (ServiceDescriptionFormatExtension extension in extensions) { if (extension is SoapBodyBinding body) { var message = messages[(body.Parent as MessageBinding).Name]; //var part = body.Parts[] foreach (MessagePart part in message.Parts) { string typeName = GetAliasedType("object"); if (DiscoveryClientReferencesElements.ContainsKey(part.Element.Name)) { var elements = DiscoveryClientReferencesElements[part.Element.Name]; var xmlObject = elements.Find(e => e is XmlSchemaElement); if ((xmlObject is XmlSchemaElement element)) { typeName = GetAliasedType(element.SchemaTypeName.Name); } else if ((xmlObject is XmlSchemaComplexType type)) { //typeName = GetAliasedType(type); } else if ((xmlObject is XmlSchemaSimpleType simpleType)) { //typeName = GetAliasedType(simpleType.SchemaTypeName.Name); } } var propertyName = part.Element.Name; var escapedPropertyName = FixupIdentifier(propertyName); var fieldName = string.Format("{0}Field", propertyName); var field = FieldDeclaration(VariableDeclaration(ParseTypeName(typeName), new SeparatedSyntaxList <VariableDeclaratorSyntax>())).AddAttributeLists(new AttributeListSyntax[] { AttributeList( SingletonSeparatedList <AttributeSyntax>( Attribute(IdentifierName("System.Xml.XmlElement")).WithArgumentList( AttributeArgumentList( SingletonSeparatedList <AttributeArgumentSyntax>( AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(propertyName))) ) ) ) ) ) }); field = field.AddDeclarationVariables(new[] { VariableDeclarator(fieldName) }).WithModifiers(TokenList(Token(SyntaxKind.PrivateKeyword))); currentClass = currentClass.AddMembers(field); var property = PropertyDeclaration(ParseTypeName(typeName), escapedPropertyName).WithAccessorList(AccessorList(new SyntaxList <AccessorDeclarationSyntax>().AddRange(new AccessorDeclarationSyntax[] { AccessorDeclaration(SyntaxKind.GetAccessorDeclaration, Block(SingletonList <StatementSyntax>(ReturnStatement(IdentifierName(fieldName))))), AccessorDeclaration(SyntaxKind.SetAccessorDeclaration, Block(SingletonList <StatementSyntax>(ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, IdentifierName(fieldName), IdentifierName("value")))))) }))).WithModifiers(TokenList(Token(SyntaxKind.PublicKeyword))); currentClass = currentClass.AddMembers(property); }
public void Find() { ServiceDescriptionFormatExtensionCollection c = new ServiceDescriptionFormatExtensionCollection(new ServiceDescription()); c.Add(new MySoapBinding()); Assert.IsNotNull(c.Find(typeof(SoapBinding))); }
static void Main() { // <Snippet2> ServiceDescription myServicDescription = ServiceDescription.Read("MimeMultiPartRelatedSample_cs.wsdl"); // Get the binding collection. BindingCollection myBindingCollection = myServicDescription.Bindings; int index = 0; for (int i = 0; i < myBindingCollection.Count; i++) { // Get the collection for MimeServiceHttpPost. if (myBindingCollection[i].Name == "MimeServiceHttpPost") { OperationBindingCollection myOperationBindingCollection = myBindingCollection[i].Operations; OutputBinding myOutputBinding = myOperationBindingCollection[0].Output; ServiceDescriptionFormatExtensionCollection myServiceDescriptionFormatExtensionCollection = myOutputBinding.Extensions; MimeMultipartRelatedBinding myMimeMultipartRelatedBinding = (MimeMultipartRelatedBinding) myServiceDescriptionFormatExtensionCollection.Find( typeof(MimeMultipartRelatedBinding)); MimePartCollection myMimePartCollection = myMimeMultipartRelatedBinding.Parts; foreach (MimePart myMimePart in myMimePartCollection) { Console.WriteLine("Extension types added to MimePart: " + index++); Console.WriteLine("----------------------------"); foreach (object myExtension in myMimePart.Extensions) { Console.WriteLine(myExtension.GetType()); } Console.WriteLine(); } break; } } // </Snippet2> }
// Methods public void AddExtensionWarningComments(System.CodeDom.CodeCommentStatementCollection comments, ServiceDescriptionFormatExtensionCollection extensions) { }
// Methods public void AddExtensionWarningComments(System.CodeDom.CodeCommentStatementCollection comments, ServiceDescriptionFormatExtensionCollection extensions) { }
static void Main() { try { // <Snippet2> ServiceDescription myServiceDescription = ServiceDescription.Read("Sample_CS.wsdl"); ServiceDescriptionFormatExtensionCollection myCollection = new ServiceDescriptionFormatExtensionCollection(myServiceDescription); // </Snippet2> // <Snippet3> SoapBinding mySoapBinding1 = new SoapBinding(); SoapBinding mySoapBinding2 = new SoapBinding(); SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding(); MyFormatExtension myFormatExtensionObject = new MyFormatExtension(); // Add elements to collection. myCollection.Add(mySoapBinding1); myCollection.Add(mySoapAddressBinding); myCollection.Add(mySoapBinding2); myCollection.Add(myFormatExtensionObject); // </Snippet3> // <Snippet4> Console.WriteLine("Collection contains following types of elements: "); // Display the 'Type' of the elements in collection. for (int i = 0; i < myCollection.Count; i++) { Console.WriteLine(myCollection[i].GetType().ToString()); } // </Snippet4> // <Snippet5> // Check element of type 'SoapAddressBinding' in collection. Object myObj = myCollection.Find(mySoapAddressBinding.GetType()); if (myObj == null) { Console.WriteLine("Element of type '{0}' not found in collection.", mySoapAddressBinding.GetType().ToString()); } else { Console.WriteLine("Element of type '{0}' found in collection.", mySoapAddressBinding.GetType().ToString()); } // </Snippet5> // <Snippet6> // Check all elements of type 'SoapBinding' in collection. Object[] myObjectArray1 = new Object[myCollection.Count]; myObjectArray1 = myCollection.FindAll(mySoapBinding1.GetType()); int myNumberOfElements = 0; IEnumerator myIEnumerator = myObjectArray1.GetEnumerator(); // Calculate number of elements of type 'SoapBinding'. while (myIEnumerator.MoveNext()) { if (mySoapBinding1.GetType() == myIEnumerator.Current.GetType()) { myNumberOfElements++; } } Console.WriteLine("Collection contains {0} objects of type '{1}'.", myNumberOfElements.ToString(), mySoapBinding1.GetType().ToString()); // </Snippet6> // <Snippet7> // Check 'IsHandled' status for 'myFormatExtensionObject' object in collection. Console.WriteLine("'IsHandled' status for {0} object is {1}.", myFormatExtensionObject.ToString(), myCollection.IsHandled(myFormatExtensionObject).ToString()); // </Snippet7> // <Snippet8> // Check 'IsRequired' status for 'myFormatExtensionObject' object in collection. Console.WriteLine("'IsRequired' status for {0} object is {1}.", myFormatExtensionObject.ToString(), myCollection.IsRequired(myFormatExtensionObject).ToString()); // </Snippet8> // <Snippet9> // Copy elements of collection to an Object array. Object[] myObjectArray2 = new Object[myCollection.Count]; myCollection.CopyTo(myObjectArray2, 0); Console.WriteLine("Collection elements are copied to an object array."); // </Snippet9> // <Snippet10> // Check for 'myFormatExtension' object in collection. if (myCollection.Contains(myFormatExtensionObject)) { // <Snippet11> // Get index of a 'myFormatExtension' object in collection. Console.WriteLine("Index of 'myFormatExtensionObject' is " + "{0} in collection.", myCollection.IndexOf(myFormatExtensionObject).ToString()); // </Snippet11> // <Snippet12> // Remove 'myFormatExtensionObject' element from collection. myCollection.Remove(myFormatExtensionObject); Console.WriteLine("'myFormatExtensionObject' is removed" + " from collection."); // </Snippet12> } // </Snippet10> // <Snippet13> // Insert 'MyFormatExtension' object. myCollection.Insert(0, myFormatExtensionObject); Console.WriteLine("'myFormatExtensionObject' is inserted to collection."); // </Snippet13> } catch (Exception e) { Console.WriteLine("The following exception was raised: {0}", e.Message); } }