IGLib
1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
|
A PropertyBag represents a collection of name/value pairs that allows duplicate entries with the same key. Methods are provided for adding a new pair as well as for setting a key to a single value. All keys are strings but _values may be of any type. Null _values are not permitted, since a null entry represents the absence of the key. More...
Public Member Functions | |
void | Add (string key, object value) |
Adds a key/value pair to the property bag More... | |
void | Set (string key, object value) |
Sets the value for a key, removing any other _values that are already in the property set. More... | |
object | Get (string key) |
Gets a single value for a key, using the first one if multiple _values are present and returning null if the value is not found. More... | |
bool | ContainsKey (string key) |
Gets a flag indicating whether the specified key has any entries in the property set. More... | |
![]() | |
TNode | ToXml (bool recursive) |
Returns a TNode representing the current object. More... | |
TNode | AddToXml (TNode parentNode, bool recursive) |
Returns a TNode representing the current object after adding it as a child of the supplied parent node. More... | |
Properties | |
IList | this[string key] [get, set] |
Gets or sets the list of _values for a particular key More... | |
ICollection< string > | Keys [get] |
Gets a collection containing all the keys in the property set More... | |
A PropertyBag represents a collection of name/value pairs that allows duplicate entries with the same key. Methods are provided for adding a new pair as well as for setting a key to a single value. All keys are strings but _values may be of any type. Null _values are not permitted, since a null entry represents the absence of the key.
The entries in a PropertyBag are of two kinds: those that take a single value and those that take multiple _values. However, the PropertyBag has no knowledge of which entries fall into each category and the distinction is entirely up to the code using the PropertyBag.
When working with multi-valued properties, client code should use the Add method to add name/value pairs and indexing to retrieve a list of all _values for a given key. For example:
bag.Add("Tag", "one"); bag.Add("Tag", "two"); Assert.That(bag["Tag"], Is.EqualTo(new string[] { "one", "two" }));
When working with single-valued propeties, client code should use the Set method to set the value and Get to retrieve the value. The GetSetting methods may also be used to retrieve the value in a type-safe manner while also providing default. For example:
bag.Set("Priority", "low"); bag.Set("Priority", "high"); // replaces value Assert.That(bag.Get("Priority"), Is.EqualTo("high")); Assert.That(bag.GetSetting("Priority", "low"), Is.EqualTo("high"));
void NUnit.Framework.Interfaces.IPropertyBag.Add | ( | string | key, |
object | value | ||
) |
Adds a key/value pair to the property bag
key | The key |
value | The value |
Implemented in NUnit.Framework.Internal.PropertyBag.
Referenced by NUnit.Framework.PlatformAttribute.ApplyToTest(), NUnit.Framework.CategoryAttribute.ApplyToTest(), NUnit.Framework.TestCaseAttribute.BuildFrom(), NUnit.Framework.TestFixtureSourceAttribute.GetParametersFor(), NUnit.Framework.TestCaseSourceAttribute.GetTestCasesFor(), NUnit.Framework.Internal.TestXmlTests.SetUp(), and NUnit.Framework.Internal.TestResultTests.SetUp().
void NUnit.Framework.Interfaces.IPropertyBag.Set | ( | string | key, |
object | value | ||
) |
Sets the value for a key, removing any other _values that are already in the property set.
key | |
value |
Implemented in NUnit.Framework.Internal.PropertyBag.
Referenced by NUnit.Framework.Internal.Builders.NUnitTestFixtureBuilder.AddTestCasesToFixture(), NUnit.Framework.CultureAttribute.ApplyToTest(), NUnit.Framework.ExplicitAttribute.ApplyToTest(), NUnit.Framework.IgnoreAttribute.ApplyToTest(), NUnit.Framework.TestAttribute.ApplyToTest(), NUnit.Framework.CategoryAttribute.ApplyToTest(), NUnit.Framework.CombiningStrategyAttribute.ApplyToTest(), NUnit.Framework.Api.DefaultTestAssemblyBuilder.Build(), NUnit.Framework.SetUpFixtureAttribute.BuildFrom(), NUnit.Framework.Api.DefaultTestAssemblyBuilder.BuildTestAssembly(), NUnit.Framework.Internal.Builders.NUnitTestFixtureBuilder.CheckTestFixtureIsValid(), NUnit.Framework.Attributes.ApplyToTestTests.ExplicitAttributeDoesNotAffectNonRunnableTest(), NUnit.Framework.Attributes.ApplyToTestTests.IgnoreAttributeDoesNotAffectNonRunnableTest(), NUnit.Framework.Internal.Builders.NUnitTestCaseBuilder.MarkAsNotRunnable(), NUnit.Framework.Internal.TestXmlTests.SetUp(), and NUnit.Framework.Internal.TestResultTests.SetUp().
object NUnit.Framework.Interfaces.IPropertyBag.Get | ( | string | key | ) |
Gets a single value for a key, using the first one if multiple _values are present and returning null if the value is not found.
Implemented in NUnit.Framework.Internal.PropertyBag.
Referenced by NUnit.Framework.Tests.Attributes.AuthorTests.Author(), NUnit.Framework.Tests.Attributes.AuthorTests.AuthorOnTestCase(), NUnit.Framework.Attributes.PropertyAttributeTests.CanDeriveFromPropertyAttribute(), NUnit.Framework.Attributes.TestCaseSourceTests.CanIgnoreIndividualTestCases(), NUnit.Framework.Attributes.TestCaseAttributeTests.CanIgnoreIndividualTestCases(), NUnit.Framework.Attributes.TestCaseSourceTests.CanMarkIndividualTestCasesExplicit(), NUnit.Framework.Attributes.TestCaseAttributeTests.CanMarkIndividualTestCasesExplicit(), NUnit.Framework.Internal.TestFixtureTests.CannotRunGenericFixtureWithNoArgsProvided(), NUnit.Framework.Attributes.ParameterizedTestFixtureTests.CanSpecifyCategory(), NUnit.Framework.Attributes.TestCaseAttributeTests.CanSpecifyDescription(), NUnit.Framework.Attributes.ApplyToTestTests.CategoryAttributeSetsCategory(), NUnit.Framework.Attributes.ApplyToTestTests.CategoryAttributeSetsCategoryOnNonRunnableTest(), NUnit.Framework.Attributes.ApplyToTestTests.CombinatorialAttributeSetsJoinType(), NUnit.Framework.Attributes.ApplyToTestTests.CombinatorialAttributeSetsJoinTypeOnNonRunnableTest(), NUnit.Framework.Attributes.ApplyToTestTests.CultureAttributeExcludingCurrentCultureSkipsTest(), NUnit.Framework.Attributes.ApplyToTestTests.CultureAttributeIncludingOtherCultureSkipsTest(), NUnit.Framework.Attributes.PropertyAttributeTests.CustomPropertyAttribute(), NUnit.Framework.Attributes.DescriptionTests.Description(), NUnit.Framework.Attributes.ApplyToTestTests.DescriptionAttributeSetsDescription(), NUnit.Framework.Attributes.ApplyToTestTests.DescriptionAttributeSetsDescriptionOnNonRunnableTest(), NUnit.Framework.Attributes.DescriptionTests.DescriptionOnTestCase(), NUnit.Framework.Tests.Attributes.TestExpectedResult.ExpectedResultDoesNotBlockApplyToTestAttributes(), NUnit.Framework.Attributes.ApplyToTestTests.ExplicitAttributeDoesNotAffectNonRunnableTest(), NUnit.Framework.Attributes.ApplyToTestTests.ExplicitAttributeSetsIgnoreReason(), NUnit.Framework.Attributes.DescriptionTests.FixtureDescription(), NUnit.Framework.Internal.TestExecutionContextTests.FixtureSetUpCanAccessFixtureProperties(), NUnit.Framework.Internal.TestFixtureTests.FixtureUsingIgnoreAttributeIsIgnored(), NUnit.Framework.Internal.TestFixtureTests.FixtureUsingIgnorePropertyIsIgnored(), NUnit.Framework.Internal.TestFixtureTests.FixtureUsingIgnoreReasonPropertyIsIgnored(), NUnit.Framework.Attributes.ApplyToTestTests.IgnoreAttributeDoesNotAffectNonRunnableTest(), NUnit.Framework.Attributes.ApplyToTestTests.IgnoreAttributeSetsIgnoreReason(), NUnit.Framework.Attributes.ApplyToTestTests.IgnoreAttributeUntilSetsTheReason(), NUnit.Framework.Attributes.ApplyToTestTests.IgnoreAttributeWithUntilAddsIgnoreUntilDateProperty(), NUnit.Framework.Attributes.ApplyToTestTests.IgnoreAttributeWithUntilAddsIgnoreUntilDatePropertyPastUntilDate(), NUnit.Framework.Attributes.ApplyToTestTests.MaxTimeAttributeSetsMaxTime(), NUnit.Framework.Attributes.ApplyToTestTests.MaxTimeAttributeSetsMaxTimeOnNonRunnableTest(), NUnit.Framework.Tests.Attributes.AuthorTests.NoAuthor(), NUnit.Framework.Attributes.DescriptionTests.NoDescription(), NUnit.Framework.Tests.Attributes.TestOfTests.NoTestOf(), NUnit.Framework.Internal.TestExecutionContextTests.OneTimeTearDown(), NUnit.Framework.Attributes.ApplyToTestTests.PairwiseAttributeSetsJoinType(), NUnit.Framework.Attributes.ApplyToTestTests.PairwiseAttributeSetsJoinTypeOnNonRunnableTest(), NUnit.Framework.Attributes.PropertyAttributeTests.PropertiesWithNumericValues(), NUnit.Framework.Attributes.PropertyAttributeTests.PropertyWorksOnFixtures(), NUnit.Framework.Attributes.ApplyToTestTests.RepeatAttributeSetsRepeatCount(), NUnit.Framework.Attributes.ApplyToTestTests.RepeatAttributeSetsRepeatCountOnNonRunnableTest(), NUnit.Framework.Attributes.ApplyToTestTests.RequiresMTAAttributeSetsApartmentState(), NUnit.Framework.Attributes.ApplyToTestTests.RequiresMTAAttributeSetsApartmentStateOnNonRunnableTest(), NUnit.Framework.Attributes.ApplyToTestTests.RequiresSTAAttributeSetsApartmentState(), NUnit.Framework.Attributes.ApplyToTestTests.RequiresSTAAttributeSetsApartmentStateOnNonRunnableTest(), NUnit.Framework.Attributes.ApplyToTestTests.RequiresThreadAttributeMaySetApartmentState(), NUnit.Framework.Attributes.ApplyToTestTests.RequiresThreadAttributeSetsRequiresThread(), NUnit.Framework.Attributes.ApplyToTestTests.RequiresThreadAttributeSetsRequiresThreadOnNonRunnableTest(), NUnit.Framework.Tests.Attributes.AuthorTests.SeparateAuthorAttribute(), NUnit.Framework.Tests.Attributes.AuthorTests.SeparateAuthorWithEmailAttribute(), NUnit.Framework.Attributes.DescriptionTests.SeparateDescriptionAttribute(), NUnit.Framework.Tests.Attributes.TestOfTests.SeparateTestOfAttribute(), NUnit.Framework.Tests.Attributes.TestOfTests.SeparateTestOfStringMethod(), NUnit.Framework.Attributes.ApplyToTestTests.SequentialAttributeSetsJoinType(), NUnit.Framework.Attributes.ApplyToTestTests.SequentialAttributeSetsJoinTypeOnNonRunnableTest(), NUnit.Framework.Attributes.ApplyToTestTests.SetCultureAttributeSetsSetCultureProperty(), NUnit.Framework.Attributes.ApplyToTestTests.SetCultureAttributeSetsSetCulturePropertyOnNonRunnableTest(), NUnit.Framework.Attributes.ApplyToTestTests.SetUICultureAttributeSetsSetUICultureProperty(), NUnit.Framework.Attributes.ApplyToTestTests.SetUICultureAttributeSetsSetUICulturePropertyOnNonRunnableTest(), NUnit.Framework.Internal.TestExecutionContextTests.SetUpCanAccessTestProperties(), NUnitLite.NUnit2XmlOutputWriter.StartTestElement(), NUnit.Framework.Tests.TestContextTests.TestCanAccessItsOwnProperties(), NUnit.Framework.Internal.TestExecutionContextTests.TestCanAccessItsOwnProperties(), NUnit.Framework.Tests.Attributes.TestOfTests.TestOf(), and NUnit.Framework.Tests.Attributes.TestOfTests.TestOfOnTestCase().
bool NUnit.Framework.Interfaces.IPropertyBag.ContainsKey | ( | string | key | ) |
Gets a flag indicating whether the specified key has any entries in the property set.
key | The key to be checked |
Implemented in NUnit.Framework.Internal.PropertyBag.
Referenced by NUnit.Framework.TestAttribute.ApplyToTest(), NUnitLite.NUnit2XmlOutputWriter.StartTestElement(), and NUnitLite.NUnit2XmlOutputWriter.WriteCategories().
|
getset |
Gets or sets the list of _values for a particular key
key | The key for which the _values are to be retrieved or set |
|
get |
Gets a collection containing all the keys in the property set
Referenced by NUnit.Framework.Internal.TestXmlTests.CheckXmlForTest().