当前位置: 首页>>代码示例>>C#>>正文


C# MessageDescription类代码示例

本文整理汇总了C#中System.ServiceModel.Description.MessageDescription的典型用法代码示例。如果您正苦于以下问题:C# MessageDescription类的具体用法?C# MessageDescription怎么用?C# MessageDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MessageDescription类属于System.ServiceModel.Description命名空间,在下文中一共展示了MessageDescription类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PrintDescription

private void PrintDescription(ServiceHost sh)
{
    // Declare variables.
    int i, j, k, l, c;
    ServiceDescription servDesc = sh.Description;
    OperationDescription opDesc;
    ContractDescription contractDesc;
    MessageDescription methDesc;
    MessageBodyDescription mBodyDesc;
    MessagePartDescription partDesc;
    IServiceBehavior servBeh;
    ServiceEndpoint servEP;

    // Print the behaviors of the service.
    Console.WriteLine("Behaviors:");
    for (c = 0; c < servDesc.Behaviors.Count; c++)
    {
        servBeh = servDesc.Behaviors[c];
        Console.WriteLine("\t{0}", servBeh.ToString());                
    }

    // Print the endpoint descriptions of the service.
    Console.WriteLine("Endpoints");
    for (i = 0; i < servDesc.Endpoints.Count; i++)
    {
        // Print the endpoint names.
        servEP = servDesc.Endpoints[i];
        Console.WriteLine("\tName: {0}", servEP.Name);
        contractDesc = servEP.Contract;

        Console.WriteLine("\tOperations:");
        for (j = 0; j < contractDesc.Operations.Count; j++)
        {
            // Print the operation names.
            opDesc = servEP.Contract.Operations[j];
            Console.WriteLine("\t\t{0}", opDesc.Name);
            Console.WriteLine("\t\tActions:");
            for (k  = 0; k < opDesc.Messages.Count; k++)
            {
                // Print the message action. 
                methDesc = opDesc.Messages[k];
                Console.WriteLine("\t\t\tAction:{0}", methDesc.Action);
               
                // Check for the existence of a body, then the body description.
                mBodyDesc = methDesc.Body;
                if (mBodyDesc.Parts.Count > 0)
                {
                    for (l = 0; l < methDesc.Body.Parts.Count; l++)
                    {
                        partDesc = methDesc.Body.Parts[l];
                        Console.WriteLine("\t\t\t\t{0}",partDesc.Name);
                    }
                }
            }
        }
    }
}
开发者ID:.NET开发者,项目名称:System.ServiceModel.Description,代码行数:57,代码来源:MessageDescription


注:本文中的System.ServiceModel.Description.MessageDescription类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。