<commit_before>﻿using System;
using Xamarin.Forms;
using System.Reflection;

namespace FFImageLoading.Forms
{
	/// <summary>
	/// Embedded resource image source.
	/// eg. resource://YourProject.Resource.Resource.png
	/// eg. resource://YourProject.Resource.Resource.png?assembly=[FULL_ASSEMBLY_NAME]
	/// </summary>
    [Preserve(AllMembers = true)]
	public class EmbeddedResourceImageSource : ImageSource
    {
        public EmbeddedResourceImageSource(Uri uri)
        {
            var text = uri.OriginalString;

            if (string.IsNullOrWhiteSpace(uri.Query))
            {
                var assemblyName = Application.Current?.GetType()?.GetTypeAssemblyFullName();
                Uri = new Uri(assemblyName == null ? text : $"{text}?assembly={Uri.EscapeUriString(assemblyName)}");
            }
            else if (!uri.Query.Contains("assembly=", StringComparison.OrdinalIgnoreCase))
            {
                var assemblyName = Application.Current?.GetType()?.GetTypeAssemblyFullName();
                Uri = new Uri(assemblyName == null ? text : $"{text}?assembly={Uri.EscapeUriString(assemblyName)}");
            }<commit_msg>Xamarin.Forms EmbeddedResourceImageSource  optimization - cache main assembly name<commit_after>﻿using System;
using Xamarin.Forms;
using System.Reflection;

namespace FFImageLoading.Forms
{
	/// <summary>
	/// Embedded resource image source.
	/// eg. resource://YourProject.Resource.Resource.png
	/// eg. resource://YourProject.Resource.Resource.png?assembly=[FULL_ASSEMBLY_NAME]
	/// </summary>
    [Preserve(AllMembers = true)]
	public class EmbeddedResourceImageSource : ImageSource
    {
        static string _cachedMainAssembly;

        public EmbeddedResourceImageSource(Uri uri)
        {
            var text = uri.OriginalString;

            if (string.IsNullOrWhiteSpace(uri.Query))
            {
                if (_cachedMainAssembly == null)
                    _cachedMainAssembly = Application.Current?.GetType()?.GetTypeAssemblyFullName();

                Uri = new Uri(_cachedMainAssembly == null ? text : $"{text}?assembly={Uri.EscapeUriString(_cachedMainAssembly)}");
            }
            else if (!uri.Query.Contains("assembly=", StringComparison.OrdinalIgnoreCase))
            {
                var assemblyName = Application.Current?.GetType()?.GetTypeAssemblyFullName();
                Uri = new Uri(assemblyName == null ? text : $"{text}?assembly={Uri.EscapeUriString(assemblyName)}");
            }
{'fraction_non_alphanumeric': 0.12098070739549839, 'fraction_numerical': 0.0, 'mean_word_length': 2.8, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3224956', 'n_tokens_mistral': 675, 'n_tokens_neox': 653, 'n_words': 119}