Updates to inheritance logic
This commit is contained in:
parent
c549e65bf5
commit
f17a7d9b06
@ -58,6 +58,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (xn != null) return xn;
|
if (xn != null) return xn;
|
||||||
//if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleNode {0},{1}", xmlNode.Name == "Step" ? "Step." + xmlNode.Attributes["Type"].Value : xmlNode.Name, path);
|
//if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleNode {0},{1}", xmlNode.Name == "Step" ? "Step." + xmlNode.Attributes["Type"].Value : xmlNode.Name, path);
|
||||||
if (xmlNode.Name == "Step") xn = LookupSingleStepNode(xmlNode, path); // Check for Step Inheritance
|
if (xmlNode.Name == "Step") xn = LookupSingleStepNode(xmlNode, path); // Check for Step Inheritance
|
||||||
|
if (xmlNode.ParentNode.Name == "Step")
|
||||||
|
xn = LookupSingleStepNode(xmlNode.ParentNode, xmlNode.Name + "/" + path); // Check for Step Inheritance
|
||||||
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);
|
||||||
@ -92,20 +94,23 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
//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;
|
tmpNode = xmlNode;
|
||||||
|
// 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) // Cannot find ParentType so do an InheritanceLookup
|
if (attr == null || attr.Value == string.Empty) // Cannot find ParentType so do an InheritanceLookup
|
||||||
return InheritLookup(xmlNode, path, false);
|
|
||||||
xmlNode = xmlNode.ParentNode.SelectSingleNode(string.Format("Step[@Type='{0}']", xmlNode.Attributes["ParentType"].InnerText));
|
|
||||||
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);
|
return InheritLookup(tmpNode2, path, true);
|
||||||
}
|
//return InheritLookup(xmlNode, path, false);
|
||||||
|
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;
|
||||||
@ -380,8 +385,16 @@ namespace VEPROMS.CSLA.Library
|
|||||||
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
|
||||||
ll = new LazyLoad<Nullable<T>>(Enum.GetName(typeof(T), 0) != null ? (Nullable<T>) Enum.Parse(typeof(T), "0") : null);
|
ll = new LazyLoad<Nullable<T>>(Enum.GetName(typeof(T), 0) != null ? (Nullable<T>) Enum.Parse(typeof(T), "0") : null);
|
||||||
else
|
else
|
||||||
|
try
|
||||||
|
{
|
||||||
ll = new LazyLoad<Nullable<T>>((Nullable<T>)Enum.Parse(typeof(T), xn.InnerText));
|
ll = new LazyLoad<Nullable<T>>((Nullable<T>)Enum.Parse(typeof(T), xn.InnerText));
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("{0} - '{1}'", ex.Message, xn.InnerText);
|
||||||
|
ll = new LazyLoad<T?>(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
return ll.Value;
|
return ll.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user