示例#1
0
        /// <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);
        }
示例#2
0
            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;
                        }
                    }
                }
            }
示例#3
0
        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();

        }
示例#4
0
        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;
            }
        }
示例#5
0
        /// <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();
        }
示例#6
0
        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);
        }