PropertyValueConverter and IoC: Where do I hook into the Property Value Converter's Resolver?
I've already hooked into the web api and generic mvc controller resolvers, like so:
var resolver = new AutofacWebApiDependencyResolver(Container);
GlobalConfiguration.Configuration.DependencyResolver = resolver;
DependencyResolver.SetResolver(new AutofacDependencyResolver(Container));
but now I would like to hook into the property value converter's resolver. Is there a way to do this? I am reading through the source code but it's a slow slog.
Maybe I should be hijacking routes instead? Here's some reference code of where I use the converter and then the definition:
cshtml
@{
var ppvm = Model.Content.GetPropertyValue<ProductionPageViewModel>("production");
}
and the property value converter:
[PropertyValueType(typeof (ProductionPageViewModel))]
[PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)]
public class ProductionPickerValueConverter : PropertyValueConverterBase
{
private readonly ProductionRepository _prodR;
private readonly PerformanceRepository _profR;
public ProductionPickerValueConverter(ProductionRepository prodR, PerformanceRepository perfR)
{
_prodR = prodR;
_profR = perfR;
//global::Umbraco.Core.PropertyEditors.PropertyEditorResolver.Current.PropertyEditors;
}
public override bool IsConverter(PublishedPropertyType propertyType)
{
return propertyType.PropertyEditorAlias.Equals("Productions.ProductionPicker");
}
public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
{
var sourceStr = source as string;
if (sourceStr == null) return null;
var productionId = 0;
if (!int.TryParse(sourceStr, out productionId)) return null;
if (UmbracoContext.Current == null)
return null;
//using (var scope = LphApplicationEventHandler.Container.BeginLifetimeScope())
//{
//var db = UmbracoContext.Current.Application.DatabaseContext.Database;
//var pr = new ProductionRepository(db);
//var tsr = new TessituraSettingsRepository(db);
//var tscp = new TessituraSoapClientFactory(tsr);
//var perfRepo = new PerformanceRepository(tscp.GetTessituraSoapClient(), db);
var prod = _prodR.GetById(productionId);
var perfs = _profR.GetPerformances(prod.ProductionId);
return new ProductionPageViewModel { Production = prod, Perfs = perfs };
//}
}
}
PropertyValueConverter and IoC: Where do I hook into the Property Value Converter's Resolver?
I've already hooked into the web api and generic mvc controller resolvers, like so:
but now I would like to hook into the property value converter's resolver. Is there a way to do this? I am reading through the source code but it's a slow slog.
Maybe I should be hijacking routes instead? Here's some reference code of where I use the converter and then the definition:
cshtml
and the property value converter:
is working on a reply...