public void SetIsLocalizable(bool isLocalizable) { var attr = (LocalizableAttribute)attributes.FirstOrDefault(a => a is LocalizableAttribute); if (attr != null) { attributes.RemoveAll(a => a is LocalizableAttribute); } attr = new LocalizableAttribute(isLocalizable); attributes.Add(attr); }
private void UpdateResourceManager() { foreach (var cpd in propertyDescriptorList) { IResourceAttribute attr = (PropertyResourceAttribute)cpd.AllAttributes.FirstOrDefault(a => a is PropertyResourceAttribute); if (attr == null) { var ac = GetAttributes(); var al = new AttributeList(ac); attr = (ClassResourceAttribute)al.FirstOrDefault(a => a is ClassResourceAttribute); } if (attr == null) { cpd.ResourceManager = null; continue; } cpd.KeyPrefix = attr.KeyPrefix; var rm = hashRM[attr] as ResourceManager; if (rm != null) { cpd.ResourceManager = rm; continue; } try { if (String.IsNullOrWhiteSpace(attr.AssemblyFullName) == false) { rm = new ResourceManager(attr.BaseName, Assembly.ReflectionOnlyLoad(attr.AssemblyFullName)); } else { rm = new ResourceManager(attr.BaseName, base.GetPropertyOwner(cpd).GetType().Assembly); } } catch (Exception ex) { Console.WriteLine(ex.Message); continue; } hashRM.Add(attr, rm); cpd.ResourceManager = rm; } }