UtilExceptions.cs 936 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5. using System.Text;
  6. namespace Ant.SQLite
  7. {
  8. static class UtilExceptions
  9. {
  10. public static NotSupportedException NotSupportedMethod(MethodInfo method)
  11. {
  12. StringBuilder sb = new StringBuilder();
  13. ParameterInfo[] parameters = method.GetParameters();
  14. for (int i = 0; i < parameters.Length; i++)
  15. {
  16. ParameterInfo p = parameters[i];
  17. if (i > 0)
  18. sb.Append(",");
  19. string s = null;
  20. if (p.IsOut)
  21. s = "out ";
  22. sb.AppendFormat("{0}{1} {2}", s, p.ParameterType.Name, p.Name);
  23. }
  24. return new NotSupportedException(string.Format("Does not support method '{0}.{1}({2})'", method.DeclaringType.Name, method.Name, sb.ToString()));
  25. }
  26. }
  27. }