- Added ShortPath Property to ItemInfo

- Added MacroList
Added CheckOff data
Added CheckOff and ChangeBar
Fixed inheritance
This commit is contained in:
Rich
2010-05-25 16:11:23 +00:00
parent f21a49d75e
commit 8fd6c2eac4
4 changed files with 402 additions and 95 deletions

View File

@@ -322,20 +322,27 @@ namespace VEPROMS.CSLA.Library
if (ll == null)
{
XmlNode xn = SelectSingleNode(xPath);
string tstr = xn != null ? xn.InnerText : "FALSE";
ll = new LazyLoad<bool>(tstr.ToUpper() == "TRUE" ? true : false);
ll = new LazyLoad<bool>(RetrieveBool(xn));
}
return ll.Value;
}
protected static bool RetrieveBool(XmlNode xn)
{
return xn != null && xn.InnerText.ToUpper() == "TRUE";
}
public string LazyLoad(ref LazyLoad<string> ll, string xPath)
{
if (ll == null)
{
XmlNode xn = SelectSingleNode(xPath);
ll = new LazyLoad<string>(xn != null ? xn.InnerText : null);
ll = new LazyLoad<string>(RetrieveString(xn));
}
return ll.Value;
}
protected static string RetrieveString(XmlNode xn)
{
return xn != null ? xn.InnerText : null;
}
public string MyPath
{
get
@@ -356,23 +363,26 @@ namespace VEPROMS.CSLA.Library
{
if (ll == null)
{
int? value=null;
XmlNode xn = this._XmlNode;
xn = SelectSingleNode(xPath);
if (xn != null)
{
int iValue =0;
if (!int.TryParse(xn.InnerText, out iValue))
{
Console.WriteLine(string.Format("'{0}'\r\n'{1}'\r\n'{2}' could not be converted to int?", MyFormat.FullName, MyPath + "/" + xPath, xn.InnerText));
throw (new Exception(string.Format("{0} = '{1}' could not be converted to int?",xPath, xn.InnerText)));
}
value = iValue;
}
ll = new LazyLoad<int?>(value);
XmlNode xn = SelectSingleNode(xPath);
ll = new LazyLoad<int?>(RetrieveInt(xPath, xn));
}
return ll.Value;
}
protected int? RetrieveInt(string xPath, XmlNode xn)
{
int? value = null;
if (xn != null)
{
int iValue = 0;
if (!int.TryParse(xn.InnerText, out iValue))
{
Console.WriteLine(string.Format("'{0}'\r\n'{1}'\r\n'{2}' could not be converted to int?", MyFormat.FullName, MyPath + "/" + xPath, xn.InnerText));
throw (new Exception(string.Format("{0} = '{1}' could not be converted to int?", xPath, xn.InnerText)));
}
value = iValue;
}
return value;
}
public Nullable<T> LazyLoad<T>(ref LazyLoad<Nullable<T>> ll, string xPath)
where T:struct
{
@@ -405,6 +415,13 @@ namespace VEPROMS.CSLA.Library
int? Index { get; }
}
#endregion
#region IVlnNamedFormatItem
public partial interface IVlnNamedFormatItem
{
string Name { get; }
bool Inherited { get; }
}
#endregion
#region LazyLoad
public class LazyLoad<T>
{
@@ -595,6 +612,95 @@ namespace VEPROMS.CSLA.Library
#endregion
}
#endregion
#region vlnNamedFormatList
public class vlnNamedFormatList<T> : vlnFormatList<T>, ICustomTypeDescriptor
where T : vlnFormatItem, IVlnNamedFormatItem, new()
{
public vlnNamedFormatList(XmlNodeList xmlNodeList, IFormatOrFormatInfo myFormat)
: base(xmlNodeList)
{
MyFormat = myFormat;
}
public vlnNamedFormatList() : base() { }
public virtual vlnNamedFormatList<T> InheritedList { get { return null; } }
public new T this[string name]
{
get
{
foreach (T tmp in this)
{
if (tmp.Name == name)
return tmp;
}
vlnNamedFormatList<T> ttlParent = InheritedList; //Check Inherited Value
if (ttlParent != null)
return ttlParent[name];
return null;
// None found - Can I find it in another format?
return null;
}
}
public new T this[int index]
{
get
{
if(base.Count > index)
return base[index];
vlnNamedFormatList<T> ttlParent = InheritedList; //Check Inherited Value
if (ttlParent != null)
return ttlParent[index];
return null;
// None found - Can I find it in another format?
return null;
}
}
public new int Count
{
get
{
return base.Count;
}
}
#region ICustomTypeDescriptor
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
public virtual PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
int i = 0;
for (i = 0; i < this.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
pds.Add(new vlnPropertyDescriptor<vlnFormatList<T>, T>(this, i));
}
// return the property descriptor collection
return pds;
}
#endregion
}
#endregion
#region vlnListConverter
internal class vlnListConverter<T, C> : ExpandableObjectConverter
where T : vlnFormatList<C>