3

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

Binson Eldhose
  • 993
  • 3
  • 14
  • 35

2 Answers2

11

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>());
});
Xenolightning
  • 4,140
  • 1
  • 26
  • 34
0

try putting braces

x.SetAllProperties(y => y.OfType<ICacheManager>());
chandresh patel
  • 309
  • 1
  • 10