/// <summary>
 ///     The add handler.
 /// </summary>
 /// <param name="topic">
 ///     The topic.
 /// </param>
 /// <param name="handler">
 ///     The handler.
 /// </param>
 public void AddEventHandler(string topic, Delegate handler, ErrorTracer errorTracer)
 {
     lock (this)
     {
         EventAction(topic, ev => ev.Addhandler(handler, errorTracer), errorTracer);
     }
 }
        /// <summary>The create.</summary>
        /// <returns>
        ///     The <see cref="object" />.
        /// </returns>
        /// <exception cref="InvalidOperationException"></exception>
        public object Create(ErrorTracer errorTracer)
        {
            try
            {
                errorTracer.Phase = "Injecting List for " + target;

                Type closed = InjectorBaseConstants.List.MakeGenericType(target.GenericTypeArguments[0]);
                if (target.IsAssignableFrom(closed))
                {
                    MethodInfo info = closed.GetMethod("Add");

                   var args = resolvers.Select(resolver => resolver.Create(errorTracer)).TakeWhile(vtemp => !errorTracer.Exceptional).ToList();

                    if (errorTracer.Exceptional) return null;

                    object temp = Activator.CreateInstance(closed);

                    foreach (object o in args) info.Invoke(temp, o);

                    return temp;
                }

                errorTracer.Exceptional = true;
                errorTracer.Exception = new InvalidOperationException(target + " is Not Compatible");

                return null;
            }
            catch (Exception e)
            {
                errorTracer.Exceptional = true;
                errorTracer.Exception = e;
                return null;
            }
        }
        public object Create(ErrorTracer errorTracer)
        {
            errorTracer.Phase = "Injecting Array for " + _target;

            try
            {
                Array arr = Array.CreateInstance(_target, _resolvers.Length);

                int index = 0;

                foreach (IResolver resolver in _resolvers)
                {
                    object val = resolver.Create(errorTracer);

                    if (errorTracer.Exceptional) return arr;

                    arr.SetValue(val, index);
                    index++;
                }

                return arr;
            }
            catch (Exception e)
            {
                errorTracer.Exceptional = true;
                errorTracer.Exception = e;
                return null;
            }
        }
        public override void Inject(object target, IContainer container, ImportMetadata metadata, IImportInterceptor interceptor, ErrorTracer errorTracer, BuildParameter[] parameters)
        {
            Contract.Requires<ArgumentNullException>(target != null, "target");
            Contract.Requires<ArgumentNullException>(container != null, "container");
            Contract.Requires<ArgumentNullException>(metadata != null, "metadata");
            Contract.Requires<ArgumentNullException>(errorTracer != null, "errorTracer");

            throw new NotImplementedException();
        }
        public override void Inject(object target, IContainer container, ImportMetadata metadata, IImportInterceptor interceptor, ErrorTracer errorTracer, BuildParameter[] parameters)
        {
            errorTracer.Phase = "EventManager Inject " + metadata.ContractName;

            try
            {
                var eventInfo = _member as EventInfo;
                if (eventInfo != null) _manager.AddPublisher(_metadata.ContractName, eventInfo, target, errorTracer);

                var method = _member as MethodInfo;
                if (method != null) _manager.AddEventHandler(_metadata.ContractName, method, target, errorTracer);
            }
            catch (Exception e)
            {
                errorTracer.Exceptional = true;
                errorTracer.Exception = e;
            }
        }
        public DefaultBuildContext(IExport targetExport, BuildMode mode, IContainer container, string contractName, 
            ErrorTracer errorTracer, BuildParameter[] parameters, IResolverExtension[] resolverExtensions)
        {
            Contract.Requires<ArgumentNullException>(targetExport != null, "targetExport");
            Contract.Requires<ArgumentNullException>(container != null, "container");
            Contract.Requires<ArgumentNullException>(errorTracer != null, "errorTracer");

            Metadata = targetExport.GetNamedExportMetadata(contractName);
            errorTracer.Export = Metadata.ToString();
            ExportType = targetExport.ImplementType;
            Target = null;
            BuildCompled = false;
            Policys = new PolicyList();
            Mode = mode;
            Container = container;
            ErrorTracer = errorTracer;
            Parameters = parameters;
            ResolverExtensions = resolverExtensions;
        }
 private void BuildUp(BuildObject build, ErrorTracer errorTracer, BuildParameter[] buildParameters)
 {
     lock (build.Export)
     {
         var context = new DefaultBuildContext(build, container, errorTracer, buildParameters);
         build.Instance = context.Target;
         Pipeline.Build(context);
     }
 }
            /// <summary>
            ///     The addhandler.
            /// </summary>
            /// <param name="dDelegate">
            ///     The d delegate.
            /// </param>
            /// <param name="target">
            ///     The target.
            /// </param>
            public void Addhandler(MethodInfo dDelegate, object target, ErrorTracer errorTracer)
            {
                Contract.Requires<ArgumentNullException>(dDelegate != null, "dDelegate");
                Contract.Requires<ArgumentNullException>(target != null, "target");

                errorTracer.Phase = "Adding Handler " + topic;
                _handler.Add(new HandlerEntry(dDelegate, target));
            }
