Avro.CodeGen.AvroGen.createProtocolInterface C# (CSharp) Метод

createProtocolInterface() приватный Метод

private createProtocolInterface ( Protocol protocol, CodeNamespace ns ) : CodeTypeReference
protocol Protocol
ns System.CodeDom.CodeNamespace
Результат System.CodeDom.CodeTypeReference
        private CodeTypeReference createProtocolInterface(Protocol protocol, CodeNamespace ns)
        {
            CodeTypeReference typeRef = new CodeTypeReference(protocol.Name);
            CodeTypeDeclaration typeInterface = createCodeTypeDeclaration(typeRef.BaseType);
            typeInterface.IsInterface = true;
            typeInterface.Attributes = MemberAttributes.Public;
            ns.Types.Add(typeInterface);
            if (!string.IsNullOrEmpty(protocol.Doc))
                typeInterface.Comments.Add(createDocComment(protocol.Doc));

            foreach (Message message in protocol.Messages)
            {
                CodeMemberMethod method = new CodeMemberMethod();
                method.Name = message.Name;
                method.ReturnType = getCodeTypeReference(message.Response);
                typeInterface.Members.Add(method);

                if (!string.IsNullOrEmpty(message.Doc))
                    method.Comments.Add(createDocComment(message.Doc));

                foreach (Message.Parameter parameter in message.Request)
                {
                    CodeTypeReference parmType = getCodeTypeReference(parameter.Schema);
                    CodeParameterDeclarationExpression parm = new CodeParameterDeclarationExpression(parmType, parameter.Name);
                    method.Parameters.Add(parm);
                }
            }

            return typeRef;
        }