public bool IsAvailable(object context, object entity, bool inFeedContext) { if (Binding == OperationParameterBindingKind.Always) { return(true); } else if (Binding == OperationParameterBindingKind.Never) { return(true); // TODO: need a way to verify we are NOT being bound... although I think this is impossible. } else if (inFeedContext && SkipAvailabilityCheckForFeeds) { return(true); } else { return((bool)AvailabilityCheckMethod.Invoke(context, new object[] { entity })); } }
public ActionInfo(MethodInfo actionMethod, OperationParameterBindingKind bindable, string availabilityMethodName) { ActionMethod = actionMethod; Binding = bindable; if ((Binding == OperationParameterBindingKind.Sometimes)) { AvailabilityCheckMethod = GetAvailabilityMethod(availabilityMethodName); if (AvailabilityCheckMethod.GetCustomAttributes(typeof(SkipCheckForFeeds), true).Length != 0) { SkipAvailabilityCheckForFeeds = true; } } else { if (availabilityMethodName != null) { throw new Exception("Unexpected availabilityMethodName provided."); } } }