/// <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 = NullProfiler.Instance; Initiate(glassContext.DependencyResolver); }
public void Fire_ObjectSaving(StorageContext context, T obj, ref bool cancel) { if (ObjectSaving != null) { var evArgs = new ObjectWithCancelEventArgs <T>(obj); foreach (var @delegate in ObjectSaving.GetInvocationList()) { var ev = (EventHandler <ObjectWithCancelEventArgs <T> >)@delegate; ev(context, evArgs); if (evArgs.Cancel) { cancel = evArgs.Cancel; return; } } } }
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(); }
protected virtual void Dispose(bool disposing) { if (disposing) { if (_configurationResolver != null) { _configurationResolver.Dispose(); } if (_objectConstruction != null) { _objectConstruction.Dispose(); } if (_objectSaving != null) { _objectSaving.Dispose(); } _configurationResolver = null; _objectConstruction = null; _objectSaving = null; } }
/// <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.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(); }
protected virtual void Dispose(bool disposing) { if (disposing) { if (_configurationResolver != null) { _configurationResolver.Dispose(); } if (_objectConstruction != null) { _objectConstruction.Dispose(); } if (_objectSaving != null) { _objectSaving.Dispose(); } _configurationResolver = null; _objectConstruction = null; _objectSaving = null; } }
/// <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); }