OperationContractGenerationContext.SyncMethod 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得同步作業的 CodeMemberMethod。
public:
property System::CodeDom::CodeMemberMethod ^ SyncMethod { System::CodeDom::CodeMemberMethod ^ get(); };
public System.CodeDom.CodeMemberMethod SyncMethod { get; }
member this.SyncMethod : System.CodeDom.CodeMemberMethod
Public ReadOnly Property SyncMethod As CodeMemberMethod
屬性值
同步作業的 CodeMemberMethod。
範例
下列範例將示範如何使用傳遞給 OperationContractGenerationContext 方法的 IOperationContractGenerationExtension.GenerateOperation 物件,以便加入從自訂 WSDL 項目擷取而來的程式碼註解。
public void GenerateOperation(OperationContractGenerationContext context)
{
context.SyncMethod.Comments.AddRange(Formatter.FormatComments(commentText));
Console.WriteLine("In generate operation.");
}
下列程式碼範例將示範所產生的程式碼註解。
/// From WSDL Documentation:
///
/// <summary>This contract is a stateless contract that provides a mechanism for
/// computing the nth Fibonacci term.</summary>
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://microsoft.wcf.documentation", ConfigurationName="IFibonacci")]
public interface IFibonacci
{
/// From WSDL Documentation:
///
/// <summary>The Compute operation returns the nth Fibonacci number. Because it
/// uses dual recursion it's very inefficient and therefore useful to demonstrate
/// caching.</summary><returns>The nth Fibonacci number.</returns><param
/// name="num">The value to use when computing the Fibonacci number.</param>
///
[System.ServiceModel.OperationContractAttribute(Action="http://microsoft.wcf.documentation/IFibonacci/Compute", ReplyAction="http://microsoft.wcf.documentation/IFibonacci/ComputeResponse")]
int Compute(int num);
/// From WSDL Documentation:
///
/// <summary>The GetPerson operation tests custom WSDL documentation
/// generation.</summary><returns>The Person object to be returned.</returns><param
/// name="FirstParameter">The value for the first parameter.</param><param
/// name="SecondParameter">The value for the second parameter.</param>
///
[System.ServiceModel.OperationContractAttribute(Action="http://microsoft.wcf.documentation/IFibonacci/GetPerson", ReplyAction="http://microsoft.wcf.documentation/IFibonacci/GetPersonResponse")]
Microsoft.WCF.Documentation.Person GetPerson(int FirstParameter, int SecondParameter);
}
'''From WSDL Documentation:
'''
'''<summary>This contract is a stateless contract that provides a mechanism for
'''computing the nth Fibonacci term.</summary>
'''
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0"), _
System.ServiceModel.ServiceContractAttribute([Namespace]:="http://microsoft.wcf.documentation", ConfigurationName:="IFibonacci")> _
Public Interface IFibonacci
'''From WSDL Documentation:
'''
'''<summary>The Compute operation returns the nth Fibonacci number. Because it
'''uses dual recursion it's very inefficient and therefore useful to demonstrate
'''caching.</summary><returns>The nth Fibonacci number.</returns><param
'''name="num">The value to use when computing the Fibonacci number.</param>
'''
<System.ServiceModel.OperationContractAttribute(Action:="http://microsoft.wcf.documentation/IFibonacci/Compute", ReplyAction:="http://microsoft.wcf.documentation/IFibonacci/ComputeResponse")> _
Function Compute(ByVal num As Integer) As Integer
'''From WSDL Documentation:
'''
'''<summary>The GetPerson operation tests custom WSDL documentation
'''generation.</summary><returns>The Person object to be returned.</returns><param
'''name="FirstParameter">The value for the first parameter.</param><param
'''name="SecondParameter">The value for the second parameter.</param>
'''
<System.ServiceModel.OperationContractAttribute(Action:="http://microsoft.wcf.documentation/IFibonacci/GetPerson", ReplyAction:="http://microsoft.wcf.documentation/IFibonacci/GetPersonResponse")> _
Function GetPerson(ByVal FirstParameter As Integer, ByVal SecondParameter As Integer) As Microsoft.WCF.Documentation.Person
End Interface
備註
您可以使用 SyncMethod 屬性在同步作業產生之前進行檢查或修改。