/// <summary> /// Adds the filter action. /// </summary> /// <param name="filterAction">The filter action.</param> public void AddFilterAction(FilterActionElement filterAction) { if (filterAction == null) { throw new ArgumentNullException("filterAction"); } _filterActions.Add(filterAction); }
public void FlowBehaviorTest() { FilterActionElement target = new FilterActionElement(); int val = 0; // TODO: Assign to an appropriate value for the property target.FlowBehavior = val; Assert.AreEqual(val, target.FlowBehavior, "Composestar.StarLight.Entities.Configuration.FilterActionElement.FlowBehavior was" + " not set correctly."); Assert.Inconclusive("Verify the correctness of this test method."); }
public void AssemblyTest() { FilterActionElement target = new FilterActionElement(); string val = null; // TODO: Assign to an appropriate value for the property target.Assembly = val; Assert.AreEqual(val, target.Assembly, "Composestar.StarLight.Entities.Configuration.FilterActionElement.Assembly was not" + " set correctly."); Assert.Inconclusive("Verify the correctness of this test method."); }
/// <summary> /// Extracts the filter action. /// </summary> /// <param name="type">The type.</param> private void ExtractFilterAction(TypeDefinition type) { // We use .NET reflection here, because Cecil can not read the enumerations // TODO Loading an assembly locks the assembly for the duration of the appdomain. // The weaver can no loner access the file to weave in it. // We now use ShadowCopy to overcome this. It is an obsolete method // Switch to a separate appdomain. SetupReflectionAssembly(type.Module.Image.FileInformation.Directory.FullName); Assembly assembly = Assembly.LoadFrom(type.Module.Image.FileInformation.FullName); if (assembly == null) { throw new ILAnalyzerException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.CouldNotFindAssembly, type.Module.Image.FileInformation.FullName)); } Type refType = assembly.GetType(type.FullName); if (refType == null) { throw new ILAnalyzerException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.CouldNotFindType, type.FullName)); } FilterActionElement faEl = null; FilterActionAttribute[] faas = (FilterActionAttribute[])refType.GetCustomAttributes(typeof(FilterActionAttribute), true); foreach (FilterActionAttribute faa in faas) { if (faEl != null) { continue; } faEl = new FilterActionElement(); faEl.FullName = type.FullName; faEl.Name = faa.ActionName; faEl.Assembly = type.Module.Assembly.Name.ToString(); switch (faa.FlowBehavior) { case FilterActionAttribute.FilterFlowBehavior.Continue: faEl.FlowBehavior = FilterActionElement.FlowContinue; break; case FilterActionAttribute.FilterFlowBehavior.Exit: faEl.FlowBehavior = FilterActionElement.FlowExit; break; case FilterActionAttribute.FilterFlowBehavior.Return: faEl.FlowBehavior = FilterActionElement.FlowReturn; break; default: faEl.FlowBehavior = FilterActionElement.FlowContinue; break; } switch (faa.SubstitutionBehavior) { case FilterActionAttribute.MessageSubstitutionBehavior.Original: faEl.MessageChangeBehavior = FilterActionElement.MessageOriginal; break; case FilterActionAttribute.MessageSubstitutionBehavior.Substituted: faEl.MessageChangeBehavior = FilterActionElement.MessageSubstituted; break; case FilterActionAttribute.MessageSubstitutionBehavior.Any: faEl.MessageChangeBehavior = FilterActionElement.MessageAny; break; default: faEl.MessageChangeBehavior = FilterActionElement.MessageOriginal; break; } faEl.CreateJPC = faa.CreateJoinPointContext; } if (faEl != null) { ResourceOperationAttribute[] roas = (ResourceOperationAttribute[])refType.GetCustomAttributes(typeof(ResourceOperationAttribute), true); foreach (ResourceOperationAttribute roa in roas) { faEl.ResourceOperations = roa.Sequence; } _filterActions.Add(faEl); } type = null; assembly = null; return; }