private static void BuildIndex(string pluginPath, DataTable dtExporters, DataTable dtImporters) { if (Directory.Exists(pluginPath)) { string[] files = Directory.GetFiles(pluginPath, "*.dll", SearchOption.AllDirectories); string[] array = files; foreach (string filename in array) { Assembly assembly = Assembly.Load(TransferContainer.LoadPluginFile(filename)); Type[] exportedTypes = assembly.GetExportedTypes(); foreach (Type type in exportedTypes) { if (type.BaseType != null) { if (type.BaseType.Name == "ExportAdapter") { TransferContainer.AddToExportIndex(type, filename, dtExporters); } else if (type.BaseType.Name == "ImportAdapter") { TransferContainer.AddToImportIndex(type, filename, dtImporters); } } } } } }
public static Dictionary <string, string> GetImportAdapters(Target importTo, string sourceName) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); DataRow[] importerList = TransferContainer.Instance().GetImporterList(sourceName, importTo.Name); if ((importerList != null) && (importerList.Length != 0)) { string str = null; int index = 0; do { Version version = new Version(importerList[index]["importToVersion"].ToString()); if (version <= importTo.Version) { str = importerList[index]["importToVersion"].ToString(); } index++; }while (string.IsNullOrEmpty(str) && (index < importerList.Length)); if (string.IsNullOrEmpty(str)) { return(dictionary); } foreach (DataRow row in importerList) { if (row["importToVersion"].ToString().Equals(str)) { dictionary.Add(row["fullName"].ToString(), row["sourceName"].ToString() + row["sourceVersion"].ToString()); } } } return(dictionary); }
private static void BuildIndex(string pluginPath, DataTable dtExporters, DataTable dtImporters) { if (!Directory.Exists(pluginPath)) { return; } string[] files = Directory.GetFiles(pluginPath, "*.dll", SearchOption.AllDirectories); string[] array = files; for (int i = 0; i < array.Length; i++) { string filename = array[i]; Assembly assembly = Assembly.Load(TransferContainer.LoadPluginFile(filename)); Type[] exportedTypes = assembly.GetExportedTypes(); for (int j = 0; j < exportedTypes.Length; j++) { Type type = exportedTypes[j]; if (type.BaseType != null) { if (type.BaseType.Name == "ExportAdapter") { TransferContainer.AddToExportIndex(type, filename, dtExporters); } else if (type.BaseType.Name == "ImportAdapter") { TransferContainer.AddToImportIndex(type, filename, dtImporters); } } } } }
public static Dictionary <string, string> GetImportAdapters(Target importTo, string sourceName) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); DataRow[] importerList = TransferContainer.Instance().GetImporterList(sourceName, importTo.Name); if (importerList != null && importerList.Length != 0) { string value = null; int num = 0; do { Version v = new Version(importerList[num]["importToVersion"].ToString()); if (v <= importTo.Version) { value = importerList[num]["importToVersion"].ToString(); } num++; }while (string.IsNullOrEmpty(value) && num < importerList.Length); if (!string.IsNullOrEmpty(value)) { DataRow[] array = importerList; foreach (DataRow dataRow in array) { string text = dataRow["importToVersion"].ToString(); if (text.Equals(value)) { dictionary.Add(dataRow["fullName"].ToString(), dataRow["sourceName"].ToString() + dataRow["sourceVersion"].ToString()); } } } return(dictionary); } return(dictionary); }
private static Type GetPlugin(string fullName, string tableName) { DataSet dataSet = TransferContainer.TransferCache.Get("Hishop_TransferIndexes") as DataSet; DataRow[] array = dataSet.Tables[tableName].Select("fullName='" + fullName.ToLower() + "'"); if (array.Length != 0 && File.Exists(array[0]["filePath"].ToString())) { Assembly assembly = Assembly.Load(TransferContainer.LoadPluginFile(array[0]["filePath"].ToString())); return(assembly.GetType(fullName, false, true)); } return(null); }
internal static TransferContainer Instance() { if (_instance == null) { lock (LockHelper) { if (_instance == null) { _instance = new TransferContainer(); } } } Init(); return(_instance); }
internal static TransferContainer Instance() { if (TransferContainer._instance == null) { lock (TransferContainer.LockHelper) { if (TransferContainer._instance == null) { TransferContainer._instance = new TransferContainer(); } } } TransferContainer.Init(); return(TransferContainer._instance); }
internal static TransferContainer Instance() { if (_instance == null) { lock (LockHelper) { if (_instance == null) { _instance = new TransferContainer(); } } } Init(); return _instance; }
public static ExportAdapter GetExporter(string fullName, params object[] exportParams) { if (string.IsNullOrEmpty(fullName)) { return(null); } Type exporter = TransferContainer.Instance().GetExporter(fullName); if (exporter == null) { return(null); } if (exportParams != null && exportParams.Length > 0) { return(Activator.CreateInstance(exporter, exportParams) as ExportAdapter); } return(Activator.CreateInstance(exporter) as ExportAdapter); }
private static void Init() { if (TransferContainer.TransferCache.Get("Hishop_TransferIndexes") == null) { string text = HttpContext.Current.Request.MapPath("~/plugins/transfer"); DataSet dataSet = new DataSet(); DataTable dataTable = new DataTable("Exporters"); DataTable dataTable2 = new DataTable("Importers"); TransferContainer.InitTable(dataTable); TransferContainer.InitTable(dataTable2); dataTable.Columns.Add(new DataColumn("exportToName")); dataTable.Columns.Add(new DataColumn("exportToVersion")); dataTable2.Columns.Add(new DataColumn("importToName")); dataTable2.Columns.Add(new DataColumn("importToVersion")); dataSet.Tables.Add(dataTable); dataSet.Tables.Add(dataTable2); TransferContainer.BuildIndex(text, dataTable, dataTable2); TransferContainer.TransferCache.Insert("Hishop_TransferIndexes", dataSet, new CacheDependency(text)); } }
internal static TransferContainer Instance() { if (TransferContainer._instance == null) { object lockHelper; Monitor.Enter(lockHelper = TransferContainer.LockHelper); try { if (TransferContainer._instance == null) { TransferContainer._instance = new TransferContainer(); } } finally { Monitor.Exit(lockHelper); } } TransferContainer.Init(); return(TransferContainer._instance); }
public static Dictionary <string, string> GetExportAdapters(Target source, string exportToName) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); DataRow[] exporterList = TransferContainer.Instance().GetExporterList(source.Name, exportToName); if (exporterList != null && exporterList.Length != 0) { string value = null; int num = 0; do { Version v = new Version(exporterList[num]["sourceVersion"].ToString()); if (v <= source.Version) { value = exporterList[num]["sourceVersion"].ToString(); } num++; if (!string.IsNullOrEmpty(value)) { break; } }while (num < exporterList.Length); if (!string.IsNullOrEmpty(value)) { DataRow[] array = exporterList; for (int i = 0; i < array.Length; i++) { DataRow dataRow = array[i]; string text = dataRow["sourceVersion"].ToString(); if (text.Equals(value)) { dictionary.Add(dataRow["fullName"].ToString(), dataRow["exportToName"].ToString() + dataRow["exportToVersion"].ToString()); } } } return(dictionary); } return(dictionary); }
internal Type GetImporter(string fullName) { return(TransferContainer.GetPlugin(fullName, "Importers")); }