Spring.Objects.Factory.Support.ObjectDefinitionBuilder.AddDependsOn C# (CSharp) Method

AddDependsOn() public method

Adds the specified object name to the list of objects that this definition depends on.
public AddDependsOn ( string objectName ) : ObjectDefinitionBuilder
objectName string Name of the object.
return ObjectDefinitionBuilder
        public ObjectDefinitionBuilder AddDependsOn(string objectName)
        {
            if (objectDefinition.DependsOn == null)
            {
                objectDefinition.DependsOn = new string[] {objectName};
            }
            else
            {
                List<string> arrayList = new List<string>();
                arrayList.AddRange(objectDefinition.DependsOn);
                arrayList.AddRange(new string[]{ objectName});
                objectDefinition.DependsOn = arrayList;
            }
            return this;
        }

Usage Example

        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;
                }
            }
        }
All Usage Examples Of Spring.Objects.Factory.Support.ObjectDefinitionBuilder::AddDependsOn