protected void DoParseInternal(XmlElement element, ObjectDefinitionBuilder builder) { builder.SetSingleton(false); string leftMenu = element.GetAttribute("menu"); if(!string.IsNullOrEmpty(leftMenu)) builder.AddPropertyReference("Menu", leftMenu); string rightScreen = element.GetAttribute("screen"); if(!string.IsNullOrEmpty(rightScreen)) builder.AddPropertyReference("MainScreen", rightScreen); foreach (XmlNode node in element.ChildNodes) { if (node is XmlComment) continue; switch (node.LocalName.ToLower()) { case "steps": XmlNodeList steps = node.ChildNodes; if (steps.Count > 0) // if flow is configured with a list of steps { IDictionary stepsDic = new System.Collections.Hashtable(); int count = 0; foreach (XmlNode step in steps) { if(step is XmlComment) continue; if (!step.LocalName.ToLower().Equals("step")) { throw new Exception("Do not support node with name " + node.Name + " in config file."); } string key = "Step" + (++count).ToString(); stepsDic[key] = step.InnerText; } builder.AddPropertyValue("FlowSteps", stepsDic); } break; case "session": string sessionRefBeanName = node.InnerText; if(!string.IsNullOrEmpty(sessionRefBeanName)) { builder.AddDependsOn(sessionRefBeanName); builder.AddPropertyReference("Session", sessionRefBeanName); } break; case "menu": string menuClassName = node.InnerText; builder.AddPropertyValue("MenuClass", Type.GetType(menuClassName)); break; case "screen": string screenClassName = node.InnerText; builder.AddPropertyValue("MainScreenClass", Type.GetType(screenClassName)); break; default: throw new Exception("Do not support node with name " + node.Name + " in config file."); break; } } }
public void ObjectTypeWithSimpleProperty() { string[] dependsOn = new string[] { "A", "B", "C" }; ObjectDefinitionBuilder odb = ObjectDefinitionBuilder.RootObjectDefinition(odf, typeof(TestObject)); odb.SetSingleton(false).AddPropertyReference("Age", "15"); foreach (string dep in dependsOn) { odb.AddDependsOn(dep); } RootObjectDefinition rod = odb.ObjectDefinition as RootObjectDefinition; Assert.IsNotNull(rod); Assert.IsFalse(rod.IsSingleton); Assert.AreEqual(typeof(TestObject), rod.ObjectType); Assert.AreEqual(dependsOn, rod.DependsOn, "DependsOn not as expected"); Assert.IsTrue(rod.PropertyValues.Contains("Age")); }