Ejemplo n.º 1
0
        internal static Expression GetExpression(IExpressionResponse expr)
        {
            if (null == expr)
                throw new ArgumentNullException("expr");

            Expression expression = new Expression();

            expression.Description = expr.Description;
            expression.Name = expr.Name;
            expression.Rating = expr.Rating;
            expression.Triggered = expr.Triggered;

            expression.ExpressionDetails = new CustomProperty[0];
            int index = 0;
            if (expr.ExpressionDetailCollection != null && expr.ExpressionDetailCollection.Count > 0)
            {
                expression.ExpressionDetails = new CustomProperty[expr.ExpressionDetailCollection.Count];
                foreach (IExpressionDetail detail in expr.ExpressionDetailCollection)
                {
                    expression.ExpressionDetails[index++] = new CustomProperty(detail.Name, detail.Value);
                }
            }

            expression.Properties = new CustomProperty[0];
            if ( expr.Properties != null && expr.Properties.Count > 0)
            {
                index = 0;
                expression.Properties = new CustomProperty[expr.Properties.Count];
                foreach (string key in expr.Properties.Keys)
                {
                    expression.Properties[index++] = new CustomProperty(key, expr.Properties[key]);
                }
            }

            return expression;
        }
Ejemplo n.º 2
0
		private void AddExpressionInfo(IExpressionResponse expressionInfo)
		{
			if (m_CurrentFileInfo.PolicySetCollection == null || m_CurrentFileInfo.PolicySetCollection.Count == 0)
				throw new PolicyEngineException("Unable to audit policy information as no policy collection exists");
			PolicyResponse pi = GetLatestPolicyInfoSet()[GetLatestPolicyInfoSet().Count - 1] as PolicyResponse;
			if (pi.ExpressionCollection == null)
				pi.ExpressionCollection = new Collection<IExpressionResponse>();
			pi.ExpressionCollection.Add(expressionInfo);
		}