public static void Initialize(Domain domain) { if (domain == null) { throw new ArgumentNullException("domain"); } if (domain.Extensions.Get <TypeLocalizationMap>() != null) { return; } var map = new TypeLocalizationMap() { Configuration = LocalizationConfiguration.Load() }; foreach (var localizableTypeInfo in domain.Model.Types.Entities) { var type = localizableTypeInfo.UnderlyingType; if (!type.IsOfGenericInterface(typeof(ILocalizable <>))) { continue; } var localizationType = type.GetInterface("ILocalizable`1").GetGenericArguments()[0]; map.Register(type, domain.Model.Types[localizationType]); } domain.Extensions.Set(map); }
private void TryInitialize() { // if there is a context then query is from upgrade handler // so it is right to initialize localization here and allow user to // perform query. // Following initialization in IModule will be skipped if (Upgrade.UpgradeScope.CurrentContext != null) { TypeLocalizationMap.Initialize(Domain); } var map = Domain.Extensions.Get <TypeLocalizationMap>(); if (map != null) { visitor = new LocalizationExpressionVisitor(map); } }
public LocalizationExpressionVisitor(TypeLocalizationMap map) { Map = map; }
/// <summary> /// Called when 'complex' build process is completed. /// </summary> /// <param name="domain">The built domain.</param> public void OnBuilt(Domain domain) { TypeLocalizationMap.Initialize(domain); }