Question

as I understand IMvxResourceLoader can load resources from platform-specific project's "Assets" or "Resources" folders. If that is true, is there a way/plugin that would load embedded resources from shared Core project? It would be convenient to maintain business logic (or localisation) related resources in one place instead of copying them to ios/win/android projects.

Was it helpful?

Solution

yes it can be done. I have managed to put some assets (audio files) in core and used in main. Finally I returned it as Byte array; I am sure it can be played around to bind more.

Here is my code which I used

    public byte[] GetApplicationResource(ApplicationResourceName resourceName)
    {
        string resourcePath;
        switch (resourceName)
        {
            case ApplicationResourceName.AudioChord:
                resourcePath = AppConstants.ResourceNameAudioChord;
                break;

            default:
                throw new ArgumentOutOfRangeException("resourceName");
        }

        var assembly = Assembly.GetExecutingAssembly();
        using (var stream = assembly.GetManifestResourceStream(resourcePath))
        {
            // sanity check
            if (stream != null)
            {
                using (var memoryStream = new MemoryStream())
                {
                    stream.CopyTo(memoryStream);
                    return memoryStream.ToArray();
                }
            }
        }

        return null;
    }

Hope that helps

OTHER TIPS

I don't think you can get all references from the core project ( unfortunatelly =/ ). There was another post similar to this one that you might find usefull: How to bind imageSource to ImageView in MvvmCross

Hope it helps =)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top