我已经定义了一个名为StringResourceCollection的类。 我的班级声明如下:
namespace EPGObjectModel.IDE
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
public class StringResourceCollection : CollectionBase, IEnumerator
{
#region Fields
private int index = -1;
#endregion Fields
#region Properties
public object Current
{
get { return this.List[index]; }
}
#endregion Properties
#region Indexers
public EPGString this[string index]
{
get
{
Reset();
while (this.MoveNext())
{
if (((EPGString)Current).StringId == index || ((EPGString)Current).StringName.Equals(index))
return (EPGString)Current;
}
return null;
}
}
#endregion Indexers
#region Methods
public int Add(EPGString item)
{
try
{
return List.Add(item);
}
catch(Exception)
{
throw;
}
}
public void Modify(string id, EPGString resourceToModify)
{
EPGString stringRes = this[id];
stringRes.DeletePermission = resourceToModify.DeletePermission;
stringRes.ModifyPermission = resourceToModify.ModifyPermission;
stringRes.StringInputLanguage = resourceToModify.StringInputLanguage;
stringRes.StringLanguage = resourceToModify.StringLanguage;
stringRes.StringName = resourceToModify.StringName;
stringRes.StringText = resourceToModify.StringText;
}
public void Modify(EPGString resourceToModify)
{
EPGString stringRes = this[resourceToModify.StringName];
if (stringRes == null)
return;
stringRes.DeletePermission = resourceToModify.DeletePermission;
stringRes.ModifyPermission = resourceToModify.ModifyPermission;
stringRes.StringInputLanguage = resourceToModify.StringInputLanguage;
stringRes.StringLanguage = resourceToModify.StringLanguage;
stringRes.StringName = resourceToModify.StringName;
stringRes.StringText = resourceToModify.StringText;
}
public bool MoveNext()
{
this.index++;
return (this.index < this.List.Count);
}
public void Remove(EPGString item)
{
try
{
List.Remove(item);
}
catch (ArgumentException)
{
throw;
}
}
public void Reset()
{
index = -1;
}
#endregion Methods
}
}
当我在我的代码上运行fxcop工具时,它会显示“枚举应强类型”的错误 如何修复FxCop规则:我的班级应该强烈输入枚举? 这里需要做些什么改变?
答案 0 :(得分:5)
由于您正在实现字符串集合,因此应实现
IEnumerator<string>
除了IEnumerator