public override int GetHashCode() { int hashCode = ControllerName.ToUpperInvariant().GetHashCode() ^ ActionName.ToUpperInvariant().GetHashCode(); if (MediaType != null) { hashCode ^= MediaType.GetHashCode(); } if (SampleDirection != null) { hashCode ^= SampleDirection.GetHashCode(); } if (ParameterType != null) { hashCode ^= ParameterType.GetHashCode(); } foreach (string parameterName in ParameterNames) { hashCode ^= parameterName.ToUpperInvariant().GetHashCode(); } return(hashCode); }
public void Validate_Route_String() { var filter = new ValidateUmbracoFormRouteStringAttribute.ValidateUmbracoFormRouteStringFilter(DataProtectionProvider); Assert.Throws<HttpUmbracoFormRouteStringException>(() => filter.ValidateRouteString(null, null, null, null)); const string ControllerName = "Test"; const string ControllerAction = "Index"; const string Area = "MyArea"; var validUfprt = EncryptionHelper.CreateEncryptedRouteString(DataProtectionProvider, ControllerName, ControllerAction, Area); var invalidUfprt = validUfprt + "z"; Assert.Throws<HttpUmbracoFormRouteStringException>(() => filter.ValidateRouteString(invalidUfprt, null, null, null)); Assert.Throws<HttpUmbracoFormRouteStringException>(() => filter.ValidateRouteString(validUfprt, ControllerName, ControllerAction, "doesntMatch")); Assert.Throws<HttpUmbracoFormRouteStringException>(() => filter.ValidateRouteString(validUfprt, ControllerName, ControllerAction, null)); Assert.Throws<HttpUmbracoFormRouteStringException>(() => filter.ValidateRouteString(validUfprt, ControllerName, "doesntMatch", Area)); Assert.Throws<HttpUmbracoFormRouteStringException>(() => filter.ValidateRouteString(validUfprt, ControllerName, null, Area)); Assert.Throws<HttpUmbracoFormRouteStringException>(() => filter.ValidateRouteString(validUfprt, "doesntMatch", ControllerAction, Area)); Assert.Throws<HttpUmbracoFormRouteStringException>(() => filter.ValidateRouteString(validUfprt, null, ControllerAction, Area)); Assert.DoesNotThrow(() => filter.ValidateRouteString(validUfprt, ControllerName, ControllerAction, Area)); Assert.DoesNotThrow(() => filter.ValidateRouteString( validUfprt, ControllerName.ToLowerInvariant(), ControllerAction.ToLowerInvariant(), Area.ToLowerInvariant())); }
public ControllerTutorialScript GetControllerTutorial(ControllerName eName) { return(m_ControllerInfos[(int)eName].Tutorial); }
public BaseControllerBehavior GetControllerBehavior(ControllerName eName) { return(m_ControllerInfos[(int)eName].Behavior); }
public void TriggerHaptics(ControllerName eName, float durationInSeconds) { m_ControllerInfos[(int)eName].TriggerControllerHaptics(durationInSeconds); }
public Vector3 GetControllerPosition(ControllerName eName) { return(m_ControllerInfos[(int)eName].Transform.position); }
public Quaternion GetControllerRotation(ControllerName eName) { return(m_ControllerInfos[(int)eName].Transform.rotation); }
public static ControllerGeometry GetControllerGeometry(ControllerName eName) { return(m_Instance.m_ControllerInfos[(int)eName].Geometry); }
public Transform GetController(ControllerName eName) { return(m_ControllerInfos[(int)eName].Transform); }
/* * /// <summary> * /// check authentication attributes for the class * /// </summary> * protected virtual void MapClassAuth() * { * object[] attributes = GetType().GetCustomAttributes(true); * foreach (object attribute in attributes) * { * if (attribute.GetType() == typeof (AuthenticatorAttribute)) * AddAuthAttribute(ClassMethodName, attribute); * if (attribute.GetType() == typeof (AuthenticationRequiredAttribute)) * AddCheckAuthAttribute(ClassMethodName, attribute); * } * } */ /// <summary> /// This method goes through all methods in the controller and /// adds them to a dictionary. They are later used to invoke /// the correct method depending on the Uri. /// </summary> /// <exception cref="InvalidOperationException">Authentication validator have already been specified.</exception> private void MapMethods() { lock (_methods) { // already mapped. if (_methods.Count > 0) { return; } object[] controllerNameAttrs = GetType().GetCustomAttributes(typeof(ControllerNameAttribute), false); if (controllerNameAttrs.Length > 0) { ControllerName = ((ControllerNameAttribute)controllerNameAttrs[0]).Name; } else { ControllerName = GetType().Name; if (ControllerName.Contains("Controller")) { ControllerName = ControllerName.Replace("Controller", ""); } ControllerName = ControllerName.ToLower(); } MethodInfo[] methods = GetType().GetMethods(BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance); foreach (MethodInfo info in methods) { ParameterInfo[] parameters = info.GetParameters(); // find regular render methods if (parameters.Length == 0 && info.ReturnType == typeof(string)) { string name = info.Name.ToLower(); if (name.Length > 3 && (name.Substring(0, 4) == "get_" || name.Substring(0, 4) == "set_")) { continue; } if (name == "tostring") { continue; } // Add authenticators object[] authAttributes = info.GetCustomAttributes(true); foreach (object attribute in authAttributes) { if (attribute.GetType() == typeof(AuthRequiredAttribute)) { _authMethods.Add(info.Name.ToLower(), ((AuthRequiredAttribute)attribute).Level); } } _methods.Add(info.Name.ToLower(), info); } // find raw handlers object[] attributes = info.GetCustomAttributes(typeof(RawHandlerAttribute), true); if (attributes.Length >= 1 && info.ReturnType == typeof(void) && parameters.Length == 0) { // Add authenticators object[] authAttributes = info.GetCustomAttributes(true); foreach (object attribute in authAttributes) { if (attribute.GetType() == typeof(AuthRequiredAttribute)) { _authMethods.Add(info.Name.ToLower(), ((AuthRequiredAttribute)attribute).Level); } } _binaryMethods.Add(info.Name.ToLower(), info); } } //foreach methods = GetType().GetMethods(BindingFlags.Instance | BindingFlags.NonPublic); foreach (MethodInfo info in methods) { ParameterInfo[] parameters = info.GetParameters(); // find before filters. if (parameters.Length != 0 || info.ReturnType != typeof(bool)) { continue; } object[] authAttributes = info.GetCustomAttributes(true); foreach (object attribute in authAttributes) { if (attribute.GetType() == typeof(AuthenticationValidatorAttribute)) { if (_authValidator != null) { throw new InvalidOperationException("Authentication validator have already been specified."); } _authValidator = info; } else if (attribute.GetType() == typeof(BeforeFilterAttribute)) { BeforeFilterAttribute attr = (BeforeFilterAttribute)attribute; LinkedListNode <MethodInfo> node = new LinkedListNode <MethodInfo>(info); switch (attr.Position) { case FilterPosition.First: _beforeFilters.AddFirst(node); break; case FilterPosition.Last: _beforeFilters.AddLast(node); break; default: if (_lastMiddleFilter == null) { _beforeFilters.AddLast(node); } else { _beforeFilters.AddAfter(_lastMiddleFilter, node); } _lastMiddleFilter = node; break; } } } } // Map index method. MethodInfo mi = GetType().GetMethod("Index", BindingFlags.Public | BindingFlags.Instance); if (mi != null && mi.ReturnType == typeof(string) && mi.GetParameters().Length == 0) { DefaultMethod = "Index"; } } }
public string AsId() { return(ControllerName.Append(ActionName, "-").TextOrEmpty().ToLower()); }
public override int GetHashCode() { return(ActionName.TextOrEmpty().GetHashCode() ^ ControllerName.TextOrEmpty().GetHashCode() ^ AreaName.TextOrEmpty().GetHashCode()); }