コード例 #1
0
ファイル: OrderManager.cs プロジェクト: Zeghs/ZeroSystem
		/// <summary>
		///   取得所有下單元件資訊
		/// </summary>
		/// <returns>返回值:OrderServiceInformation類別的陣列</returns>
		public OrderServiceInformation[] GetOrderServiceInformations() {
			OrderServiceInformation[] cOrderServiceInfos = null;

			lock (__cOrderServiceInfos) {
				int iCount = __cOrderServiceInfos.Count;
				cOrderServiceInfos = new OrderServiceInformation[iCount];
				__cOrderServiceInfos.Values.CopyTo(cOrderServiceInfos, 0);
			}
			return cOrderServiceInfos;
		}
コード例 #2
0
ファイル: OrderManager.cs プロジェクト: Zeghs/ZeroSystem
		/// <summary>
		///   更新下單元件資訊
		/// </summary>
		/// <param name="orderDirectory">下單元件資料夾</param>
		public void Refresh(string orderDirectory) {
			string[] sDllFiles = Directory.GetFiles(orderDirectory, "*.dll", SearchOption.AllDirectories);

			int iLength = sDllFiles.Length;
			if (iLength > 0) {
				for (int i = 0; i < iLength; i++) {
					string sDllFile = sDllFiles[i];
					string sAssembly = Path.GetFileNameWithoutExtension(sDllFile);
					FileVersionInfo cFileInfo = FileVersionInfo.GetVersionInfo(sDllFile);

					OrderServiceInformation cOrderInfo = null;
					lock (__cOrderServiceInfos) {
						if (!__cOrderServiceInfos.TryGetValue(sAssembly, out cOrderInfo)) {
							List<string> cServices = new List<string>();
							Assembly cAssembly = Assembly.LoadFile(Path.GetFullPath(sDllFile));
							
							Type[] cTypes = cAssembly.GetTypes();
							foreach (Type cType in cTypes) {
								if (CheckAbstractOrderService(cType)) {
									cServices.Add(cType.FullName);
								}
							}

							cOrderInfo = new OrderServiceInformation();
							cOrderInfo.Services = cServices.ToArray();
							
							__cOrderServiceInfos.Add(sAssembly, cOrderInfo);
						}
					}

					//更新下單資訊
					cOrderInfo.Company = cFileInfo.CompanyName;
					cOrderInfo.Description = cFileInfo.Comments;
					cOrderInfo.FileVersion = cFileInfo.FileVersion;
					cOrderInfo.ModuleName = sAssembly;
					cOrderInfo.Location = sDllFile;
					cOrderInfo.ProductVersion = cFileInfo.ProductVersion;
				}
			}
		}