I am developing one class library for my projects.
I am having some casting problem please help me to resolve the problem.
here are class list.
IComposite Class
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace ClassLibrary_V1._0.Steps
{
public interface IComposite :IEnumerable
{
string Name { set; get; }
string NameSym { get; }
string NameWide { get;set;}
int Count { get;}
int LastError { get; }
string Type { get;}
int Handle { get; }
IComposite Parent { get; }
IComposite HardwareDatum { get; }
EnumEditabilityFlags Editability { get; set; }
EnumVisiblityFlags Visibility { get; set; }
void Add(object AvpThing, int Index, EumCAddOption AddOption);
void Remove( int Index);
void Clear();
}
}
ICollection Class
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassLibrary_V1._0.Steps
{
public interface ICollection : IComposite
{
}
}
istep
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassLibrary_V1._0.Steps
{
public interface IStep : IComposite
{
int Index { get; }
EnumStepCategory Category { get; set; }
IStep Prev { get; }
IStep Next { get; }
ICollection Datums { get; }
EnumStepStateFlags StateFlags { get; set; }
Datum Datum(string DatumSymName);
DatumList DatumList(EnumDatumCategory Cat);
IDatum get_Datum(string CymName);
DatumList get_DatumList(EnumDatumCategory Cat);
IStep AddStep(object StepOrType, EnumStepCategory WhichCategory, IStep Relative, ECAddOption Option);
IStep AddStep(string Name);
IStep AddStep(string Type, string Name);
IDatum AddDatum(object DatumOrType, EnumDatumCategory WhichCategory, IDatum relative, ECAddOption Option);
void RemoveStep(int Index, int DelChildStep);
int MoveStep(IStep DtepSrc, IStep DtepDst, int InsertBefore);
IComposite Find(string NameOrType, EnumFindOption Option, EnumStepCategory WhichCategory);
ICollection FindByType(string StepType, int FindInAllChildren);
StepList GetChildList(EnumStepCategory Cat);
int ChildCount(EnumStepCategory Category);
IStep FirstChild(EnumStepCategory Category);
}
}
iDatum
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassLibrary_V1._0.Steps
{
public interface IDatum :IComposite
{
EnumDatumCategory Category { get; }
object Value { get;set;}
string ValueAsString { get;set;}
object ValueCalibrated { get;set;}
int NumScalars { get; }
int Visible { get;set;}
IDatum AddDatum(object DatumOrType,
EnumDatumCategory WhichCategory, IDatum Relative, ECAddOption Option);
IDatum AddDatum(string Name);
IDatum AddDatum(string Type, string Name);
}
}
StepClass
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassLibrary_V1._0.Steps
{
public class StepClass : IStep, Step
{
internal string mName;
internal string mNameSym;
internal string mNameWide;
internal string mType;
internal StepList mStepList;
internal DatumList mDatumList;
internal int nIndex;
internal EnumStepCategory mCategory;
internal EnumStepStateFlags mStateFlags;
internal EnumVisiblityFlags mVisibility;
IDatum m_ResultDatum;
private ICollection RetCollection;
private int ChildCounter;
private IStep RetStep;
public StepClass()
{
mStepList = new StepList();
mDatumList = new DatumList();
}
public string Name
{
get
{
return mName;
}
set
{
mName = value;
}
}
public string NameSym
{
get
{
return mNameSym;
}
set
{
mNameSym = value;
}
}
public string NameWide
{
get
{
return mNameWide;
}
set
{
mNameWide = value;
}
}
public string Type
{
get
{
return "MotherStep";
}
set
{
mType = value;
}
}
public EnumVisiblityFlags Visibility
{
get
{
return mVisibility;
}
set
{
mVisibility = value;
}
}
public int Index
{
get
{
return nIndex;
}
}
public EnumStepCategory Category
{
get
{
return mCategory;
}
set
{
mCategory = value;
}
}
public IStep Prev
{
get
{
nIndex--;
if (nIndex >= 0)
{
return mStepList[nIndex];
}
else
{
throw new IndexOutOfRangeException("No more Element in StelpList");
}
}
}
public IStep Next
{
get
{
nIndex++;
if (nIndex < mStepList.Count)
{
return mStepList[nIndex];
}
else
{
throw new IndexOutOfRangeException("No more Element in StelpList");
}
}
}
public ICollection Datums
{
get
{
return (ICollection)mDatumList;
}
}
public EnumStepStateFlags StateFlags
{
get
{
return mStateFlags;
}
set
{
mStateFlags = value;
}
}
public Datum Datum(string DatumSymName)
{
return (Datum)get_Datum(DatumSymName);
}
public DatumList DatumList(EnumDatumCategory Cat)
{
return get_DatumList(Cat);
}
public IDatum get_Datum(string CymName)
{
for (int i = 0; i < mDatumList.Count; i++)
{
if (mDatumList[i].Name == CymName)
{
m_ResultDatum = mDatumList[i];
}
}
return (Datum)m_ResultDatum;
}
public DatumList get_DatumList(EnumDatumCategory Cat)
{
DatumList mDatumListResult = new DatumList();
for (int i = 0; i < mDatumList.Count; i++)
{
if (mDatumList[i].Category == Cat)
{
mDatumListResult.Add(mDatumList[i]);
}
else if (Cat == EnumDatumCategory.D_ALL)
{
mDatumListResult.Add(mDatumList[i]);
}
}
return mDatumListResult;
}
public IDatum AddDatum(object DatumOrType, EnumDatumCategory WhichCategory,
IDatum relative, ECAddOption Option)
{
int foundindex;
DatumClass newdatum = new DatumClass();
newdatum.Type = (string)DatumOrType;
newdatum.Category = WhichCategory;
try
{
foundindex = mDatumList.IndexOf(relative);
mDatumList.Insert(foundindex, newdatum);
}
catch (ArgumentOutOfRangeException ae)
{
mDatumList.Add(newdatum);
}
return newdatum;
}
public IStep AddStep(object StepOrType, EnumStepCategory WhichCategory,
IStep Relative, ECAddOption Option)
{
int foundindex;
StepClass newstep = new StepClass();
newstep.Type = (string)StepOrType;
newstep.Category = WhichCategory;
nIndex++;
try
{
foundindex = mStepList.IndexOf(Relative);
mStepList.Insert(foundindex, newstep);
return mStepList[foundindex];
}
catch (ArgumentOutOfRangeException ae)
{
mStepList.Add(newstep);
return mStepList[mStepList.Count - 1];
}
return newstep;
}
public IStep AddStep(string Type, string Name)
{
IStep step2 = (IStep)AddStep(Type, EnumStepCategory.S_POSTPROC, null, ECAddOption.ADD_UNINIT);
step2.Name = Name;
return step2;
}
public IStep AddStep(string Name)
{
IStep step2 = (IStep)AddStep(null,
EnumStepCategory.S_POSTPROC, null, ECAddOption.ADD_AFTER);
step2.Name = Name;
return step2;
}
public void Add(object AvpThing, int Index, EumCAddOption AddOption)
{
throw new Exception("The method or operation is not implemented.");
}
void RemoveStep(int Index, int DelChildStep)
{
mStepList.RemoveAt(Index);
}
#region IComposite Members
public int Count
{
get { return mStepList.Count; }
}
public int LastError
{
get { throw new Exception("The method or operation is not implemented."); }
}
public int Handle
{
get { throw new Exception("The method or operation is not implemented."); }
}
public IComposite Parent
{
get { throw new Exception("The method or operation is not implemented."); }
}
public IComposite HardwareDatum
{
get { throw new Exception("The method or operation is not implemented."); }
}
public EnumEditabilityFlags Editability
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
public void Remove(int Index)
{
mStepList.RemoveAt(Index);
}
public void Clear()
{
mStepList.Clear();
}
public System.Collections.IEnumerator GetEnumerator()
{
foreach (Step stp in mStepList)
yield return stp;
}
#endregion
public int MoveStep(IStep DtepSrc, IStep DtepDst, int InsertBefore)
{
throw new NotImplementedException();
}
public IComposite Find(string NameOrType, EnumFindOption Option, EnumStepCategory WhichCategory)
{
StepList RetStepList = new StepList();
for (int i = 0; i < mStepList.Count; i++)
{
if (mStepList[i].Category == WhichCategory)
{
if (Option == EnumFindOption.FIND_BY_SYMNAME && mStepList[i].Name == NameOrType)
{
RetStepList.Add(mStepList[i]);
}
else if (Option == EnumFindOption.FIND_BY_TYPE && mStepList[i].Type == NameOrType)
{
RetStepList.Add(mStepList[i]);
}
else if (Option == EnumFindOption.FIND_BY_USERNAME)
{
}
}
}
return (IComposite)RetStepList;
}
public ICollection FindByType(string StepType, int FindInAllChildren)
{
StepList RetStepList = new StepList();
for (int i = 0; i < mStepList.Count; i++)
{
if (mStepList[i].Type == StepType)
{
RetStepList.Add(mStepList[i]);
}
}
return (ICollection)RetStepList;
}
public StepList GetChildList(EnumStepCategory Cat)
{
StepList t = new StepList();
for (int i = 0; i < mStepList.Count; i++)
{
if (mStepList[i].Category == Cat)
{
t.Add(mStepList[i]);
}
else if (Cat == EnumStepCategory.S_ALL)
{
t.Add(mStepList[i]);
}
}
return t;
}
public int ChildCount(EnumStepCategory Category)
{
for (int i = 0; i < mStepList.Count; i++)
{
if (mStepList[i].Category == Category)
{
ChildCounter += mStepList[i].Datums.Count;
}
}
return ChildCounter;
}
public IStep FirstChild(EnumStepCategory Category)
{
for (int i = 0; i < mStepList.Count; i++)
{
if (mStepList[i].Category == Category)
{
RetStep = mStepList[i];
break;
}
}
return RetStep;
}
void IStep.RemoveStep(int Index, int DelChildStep)
{
mStepList.RemoveAt(Index);
}
}
}
public ICollection Datums
{
get
{
return (ICollection)mDatumList;
}
}
In above propery i have casting problem.