// // Generate the "Signature2" binary serialization string for ConstructorInfos // // Because the string is effectively a file format for serialized Reflection objects, it must be exactly correct. If missing // metadata prevents generating the string, this method throws a MissingMetadata exception. // public static string SerializationToString(this ConstructorInfo constructor) { StringBuilder sb = new StringBuilder(); sb.Append(constructor.Name); sb.Append('('); sb.AppendParameters(constructor.GetParametersNoCopy(), constructor.CallingConvention == CallingConventions.VarArgs); sb.Append(')'); return(sb.ToString()); }
// // Generate the "Signature2" binary serialization string for PropertyInfos // // Because the string is effectively a file format for serialized Reflection objects, it must be exactly correct. If missing // metadata prevents generating the string, this method throws a MissingMetadata exception. // public static string SerializationToString(this PropertyInfo property) { StringBuilder sb = new StringBuilder(); sb.AppendSerializationString(property.PropertyType); sb.Append(' '); sb.Append(property.Name); ParameterInfo[] parameters = property.GetIndexParameters(); if (parameters.Length != 0) { sb.Append(" ["); sb.AppendParameters(parameters, isVarArg: false); sb.Append(']'); } return(sb.ToString()); }
// // Generate the "Signature2" binary serialization string for MethodInfos // // Because the string is effectively a file format for serialized Reflection objects, it must be exactly correct. If missing // metadata prevents generating the string, this method throws a MissingMetadata exception. // public static string SerializationToString(this MethodInfo method) { StringBuilder sb = new StringBuilder(); sb.AppendSerializationString(method.ReturnType); sb.Append(' '); sb.Append(method.Name); if (method.IsGenericMethod) { // Method is a generic method definition or a constructed generic method. Either way, the emit the generic parameters or arguments in brackets. sb.AppendGenericTypeArguments(method.GetGenericArguments()); } sb.Append('('); sb.AppendParameters(method.GetParametersNoCopy(), method.CallingConvention == CallingConventions.VarArgs); sb.Append(')'); return(sb.ToString()); }