Exemplo n.º 1
0
 private void zRecursiveClearVariable(IStateVariable stateVariable)
 {
     if (stateVariable is ObjectStateVariable)
     {
         ObjectStateVariable objectStateVariable = (ObjectStateVariable)stateVariable;
         zRecursiveClearStateVariableCollection(objectStateVariable.Value.Values);
         objectStateVariable.Value.Clear();
     }
     if (stateVariable is ListStateVariable)
     {
         ListStateVariable listStateVariable = (ListStateVariable)stateVariable;
         zRecursiveClearStateVariableCollection(listStateVariable.Value);
         listStateVariable.Value.Clear();
     }
 }
Exemplo n.º 2
0
 private void zToXmlRecursive(IStateVariable stateVariable, XmlWriter xWriter, bool isList)
 {
     if (stateVariable.XMLFieldOutputMode != XMLFieldOutputMode.None)
     {
         string nodeName = isList && stateVariable is ObjectStateVariable
             ? ((ObjectStateVariable)stateVariable).ObjectClassName
             : stateVariable.Name;
         if (stateVariable.XMLFieldOutputMode == XMLFieldOutputMode.Element)
         {
             xWriter.WriteStartElement(nodeName);
         }
         else
         {
             xWriter.WriteStartAttribute(nodeName);
         }
         if (stateVariable is ListStateVariable)
         {
             foreach (IStateVariable childVariable in ((ListStateVariable)stateVariable).Value)
             {
                 zToXmlRecursive(childVariable, xWriter, true);
             }
         }
         else if (stateVariable is ObjectStateVariable)
         {
             foreach (IStateVariable memberVariable in ((ObjectStateVariable)stateVariable).Value.Values)
             {
                 zToXmlRecursive(memberVariable, xWriter, false);
             }
         }
         else
         {
             xWriter.WriteString(stateVariable.ValueAsString());
         }
         if (stateVariable.XMLFieldOutputMode == XMLFieldOutputMode.Element)
         {
             xWriter.WriteEndElement();
         }
         else
         {
             xWriter.WriteEndAttribute();
         }
     }
 }
        public bool EvaulateExpression(ExpressionNode expression, DataScope dataScope)
        {
            IStateVariable variable1 = dataScope.GetStateVariable(expression.StateVariable);

            if (variable1 == null)
            {
                throw zGetMissingVariableException(expression, false);
            }
            string strValue1 = variable1.ValueAsString();
            T      value1;

            if (!zGetTypeData(strValue1, out value1))
            {
                throw zGetFormatException(strValue1);
            }

            string strValue2;

            if (expression.VariableAsValue)
            {
                IStateVariable variable2 = dataScope.GetStateVariable(expression.Value);
                if (variable2 == null)
                {
                    throw zGetMissingVariableException(expression, true);
                }
                strValue2 = variable2.ValueAsString();
            }
            else
            {
                strValue2 = expression.Value;
            }
            T value2;

            if (!zGetTypeData(strValue2, out value2))
            {
                throw zGetFormatException(strValue2);
            }

            bool result = zEvaluateExpression(expression, value1, value2);

            return(expression.Negated ? !result : result);
        }
Exemplo n.º 4
0
        public void SetStateVariable(string stateVariableName, IStateVariable stateVariable)
        {
            if (!String.IsNullOrEmpty(stateVariableName) && stateVariable != null)
            {
                if (m_StateVariables.Count == 0)
                {
                    this.Add(m_CurrentScopeName, new Dictionary <string, IStateVariable>());
                }

                string scopeNamePart;
                string variableNamePart;
                DataUtils.ParseStateVariableName(m_CurrentScopeName, stateVariableName, out scopeNamePart, out variableNamePart);

                Dictionary <string, IStateVariable> scopedStateVariables;
                if (!m_StateVariables.TryGetValue(scopeNamePart, out scopedStateVariables))
                {
                    throw new ArgumentException(String.Format("Data Scope \"{0}\" was not found.", scopeNamePart));
                }
                scopedStateVariables[variableNamePart] = stateVariable;
            }
        }