Esempio n. 1
0
        internal static IExpressionResponse GetIExpressionResponse(Expression expIn)
        {
            ExpressionResponse expOut = new ExpressionResponse();

            expOut.Description = expIn.Description;
            expOut.Name = expIn.Name;
            expOut.Rating = expIn.Rating;
            expOut.Triggered = expIn.Triggered;
            
            expOut.ExpressionDetailCollection = new Collection<IExpressionDetail>();
            if ( expIn.ExpressionDetails != null)
            {
                foreach (CustomProperty prop in expIn.ExpressionDetails)
                {
                    expOut.ExpressionDetailCollection.Add(new ExpressionDetail(prop.Name,prop.Value));
                }
            }

            if ( expIn.Properties != null)
            {
                foreach (CustomProperty property in expIn.Properties)
                {
                    expOut.Properties[property.Name] = property.Value;
                }
            }

            return expOut;
        }
		private object ConditionLinePassedHandler(IBRERuleContext aBrc, Hashtable aMap, object aStep)
		{
			if (m_CurrentFileInfo.PolicySetCollection == null || m_CurrentFileInfo.PolicySetCollection.Count == 0)
				throw new PolicyEngineException("Unable to audit expression information as no policy collection exists");

			ExpressionResponse expressionInfo = new ExpressionResponse();

			expressionInfo.Name = GetName(aMap);

			if (aMap.ContainsKey("Rating"))
				expressionInfo.Rating = aMap["Rating"] as string;

			expressionInfo.Triggered = false;

			if (aMap.Contains("Description"))
				expressionInfo.Description = aMap["Description"] as string;

			expressionInfo.ExpressionDetailCollection = new Collection<IExpressionDetail>();

			AddExpressionInfo(expressionInfo);

			return null;
		}
		private object ConditionLineFiredHandler(IBRERuleContext aBrc, Hashtable aMap, object aStep)
		{
			if (m_CurrentFileInfo.PolicySetCollection == null || m_CurrentFileInfo.PolicySetCollection.Count == 0)
				throw new PolicyEngineException("Unable to audit expression information as no rule collection exists");

			ExpressionResponse expressionInfo = new ExpressionResponse();

			expressionInfo.Name = GetName(aMap);

			if (aMap.ContainsKey("Rating"))
				expressionInfo.Rating = aMap["Rating"] as string;
			expressionInfo.Triggered = true;

			if (aMap.Contains("Description"))
				expressionInfo.Description = aMap["Description"] as string;

			OnPolicyProgressEvent(new PolicyProgressEventArgs(m_CurrentFileInfo.File, EventType.condition, expressionInfo.Name));

			expressionInfo.ExpressionDetailCollection = new Collection<IExpressionDetail>();

			foreach (DictionaryEntry de in aMap)
			{
				if ((string.Compare(de.Key as string, "Type", true, CultureInfo.InvariantCulture) == 0) ||
					(string.Compare(de.Key as string, "Name", true, CultureInfo.InvariantCulture) == 0) ||
					(string.Compare(de.Key as string, "Description", true, CultureInfo.InvariantCulture) == 0) ||
					(string.Compare(de.Key as string, "Rating", true, CultureInfo.InvariantCulture) == 0))
					continue;

				if (string.Compare(de.Key as string, "Properties", true, CultureInfo.InvariantCulture) == 0)
				{
					DictionaryEntry[] props = de.Value as DictionaryEntry[];
					foreach (DictionaryEntry dictprop in props)
					{
						if (dictprop.Key == null || dictprop.Value == null)
							continue;

						string name = dictprop.Key as string;
						string value = dictprop.Value as string;

						expressionInfo.ExpressionDetailCollection.Add(new ExpressionDetail(name, value));
					}
					continue;
				}
				expressionInfo.ExpressionDetailCollection.Add(new ExpressionDetail(de.Key as string, de.Value as string));
			}
			AddExpressionInfo(expressionInfo);

			return null;
		}