Пример #9
0
 public Page_DAL(Page_Property objPage_Property)
 {
     objPageProperty = objPage_Property;
     objErrorTrace   = new ErrorTracer();
 }
        /// <summary>
        ///     The build up.
        /// </summary>
        /// <param name="toBuild"></param>
        /// <param name="export">
        ///     The export.
        /// </param>
        /// <param name="errorTracer"></param>
        /// <returns>
        ///     The <see cref="object" />.
        /// </returns>
        public object BuildUp(object toBuild, ErrorTracer errorTracer, BuildParameter[] buildParameters)
        {
            Contract.Requires<ArgumentNullException>(errorTracer != null, "errorTracer");
            Contract.Requires<ArgumentNullException>(toBuild != null, "export");

            lock (toBuild)
            {
                try
                {
                    errorTracer.Phase = "Begin Building Up";
                    var context = new DefaultBuildContext(
                        _factory.CreateAnonymosWithTarget(toBuild.GetType(), toBuild),
                        BuildMode.BuildUpObject,
                        container,
                        toBuild.GetType().Name, errorTracer,
                        buildParameters, _componentRegistry.GetAll<IResolverExtension>().ToArray());
                    Pipeline.Build(context);
                    Contract.Assume(context.Target != null);
                    return context.Target;
                }
                catch (Exception e)
                {
                    errorTracer.Exceptional = true;
                    errorTracer.Exception = e;
                    return null;
                }
            }
        }
Пример #11
0
 public Product_Form_DAL(Product_Form_Property objProduct_FormProperty)
 {
     objProductFormProperty = objProduct_FormProperty;
     objErrorTrace          = new ErrorTracer();
 }
Пример #12
0
 public Capability_DAL(Capability_Property objCapability_sProperty)
 {
     objCapabilityProperty = objCapability_sProperty;
     objErrorTrace         = new ErrorTracer();
 }
Пример #13
0
 public Role_Capability_DAL(Role_Capability_Property objRoleCapability_Property)
 {
     objRoleCapabilityProperty = objRoleCapability_Property;
     objErrorTrace             = new ErrorTracer();
 }
