问题描述
我是 C# 新手,一直在修改前任员工编写的一些代码。如果我理解正确,并且我确定我没有理解,我需要向 MachineInfoClass 添加一个 Add 方法。它似乎已经接近尾声了。也许它的方法的范围不是公开的?非常感谢这位绿色 C# 程序员的帮助。
namespace Aims_CMM_Calibration_Reporter
{
using System;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Class to describe information related the CMM that was calibrated
/// </summary>
public class MachineInfoClass:IEnumerator,IEnumerable
{
public MachineInfoClass()
{`enter code here`
//default empty constructor
}
public string SerialNumber { get; set; }
public string ModelNumber { get; set; }
public string YearBuilt { get; set; }
//private double _measUncertMicrons = 0.1;
//public double MeasUncertMicrons
//{
// get { return _measUncertMicrons; }
// set
// {//Todo: Measurement Uncertainty maths
// _measUncertMicrons = value;
// double linearuncert = Math.Round(_measUncertMicrons + (1000 / 250),1);
// double volumnUncert = Math.Round(linearuncert * 2,1);
// _measUncertCalcText = "MPE = " + _measUncertMicrons.ToString() + " um +( L / 250.0 mm) um Value outside maximum limit (Linear/Volumetric uncertainty to 1000mm " + linearuncert.ToString() + "um/ " + volumnUncert.ToString() + "um)";
// }
//}
//private string _measUncertCalcText = string.Empty;
public string MeasUncertText { get; set; } = string.Empty;
//{
// get { return _measUncertCalcText; }
//}
public string MachinePerformanceSpec { get; set; } = string.Empty;
public MeasurementRange MeasRange { get; set; } = new MeasurementRange();
public ProbeSystemClass Probedetails { get; set; } = new ProbeSystemClass();
object IEnumerator.Current
{
get
{
throw new NotImplementedException();
}
}
/// <summary>
/// Class to describe information related to the CMM capabilities
/// </summary>
public class MeasurementRange
{
public string MachineUnits { get; set; }
public string xrange { get; set; }
public string Yrange { get; set; }
public string Zrange { get; set; }
}
bool IEnumerator.MoveNext()
{
throw new NotImplementedException();
}
void IEnumerator.Reset()
{
throw new NotImplementedException();
}
IEnumerator IEnumerable.GetEnumerator()
{
throw new NotImplementedException();
}
public static implicit operator MachineInfoClass(List<MachineInfoClass> v)
{
throw new NotImplementedException();
}
internal void Remove(object item)
{
throw new NotImplementedException();
}
internal void Add(MachineInfoClass newCMM)
{
throw new NotImplementedException();
}
}
}
****这是在 xlmserializer 的 frmMain.CS 中实际弹出错误的地方 ****
public bool SaveReport(string filePath)
{
try
{
//load values from the form into the calreport object
if (!saveValuesintoCalReportObj()) throw new Exception("Form to CalReportObj Failed.");
//save the calibration object data to xml
XmlWriterSettings ws = new XmlWriterSettings();
ws.NewLineHandling = NewLineHandling.Entitize; //<-- needed to keep newlines for addresses,etc
XmlSerializer xSave = new XmlSerializer(typeof(CalibrationReport));
using (XmlWriter xWrite = XmlWriter.Create(filePath,ws))
{
xSave.Serialize(xWrite,calReport);
}
activeReportXMLFilename = filePath;
this.Text = Application.ProductName + " :: " + activeReportXMLFilename;
updateMRUlist(activeReportXMLFilename);
return true;
}
catch (Exception ex)
{
//String innerMessage = (ex.InnerException != null)
// ? ex.InnerException.Message
// : "";
MessageBox.Show("Failed to serialize and/or save." + Environment.NewLine + Environment.NewLine + ex.Message );
return false;
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)