如何解决要进行 XML 序列化,从 IEnumerable 继承的类型必须在其继承的所有级别都实现 ADD(System.Object) h
我是 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 举报,一经查实,本站将立刻删除。