Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="assemblyinfo"></param>
        /// <param name="errinfo"></param>
        /// <returns></returns>
        public bool ValidatePackage(ServicePackageInfo assemblyinfo, out ErrPackageInfo errinfo)
        {
            errinfo = new ErrPackageInfo();
            string infpath   = assemblyinfo.InfAssemblyName;
            string implepath = assemblyinfo.ImpleAssemblyName;

            Assembly infAssembly   = GetAssembly(ConfigUtil.GetBizPluginFullPath(infpath));
            Assembly impleAssembly = GetAssembly(ConfigUtil.GetBizPluginFullPath(implepath));

            if (!ValidateAssembly(errinfo, infAssembly, impleAssembly))
            {
                return(false);
            }

            List <ServiceInfo> errservices = CheckServices(infAssembly, impleAssembly, assemblyinfo);

            foreach (ServiceInfo info in errservices)
            {
                ErrServiceInfo errserviceinfo = new ErrServiceInfo();
                errserviceinfo.ServiceKey = info.Key;
                errinfo.ErrServiceInfoList.Add(errserviceinfo);
            }

            //if (errservices.Count != 0)
            //{
            //Console.WriteLine(errservices.Count);
            //for (int i = 0; i < errservices.Count; i++)
            //{
            //   Console.WriteLine("service: " + errservices[i].ServiceTypeName + " imple:" + errservices[i].ImpleTypeName);
            //}
            //throw new ConfigException("配置文件服务和对应Assembly内服务不符");
            //}
            return(true);
        }
Example #2
0
 private static bool ValidateAssembly(ErrPackageInfo errinfo, Assembly infAssembly, Assembly impleAssembly)
 {
     if (infAssembly == null || impleAssembly == null)
     {
         errinfo.ErrAssemblyInfo.HasAssembly = false;
         return(false);
     }
     object[] infattributes   = infAssembly.GetCustomAttributes(typeof(BizPluginAttribute), true);
     object[] impleattributes = impleAssembly.GetCustomAttributes(typeof(BizPluginAttribute), true);
     if (infattributes.Length == 0 || impleattributes.Length == 0)
     {
         errinfo.ErrAssemblyInfo.AssemblyHasAttribute = false;
         return(false);
     }
     return(true);
 }