B2026-077 – Update Format inheritance to use index id instead of position/order. #819
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -12,47 +12,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private static XmlElement mydocele;
|
private static XmlElement mydocele;
|
||||||
public vlnFormatDocument(IFormatOrFormatInfo myFormat)
|
public vlnFormatDocument(IFormatOrFormatInfo myFormat)
|
||||||
{
|
{
|
||||||
_MyFormat = myFormat;
|
MyFormat = myFormat;
|
||||||
LoadXml(MyFormat.Data);
|
LoadXml(MyFormat.Data);
|
||||||
mydocele = this.DocumentElement;
|
mydocele = DocumentElement;
|
||||||
}
|
|
||||||
private IFormatOrFormatInfo _MyFormat;
|
|
||||||
public IFormatOrFormatInfo MyFormat
|
|
||||||
{
|
|
||||||
get { return _MyFormat; }
|
|
||||||
set { _MyFormat = value; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IFormatOrFormatInfo MyFormat { get; set; }
|
||||||
public static XmlNode LookupSingleNode(XmlNode xmlNode, string path)
|
public static XmlNode LookupSingleNode(XmlNode xmlNode, string path)
|
||||||
{
|
{
|
||||||
//original:
|
|
||||||
//if (xmlNode == null) return null;
|
|
||||||
//XmlNode xn = xmlNode.SelectSingleNode(path);
|
|
||||||
//if (xn != null) return xn;
|
|
||||||
//if (xmlNode.Name == "Step") xn = LookupSingleStepNode(xmlNode, path);
|
|
||||||
//if (xn != null) return xn;
|
|
||||||
//if (path.StartsWith("Font")) return LookupSingleFontNode(xmlNode, path);
|
|
||||||
//return InheritLookup(xmlNode, path);
|
|
||||||
/* RHM 20090821 -
|
|
||||||
if (path.StartsWith("Font"))
|
|
||||||
{
|
|
||||||
XmlNode xn = null;
|
|
||||||
if (xmlNode != null)
|
|
||||||
{
|
|
||||||
xn = xmlNode.SelectSingleNode(path);
|
|
||||||
// RHM 2008-12-15 - Added logic to keep looking if a blank attribute is found
|
|
||||||
if (xn != null && xn is XmlAttribute && (xn as XmlAttribute).Value != "") return xn;
|
|
||||||
//if (xn != null) return xn;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
xmlNode = LookupSingleNode(mydocele.FirstChild, "/PlantFormat/FormatData");
|
|
||||||
}
|
|
||||||
if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleNode {0},{1}", xmlNode.Name == "Step" ? "Step." + xmlNode.Attributes["Type"].Value : xmlNode.Name, path);
|
|
||||||
return LookupSingleFontNode(xmlNode, path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*/
|
|
||||||
if (xmlNode == null) return null;
|
if (xmlNode == null) return null;
|
||||||
XmlNode xn = xmlNode.SelectSingleNode(path);
|
XmlNode xn = xmlNode.SelectSingleNode(path);
|
||||||
if (xmlNode.Name == "Box") return xn; // if box, don't do inheritance.
|
if (xmlNode.Name == "Box") return xn; // if box, don't do inheritance.
|
||||||
@@ -72,7 +39,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (xn != null) return xn;
|
if (xn != null) return xn;
|
||||||
if (path.StartsWith("Font")) return LookupSingleFontNode(xmlNode, path); // Then do Font Inheritance
|
if (path.StartsWith("Font")) return LookupSingleFontNode(xmlNode, path); // Then do Font Inheritance
|
||||||
return InheritLookup(xmlNode, path, false);
|
return InheritLookup(xmlNode, path, false);
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
public static XmlNode LookupSingleFontNode(XmlNode xmlNode, string path)
|
public static XmlNode LookupSingleFontNode(XmlNode xmlNode, string path)
|
||||||
{
|
{
|
||||||
@@ -108,29 +74,15 @@ namespace VEPROMS.CSLA.Library
|
|||||||
|
|
||||||
if (xmlNode == null) return null;
|
if (xmlNode == null) return null;
|
||||||
XmlNode xn = xmlNode.SelectSingleNode(path);
|
XmlNode xn = xmlNode.SelectSingleNode(path);
|
||||||
XmlNode tmpNode = xmlNode;
|
|
||||||
XmlNode tmpNode2 = xmlNode;
|
XmlNode tmpNode2 = xmlNode;
|
||||||
while (xn == null) //Walk-up the format tree to find a step node
|
while (xn == null) //Walk-up the format tree to find a step node
|
||||||
{
|
{
|
||||||
//if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleStepNode -> Loop {0},{1}", xmlNode.Name == "Step" ? "Step." + xmlNode.Attributes["Type"].Value : xmlNode.Name, path);
|
//if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleStepNode -> Loop {0},{1}", xmlNode.Name == "Step" ? "Step." + xmlNode.Attributes["Type"].Value : xmlNode.Name, path);
|
||||||
tmpNode = xmlNode;
|
|
||||||
// RHM 20090831 Try doing a lookup of the parent. If no parent, go back to the original and do an inheritance lookup
|
// RHM 20090831 Try doing a lookup of the parent. If no parent, go back to the original and do an inheritance lookup
|
||||||
XmlAttribute attr = xmlNode.Attributes["ParentType"];
|
XmlAttribute attr = xmlNode.Attributes["ParentType"];
|
||||||
if (attr == null || attr.Value == string.Empty) // Cannot find ParentType so do an InheritanceLookup
|
if (attr == null || attr.Value == string.Empty) // Cannot find ParentType so do an InheritanceLookup
|
||||||
return InheritLookup(tmpNode2, path, true);
|
return InheritLookup(tmpNode2, path, true);
|
||||||
//return InheritLookup(xmlNode, path, false);
|
|
||||||
xmlNode = xmlNode.ParentNode.SelectSingleNode(string.Format("Step[@Type='{0}']", xmlNode.Attributes["ParentType"].InnerText));
|
xmlNode = xmlNode.ParentNode.SelectSingleNode(string.Format("Step[@Type='{0}']", xmlNode.Attributes["ParentType"].InnerText));
|
||||||
// Based upon our current data - the following conditions are never met.
|
|
||||||
//if (xmlNode == null && path.StartsWith("Font"))
|
|
||||||
//{
|
|
||||||
// //if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleStepNode -> Font {0},{1}", tmpNode.Name == "Step" ? "Step." + tmpNode.Attributes["Type"].Value : tmpNode.Name, path);
|
|
||||||
// return LookupSingleFontNode(tmpNode, path);
|
|
||||||
//}
|
|
||||||
//if (xmlNode == null)
|
|
||||||
//{
|
|
||||||
// //if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleStepNode -> Font {0},{1}", tmpNode2.Name == "Step" ? "Step." + tmpNode2.Attributes["Type"].Value : tmpNode2.Name, path);
|
|
||||||
// return InheritLookup(tmpNode2, path, true);
|
|
||||||
//}
|
|
||||||
xn = xmlNode.SelectSingleNode(path);
|
xn = xmlNode.SelectSingleNode(path);
|
||||||
}
|
}
|
||||||
return xn;
|
return xn;
|
||||||
@@ -145,36 +97,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public static string Lookup(XmlNode xmlNode, string path)
|
public static string Lookup(XmlNode xmlNode, string path)
|
||||||
{
|
{
|
||||||
//if (xmlNode == null) return null;
|
|
||||||
XmlNode xn = LookupSingleNode(xmlNode, path);
|
XmlNode xn = LookupSingleNode(xmlNode, path);
|
||||||
//if (xn == null) xn = InheritLookup(xmlNode, path);
|
return xn?.InnerText;
|
||||||
if (xn == null) return null;
|
|
||||||
return xn.InnerText;
|
|
||||||
}
|
}
|
||||||
//public static string StepLookup(XmlNode xmlNode, string path)
|
|
||||||
//{
|
|
||||||
// //if (xmlNode == null) return null;
|
|
||||||
// XmlNode xn = LookupSingleStepNode(xmlNode, path);
|
|
||||||
// //if (xn == null) xn = InheritLookup(xmlNode, path);
|
|
||||||
// if (xn == null) return null;
|
|
||||||
// return xn.InnerText;
|
|
||||||
//}
|
|
||||||
public static T EnumLookup<T>(XmlNode xmlNode, string path)
|
public static T EnumLookup<T>(XmlNode xmlNode, string path)
|
||||||
{
|
{
|
||||||
string str = Lookup(xmlNode,path);
|
string str = Lookup(xmlNode,path);
|
||||||
if (str == null) return default(T);
|
return str == null ? default : (T)Enum.Parse(typeof(T), str);
|
||||||
return (T)Enum.Parse(typeof(T), str);
|
|
||||||
}
|
}
|
||||||
public static int? IntLookup(XmlNode xmlNode, string path)
|
public static int? IntLookup(XmlNode xmlNode, string path)
|
||||||
{
|
{
|
||||||
//if (xmlNode == null) return null;
|
|
||||||
//XmlNode xn = LookupSingleNode(xmlNode, path);
|
|
||||||
//if (xn == null) xn = InheritLookup(xmlNode, path);
|
|
||||||
//if (xn == null) return null;
|
|
||||||
//return int.Parse(xn.InnerText);
|
|
||||||
string str = Lookup(xmlNode, path);
|
string str = Lookup(xmlNode, path);
|
||||||
if (str == null) return null;
|
return str == null ? null : (int?)int.Parse(str);
|
||||||
return int.Parse(str);
|
|
||||||
}
|
}
|
||||||
public static int SiblingCount(XmlNode xmlNode)
|
public static int SiblingCount(XmlNode xmlNode)
|
||||||
{
|
{
|
||||||
@@ -189,22 +123,32 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public static string Path(XmlNode xmlNode)
|
public static string Path(XmlNode xmlNode)
|
||||||
{
|
{
|
||||||
// Walk the path
|
// Walk the path
|
||||||
string parentPath = (xmlNode.ParentNode == xmlNode.OwnerDocument ? "" : Path(xmlNode.ParentNode));
|
string parentPath = xmlNode.ParentNode == xmlNode.OwnerDocument ? "" : Path(xmlNode.ParentNode);
|
||||||
// Count Siblings with the Same Name
|
// Count Siblings with the Same Name
|
||||||
int sibCount = SiblingCount(xmlNode);
|
int sibCount = SiblingCount(xmlNode);
|
||||||
return string.Format("{0}/{1}[{2}]", parentPath, xmlNode.Name, sibCount);
|
return string.Format("{0}/{1}[{2}]", parentPath, xmlNode.Name, sibCount);
|
||||||
}
|
}
|
||||||
|
//B2026-077 – Update Format inheritance to use index id instead of position/order.
|
||||||
|
public static string PathByIndex(XmlNode xmlNode)
|
||||||
|
{
|
||||||
|
if (xmlNode.Name == "TransTypes" || xmlNode.Name == "Step")
|
||||||
|
{
|
||||||
|
string parentPath = xmlNode.ParentNode == xmlNode.OwnerDocument ? "" : Path(xmlNode.ParentNode);
|
||||||
|
string Indx = xmlNode.Attributes["Index"].Value;
|
||||||
|
return $@"{parentPath}/{xmlNode.Name}[@Index='{Indx}']";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Path(xmlNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
public static XmlNode InheritLookup(XmlNode xmlNode, string path, bool stepLookup)
|
public static XmlNode InheritLookup(XmlNode xmlNode, string path, bool stepLookup)
|
||||||
{
|
{
|
||||||
//stepLookup = false; // 8/2 change for inheritance
|
//stepLookup = false; // 8/2 change for inheritance
|
||||||
if (xmlNode == null) return null;// No path to match
|
if (xmlNode == null) return null;// No path to match
|
||||||
string xPath = Path(xmlNode);// Build xPath from xmlNode
|
string xPath = PathByIndex(xmlNode);// Build xPath from xmlNode
|
||||||
if (xmlNode.Name == "TransTypes")
|
|
||||||
{
|
vlnFormatDocument fd = (vlnFormatDocument)xmlNode.OwnerDocument;//First Get the vlnFormatDocument - This also ties it to a FormatInfo object
|
||||||
string TransIndex = xmlNode.Attributes["Index"].Value;
|
|
||||||
xPath = System.Text.RegularExpressions.Regex.Replace(xPath, @"\[[0-9]*\]$", @"[@Index='" + TransIndex + @"']");
|
|
||||||
}
|
|
||||||
vlnFormatDocument fd = (vlnFormatDocument)(xmlNode.OwnerDocument);//First Get the vlnFormatDocument - This also ties it to a FormatInfo object
|
|
||||||
while(fd.MyFormat.MyIParent != null)
|
while(fd.MyFormat.MyIParent != null)
|
||||||
{
|
{
|
||||||
fd = fd.MyFormat.MyIParent.PlantFormat.XmlDoc;// Get the parents vlnFormatDocument
|
fd = fd.MyFormat.MyIParent.PlantFormat.XmlDoc;// Get the parents vlnFormatDocument
|
||||||
@@ -215,7 +159,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
else xp = fd.SelectSingleNode(xPath);// Get the related node
|
else xp = fd.SelectSingleNode(xPath);// Get the related node
|
||||||
if (xp != null)
|
if (xp != null)
|
||||||
{
|
{
|
||||||
XmlNode xn = null;
|
XmlNode xn;
|
||||||
if (stepLookup)
|
if (stepLookup)
|
||||||
{
|
{
|
||||||
//if (path.Contains("Font")) Console.WriteLine("vlnFormatItem.SelectSingleNode {0},{1}", xp.Name == "Step" ? "Step." + xp.Attributes["Type"].Value : xp.Name, path);
|
//if (path.Contains("Font")) Console.WriteLine("vlnFormatItem.SelectSingleNode {0},{1}", xp.Name == "Step" ? "Step." + xp.Attributes["Type"].Value : xp.Name, path);
|
||||||
@@ -233,7 +177,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (xmlNode == null) return null;// No path to match
|
if (xmlNode == null) return null;// No path to match
|
||||||
string xPath = Path(xmlNode);// Build xPath from xmlNode
|
string xPath = Path(xmlNode);// Build xPath from xmlNode
|
||||||
vlnFormatDocument fd = (vlnFormatDocument)(xmlNode.OwnerDocument);//First Get the vlnFormatDocument - This also ties it to a FormatInfo object
|
vlnFormatDocument fd = (vlnFormatDocument)xmlNode.OwnerDocument;//First Get the vlnFormatDocument - This also ties it to a FormatInfo object
|
||||||
while (fd.MyFormat.MyIParent != null)
|
while (fd.MyFormat.MyIParent != null)
|
||||||
{
|
{
|
||||||
fd = fd.MyFormat.MyIParent.PlantFormat.XmlDoc;// Get the parents vlnFormatDocument
|
fd = fd.MyFormat.MyIParent.PlantFormat.XmlDoc;// Get the parents vlnFormatDocument
|
||||||
@@ -256,17 +200,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||||
public class vlnFormatItem
|
public class vlnFormatItem
|
||||||
{
|
{
|
||||||
public vlnFormatItem(XmlNode xmlNode)
|
public vlnFormatItem(XmlNode xmlNode) => XmlNode = xmlNode;
|
||||||
{
|
|
||||||
_XmlNode = xmlNode;
|
|
||||||
}
|
|
||||||
public vlnFormatItem() { }
|
public vlnFormatItem() { }
|
||||||
XmlNode _XmlNode;
|
|
||||||
internal XmlNode XmlNode
|
internal XmlNode XmlNode { get; set; }
|
||||||
{
|
|
||||||
get { return _XmlNode; }
|
|
||||||
set { _XmlNode = value; }
|
|
||||||
}
|
|
||||||
private IFormatOrFormatInfo _MyFormat;
|
private IFormatOrFormatInfo _MyFormat;
|
||||||
public IFormatOrFormatInfo MyFormat
|
public IFormatOrFormatInfo MyFormat
|
||||||
{
|
{
|
||||||
@@ -274,81 +211,29 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (_MyFormat == null)
|
if (_MyFormat == null)
|
||||||
{
|
{
|
||||||
vlnFormatDocument doc = (XmlNode.OwnerDocument) as vlnFormatDocument;
|
if (XmlNode.OwnerDocument is vlnFormatDocument doc)
|
||||||
if(doc != null)
|
|
||||||
_MyFormat = doc.MyFormat;
|
_MyFormat = doc.MyFormat;
|
||||||
}
|
}
|
||||||
return _MyFormat;
|
return _MyFormat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private IFormatOrFormatInfo _MyParentFormat;
|
public IFormatOrFormatInfo MyParentFormat => MyFormat.MyIParent;
|
||||||
public IFormatOrFormatInfo MyParentFormat
|
public virtual string GetPDDisplayName() => ToString();
|
||||||
{
|
public virtual string GetPDName() => ToString();
|
||||||
get
|
public virtual string GetPDDescription() => ToString();
|
||||||
{
|
public virtual string GetPDCategory() => ToString();
|
||||||
return MyFormat.MyIParent;
|
public XmlNodeList SelectNodes(string path) => vlnFormatDocument.LookupNodes(XmlNode, path);
|
||||||
}
|
|
||||||
}
|
|
||||||
public virtual string GetPDDisplayName()
|
|
||||||
{ return ToString(); }
|
|
||||||
public virtual string GetPDName()
|
|
||||||
{ return ToString(); }
|
|
||||||
public virtual string GetPDDescription()
|
|
||||||
{ return ToString(); }
|
|
||||||
public virtual string GetPDCategory()
|
|
||||||
{ return ToString(); }
|
|
||||||
public XmlNodeList SelectNodes(string path)
|
|
||||||
{
|
|
||||||
return vlnFormatDocument.LookupNodes(_XmlNode, path);
|
|
||||||
}
|
|
||||||
public XmlNode SelectSingleNode(string path)
|
public XmlNode SelectSingleNode(string path)
|
||||||
{
|
{
|
||||||
//AdjustLookup(_XmlNode, path);
|
|
||||||
//if(path.Contains("Font")) Console.WriteLine("vlnFormatItem.SelectSingleNode {0},{1}", _XmlNode.Name == "Step" ? "Step." + _XmlNode.Attributes["Type"].Value : _XmlNode.Name, path);
|
//if(path.Contains("Font")) Console.WriteLine("vlnFormatItem.SelectSingleNode {0},{1}", _XmlNode.Name == "Step" ? "Step." + _XmlNode.Attributes["Type"].Value : _XmlNode.Name, path);
|
||||||
return vlnFormatDocument.LookupSingleNode(_XmlNode, path);
|
return vlnFormatDocument.LookupSingleNode(XmlNode, path);
|
||||||
}
|
|
||||||
//public static string _LookUpNode;
|
|
||||||
//private static void AdjustLookup(XmlNode xmlNode,string path)
|
|
||||||
//{
|
|
||||||
// if (xmlNode.Name == "Step")
|
|
||||||
// {
|
|
||||||
// XmlAttribute attr = xmlNode.Attributes["Type"];
|
|
||||||
// if (attr != null) _LookUpNode = attr.Value;
|
|
||||||
// //Console.WriteLine("AdjustLookup Type = {0}/{1}", _LookUpNode, path);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// //Console.WriteLine("AdjustLookup {0}", xmlNode.Name);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
public XmlNode SelectSingleFontNode(string path)
|
|
||||||
{
|
|
||||||
return vlnFormatDocument.LookupSingleFontNode(_XmlNode, path);
|
|
||||||
}
|
|
||||||
public string Lookup(string path)
|
|
||||||
{
|
|
||||||
return vlnFormatDocument.Lookup(_XmlNode, path);
|
|
||||||
}
|
|
||||||
public string Lookup(string path, ref string local)
|
|
||||||
{
|
|
||||||
return (local != null? local : local = Lookup(path));
|
|
||||||
}
|
|
||||||
//public string StepLookup(string path)
|
|
||||||
//{
|
|
||||||
// return vlnFormatDocument.StepLookup(_XmlNode, path);
|
|
||||||
//}
|
|
||||||
public int? IntLookup(string path)
|
|
||||||
{
|
|
||||||
return vlnFormatDocument.IntLookup(_XmlNode, path);
|
|
||||||
}
|
|
||||||
public int? IntLookup(string path, ref int? local)
|
|
||||||
{
|
|
||||||
return (local != null ? local : local = IntLookup(path));
|
|
||||||
}
|
|
||||||
public T EnumLookup<T>(string path)
|
|
||||||
{
|
|
||||||
return vlnFormatDocument.EnumLookup<T>(_XmlNode, path);
|
|
||||||
}
|
}
|
||||||
|
public XmlNode SelectSingleFontNode(string path) => vlnFormatDocument.LookupSingleFontNode(XmlNode, path);
|
||||||
|
public string Lookup(string path) => vlnFormatDocument.Lookup(XmlNode, path);
|
||||||
|
public string Lookup(string path, ref string local) => local ?? (local = Lookup(path));
|
||||||
|
public int? IntLookup(string path) => vlnFormatDocument.IntLookup(XmlNode, path);
|
||||||
|
public int? IntLookup(string path, ref int? local) => local != null ? local : local = IntLookup(path);
|
||||||
|
public T EnumLookup<T>(string path) => vlnFormatDocument.EnumLookup<T>(XmlNode, path);
|
||||||
public bool LazyLoad(ref LazyLoad<bool> ll, string xPath)
|
public bool LazyLoad(ref LazyLoad<bool> ll, string xPath)
|
||||||
{
|
{
|
||||||
if (ll == null)
|
if (ll == null)
|
||||||
@@ -358,11 +243,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
return ll.Value;
|
return ll.Value;
|
||||||
}
|
}
|
||||||
protected static bool RetrieveBool(XmlNode xn)
|
protected static bool RetrieveBool(XmlNode xn) => xn != null && xn.InnerText.ToUpper() == "TRUE";
|
||||||
{
|
// a LazyLoad that allows you to pass in the default setting
|
||||||
return xn != null && xn.InnerText.ToUpper() == "TRUE";
|
|
||||||
}
|
|
||||||
// a LaxyLoad that allows you to pass in the default setting
|
|
||||||
public bool LazyLoad(ref LazyLoad<bool> ll, string xPath, bool defaultReturn)
|
public bool LazyLoad(ref LazyLoad<bool> ll, string xPath, bool defaultReturn)
|
||||||
{
|
{
|
||||||
if (ll == null)
|
if (ll == null)
|
||||||
@@ -373,10 +255,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return ll.Value;
|
return ll.Value;
|
||||||
}
|
}
|
||||||
// if nothing is set for this node, then use the passed in default value
|
// if nothing is set for this node, then use the passed in default value
|
||||||
protected static bool RetrieveBool(XmlNode xn, bool defaultReturn)
|
protected static bool RetrieveBool(XmlNode xn, bool defaultReturn) => (xn != null) ? xn.InnerText.ToUpper() == "TRUE" : defaultReturn;
|
||||||
{
|
|
||||||
return (xn != null) ? xn.InnerText.ToUpper() == "TRUE" : defaultReturn;
|
|
||||||
}
|
|
||||||
public string LazyLoad(ref LazyLoad<string> ll, string xPath)
|
public string LazyLoad(ref LazyLoad<string> ll, string xPath)
|
||||||
{
|
{
|
||||||
if (ll == null)
|
if (ll == null)
|
||||||
@@ -386,16 +265,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
return ll.Value;
|
return ll.Value;
|
||||||
}
|
}
|
||||||
protected static string RetrieveString(XmlNode xn)
|
protected static string RetrieveString(XmlNode xn) => xn?.InnerText;
|
||||||
{
|
|
||||||
return xn != null ? xn.InnerText : null;
|
|
||||||
}
|
|
||||||
public string MyPath
|
public string MyPath
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
XmlNode node = _XmlNode;
|
XmlNode node = XmlNode;
|
||||||
string prefix = "";
|
string prefix = "";
|
||||||
while (node != null)
|
while (node != null)
|
||||||
{
|
{
|
||||||
@@ -429,12 +305,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
int? value = null;
|
int? value = null;
|
||||||
if (xn != null)
|
if (xn != null)
|
||||||
{
|
{
|
||||||
int iValue = 0;
|
if (!int.TryParse(xn.InnerText, out int iValue))
|
||||||
if (!int.TryParse(xn.InnerText, out iValue))
|
|
||||||
{
|
{
|
||||||
if (xn.InnerText == "") return null;
|
if (xn.InnerText == "") return null;
|
||||||
Console.WriteLine(string.Format("'{0}'\r\n'{1}'\r\n'{2}' could not be converted to int?", MyFormat.FullName, MyPath + "/" + xPath, xn.InnerText));
|
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)));
|
throw new Exception(string.Format("{0} = '{1}' could not be converted to int?", xPath, xn.InnerText));
|
||||||
}
|
}
|
||||||
value = iValue;
|
value = iValue;
|
||||||
}
|
}
|
||||||
@@ -445,11 +320,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
float? value = null;
|
float? value = null;
|
||||||
if (xn != null)
|
if (xn != null)
|
||||||
{
|
{
|
||||||
float fValue = 0;
|
if (!float.TryParse(xn.InnerText, out float fValue))
|
||||||
if (!float.TryParse(xn.InnerText, out fValue))
|
|
||||||
{
|
{
|
||||||
Console.WriteLine(string.Format("'{0}'\r\n'{1}'\r\n'{2}' could not be converted to float?", MyFormat.FullName, MyPath + "/" + xPath, xn.InnerText));
|
Console.WriteLine(string.Format("'{0}'\r\n'{1}'\r\n'{2}' could not be converted to float?", MyFormat.FullName, MyPath + "/" + xPath, xn.InnerText));
|
||||||
throw (new Exception(string.Format("{0} = '{1}' could not be converted to float?", xPath, xn.InnerText)));
|
throw new Exception(string.Format("{0} = '{1}' could not be converted to float?", xPath, xn.InnerText));
|
||||||
}
|
}
|
||||||
value = fValue;
|
value = fValue;
|
||||||
}
|
}
|
||||||
@@ -460,8 +334,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (ll == null)
|
if (ll == null)
|
||||||
{
|
{
|
||||||
XmlNode xn = this._XmlNode;
|
XmlNode xn = SelectSingleNode(xPath);
|
||||||
xn = SelectSingleNode(xPath);
|
|
||||||
if (xn == null)
|
if (xn == null)
|
||||||
ll = new LazyLoad<T?>(null);
|
ll = new LazyLoad<T?>(null);
|
||||||
else if (xn.Value == "")// No value specified - Use zero value if it is defined - GetName returns a null if it is not defined
|
else if (xn.Value == "")// No value specified - Use zero value if it is defined - GetName returns a null if it is not defined
|
||||||
@@ -497,16 +370,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
#region LazyLoad
|
#region LazyLoad
|
||||||
public class LazyLoad<T>
|
public class LazyLoad<T>
|
||||||
{
|
{
|
||||||
public LazyLoad(T value)
|
public LazyLoad(T value) => Value = value;
|
||||||
{
|
|
||||||
_Value = value;
|
public T Value { get; set; }
|
||||||
}
|
|
||||||
private T _Value;
|
|
||||||
public T Value
|
|
||||||
{
|
|
||||||
get { return _Value; }
|
|
||||||
set { _Value = value; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region vlnFormatList, new()
|
#region vlnFormatList, new()
|
||||||
@@ -522,8 +388,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_XmlNodeList = value;
|
_XmlNodeList = value;
|
||||||
foreach (XmlNode xn in _XmlNodeList)
|
foreach (XmlNode xn in _XmlNodeList)
|
||||||
{
|
{
|
||||||
T tt = new T();
|
T tt = new T
|
||||||
tt.XmlNode = xn;
|
{
|
||||||
|
XmlNode = xn
|
||||||
|
};
|
||||||
Add(tt);
|
Add(tt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -546,7 +414,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
XmlNode node = _XmlNodeList[0]; // Get the first node in a list
|
XmlNode node = _XmlNodeList[0]; // Get the first node in a list
|
||||||
vlnFormatDocument doc = null;
|
vlnFormatDocument doc = null;
|
||||||
if (node != null)
|
if (node != null)
|
||||||
doc = (node.OwnerDocument) as vlnFormatDocument; // Get the owner document as a vlnFormatDocument
|
doc = node.OwnerDocument as vlnFormatDocument; // Get the owner document as a vlnFormatDocument
|
||||||
if (doc != null)
|
if (doc != null)
|
||||||
_MyFormat = doc.MyFormat; // Get the Format associated with the vlnFormatDocument
|
_MyFormat = doc.MyFormat; // Get the Format associated with the vlnFormatDocument
|
||||||
}
|
}
|
||||||
@@ -558,35 +426,23 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#region ICustomTypeDescriptor
|
#region ICustomTypeDescriptor
|
||||||
public String GetClassName()
|
public string GetClassName() => TypeDescriptor.GetClassName(this, true);
|
||||||
{ return TypeDescriptor.GetClassName(this, true); }
|
public AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
|
||||||
public AttributeCollection GetAttributes()
|
public string GetComponentName() => TypeDescriptor.GetComponentName(this, true);
|
||||||
{ return TypeDescriptor.GetAttributes(this, true); }
|
public TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
|
||||||
public String GetComponentName()
|
public EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
{ return TypeDescriptor.GetComponentName(this, true); }
|
public PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
|
||||||
public TypeConverter GetConverter()
|
public object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
{ return TypeDescriptor.GetConverter(this, true); }
|
public EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
|
||||||
public EventDescriptor GetDefaultEvent()
|
public EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
|
||||||
{ return TypeDescriptor.GetDefaultEvent(this, true); }
|
public object GetPropertyOwner(PropertyDescriptor pd) => this;
|
||||||
public PropertyDescriptor GetDefaultProperty()
|
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
{ 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()
|
public virtual PropertyDescriptorCollection GetProperties()
|
||||||
{
|
{
|
||||||
// Create a collection object to hold property descriptors
|
// Create a collection object to hold property descriptors
|
||||||
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
||||||
// Iterate the list
|
// Iterate the list
|
||||||
int i = 0;
|
for (int i = 0; i < Count; i++)
|
||||||
for (i = 0; i < this.Count; i++)
|
|
||||||
{
|
{
|
||||||
// Create a property descriptor for the item and add to the property descriptor collection
|
// Create a property descriptor for the item and add to the property descriptor collection
|
||||||
pds.Add(new vlnPropertyDescriptor<vlnFormatList<T>, T>(this, i));
|
pds.Add(new vlnPropertyDescriptor<vlnFormatList<T>, T>(this, i));
|
||||||
@@ -601,12 +457,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public class vlnIndexedFormatList<T> : vlnFormatList<T>, ICustomTypeDescriptor
|
public class vlnIndexedFormatList<T> : vlnFormatList<T>, ICustomTypeDescriptor
|
||||||
where T : vlnFormatItem,IVlnIndexedFormatItem, new()
|
where T : vlnFormatItem,IVlnIndexedFormatItem, new()
|
||||||
{
|
{
|
||||||
public vlnIndexedFormatList(XmlNodeList xmlNodeList,IFormatOrFormatInfo myFormat) : base(xmlNodeList)
|
public vlnIndexedFormatList(XmlNodeList xmlNodeList, IFormatOrFormatInfo myFormat) : base(xmlNodeList) => MyFormat = myFormat;
|
||||||
{
|
|
||||||
MyFormat = myFormat;
|
|
||||||
}
|
|
||||||
public vlnIndexedFormatList() : base() { }
|
public vlnIndexedFormatList() : base() { }
|
||||||
public virtual vlnIndexedFormatList<T> InheritedList { get { return null; } }
|
public virtual vlnIndexedFormatList<T> InheritedList => null;
|
||||||
public new T this[int index]
|
public new T this[int index]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -620,8 +473,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (ttlParent != null)
|
if (ttlParent != null)
|
||||||
return ttlParent[index];
|
return ttlParent[index];
|
||||||
return null;
|
return null;
|
||||||
// None found - Can I find it in another format?
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int MaxIndex
|
public int MaxIndex
|
||||||
@@ -658,35 +509,24 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#region ICustomTypeDescriptor
|
#region ICustomTypeDescriptor
|
||||||
public String GetClassName()
|
public new string GetClassName() => TypeDescriptor.GetClassName(this, true);
|
||||||
{ return TypeDescriptor.GetClassName(this, true); }
|
public new AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
|
||||||
public AttributeCollection GetAttributes()
|
public new string GetComponentName() => TypeDescriptor.GetComponentName(this, true);
|
||||||
{ return TypeDescriptor.GetAttributes(this, true); }
|
public new TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
|
||||||
public String GetComponentName()
|
public new EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
{ return TypeDescriptor.GetComponentName(this, true); }
|
public new PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
|
||||||
public TypeConverter GetConverter()
|
public new object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
{ return TypeDescriptor.GetConverter(this, true); }
|
public new EventDescriptorCollection GetEvents(Attribute[] attributes)
|
||||||
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); }
|
{ return TypeDescriptor.GetEvents(this, attributes, true); }
|
||||||
public EventDescriptorCollection GetEvents()
|
public new EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
|
||||||
{ return TypeDescriptor.GetEvents(this, true); }
|
public new object GetPropertyOwner(PropertyDescriptor pd) => this;
|
||||||
public object GetPropertyOwner(PropertyDescriptor pd)
|
public new PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
{ return this; }
|
public new virtual PropertyDescriptorCollection GetProperties()
|
||||||
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
|
||||||
{ return GetProperties(); }
|
|
||||||
public virtual PropertyDescriptorCollection GetProperties()
|
|
||||||
{
|
{
|
||||||
// Create a collection object to hold property descriptors
|
// Create a collection object to hold property descriptors
|
||||||
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
||||||
// Iterate the list
|
// Iterate the list
|
||||||
int i = 0;
|
for (int i = 0; i < Count; i++)
|
||||||
for (i = 0; i < this.Count; i++)
|
|
||||||
{
|
{
|
||||||
// Create a property descriptor for the item and add to the property descriptor collection
|
// Create a property descriptor for the item and add to the property descriptor collection
|
||||||
pds.Add(new vlnPropertyDescriptor<vlnFormatList<T>, T>(this, i));
|
pds.Add(new vlnPropertyDescriptor<vlnFormatList<T>, T>(this, i));
|
||||||
@@ -702,13 +542,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
where T : vlnFormatItem, IVlnNamedFormatItem, new()
|
where T : vlnFormatItem, IVlnNamedFormatItem, new()
|
||||||
{
|
{
|
||||||
public vlnNamedFormatList(XmlNodeList xmlNodeList, IFormatOrFormatInfo myFormat)
|
public vlnNamedFormatList(XmlNodeList xmlNodeList, IFormatOrFormatInfo myFormat)
|
||||||
: base(xmlNodeList)
|
: base(xmlNodeList) => MyFormat = myFormat;
|
||||||
{
|
|
||||||
MyFormat = myFormat;
|
|
||||||
}
|
|
||||||
public vlnNamedFormatList() : base() { }
|
public vlnNamedFormatList() : base() { }
|
||||||
public virtual vlnNamedFormatList<T> InheritedList { get { return null; } }
|
public virtual vlnNamedFormatList<T> InheritedList => null;
|
||||||
public new T this[string name]
|
public T this[string name]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -721,8 +558,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (ttlParent != null)
|
if (ttlParent != null)
|
||||||
return ttlParent[name];
|
return ttlParent[name];
|
||||||
return null;
|
return null;
|
||||||
// None found - Can I find it in another format?
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public new T this[int index]
|
public new T this[int index]
|
||||||
@@ -735,47 +570,27 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (ttlParent != null)
|
if (ttlParent != null)
|
||||||
return ttlParent[index];
|
return ttlParent[index];
|
||||||
return null;
|
return null;
|
||||||
// None found - Can I find it in another format?
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public new int Count
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return base.Count;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public new int Count => base.Count;
|
||||||
#region ICustomTypeDescriptor
|
#region ICustomTypeDescriptor
|
||||||
public String GetClassName()
|
public new string GetClassName() => TypeDescriptor.GetClassName(this, true);
|
||||||
{ return TypeDescriptor.GetClassName(this, true); }
|
public new AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
|
||||||
public AttributeCollection GetAttributes()
|
public new string GetComponentName() => TypeDescriptor.GetComponentName(this, true);
|
||||||
{ return TypeDescriptor.GetAttributes(this, true); }
|
public new TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
|
||||||
public String GetComponentName()
|
public new EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
{ return TypeDescriptor.GetComponentName(this, true); }
|
public new PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
|
||||||
public TypeConverter GetConverter()
|
public new object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
{ return TypeDescriptor.GetConverter(this, true); }
|
public new EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
|
||||||
public EventDescriptor GetDefaultEvent()
|
public new EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
|
||||||
{ return TypeDescriptor.GetDefaultEvent(this, true); }
|
public new object GetPropertyOwner(PropertyDescriptor pd) => this;
|
||||||
public PropertyDescriptor GetDefaultProperty()
|
public new PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
{ return TypeDescriptor.GetDefaultProperty(this, true); }
|
public new virtual PropertyDescriptorCollection GetProperties()
|
||||||
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
|
// Create a collection object to hold property descriptors
|
||||||
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
|
||||||
// Iterate the list
|
// Iterate the list
|
||||||
int i = 0;
|
for (int i = 0; i < Count; i++)
|
||||||
for (i = 0; i < this.Count; i++)
|
|
||||||
{
|
{
|
||||||
// Create a property descriptor for the item and add to the property descriptor collection
|
// Create a property descriptor for the item and add to the property descriptor collection
|
||||||
pds.Add(new vlnPropertyDescriptor<vlnFormatList<T>, T>(this, i));
|
pds.Add(new vlnPropertyDescriptor<vlnFormatList<T>, T>(this, i));
|
||||||
@@ -793,16 +608,16 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
private string Plural(string name)
|
private string Plural(string name)
|
||||||
{
|
{
|
||||||
if (name.EndsWith("y")) return name.Substring(0, name.Length - 1) + "ies";
|
if (name.EndsWith("y")) return $"{name.Substring(0, name.Length - 1)}ies";
|
||||||
if (name.EndsWith("ss")) return name + "es";
|
if (name.EndsWith("ss")) return $"{name}es";
|
||||||
else return name + "s";
|
else return $"{name}s";
|
||||||
}
|
}
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is T)
|
if (destType == typeof(string) && value is T vart)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((T)value).Count.ToString() + " " + (((T)value).Count == 1 ? typeof(C).Name : Plural(typeof(C).Name));
|
return $"{vart.Count} {(vart.Count == 1 ? typeof(C).Name : Plural(typeof(C).Name))}";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
@@ -815,17 +630,16 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
private string Plural(string name)
|
private string Plural(string name)
|
||||||
{
|
{
|
||||||
if (name.EndsWith("y")) return name.Substring(0, name.Length - 1) + "ies";
|
if (name.EndsWith("y")) return $"{name.Substring(0, name.Length - 1)}ies";
|
||||||
if (name.EndsWith("ss")) return name + "es";
|
if (name.EndsWith("ss")) return $"{name}es";
|
||||||
if (name.EndsWith("x")) return name + "es";
|
return name.EndsWith("x") ? $"{name}es" : $"{name}s";
|
||||||
else return name + "s";
|
|
||||||
}
|
}
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||||
{
|
{
|
||||||
if (destType == typeof(string) && value is T)
|
if (destType == typeof(string) && value is T vart)
|
||||||
{
|
{
|
||||||
// Return department and department role separated by comma.
|
// Return department and department role separated by comma.
|
||||||
return ((T)value).MaxIndex.ToString() + " " + (((T)value).MaxIndex == 1 ? typeof(C).Name : Plural(typeof(C).Name));
|
return $"{vart.MaxIndex} {(vart.MaxIndex == 1 ? typeof(C).Name : Plural(typeof(C).Name))}";
|
||||||
}
|
}
|
||||||
return base.ConvertTo(context, culture, value, destType);
|
return base.ConvertTo(context, culture, value, destType);
|
||||||
}
|
}
|
||||||
@@ -838,36 +652,21 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
protected C _Item = null;
|
protected C _Item = null;
|
||||||
public vlnPropertyDescriptor(T itemList, int index)
|
public vlnPropertyDescriptor(T itemList, int index)
|
||||||
: base("#" + index.ToString(), null)
|
: base("#" + index.ToString(), null) => _Item = itemList[index];
|
||||||
{
|
public override bool CanResetValue(object component) => true;
|
||||||
_Item = itemList[index];
|
public override Type ComponentType => _Item.GetType();
|
||||||
}
|
public override object GetValue(object component) => _Item;
|
||||||
public override bool CanResetValue(object component)
|
public override bool IsReadOnly => true;
|
||||||
{ return true; }
|
public override Type PropertyType => _Item.GetType();
|
||||||
public override Type ComponentType
|
|
||||||
{ get { return _Item.GetType(); } }
|
|
||||||
public override object GetValue(object component)
|
|
||||||
{ return _Item; }
|
|
||||||
public override bool IsReadOnly
|
|
||||||
{ get { return true; } }
|
|
||||||
public override Type PropertyType
|
|
||||||
{ get { return _Item.GetType(); } }
|
|
||||||
public override void ResetValue(object component)
|
public override void ResetValue(object component)
|
||||||
{ ;}
|
{ ;}
|
||||||
public override bool ShouldSerializeValue(object component)
|
public override bool ShouldSerializeValue(object component) => true;
|
||||||
{ return true; }
|
|
||||||
public override void SetValue(object component, object value)
|
public override void SetValue(object component, object value)
|
||||||
{ /*_Item = value*/;}
|
{ /*_Item = value*/;}
|
||||||
//public override AttributeCollection Attributes
|
public override string DisplayName => _Item.GetPDDisplayName();
|
||||||
//{ get { return new AttributeCollection(null); } }
|
public override string Description => _Item.GetPDDescription();
|
||||||
public override string DisplayName
|
public override string Name => _Item.GetPDName();
|
||||||
{ get { return _Item.GetPDDisplayName(); } }
|
public override string Category => _Item.GetPDCategory();
|
||||||
public override string Description
|
|
||||||
{ get { return _Item.GetPDDescription(); } }
|
|
||||||
public override string Name
|
|
||||||
{ get { return _Item.GetPDName(); } }
|
|
||||||
public override string Category
|
|
||||||
{ get { return _Item.GetPDCategory(); } }
|
|
||||||
} // Class
|
} // Class
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user