internal DxLocalizer(ILocalizator owner, XtraLocalizer <T> sysLocalizer) { LocalizerType = typeof(T).FullName; _Owner = owner; _SysLocalizer = sysLocalizer; _ScanThisLocalization(); }
private XtraLocalizer <T> GetLocalizer <T>(XtraLocalizer <T> current, Func <XtraLocalizer <T>, XtraLocalizer <T> > creator) where T : struct { if (current == null) { return(creator(null)); } if (current is DxLocalizer <T> ) { return(current); } return(creator(current)); }
/// <summary> /// 无意义 备用未删除临时函数 /// </summary> private void InitializeTempLocalizer() { XtraLocalizer <DiagramControlStringId> diagramControlLocalizer = DiagramControlLocalizer.Active; for (int i = 0; i <= 588; i++) { string enumName = Enum.GetName(typeof(DiagramControlStringId), i); List <MyParameter> myParameters = new List <MyParameter>(); myParameters.Add("@Globalization_Cultural", DbType.Int32, Provider.SysUser.User_Cultural, null); myParameters.Add("@Globalization_Partition", DbType.String, "Devexpress", null); myParameters.Add("@Globalization_Localizer", DbType.String, "MyDiagramControlLocalizer", null); myParameters.Add("@Globalization_Name", DbType.String, enumName, null); myParameters.Add("@Globalization_Nick", DbType.String, diagramControlLocalizer.GetLocalizedString((DiagramControlStringId)i), null); myParameters.Add("@Globalization_StringId", DbType.Int32, i, null); BaseService.Open("SystemGlobalization_Save", myParameters); } }
private void MapDlls(string path) { _MapPath = path; AppDomain.CurrentDomain.AssemblyResolve += _TestAssemblyResolve; string actives = ""; string line; var files = System.IO.Directory.GetFiles(path, "*.dll").ToList(); files.Sort(); foreach (var file in files) { bool addAsm = true; var types = _MapTypesIn(file); if (types == null) { // line = " ==> " + file + " LOADING ERROR "; // actives += line + Environment.NewLine; continue; } foreach (var type in types) { bool isClass = (type.IsClass && !type.IsAbstract); if (!isClass) { continue; // Nechci ani struct, ani interface, ani abstract class } var property = type.GetProperty("Active"); if (property == null) { continue; // Musí mít property Active } Type propertyType = property.PropertyType; string propertyName = property.Name; string propertyTypeName = propertyType.Name; if (!propertyTypeName.StartsWith("XtraLocalizer")) { continue; // ... typu odvozeného od XtraLocalizer } // Tohle už mě zajímá: if (addAsm) { line = Environment.NewLine + " // From assembly: " + System.IO.Path.GetFileName(file); actives += line + Environment.NewLine; addAsm = false; } var typeName = type.FullName; var propertyTypeGenericTypes = propertyType.GetGenericArguments(); if (propertyTypeGenericTypes.Length != 1) { line = $"// {typeName}.{propertyName} is type: {propertyTypeName}, it does not have exactly one generic argument."; actives += line + Environment.NewLine; continue; } string genericTypeName = propertyTypeGenericTypes[0].FullName; line = $"{propertyTypeName}<{genericTypeName}> {typeName}.{propertyName};"; string code = $"{typeName}.{propertyName} = GetLocalizer({typeName}.{propertyName}, current => new DxLocalizer<{genericTypeName}>(owner, current));"; actives += code + Environment.NewLine; continue; object target = property.GetValue(null); // Static property System.Reflection.MethodInfo mi = target.GetType().GetMethod("CreateXmlDocument"); object result = mi.Invoke(target, null); XtraLocalizer xtraLocalizer = target as XtraLocalizer; } } AppDomain.CurrentDomain.AssemblyResolve -= _TestAssemblyResolve; }