protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, XConstructorInfoAuthorizationRequirement requirement) { bool success = false; if (context.User != null && context.Resource is AuthorizationFilterContext authContext && authContext.ModelState.IsValid) { XType xtype = _XTypeModel.XFromRoute(authContext.RouteData, x); if (xtype != null) { _XThisCache xthis = _XThisModel.XAuthenticate(context.User, cache, authContext.HttpContext.Session); if (xthis != null) { success = _XThisModel.XAuthorize(xthis.XThis.XGetType(), xtype); if (success == false) { List <XType> xtypes = _XTypeModel.XFromQuery(authContext.HttpContext.Request.Query, x); XConstructorInfo xconstructor = xtype.XGetConstructor(xtypes.ToArray()); if (xconstructor != null) { success = _XThisModel.XAuthorize(xthis.XThis.XGetType(), xconstructor); } } } } } if (success) { context.Succeed(requirement); } return(Task.CompletedTask); }
public static bool XAuthorize(XType xthis, XConstructorInfo xconstructor) { bool success = false; bool isCustom = false; success = _XModel.XCheckXTypeAttribute(xthis, xconstructor.XGetCustomAttributes(), out isCustom); if (isCustom == false) { success = true; } return(success); }
public async Task <IViewComponentResult> InvokeAsync(XConstructorInfo xconstructor) { _XConstructorInfoModel xmodel = new _XConstructorInfoModel(); xmodel.XParameters = xconstructor.XGetParameters(); Dictionary <string, char> accessKeyMap = null; List <char> accessKeys = null; _XMethodInfoModel.XToAccessKeyMap(xmodel.XParameters, out accessKeyMap, out accessKeys); xmodel.XAccessKeys = accessKeys; return(View(xmodel)); }
public static string XToKey(XType xtype, XConstructorInfo xconstructor, XParameterInfo xparam) { return(xtype.XFullName + "/" + xtype.XName + "/" + xparam.XName); }
public static string XToHref(XType xtype, XConstructorInfo ctor) { return(_XTypeModel.XToHref(xtype) + "/" + XConst.XNEW); }
private void Application_Startup(object sender, StartupEventArgs e) { X = new XInternal(); X.XAssembly = XAssemblyInternal.XNew; List <string> argNames = new List <string>(); List <string> argValues = new List <string>(); for (int i = 0; i < e.Args.Length; i++) { string arg = e.Args[i]; if (arg.StartsWith("-")) { int index = arg.IndexOf("="); if (index > 0) { string name = arg.Substring(1, index - 1); string value = arg.Substring(index + 1); argNames.Add(name); argValues.Add(value); } } } string assembly = FindResource("Assembly").ToString(); string type = string.Format("{0}.{0},{0}", assembly); XType = X.XGetType(type); XTypeConverter = new XObjectConverterInternal(X); XConstructorInfo xconstructor = null; List <XObject> xparams = null; foreach (XConstructorInfo xctor in XType.XGetConstructors()) { bool match = true; List <XObject> xvalues = new List <XObject>(); IEnumerator <string> name = argNames.GetEnumerator(); IEnumerator <string> value = argValues.GetEnumerator(); List <XParameterInfo> xparmeters = new List <XParameterInfo>(xctor.XGetParameters()); IEnumerator <XParameterInfo> xparam = xparmeters.GetEnumerator(); while (name.MoveNext() && value.MoveNext() && xparam.MoveNext()) { match = false; if (name.Current == xparam.Current.XName) { XType xparamType = xparam.Current.XParameterType; if (XTypeConverter.XCanConvertTo(xparamType)) { XObject xvalue = XTypeConverter.XConvertTo(value, xparamType); if (xvalue != null) { xvalues.Add(xvalue); match = true; } } } if (match == false) { break; } } if (match) { xconstructor = xctor; xparams = xvalues; break; } } XObject = null; if (xconstructor != null) { XObject = xconstructor.XInvoke(xparams.ToArray()); } }