public GetQualifierValue ( [ qualifierName ) : string | ||
qualifierName | [ | |
Результат | string |
public static string?Convert(ResourceCandidate resourceCandidate, string defaultLanguage) { try { ValidatePlatform(resourceCandidate); var language = GetLanguage(resourceCandidate.GetQualifierValue("language"), defaultLanguage); var dpi = GetDpi(resourceCandidate.GetQualifierValue("scale")); var fileName = AndroidResourceNameEncoder.Encode(Path.GetFileNameWithoutExtension(resourceCandidate.LogicalPath)) + Path.GetExtension(resourceCandidate.LogicalPath); return(Path.Combine($"drawable{language}{dpi}", fileName)); } catch (Exception ex) { ex.Log().Info($"Couldn't convert {resourceCandidate.ValueAsString} to an Android resource path.", ex); return(null); } }
private static void ValidatePlatform(ResourceCandidate resourceCandidate) { var custom = resourceCandidate.GetQualifierValue("custom"); if (custom != null && custom != "ios") { throw new NotSupportedException($"Custom qualifier of value {custom} is not supported on iOS."); } }
public static string?Convert(ResourceCandidate resourceCandidate, string defaultLanguage) { try { ValidatePlatform(resourceCandidate); var language = GetLanguage(resourceCandidate.GetQualifierValue("language"), defaultLanguage); var dpi = GetDpi(resourceCandidate.GetQualifierValue("scale")); var theme = GetTheme(resourceCandidate.GetQualifierValue("theme")); var fileName = AndroidResourceNameEncoder.EncodeDrawablePath(resourceCandidate.LogicalPath); return(Path.Combine($"drawable{language}{theme}{dpi}", fileName)); } #if HAS_UNO catch (Exception ex) { ex.Log().Info($"Couldn't convert {resourceCandidate.ValueAsString} to an Android resource path.", ex); #else catch (Exception) { #endif return(null); } }
private static string GetLanguage(ResourceCandidate resourceCandidate) { var language = resourceCandidate.GetQualifierValue("language"); if (language == null) { return(""); } if (language.Contains("-")) { language = language.Replace("-", "_"); } return($"{language}.lproj"); }
private static string GetScale(ResourceCandidate resourceCandidate) { var scale = resourceCandidate.GetQualifierValue("scale"); switch (scale) { case null: case "100": return(""); case "200": return("@2x"); case "300": return("@3x"); default: throw new NotSupportedException($"Scale qualifier of value {scale} is not supported on iOS."); } }