protected static string XToKey(XPropertyInfo xproperty) { string key = string.Format("{0}.{1}", xproperty.XDeclaringType.XFullName, xproperty.XName); key = key.Replace('.', '_'); return(key); }
static AspNetJsonExecutor() { var xTypeInfo = XTypeInfo.Create <TJsonResult>( XBindingFlags.Public | XBindingFlags.Instance | XBindingFlags.Property); valueProperty = xTypeInfo.GetProperty("Value") ?? xTypeInfo.GetProperty("Data") ?? throw new NotSupportedException("Value"); settingsProperty = xTypeInfo.GetProperty("SerializerSettings") ?? throw new NotSupportedException("SerializerSettings"); statusProperty = xTypeInfo.GetProperty("StatusCode") ?? throw new NotSupportedException("StatusCode"); contentTypeProperty = xTypeInfo.GetProperty("ContentType") ?? throw new NotSupportedException("ContentType"); }
public static string XToString(XPropertyInfo xprop, IStringLocalizer xstring) { if (xstring != null) { string key = XToKey(xprop); string value = xstring[key]; if (key != value) { return(value); } } return(XToString(xprop.XName, xstring)); }
public static string XToTitle(X x, XPropertyInfo xproperty, IStringLocalizer xstring) { string key = XToKey(xproperty); key += "_string"; string value = xstring[key]; if (key == value) { XType _string = x.XTypeOf(typeof(_XString)); XObject[] xattrs = xproperty.XGetCustomAttributes(_string, true); if (XToTitle(xattrs, out value) == false) { value = ""; } } return(value); }
public static Dictionary <string, string> XToAbout(XAssembly assemly, IStringLocalizer xstring) { Dictionary <string, string> about = new Dictionary <string, string>(); foreach (XAttribute xattr in assemly.XGetCustomAttributes()) { if (xattr.XGetType().XName.StartsWith("Assembly") && xattr.XGetType().XName.EndsWith("Attribute") && xattr.XGetType().XNamespace == "System.Reflection") { string attr = xattr.XGetType().XName; attr = attr.Substring("Assembly".Length); attr = attr.Substring(0, attr.Length - "Attribute".Length); XPropertyInfo xprop = xattr.XGetType().XGetProperty(attr); if (xprop != null && xprop.XIsStatic == false) { string v = _XStringModel.XToString(xprop.XGetValue(xattr), xstring); about[attr] = v; } } } return(about); }
protected async Task <IViewComponentResult> xpropertyInfo(XPropertyInfo xproperty, char accessKey, int tabIndex, _XThisCache xthis) { _XInModel xmodel = new _XInModel(); xmodel.AccessKey = accessKey; xmodel.Class = _XPropertyInfoModel.XToClass(xproperty); xmodel.Name = xproperty.XName; xmodel.TabIndex = tabIndex; xmodel.Text = _XStringModel.XToString(xproperty, xstring); //xmodel.Title = _XStringModel.XToTitle(x, xproperty, xstring); xmodel.XString = xstring; xmodel.XType = xproperty.XPropertyType; bool ximplicit = _XPropertyInfoModel.XIsImplicit(xproperty, x); string view = null; XBuild(xmodel, out view, xthis, ximplicit); if (view != null) { return(View(view, xmodel)); } return(View(xmodel)); }
public _XPropertyInfoModel(_XTypeModel t, XPropertyInfo prop, char key, int index) { XAccessKey = key; XTabIndex = index; }
public static string XToClass(XPropertyInfo xpropertyInfo) { return("property-info"); }
public static bool XIsImplicit(XPropertyInfo xprop, X x) { return(xprop.XGetCustomAttributes(x.XTypeOf(typeof(_XImplicit)), false).Length > 0); }
public string XGetValue(XPropertyInfo xproperty) { XObject value = xproperty.XGetValue(null); return(XConverter.XConvertToString(value)); }
public async Task <IViewComponentResult> InvokeAsync(XType xtype, XObject xobject, XPropertyInfo property, char key, int index) { return(View(new _XPropertyInfoModel(null, property, key, index))); }