|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace connor_zwcadm.model {
|
|
|
public class PropertyInfo {
|
|
|
public enum PropLocation {
|
|
|
BOMLine, Item, Rev, ItemMaster, RevMaster, Undefined
|
|
|
}
|
|
|
public PropLocation Location { get; }
|
|
|
public string TcPropName { get; }
|
|
|
public string CadPropName { get; }
|
|
|
public bool UseRealValue { get; }
|
|
|
|
|
|
private PropertyInfo(PropLocation location, string tcPropName, string cadPropName, bool useRealValue) {
|
|
|
this.Location = location;
|
|
|
this.TcPropName = tcPropName;
|
|
|
this.CadPropName = cadPropName;
|
|
|
UseRealValue = useRealValue;
|
|
|
}
|
|
|
|
|
|
public override string ToString() {
|
|
|
return "["+Location+"."+TcPropName+" - "+CadPropName+"]";
|
|
|
}
|
|
|
|
|
|
public static PropertyInfo parse(string cadConfig, string tcConfig) {
|
|
|
if (string.IsNullOrWhiteSpace(cadConfig) || string.IsNullOrWhiteSpace(tcConfig)) {
|
|
|
return null;
|
|
|
}
|
|
|
bool useRealValue = false;
|
|
|
string tcPropName = null, cadPropName = null;
|
|
|
PropLocation location = PropLocation.Undefined;
|
|
|
string[] split = tcConfig.Split('.');
|
|
|
if (split.Length == 2) {
|
|
|
switch (split[0].ToUpper()) {
|
|
|
case "BOMLINE":
|
|
|
location = PropLocation.BOMLine;
|
|
|
break;
|
|
|
case "ITEM":
|
|
|
location = PropLocation.Item;
|
|
|
break;
|
|
|
case "REV":
|
|
|
location = PropLocation.Rev;
|
|
|
break;
|
|
|
case "ITEMMASTER":
|
|
|
location = PropLocation.ItemMaster;
|
|
|
break;
|
|
|
case "REVMASTER":
|
|
|
location = PropLocation.RevMaster;
|
|
|
break;
|
|
|
default:
|
|
|
location = PropLocation.Undefined;
|
|
|
break;
|
|
|
}
|
|
|
tcPropName = split[1].Trim();
|
|
|
if (tcPropName.StartsWith("#")) {
|
|
|
tcPropName = tcPropName.Substring(1);
|
|
|
useRealValue = true;
|
|
|
}
|
|
|
}
|
|
|
if (string.IsNullOrWhiteSpace(tcPropName) || location == PropLocation.Undefined) {
|
|
|
throw new Exception("无法解析TC属性配置:" + tcConfig);
|
|
|
}
|
|
|
cadPropName = cadConfig.Trim();
|
|
|
return new PropertyInfo(location, tcPropName, cadPropName, useRealValue);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|