public ExecutionManager(CameraManager cameraManager) { listMeasureManager = new List <MeasureManager>();//实例化 foreach (var camera in cameraManager.listCamera) { MeasureManager measureManager = new MeasureManager(camera); measureManager.ImageAcqed(); measureManager.MeasureFinish += MeasureManager_MeasureFinish;//绑定测量单元管理器测量完成事件 listMeasureManager.Add(measureManager); } Initialize();//初始化 }
public MeasureManager(MeasureManager data)//用于克隆副本的构造函数 { FieldInfo[] fields = data.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (var item in fields) { Type type = this.GetType(); FieldInfo fieldInfo = type.GetField(item.Name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo.FieldType == typeof(Func <object, object, int>) || fieldInfo.FieldType == typeof(Func <int, int, int>)) { continue; } Type type2 = data.GetType(); FieldInfo fieldInfo2 = type2.GetField(item.Name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); object value = fieldInfo2.GetValue(data); fieldInfo.SetValue(this, value); } }
/// <summary> /// 克隆 /// </summary> /// <returns></returns> public object Clone() { MeasureManager mUM = new MeasureManager(this); return(mUM); }