using EnVisage.Code.BLL; using EnVisage.Models; using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Text; using System.Threading.Tasks; namespace EnVisage.Code.Integration { public class IntergrationHelper { private static string HelperClass = "EnVisage.Code.Integration.AccessInf, IntergrationAccessInf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"; public static AccessInf GetIntergrationClass(IntergrationAccessType t, IntegrationConnectionModel model) { if (model == null) { IntegrationManager man = new IntegrationManager(new EnVisageEntities()); model = man.getModel(t); } string AccessStringType = model.AccessClass; if (String.IsNullOrEmpty(AccessStringType)) { return null; } else { System.Type AccessType = System.Type.GetType(AccessStringType); if (AccessType == null) { throw (new NullReferenceException("AccessType"+ AccessStringType + " can not be found")); } System.Type tp = System.Type.GetType(HelperClass); if (!tp.IsAssignableFrom(AccessType)) { throw (new ArgumentException("AccessType("+ AccessStringType + ") does not inherit from "+ HelperClass)); } AccessInf crm = (AccessInf) Activator.CreateInstance(AccessType,model.Url,model.UserId,model.Password); return (crm); } } } }