Пример #14
0
 public Sales_Category_DAL(Sales_Category_Property Sales_Category_Property)
 {
     ObjSalesCategoryProperty = Sales_Category_Property;
     objErrorTrace            = new ErrorTracer();
 }
 /// <summary>
 ///     The add publisher.
 /// </summary>
 /// <param name="topic">
 ///     The topic.
 /// </param>
 /// <param name="eventInfo">
 ///     The event info.
 /// </param>
 /// <param name="publisher">
 ///     The publisher.
 /// </param>
 public void AddPublisher(string topic, EventInfo eventInfo, object publisher, ErrorTracer errorTracer)
 {
     lock (this) EventAction(topic, ev => ev.AddPublisher(eventInfo, publisher, errorTracer), errorTracer);
 }
        /// <summary>
        ///     The add publisher.
        /// </summary>
        /// <param name="topic">
        ///     The topic.
        /// </param>
        /// <param name="eventInfo">
        ///     The event info.
        /// </param>
        /// <param name="publisher">
        ///     The publisher.
        /// </param>
        /// <exception cref="NotImplementedException">
        /// </exception>
        public void AddPublisher(string topic, EventInfo eventInfo, object publisher, ErrorTracer errorTracer)
        {
            Contract.Requires<ArgumentNullException>(topic != null, "topic");
            Contract.Requires<ArgumentNullException>(eventInfo != null, "eventInfo");
            Contract.Requires<ArgumentNullException>(publisher != null, "publisher");
            Contract.Requires<ArgumentNullException>(errorTracer != null, "errorTracer");

            throw new NotImplementedException();
        }
 /// <summary>
 ///     The add handler.
 /// </summary>
 /// <param name="topic">
 ///     The topic.
 /// </param>
 /// <param name="handler">
 ///     The handler.
 /// </param>
 /// <param name="target">
 ///     The target.
 /// </param>
 public void AddEventHandler(string topic, MethodInfo handler, object target, ErrorTracer errorTracer)
 {
     EventAction(topic, entry => entry.Addhandler(handler, target, errorTracer), errorTracer);
 }
        /// <summary>
        ///     The event action.
        /// </summary>
        /// <param name="topic">
        ///     The topic.
        /// </param>
        /// <param name="entryAction">
        ///     The entry action.
        /// </param>
        private void EventAction(string topic, Action<EventEntry> entryAction, ErrorTracer errorTracer)
        {
            Contract.Requires(_entrys != null);
            Contract.Requires<ArgumentNullException>(topic != null, "topic");
            Contract.Requires<ArgumentNullException>(entryAction != null, "entryAction");

            errorTracer.Phase = "Resolve Topic " + topic;

            EventEntry entry = _entrys.FirstOrDefault(ent => ent.Topic == topic);
            bool add = false;
            if (entry == null)
            {
                add = true;
                entry = new EventEntry(topic);
            }

            entryAction(entry);

            if (add) _entrys.Add(entry);
        }
            /// <summary>
            ///     The add publisher.
            /// </summary>
            /// <param name="info">
            ///     The info.
            /// </param>
            /// <param name="publisher">
            ///     The publisher.
            /// </param>
            public void AddPublisher(EventInfo info, object publisher, ErrorTracer errorTracer)
            {
                Contract.Requires<ArgumentNullException>(info != null, "info");
                Contract.Requires<ArgumentNullException>(publisher != null, "publisher");

                errorTracer.Phase = "Adding Publisher " + topic;
                info.AddEventHandler(publisher, Delegate.CreateDelegate(info.EventHandlerType, this, Handlermethod));
                _publisher.Add(publisher);
            }
Пример #20
0
 public Department_DAL(Department_Setup_Property ObjDepartmentSetup_Property)
 {
     ObjDepartmentProperty = ObjDepartmentSetup_Property;
     objErrorTrace         = new ErrorTracer();
 }
Пример #21
0
 public User_Role_DAL(User_Role_Property objUserRole_Property)
 {
     objUserRoleProperty = objUserRole_Property;
     objErrorTrace       = new ErrorTracer();
 }
        /// <summary>
        ///     The add event handler.
        /// </summary>
        /// <param name="topic">
        ///     The topic.
        /// </param>
        /// <param name="handler">
        ///     The handler.
        /// </param>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <exception cref="NotImplementedException">
        /// </exception>
        public void AddEventHandler(string topic, MethodInfo handler, object target, ErrorTracer errorTracer)
        {
            Contract.Requires<ArgumentNullException>(topic != null, "topic");
            Contract.Requires<ArgumentNullException>(handler != null, "handler");
            Contract.Requires<ArgumentNullException>(target != null, "target");
            Contract.Requires<ArgumentNullException>(errorTracer != null, "errorTracer");

            throw new NotImplementedException();
        }
