public void Setup() { matchingRuleData = new MemberNameMatchingRuleData( "member", new[] { new MatchData("foo", true), new MatchData("bar", false) }); }
protected static MatchingRuleData SerializeAndDeserializeMatchingRule(MatchingRuleData typeMatchingRule) { PolicyData policy = new PolicyData("policy"); policy.MatchingRules.Add(typeMatchingRule); PolicyInjectionSettings settings = new PolicyInjectionSettings(); settings.Policies.Add(policy); Dictionary <string, ConfigurationSection> sections = new Dictionary <string, ConfigurationSection>(); sections.Add(PolicyInjectionSettings.SectionName, settings); IConfigurationSource configurationSource = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections); PolicyInjectionSettings deserializedSection = configurationSource.GetSection(PolicyInjectionSettings.SectionName) as PolicyInjectionSettings; Assert.IsNotNull(deserializedSection); PolicyData deserializedPolicy = deserializedSection.Policies.Get(0); Assert.IsNotNull(deserializedPolicy); return(deserializedPolicy.MatchingRules.Get(0)); }
public void Setup() { matchingRuleData = new CustomAttributeMatchingRuleData( "custom attribute", typeof(CLSCompliantAttribute).AssemblyQualifiedName, true); }
public void Setup() { matchingRuleData = new CustomMatchingRuleData("custom", typeof(AlwaysMatchingRule).AssemblyQualifiedName) { Attributes = { { "foo", "bar" }, { "bar", "baz" } } }; }
public void Setup() { matchingRuleData = new TagAttributeMatchingRuleData("tag", "match") { IgnoreCase = true }; }
public void Setup() { matchingRuleData = new ReturnTypeMatchingRuleData("returnType", typeof(object).FullName) { IgnoreCase = true }; }
public void Setup() { matchingRuleData = new CustomAttributeMatchingRuleData( "custom attribute", typeof(InjectionMethodAttribute).AssemblyQualifiedName, true); }
public void Setup() { matchingRuleData = new PropertyMatchingRuleData("properties") { Matches = { new PropertyMatchData("foo", PropertyMatchingOption.Get, true), new PropertyMatchData("bar", PropertyMatchingOption.Set, false) } }; }
public void Setup() { matchingRuleData = new ParameterTypeMatchingRuleData("parameters") { Matches = { new ParameterTypeMatchData("foo", ParameterKind.Input, true), new ParameterTypeMatchData("bar", ParameterKind.ReturnValue, false) } }; }
public void Setup() { matchingRuleData = new NamespaceMatchingRuleData("namespace") { Matches = { new MatchData("foo", true), new MatchData("bar", false) } }; }
public void Setup() { matchingRuleData = new ParameterTypeMatchingRuleData("parameters") { Matches = { new ParameterTypeMatchData(typeof(int).FullName, ParameterKind.Input, true), new ParameterTypeMatchData(typeof(string).FullName, ParameterKind.ReturnValue, false) } }; }
public void CanSerializeConfigurationFixture() { PolicyInjectionSettings settings = new PolicyInjectionSettings(); PolicyData policy1 = new PolicyData(policy1Name); PolicyData policy2 = new PolicyData(policy2Name); settings.Policies.Add(policy1); settings.Policies.Add(policy2); CustomCallHandlerData handler1 = new CustomCallHandlerData(handler1Name, typeof(CallCountHandler)); handler1.SetAttributeValue("customHandlerAttribute", "customHandlerAttributeValue"); CustomMatchingRuleData customMatchingRule = new CustomMatchingRuleData(matchingRule1Name, typeof(TypeMatchingAssignmentRule)); customMatchingRule.SetAttributeValue("customMatchingRuleAttribute", "customMatchingRuleAttributeValue"); policy1.Handlers.Add(handler1); policy1.MatchingRules.Add(customMatchingRule); Dictionary <string, ConfigurationSection> sections = new Dictionary <string, ConfigurationSection>(); sections.Add(PolicyInjectionSettings.SectionName, settings); IConfigurationSource configurationSource = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections); PolicyInjectionSettings deserializedSection = (PolicyInjectionSettings)configurationSource.GetSection(PolicyInjectionSettings.SectionName); Assert.AreEqual(2, deserializedSection.Policies.Count); PolicyData deserializedPolicy1 = deserializedSection.Policies.Get(0); Assert.IsNotNull(deserializedPolicy1); Assert.AreEqual(policy1Name, deserializedPolicy1.Name); CallHandlerData deserializedHandler = deserializedPolicy1.Handlers.Get(0); Assert.IsNotNull(deserializedHandler); Assert.IsNotNull(deserializedHandler as CustomCallHandlerData); Assert.AreEqual(handler1Name, deserializedHandler.Name); Assert.AreEqual(typeof(CallCountHandler), deserializedHandler.Type); Assert.AreEqual("customHandlerAttributeValue", (string)deserializedHandler.ElementInformation.Properties["customHandlerAttribute"].Value); Assert.AreEqual(policy2Name, deserializedSection.Policies.Get(1).Name); MatchingRuleData deserializedMatchingRule = deserializedPolicy1.MatchingRules.Get(0); Assert.IsNotNull(deserializedMatchingRule as CustomMatchingRuleData); Assert.AreEqual(matchingRule1Name, deserializedMatchingRule.Name); Assert.AreEqual(typeof(TypeMatchingAssignmentRule), deserializedMatchingRule.Type); Assert.AreEqual("customMatchingRuleAttributeValue", (string)deserializedMatchingRule.ElementInformation.Properties["customMatchingRuleAttribute"].Value); }
public void Setup() { matchingRuleData = new MethodSignatureMatchingRuleData("signature", "pattern") { IgnoreCase = true, Parameters = { new ParameterTypeElement("foo", typeof(object).FullName), new ParameterTypeElement("bar", typeof(int).FullName) } }; }
private PolicyData BuildPolicyData(PolicyNode policyNode) { PolicyData policyData = new PolicyData(policyNode.Name); foreach (MatchingRuleNode ruleNode in MatchingRuleNodesInPolicy(policyNode)) { MatchingRuleData ruleData = ruleNode.GetConfigurationData(); policyData.MatchingRules.Add(ruleData); } foreach (CallHandlerNode handlerNode in CallHandlerNodesInPolicy(policyNode)) { CallHandlerData handlerData = handlerNode.CreateCallHandlerData(); policyData.Handlers.Add(handlerData); } return(policyData); }
protected override void Arrange() { updatableConfigurationSource = new ConfigurationSourceUpdatable(); matchingRuleData1 = new MemberNameMatchingRuleData("Member()"); matchingRuleData1.Name = "matchingRuleData1"; callHandler1 = new CustomCallHandlerData("callHandler1", typeof(GlobalCountCallHandler)); policy1 = new PolicyData(); policy1.Name = "policy1"; policy1.MatchingRules.Add(matchingRuleData1); policy1.Handlers.Add(callHandler1); settings = new PolicyInjectionSettings(); settings.Policies.Add(policy1); updatableConfigurationSource.Add(PolicyInjectionSettings.SectionName, settings); container = new UnityContainer(); containerConfigurator = new UnityContainerConfigurator(container); EnterpriseLibraryContainer.ConfigureContainer(containerConfigurator, updatableConfigurationSource); }
public void Setup() { matchingRuleData = new TypeMatchingRuleData("type", typeof(object).FullName); }
public void Setup() { matchingRuleData = new AssemblyMatchingRuleData("assembly", typeof(object).Assembly.FullName); }
/// <summary> /// Initializes a new instance of the <see cref="MatchingRuleNode"/> class representing a <see cref="MatchingRuleData"/>. /// </summary> /// <param name="matchingRuleData">The <see cref="MatchingRuleData"/> to represent.</param> protected MatchingRuleNode(MatchingRuleData matchingRuleData) : base(matchingRuleData.Name) { }