Ejemplo n.º 1
0
        public static ICarrierService CreateCarrierService(PXGraph graph, CarrierPlugin plugin)
        {
            ICarrierService service = null;

            if (!string.IsNullOrEmpty(plugin.PluginTypeName))
            {
                try
                {
                    Type carrierType = PXBuildManager.GetType(plugin.PluginTypeName, true);
                    service = (ICarrierService)Activator.CreateInstance(carrierType);

                    PXSelectBase <CarrierPluginDetail> select    = new PXSelect <CarrierPluginDetail, Where <CarrierPluginDetail.carrierPluginID, Equal <Required <CarrierPluginDetail.carrierPluginID> > > >(graph);
                    PXResultset <CarrierPluginDetail>  resultset = select.Select(plugin.CarrierPluginID);
                    IList <ICarrierDetail>             list      = new List <ICarrierDetail>(resultset.Count);

                    foreach (CarrierPluginDetail item in resultset)
                    {
                        list.Add(item);
                    }

                    service.LoadSettings(list);
                }
                catch (Exception ex)
                {
                    throw new PXException(Messages.FailedToCreateCarrierPlugin, ex.Message);
                }
            }


            return(service);
        }