Nexus.Client.ModManagement.Scripting.XmlScript.CPL.CPLConverter.BuildCompositeCondition C# (CSharp) Method

BuildCompositeCondition() protected method

protected BuildCompositeCondition ( ITree p_astCPL ) : ICondition
p_astCPL ITree
return ICondition
		protected virtual ICondition BuildCompositeCondition(ITree p_astCPL)
		{
			switch (p_astCPL.Type)
			{
				case CPLParser.AND:
					CompositeCondition cpcAndCondition = new CompositeCondition(ConditionOperator.And);
					for (Int32 i = 0; i < p_astCPL.ChildCount; i++)
						cpcAndCondition.Conditions.Add(BuildCompositeCondition(p_astCPL.GetChild(i)));
					return cpcAndCondition;
				case CPLParser.OR:
					CompositeCondition cpcOrCondition = new CompositeCondition(ConditionOperator.Or);
					for (Int32 i = 0; i < p_astCPL.ChildCount; i++)
						cpcOrCondition.Conditions.Add(BuildCompositeCondition(p_astCPL.GetChild(i)));
					return cpcOrCondition;
				case CPLParser.EQUALS:
					string strFlagName = p_astCPL.GetChild(0).Text.Trim('$');
					string strFlagValue = p_astCPL.GetChild(1).Text.Trim('"');
					FlagCondition flcCondition = new FlagCondition(strFlagName, strFlagValue);
					return flcCondition;
				case CPLParser.IS:
					string strPluginPath = p_astCPL.GetChild(0).Text.Trim('"');
					string strState = p_astCPL.GetChild(1).Text.ToUpperInvariant();
					strState = strState[0] + strState.Remove(0, 1).ToLowerInvariant();
					PluginState pnsState = (PluginState)Enum.Parse(typeof(PluginState), strState);
					PluginCondition pncCondition = new PluginCondition(strPluginPath, pnsState);
					return pncCondition;
				case CPLParser.ATLEAST:
					string strVersion = p_astCPL.GetChild(1).Text;
					if (!strVersion.Contains("."))
						strVersion += ".0";
					Version verVersion = new Version(strVersion);
					switch (p_astCPL.GetChild(0).Type)
					{
						case CPLParser.GAME_VERSION:
							return new GameVersionCondition(verVersion);
						case CPLParser.MANAGER_VERSION:
							return new ModManagerCondition(verVersion);
					}
					throw new Exception("Unknown: " + p_astCPL.Text);
				default:
					throw new Exception("Unknown: " + p_astCPL.Text);
			}
		}