本文整理汇总了C#中Spring.Objects.MutablePropertyValues.Add方法的典型用法代码示例。如果您正苦于以下问题:C# MutablePropertyValues.Add方法的具体用法?C# MutablePropertyValues.Add怎么用?C# MutablePropertyValues.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spring.Objects.MutablePropertyValues
的用法示例。
在下文中一共展示了MutablePropertyValues.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Instantiation
public void Instantiation () {
MutablePropertyValues root = new MutablePropertyValues ();
root.Add (new PropertyValue ("Name", "Fiona Apple"));
root.Add (new PropertyValue ("Age", 24));
MutablePropertyValues props = new MutablePropertyValues (root);
Assert.AreEqual (2, props.PropertyValues.Count);
}
示例2: AddAllInNullList
public void AddAllInNullList()
{
MutablePropertyValues props = new MutablePropertyValues ();
props.Add (new PropertyValue ("Name", "Fiona Apple"));
props.Add (new PropertyValue ("Age", 24));
props.AddAll ((IList) null);
Assert.AreEqual (2, props.PropertyValues.Length);
}
示例3: ParseTestObjectDefinition
private ObjectDefinitionHolder ParseTestObjectDefinition(XmlElement rootElement, ParserContext parserContext)
{
MutablePropertyValues properties = new MutablePropertyValues();
XmlNodeList childNodes = rootElement.ChildNodes;
//Get all properties (from non whitespace nodes)
foreach (XmlNode childNode in childNodes)
{
if (XmlNodeType.Whitespace != childNode.NodeType)
{
properties.Add(new PropertyValue(childNode.LocalName, childNode.InnerText));
}
}
IConfigurableObjectDefinition od = new RootObjectDefinition(typeof (TestObject), null, properties);
od.IsSingleton = false;
//HardCoded for now.
string id = "testObject";
//id = ObjectDefinitionReaderUtils.GenerateObjectName(od, reader.ObjectReader.Registry);
return new ObjectDefinitionHolder(od, id);
}
示例4: AddAllInNullMap
public void AddAllInNullMap()
{
MutablePropertyValues props = new MutablePropertyValues ();
props.Add (new PropertyValue ("Name", "Fiona Apple"));
props.AddAll ((IDictionary) null);
Assert.AreEqual (1, props.PropertyValues.Length);
}
示例5: getMutablePropertyValues
private MutablePropertyValues getMutablePropertyValues(TypeRegistration registrationEntry)
{
MutablePropertyValues properties = new MutablePropertyValues();
foreach (InjectedProperty property in registrationEntry.InjectedProperties)
{
properties.Add(new PropertyValue(property.PropertyName,getInjectionParameterValue(property.PropertyValue)));
}
return properties;
}
示例6: PostProcessPropertyValues
public override IPropertyValues PostProcessPropertyValues(IPropertyValues propertyValues, PropertyInfo[] propertyInfos, object objectInstance, string objectName)
{
MutablePropertyValues mpv = new MutablePropertyValues(propertyValues);
IConfigurableObjectDefinition objectDefinition = (IConfigurableObjectDefinition)_objectFactory.GetObjectDefinition(objectName);
DependencyCheckingMode checkMode = objectDefinition.DependencyCheck;
PropertyInfo[] unresolvedProperties = AutowireUtils.GetUnsatisfiedDependencies(propertyInfos, propertyValues, checkMode);
foreach(PropertyInfo propertyInfo in unresolvedProperties)
{
object value = ResolveDependency(objectName, objectDefinition, new ObjectWrapper(objectInstance), propertyInfo);
if (value != null)
{
mpv.Add(propertyInfo.Name, value);
}
}
return base.PostProcessPropertyValues(mpv, propertyInfos, objectInstance, objectName);
}
示例7: RemoveByPropertyValue
public void RemoveByPropertyValue ()
{
MutablePropertyValues props = new MutablePropertyValues ();
PropertyValue propName = new PropertyValue ("Name", "Fiona Apple");
props.Add (propName);
props.Add (new PropertyValue ("Age", 24));
Assert.AreEqual (2, props.PropertyValues.Count);
props.Remove (propName);
Assert.AreEqual (1, props.PropertyValues.Count);
}
示例8: ParseCaoExporter
/// <summary>
/// Parses the CaoExporter definition.
/// </summary>
/// <param name="element">The element to parse.</param>
/// <param name="name">The name of the object definition.</param>
/// <param name="parserContext">The parser context.</param>
/// <returns>CaoExporter object definition.</returns>
private IConfigurableObjectDefinition ParseCaoExporter(
XmlElement element, string name, ParserContext parserContext)
{
string typeName = GetTypeName(element);
string targetName = element.GetAttribute(CaoExporterConstants.TargetNameAttribute);
string infinite = element.GetAttribute(CaoExporterConstants.InfiniteAttribute);
MutablePropertyValues properties = new MutablePropertyValues();
if (StringUtils.HasText(targetName))
{
properties.Add("TargetName", targetName);
}
if (StringUtils.HasText(infinite))
{
properties.Add("Infinite", infinite);
}
foreach (XmlElement child in element.ChildNodes)
{
switch (child.LocalName)
{
case LifeTimeConstants.LifeTimeElement:
ParseLifeTime(properties, child, parserContext);
break;
case InterfacesConstants.InterfacesElement:
properties.Add("Interfaces", base.ParseListElement(child, name, parserContext));
break;
}
}
IConfigurableObjectDefinition cod = parserContext.ReaderContext.ObjectDefinitionFactory.CreateObjectDefinition(
typeName, null, parserContext.ReaderContext.Reader.Domain);
cod.PropertyValues = properties;
return cod;
}
示例9: ParseLifeTime
/// <summary>
/// Parses the LifeTime definition.
/// </summary>
private void ParseLifeTime(MutablePropertyValues properties, XmlElement child, ParserContext parserContext)
{
string initialLeaseTime = child.GetAttribute(LifeTimeConstants.InitialLeaseTimeAttribute);
string renewOnCallTime = child.GetAttribute(LifeTimeConstants.RenewOnCallTimeAttribute);
string sponsorshipTimeout = child.GetAttribute(LifeTimeConstants.SponsorshipTimeoutAttribute);
if (StringUtils.HasText(initialLeaseTime))
{
properties.Add("InitialLeaseTime", initialLeaseTime);
}
if (StringUtils.HasText(renewOnCallTime))
{
properties.Add("RenewOnCallTime", renewOnCallTime);
}
if (StringUtils.HasText(sponsorshipTimeout))
{
properties.Add("SponsorshipTimeout", sponsorshipTimeout);
}
}
示例10: ParseNVelocityEngine
/// <summary>
/// Parses the object definition for the engine object, configures a single NVelocity template engine based
/// on the element definitions.
/// </summary>
/// <param name="element">the root element defining the velocity engine</param>
/// <param name="parserContext">the parser context</param>
private IConfigurableObjectDefinition ParseNVelocityEngine(XmlElement element, ParserContext parserContext) {
string typeName = GetTypeName(element);
IConfigurableObjectDefinition configurableObjectDefinition = parserContext.ReaderContext.ObjectDefinitionFactory.CreateObjectDefinition(
typeName, null, parserContext.ReaderContext.Reader.Domain);
string preferFileSystemAccess = GetAttributeValue(element, TemplateDefinitionConstants.AttributePreferFileSystemAccess);
string overrideLogging = GetAttributeValue(element, TemplateDefinitionConstants.AttributeOverrideLogging);
string configFile = GetAttributeValue(element, TemplateDefinitionConstants.AttributeConfigFile);
MutablePropertyValues objectDefinitionProperties = new MutablePropertyValues();
if (StringUtils.HasText(preferFileSystemAccess)) {
objectDefinitionProperties.Add(TemplateDefinitionConstants.PropertyPreferFileSystemAccess, preferFileSystemAccess);
}
if (StringUtils.HasText(overrideLogging)) {
objectDefinitionProperties.Add(TemplateDefinitionConstants.PropertyOverrideLogging, overrideLogging);
}
if (StringUtils.HasText(configFile)) {
objectDefinitionProperties.Add(TemplateDefinitionConstants.PropertyConfigFile, configFile);
}
XmlNodeList childElements = element.ChildNodes;
if (childElements.Count > 0) {
ParseChildDefinitions(childElements, parserContext, objectDefinitionProperties);
}
configurableObjectDefinition.PropertyValues = objectDefinitionProperties;
return configurableObjectDefinition;
}
示例11: AllValid
public void AllValid()
{
TestObject t = new TestObject();
string newName = "tony";
int newAge = 65;
string newTouchy = "valid";
IObjectWrapper wrapper = GetWrapper(t);
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.Add(new PropertyValue("Age", newAge));
pvs.Add(new PropertyValue("Name", newName));
pvs.Add(new PropertyValue("Touchy", newTouchy));
wrapper.SetPropertyValues(pvs);
Assert.IsTrue(t.Name.Equals(newName), "Validly set property must stick");
Assert.IsTrue(t.Touchy.Equals(newTouchy), "Validly set property must stick");
Assert.IsTrue(t.Age == newAge, "Validly set property must stick");
}
示例12: ChangesSince
public void ChangesSince ()
{
IDictionary<string, object> map = new Dictionary<string, object>();
PropertyValue propName = new PropertyValue("Name", "Fiona Apple");
map.Add (propName.Name, propName.Value);
map.Add ("Age", 24);
MutablePropertyValues props = new MutablePropertyValues (map);
MutablePropertyValues newProps = new MutablePropertyValues (map);
// change the name... this is the change we'll be looking for
newProps.SetPropertyValueAt (new PropertyValue (propName.Name, "Naomi Woolf"), 0);
IPropertyValues changes = newProps.ChangesSince (props);
Assert.AreEqual (1, changes.PropertyValues.Count);
// the name was changed, so its the name property that should be in the changed list
Assert.IsTrue (changes.Contains ("name"));
newProps.Add (new PropertyValue ("Commentator", "Naomi Woolf"));
changes = newProps.ChangesSince (props);
Assert.AreEqual (2, changes.PropertyValues.Count);
// the Commentator was added, so its the Commentator property that should be in the changed list
Assert.IsTrue (changes.Contains ("commentator"));
// the name was changed, so its the name property that should be in the changed list
Assert.IsTrue (changes.Contains ("name"));
}
示例13: ParseChildDefinitions
/// <summary>
/// Parses child element definitions for the NVelocity engine. Typically resource loaders and locally defined properties are parsed here
/// </summary>
/// <param name="childElements">the XmlNodeList representing the child configuration of the root NVelocity engine element</param>
/// <param name="parserContext">the parser context</param>
/// <param name="objectDefinitionProperties">the MutablePropertyValues used to configure this object</param>
private void ParseChildDefinitions(XmlNodeList childElements, ParserContext parserContext, MutablePropertyValues objectDefinitionProperties) {
IDictionary<string, object> properties = new Dictionary<string, object>();
foreach (XmlElement element in childElements) {
switch (element.LocalName) {
case TemplateDefinitionConstants.ElementResourceLoader:
ParseResourceLoader(element, objectDefinitionProperties, properties);
break;
case TemplateDefinitionConstants.ElementNVelocityProperties:
ParseNVelocityProperties(element, parserContext, properties);
break;
}
}
if (properties.Count > 0) {
objectDefinitionProperties.Add(TemplateDefinitionConstants.PropertyVelocityProperties, properties);
}
}
示例14: ParseExceptionAction
private IObjectDefinition ParseExceptionAction(XmlElement element, ParserContext parserContext)
{
string typeName = "Spring.Validation.Actions.ExceptionAction, Spring.Core";
string throwExpression = GetAttributeValue(element, ValidatorDefinitionConstants.ThrowAttribute);
ConstructorArgumentValues ctorArgs = new ConstructorArgumentValues();
ctorArgs.AddGenericArgumentValue(throwExpression);
string when = GetAttributeValue(element, ValidatorDefinitionConstants.WhenAttribute);
MutablePropertyValues properties = new MutablePropertyValues();
if (StringUtils.HasText(when))
{
properties.Add("When", when);
}
IConfigurableObjectDefinition action =
parserContext.ReaderContext.ObjectDefinitionFactory.CreateObjectDefinition(typeName, null, parserContext.ReaderContext.Reader.Domain);
action.ConstructorArgumentValues = ctorArgs;
action.PropertyValues = properties;
return action;
}
示例15: ParseValidatorReference
/// <summary>
/// Creates object definition for the validator reference.
/// </summary>
/// <param name="element">The action definition element.</param>
/// <param name="parserContext">The parser helper.</param>
/// <returns>Generic validation action definition.</returns>
private IObjectDefinition ParseValidatorReference(XmlElement element, ParserContext parserContext)
{
string typeName = "Spring.Validation.ValidatorReference, Spring.Core";
string name = GetAttributeValue(element, ValidatorDefinitionConstants.ReferenceNameAttribute);
string context = GetAttributeValue(element, ValidatorDefinitionConstants.ReferenceContextAttribute);
string when = GetAttributeValue(element, ValidatorDefinitionConstants.WhenAttribute);
MutablePropertyValues properties = new MutablePropertyValues();
properties.Add("Name", name);
if (StringUtils.HasText(context))
{
properties.Add("Context", context);
}
if (StringUtils.HasText(when))
{
properties.Add("When", when);
}
IConfigurableObjectDefinition reference =
parserContext.ReaderContext.ObjectDefinitionFactory.CreateObjectDefinition(typeName, null, parserContext.ReaderContext.Reader.Domain);
reference.PropertyValues = properties;
return reference;
}