public string GetLocalizedString(LocalizedStringGroups group, uint index) { if (index == 0) { return(string.Empty); } switch (group) { case LocalizedStringGroups.Strings: return(StringLocator.GetString(index)); case LocalizedStringGroups.DLStrings: return(StringLocator.GetDLString(index)); case LocalizedStringGroups.ILStrings: return(StringLocator.GetILString(index)); default: throw new ArgumentException("Illegal localized string group: " + group); } }
public LocalizedStringAttribute(LocalizedStringGroups group) { this.group = group; }
public MemberInfo(MemberAttribute attribute, PropertyInfo property) { this.property = property; fieldNames = attribute.FieldNames; IsLazy = property.GetCustomAttributes(typeof(LazyAttribute), false).Length > 0; IsFakeFloat = property.GetCustomAttributes(typeof(FakeFloatAttribute), false).Length > 0; Initialize = property.GetCustomAttributes(typeof(InitializeAttribute), false).Length > 0; IsRequired = property.GetCustomAttributes(typeof(RequiredAttribute), false).Length > 0; var orderAttribute = (OrderAttribute)property.GetCustomAttributes(typeof(OrderAttribute), false).FirstOrDefault(); if (orderAttribute != null) { Order = orderAttribute.Order; } var localizedStringAttribute = (LocalizedStringAttribute)property.GetCustomAttributes(typeof(LocalizedStringAttribute), false).FirstOrDefault(); if (localizedStringAttribute != null) { localizedStringGroup = localizedStringAttribute.LocalizedStringGroup; } var referenceAttribute = (ReferenceAttribute)property.GetCustomAttributes(typeof(ReferenceAttribute), false).FirstOrDefault(); if (referenceAttribute != null) { IsReference = true; ReferencedFormKinds = referenceAttribute.ReferenceFormKinds; } if (property.PropertyType.IsGenericType && property.PropertyType.GetGenericTypeDefinition() == typeof(List <>)) { fieldType = property.PropertyType.GetGenericArguments()[0]; IsListType = true; addValueToListMethod = typeof(ICollection <>).MakeGenericType(property.PropertyType.GetGenericArguments()).GetMethod("Add"); createListCtor = typeof(List <>).MakeGenericType(property.PropertyType.GetGenericArguments()).GetConstructor(paramlessTypes); } else if (property.PropertyType.IsGenericType && property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>)) { fieldType = property.PropertyType.GetGenericArguments()[0]; IsNullableType = true; } else { fieldType = property.PropertyType; IsListType = false; } IsPrimitiveType = !typeof(Field).IsAssignableFrom(fieldType); // Field is dynamic if any of its field names contains a . IsDynamic = fieldNames.Where(n => n.Contains('.')).Any(); if (IsDynamic) { // Replace . with (.|\n) to cover also new line var pattern = string.Join("|", fieldNames).Replace(".", "(.|\n)"); DynamicArrayRegex = new Regex(pattern); } //Enums treat enums as if the where the underlaying primitive type. if (fieldType.IsEnum) { fieldType = fieldType.GetEnumUnderlyingType(); } }
public MemberInfo(MemberAttribute attribute, PropertyInfo property) { this.property = property; fieldNames = attribute.FieldNames; IsLazy = property.GetCustomAttributes(typeof(LazyAttribute), false).Length > 0; IsFakeFloat = property.GetCustomAttributes(typeof(FakeFloatAttribute), false).Length > 0; Initialize = property.GetCustomAttributes(typeof(InitializeAttribute), false).Length > 0; IsRequired = property.GetCustomAttributes(typeof(RequiredAttribute), false).Length > 0; var orderAttribute = (OrderAttribute)property.GetCustomAttributes(typeof(OrderAttribute), false).FirstOrDefault(); if (orderAttribute != null) { Order = orderAttribute.Order; } var localizedStringAttribute = (LocalizedStringAttribute)property.GetCustomAttributes(typeof(LocalizedStringAttribute), false).FirstOrDefault(); if (localizedStringAttribute != null) { localizedStringGroup = localizedStringAttribute.LocalizedStringGroup; } var referenceAttribute = (ReferenceAttribute)property.GetCustomAttributes(typeof(ReferenceAttribute), false).FirstOrDefault(); if (referenceAttribute != null) { IsReference = true; ReferencedFormKinds = referenceAttribute.ReferenceFormKinds; } if (property.PropertyType.IsGenericType && property.PropertyType.GetGenericTypeDefinition() == typeof(List<>)) { fieldType = property.PropertyType.GetGenericArguments()[0]; IsListType = true; addValueToListMethod = typeof(ICollection<>).MakeGenericType(property.PropertyType.GetGenericArguments()).GetMethod("Add"); createListCtor = typeof(List<>).MakeGenericType(property.PropertyType.GetGenericArguments()).GetConstructor(paramlessTypes); } else if (property.PropertyType.IsGenericType && property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>)) { fieldType = property.PropertyType.GetGenericArguments()[0]; IsNullableType = true; } else { fieldType = property.PropertyType; IsListType = false; } IsPrimitiveType = !typeof(Field).IsAssignableFrom(fieldType); // Field is dynamic if any of its field names contains a . IsDynamic = fieldNames.Where(n => n.Contains('.')).Any(); if (IsDynamic) { // Replace . with (.|\n) to cover also new line var pattern = string.Join("|", fieldNames).Replace(".", "(.|\n)"); DynamicArrayRegex = new Regex(pattern); } //Enums treat enums as if the where the underlaying primitive type. if (fieldType.IsEnum) { fieldType = fieldType.GetEnumUnderlyingType(); } }