public void Add(IParameterBinding p) { if (_bindings.Contains(p)) return; _bindings.Add(p); }
public bool Contains(IParameterBinding pb) { foreach(IParameterBinding b in _bindings) { if (b.Parameter.Value.ToLower() == pb.Parameter.Value.ToLower() && b.Binding.Value.ToLower() == pb.Binding.Value.ToLower()) { return true; } } return false; }
public void Remove(IParameterBinding p) { if (_bindings.Contains(p)) { _bindings.Remove(p); } }
void IActionBinding.Initialize(MethodInfo method) { if (Bindings != null) return; _returnType = method.ReturnType; ParameterInfo[] parameters = method.GetParameters(); if (parameters.Length == 0) { Initialize(method); return; } Bindings = new ParamBindings[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { ParameterInfo p = parameters[i]; IParameterBinding[] bindings; IBindingConstraint[] constraints; object[] atts = p.GetCustomAttributes(typeof(IParameterBinding), true); if (atts.Length > 0) { bindings = new IParameterBinding[atts.Length]; for (int a = 0; a < atts.Length; a++) { IParameterBinding b = (IParameterBinding)atts[a]; if (b is DefaultAttribute) { b = ContextAttribute.IsContextType(p.ParameterType.IsByRef ? p.ParameterType.GetElementType() : p.ParameterType) ? new ContextAttribute() : (IParameterBinding)Activator.CreateInstance(DefaultParameterBinderType); } b.Initialize(p); bindings[a] = b; } } else { IParameterBinding b = ContextAttribute.IsContextType(p.ParameterType.IsByRef ? p.ParameterType.GetElementType() : p.ParameterType) ? new ContextAttribute() : (IParameterBinding)Activator.CreateInstance(DefaultParameterBinderType); b.Initialize(p); bindings = new IParameterBinding[] { b }; } atts = p.GetCustomAttributes(typeof(IBindingConstraint), true); if (atts.Length > 0) { constraints = new IBindingConstraint[atts.Length]; for (int a = 0; a < atts.Length; a++) { IBindingConstraint c = (IBindingConstraint)atts[a]; c.Initialize(p); constraints[a] = c; } } else { constraints = null; } Bindings[i] = new ParamBindings { Bindings = bindings, Constraints = constraints, IsIn = !p.IsOut, IsOut = p.ParameterType.IsByRef }; } Initialize(method); }