public UnityDataContractResolverBehaviorAttribute(Type entityFactoryType) { if (entityFactoryType == null) { throw new ArgumentNullException("entityFactoryType"); } if (!entityFactoryType.GetInterfaces().Any(x => x == typeof(IFactory))) { throw new ArgumentException("entityFactoryType must implement IFactory"); } var container = ServiceLocator.Current; //var container = new UnityContainer(); //container.LoadConfiguration(); var entityFactory = container.GetInstance(entityFactoryType) as IFactory; var knownTypes = entityFactory as IKnownSerializationTypes; _resolver = new ContractResolver(entityFactory, knownTypes); _surrogate = new DataContractSurrogate(entityFactory, knownTypes); }