ResolutionGroupName and multiple effects
Asked Answered
S

1

11

I have created a folder called Effects, which should contain all the effects for my project. It has one effect in it with the following attribution:

[assembly: ResolutionGroupName("Effects")]
[assembly: ExportEffect(typeof(SomeProject.iOS.Effects.SliderEffect), "SliderEffect")]

Now I want to add another effect (as separate file), with the same ResolutionGroupName, but I get

Duplicate 'ResolutionGroupName' attribute

I understand that

Note that this attribute can only be applied once per project.

and

Attribute that identifies a group name, typically a company name or reversed company URL, that provides a scope for effect names.

, but how can you use multiple effects in separate files? All the examples I found are only using one effect ...

Saloma answered 24/10, 2017 at 8:37 Comment(0)
M
23

Note that this attribute can only be applied once per project.

Yes that's correct, you can use it only once, for the rest of the effects you don't have to declare the ResolutionGroupName. The system will resolve the effects based on Unique effects name.

Below sample code should give a clear idea.

The below code has DummyApp as groupname which can't be changed for different effects and ImageEffects which should be unique to get executed.

[assembly: ResolutionGroupName("DummyApp")]
[assembly: ExportEffect(typeof(ImageEffects), "ImageEffects")]
namespace DummyApp.Droid.Effects
{
    public class ImageEffects : PlatformEffect
    {

now for the second Effect you can simply declare and register the export effect attribute.

[assembly: ExportEffect(typeof(FocusEffect), "FocusEffect")]
namespace GrowerApp.Droid.Effects
{
    public class FocusEffect : PlatformEffect
    {

Now the Forms Declaration sample code will be

public class ImageEffects : RoutingEffect
    {
        public ImageEffects() : base("DummyApp.ImageEffects")
        {

        }
    }

    public class FocusEffect : RoutingEffect
    {
        public FocusEffect() : base("DummyApp.FocusEffect")
        {

        }
    }

Hope this helps!

Migrant answered 24/10, 2017 at 10:1 Comment(2)
Still a strange behavior ... The Forms decalaration is only there for the use in XAML?Saloma
Link to the official documentationSaloma

© 2022 - 2024 — McMap. All rights reserved.