System.Xml.Serialization.XmlSerializationILGen.EnsureMethodBuilder C# (CSharp) Method

EnsureMethodBuilder() private method

private EnsureMethodBuilder ( TypeBuilder typeBuilder, string methodName, MethodAttributes attributes, Type returnType, Type parameterTypes ) : MethodBuilder
typeBuilder System.Reflection.Emit.TypeBuilder
methodName string
attributes MethodAttributes
returnType System.Type
parameterTypes System.Type
return System.Reflection.Emit.MethodBuilder
        internal MethodBuilder EnsureMethodBuilder(TypeBuilder typeBuilder, string methodName,
            MethodAttributes attributes, Type returnType, Type[] parameterTypes)
        {
            MethodBuilderInfo methodBuilderInfo;
            if (!_methodBuilders.TryGetValue(methodName, out methodBuilderInfo))
            {
                MethodBuilder methodBuilder = typeBuilder.DefineMethod(
                    methodName,
                    attributes,
                    returnType,
                    parameterTypes);
                methodBuilderInfo = new MethodBuilderInfo(methodBuilder, parameterTypes);
                _methodBuilders.Add(methodName, methodBuilderInfo);
            }
#if DEBUG
            else
            {
                methodBuilderInfo.Validate(returnType, parameterTypes, attributes);
            }
#endif
            return methodBuilderInfo.MethodBuilder;
        }