While I was going through some code sample, I noticed the following attributes which I do not understand how used.This classes seems to be generated from xsd.
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="FlightHistoryGetRecordsSOAPBinding", Namespace="http://www.pathfinder-xml.com/FlightHistoryService.wsdl")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("FlightHistoryGetRecordsResponse", Namespace="http://pathfinder-xml/FlightHistoryService.xsd")]
Also could not understand the following methods:
public System.IAsyncResult BeginFlightHistoryGetRecordsOperation(FlightHistoryGetRecordsRequest FlightHistoryGetRecordsRequest, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("FlightHistoryGetRecordsOperation", new object[] {
FlightHistoryGetRecordsRequest}, callback, asyncState);
}
/// <remarks/>
public FlightHistoryGetRecordsResponse EndFlightHistoryGetRecordsOperation(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((FlightHistoryGetRecordsResponse)(results[0]));
}
So I have the following questions:
1. What does each attribute do.
2.What is the return doing in attributes?
3.What are the parameters used in FlightHistoryGetRecordsResponse method and why is it returning this.BeginInvoke?
1a: The DebuggerStepThough attribute indicates that when a breakpoint is hit and the coder is stepping through the code, the debugger will skip over this method rather than pausing on each line.
1b: The DesignerCategory attribute indicates the grouping for the class if/when it appears in design time controls such as the property grid in visual studio.
1c: The WebServiceBinding attribute attaches the name and the namespace to a class which represents a web service.
It’s important to understand that attributes don’t “do” anything, they just contain meta-data and it’s up to other parts of code what to do with that meta-data.
2: The return statement before the attribute indicates that the attribute applies to the value being returned from the method, not to the method itself. Similarly you can apply attributes to the method parameters. In this case the attribute is describing how the return value should be serialized into XML.
3: This is similar to a regular request/response web service call, but it has been modified to be asynchronous. The AsyncCallback is a method that should be called when the asynchronous operation has compelted, and the return value is an AsyncResult which can be used to inspect the running operation from other parts of code. This is the old pattern of asynchronous method calls and you don’t find this kind of code much anymore. See Async Pattern on MSDN…