Пример #23
0
 public Supplier_DAL(Suppliers_Property Objsupplier_Property)
 {
     ObjsupplierProperty = Objsupplier_Property;
     objErrorTrace       = new ErrorTracer();
 }
            public object BuildUp([CanBeNull] BuildParameter[] parameters, [CanBeNull] ErrorTracer error)
            {
                if (error == null)
                    error = new ErrorTracer();

                var temp = _container.BuildUp(_buildMetadata, error, parameters);
                if (error.Exceptional) throw new BuildUpException(error);

                var effectiveType = temp.GetType();
                var extension = _extensions.FirstOrDefault(e => e.TargetType == effectiveType);
                if (extension != null)
                    temp = extension.Progress(_buildMetadata, temp);

                bool flag = _interceptor == null || _interceptor(ref temp);

                return !flag ? null : temp;
            }
Пример #25
0
 public Sales_Type_DAL(Sales_Type_Property ObjSalesType_Property)
 {
     ObjSalesTypeProperty = ObjSalesType_Property;
     objErrorTrace        = new ErrorTracer();
 }
        /// <summary>
        ///     The add event handler.
        /// </summary>
        /// <param name="topic">
        ///     The topic.
        /// </param>
        /// <param name="handler">
        ///     The handler.
        /// </param>
        /// <exception cref="NotImplementedException">
        /// </exception>
        public void AddEventHandler(string topic, Delegate handler, ErrorTracer errorTracer)
        {
            Contract.Requires<ArgumentNullException>(topic != null, "topic");
            Contract.Requires<ArgumentNullException>(handler != null, "handler");
            Contract.Requires<ArgumentNullException>(errorTracer != null, "errorTracer");

            throw new NotImplementedException();
        }
Пример #27
0
 /// <summary>
 /// Exception saving
 /// </summary>       
 /// <summary>
 /// Adds logger to list of errors saving handlers
 /// </summary>
 /// <param name="logger">delegate of form: void ErrorTracer(string errorMessage); </param>
 public void AddErrorLogger(ErrorTracer logger)
 {
     Configuration.AddErrorLogger(logger);
 }
Пример #28
0
 public Role_Setup_DAL(Role_Setup_Property objRole_Property)
 {
     objRoleProperty = objRole_Property;
     objErrorTrace   = new ErrorTracer();
 }
 public StockAdjustmentOutMasterDetail_DAL(StockAdjustmentOutMaster_Property objStockAdjOut_Property)
 {
     objStockAdjOutProperty = objStockAdjOut_Property;
     objErrorTrace          = new ErrorTracer();
 }
        /// <summary>
        ///     The build up.
        /// </summary>
        /// <param name="export">
        ///     The export.
        /// </param>
        /// <param name="contractName">
        ///     The contract name.
        /// </param>
        /// <param name="tracer"></param>
        /// <param name="buildParameters"></param>
        /// <returns>
        ///     The <see cref="object" />.
        /// </returns>
        public object BuildUp(IExport export, string contractName, ErrorTracer tracer, BuildParameter[] buildParameters)
        {
            Contract.Requires<ArgumentNullException>(export != null, "export");

            lock (export)
            {
                try
                {
                    tracer.Phase = "Begin Building Up";
                    var context = new DefaultBuildContext(export, BuildMode.Resolve, container, contractName,
                        tracer, buildParameters, _componentRegistry.GetAll<IResolverExtension>().ToArray());
                    var buildObject = new BuildObject(export.ImportMetadata, context.Metadata, buildParameters);
                    Pipeline.Build(context);
                    if (tracer.Exceptional) return null;
                    buildObject.Instance = context.Target;
                    if (!export.ExternalInfo.External && !export.ExternalInfo.HandlesLiftime)
                        RebuildManager.AddBuild(buildObject);

                    Contract.Assume(context.Target != null);
                    return context.Target;
                }
                catch (Exception e)
                {
                    tracer.Exceptional = true;
                    tracer.Exception = e;
                    return null;
                }
            }
        }
