Monobjc.ObjectiveCEncoding.GetSelector C# (CSharp) Метод

GetSelector() публичный статический Метод

Gets the selector for the given method.

The selector for a method is build with the following rules: Selector begins with the method name The first parameter if present is appended by its name with the "With" prefix The other parameters if present are appended by their names

Here are some examples of result: Method Corresponding selector public void DoThis() DoThis public void DoThis(int value) DoThisWithValue: public void DoThis(NSString str, int val) DoThisWithStr:val:

public static GetSelector ( MethodBase methodBase ) : String
methodBase System.Reflection.MethodBase The method.
Результат String
		public static String GetSelector (MethodBase methodBase)
		{
			if (methodBase == null) {
				throw new ArgumentNullException ("methodBase");
			}

			StringBuilder builder = new StringBuilder ();
			ParameterInfo[] parameters = methodBase.GetParameters ();

			// Add name
			builder.Append (methodBase.Name);

			for (int i = 0; i < parameters.Length; i++) {
				String name = parameters [i].Name;

				// If first parameter, use "With" prefix
				if (i == 0) {
					builder.Append (WITH);
					builder.Append (name.Substring (0, 1).ToUpperInvariant ());
					if (name.Length > 1) {
						builder.Append (name.Substring (1));
					}
				} else {
					builder.Append (name);
				}

				builder.Append (COLON);
			}

			return builder.ToString ();
		}