public override IConfigurationLoader[] GetGlassLoaders(Glass.Mapper.Context context) { var loaders1 = GlassMapperScCustom.GlassLoaders(); var loaders2 = base.GetGlassLoaders(context); return(loaders1.Concat(loaders2).ToArray()); }
public void Setup() { var resolver = DependencyResolver.CreateStandardResolver(); GlassMapperScCustom.CastleConfig(resolver.Container); _context = Context.Create(resolver); _context.Load(GlassMapperScCustom.GlassLoaders()); GlassMapperScCustom.PostLoad(); _context.Load(); }
/// <summary> /// Creates a new context and adds it to the Contexts dictionary. /// </summary> /// <param name="resolver">The resolver.</param> /// <param name="contextName">The context name, used as the key in the Contexts dictionary.</param> /// <param name="isDefault">Indicates if this is the default context. If it is the context is assigned to the Default static property.</param> /// <returns>Context.</returns> /// <exception cref="System.NullReferenceException">No dependency resolver set.</exception> public static Context Create(IDependencyResolver resolver, string contextName, bool isDefault = false) { if (resolver == null) throw new NullReferenceException("No dependency resolver set."); var context = new Context(); context.DependencyResolver = resolver; Contexts[contextName] = context; if (isDefault) Default = context; return context; }
public static void LoadConfigurationMaps(IDependencyResolver resolver, GM.Context context) { var dependencyResolver = resolver as DependencyResolver; if (dependencyResolver == null) { return; } if (dependencyResolver.ConfigurationMapFactory is ConfigurationMapConfigFactory) { GlassMapperScCustom.AddMaps(dependencyResolver.ConfigurationMapFactory); } IConfigurationMap configurationMap = new ConfigurationMap(dependencyResolver); SitecoreFluentConfigurationLoader configurationLoader = configurationMap.GetConfigurationLoader <SitecoreFluentConfigurationLoader>(); context.Load(configurationLoader); }
public AbstractService(Context glassContext) { GlassContext = glassContext; if (GlassContext == null) throw new NullReferenceException("Context is null"); var objectConstructionTasks = glassContext.DependencyResolver.ResolveAll<IObjectConstructionTask>(); _objectConstruction = new ObjectConstruction(objectConstructionTasks); var configurationResolverTasks = glassContext.DependencyResolver.ResolveAll<IConfigurationResolverTask>(); _configurationResolver = new ConfigurationResolver(configurationResolverTasks); var objectSavingTasks = glassContext.DependencyResolver.ResolveAll<IObjectSavingTask>(); _objectSaving = new ObjectSaving(objectSavingTasks); Profiler = new NullProfiler(); }
/// <summary> /// Determines whether this instance can handle the specified configuration. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="context">The context.</param> /// <returns><c>true</c> if this instance can handle the specified configuration; otherwise, <c>false</c>.</returns> public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context) { var fieldConfiguration = configuration as SitecoreFieldConfiguration; if (fieldConfiguration == null) { return false; } Type propertyType = fieldConfiguration.PropertyInfo.PropertyType; return propertyType.IsGenericType && (!(propertyType.GetGenericTypeDefinition() != typeof(IDictionary<,>))); }
/// <summary> /// Indicates that the data mapper will mapper to and from the property /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="context">The context.</param> /// <returns><c>true</c> if this instance can handle the specified configuration; otherwise, <c>false</c>.</returns> public abstract bool CanHandle(AbstractPropertyConfiguration configuration, Context context);
/// <summary> /// Initializes a new instance of the <see cref="AbstractService"/> class. /// </summary> /// <param name="glassContext">The glass context.</param> /// <exception cref="System.NullReferenceException">Context is null</exception> protected AbstractService(Context glassContext) { GlassContext = glassContext; if (GlassContext == null) throw new NullReferenceException("Context is null"); var objectConstructionTasks = glassContext.DependencyResolver.ObjectConstructionFactory.GetItems(); _objectConstruction = new ObjectConstruction(objectConstructionTasks); var configurationResolverTasks = glassContext.DependencyResolver.ConfigurationResolverFactory.GetItems(); _configurationResolver = new ConfigurationResolver(configurationResolverTasks); var objectSavingTasks = glassContext.DependencyResolver.ObjectSavingFactory.GetItems(); _objectSaving = new ObjectSaving(objectSavingTasks); Profiler = new NullProfiler(); Initiate(glassContext.DependencyResolver); }