Пример #31
0
 public WareHouse_DAL(WareHouse_Property objwarehouseproperty)
 {
     objWarehouse  = objwarehouseproperty;
     objErrorTrace = new ErrorTracer();
 }
        /// <summary>
        ///     The build up.
        /// </summary>
        /// <param name="type">
        ///     The type.
        /// </param>
        /// <param name="constructorArguments">
        ///     The constructor arguments.
        /// </param>
        /// <returns>
        ///     The <see cref="object" />.
        /// </returns>
        internal object BuildUp(Type type, object[] constructorArguments, ErrorTracer errorTracer, BuildParameter[] buildParameters)
        {
            Contract.Requires<ArgumentNullException>(type != null, "type");

            errorTracer.Phase = "Begin Building Up";
            try
            {
                var context = new DefaultBuildContext(
                    _factory.CreateAnonymos(type, constructorArguments),
                    BuildMode.BuildUpObject,
                    container,
                    type.Name, errorTracer,
                    buildParameters, _componentRegistry.GetAll<IResolverExtension>().ToArray());
                Pipeline.Build(context);
                Contract.Assume(context.Target != null);
                return context.Target;
            }
            catch (Exception e)
            {
                errorTracer.Exceptional = true;
                errorTracer.Exception = e;
                return null;
            }
        }
Пример #33
0
 public Wh_Location_DAL(Wh_Location_Property objWh_Location_Property)
 {
     ObjWhLocationProperty = objWh_Location_Property;
     objErrorTrace         = new ErrorTracer();
 }
        /// <summary>
        ///     The exports changed.
        /// </summary>
        /// <param name="sender">
        ///     The sender.
        /// </param>
        /// <param name="e">
        ///     The e.
        /// </param>
        private void ExportsChanged(object sender, ExportChangedEventArgs e)
        {
            Contract.Requires<ArgumentNullException>(sender != null, "sender");

            IEnumerable<BuildObject> parts = RebuildManager.GetAffectedParts(e.Added, e.Removed);

            var errors = new List<ErrorTracer>();

            foreach (BuildObject buildObject in parts)
            {
                var errorTracer = new ErrorTracer();
                BuildUp(buildObject, errorTracer, buildObject.BuildParameters);

                if(errorTracer.Exceptional)
                    errors.Add(errorTracer);
            }

            if(errors.Count != 0)
                throw new AggregateException(errors.Select(err => new BuildUpException(err)));
        }
            /// <summary>
            ///     The addhandler.
            /// </summary>
            /// <param name="dDelegate">
            ///     The d delegate.
            /// </param>
            public void Addhandler(Delegate dDelegate, ErrorTracer errorTracer)
            {
                Contract.Requires<ArgumentNullException>(dDelegate != null, "dDelegate");

                errorTracer.Phase = "Adding Handler " + topic;
                _handler.Add(new HandlerEntry(dDelegate));
            }
Пример #36
0
 /// <summary>
 /// Removes logger from current list of errors saving handlers
 /// </summary>
 /// <param name="logger">delegate of form: void ErrorTracer(string errorMessage); </param>
 public void RemoveErrorLogger(ErrorTracer logger)
 {
     Configuration.RemoveErrorLogger(logger);
 }
Пример #37
0
 /// <summary>
 /// Adds logger to list of errors saving handlers
 /// </summary>
 /// <param name="logger">delegate of form: void ErrorTracer(string errorMessage); </param>
 public void AddErrorLogger(ErrorTracer logger)
 {
     _errorTracerLogger += logger;
 }
Пример #38
0
 /// <summary>
 /// Removes logger from current list of errors saving handlers
 /// </summary>
 /// <param name="logger">delegate of form: void ErrorTracer(string errorMessage); </param>
 public void RemoveErrorLogger(ErrorTracer logger)
 {
     _errorTracerLogger -= logger;
 }
 public Paking_Unit_Setup_DAL(Paking_Unit_Setup_Property objPacking_UnitProperty)
 {
     objPackingUnitProperty = objPacking_UnitProperty;
     objErrorTrace          = new ErrorTracer();
 }