Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot resolve symbol SetAllProperties in StructureMap.Net4

In my project i am using structureMap.Net4 (version 3.0.3) with StructureMap (3.0.3) . I configured the Ioc with following code for setter injection

public static IContainer Initialize()
        {

            ObjectFactory.Initialize(x =>
                        {





                            x.For<ICacheManager>().Use<MemmoryCacheManager>();
                            x.SetAllProperties(y => y.OfType<ICacheManager>);
                            //x.ForConcreteType<AuthorizationManager>()
                            //    .Configure.Setter<ICacheManager>(y => y.CacheManager)
                            //    .IsTheDefault();
                        });
            return ObjectFactory.Container;
        }

But i am getting an error cannot resolve symbol SetAllProperties . i already referenced this following namespace

using StructureMap;
using StructureMap.Graph;

Why i am getting this error ? how i can solve this ? or should i reference any other namespace

like image 210
Binson Eldhose Avatar asked Mar 20 '26 09:03

Binson Eldhose


1 Answers

StructureMap 3 has changed where Setter Injection is configured. It is now configured using a PolicyExpression, it can be accessed at ConfigurationExpression.Policies. I've attached a sample below.

ObjectFactory.Configure(x =>
{
    x.Policies.SetAllProperties(y => y.OfType<ICacheManager>());
});
like image 106
Xenolightning Avatar answered Mar 23 '26 02:03

Xenolightning



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!