From 2c1b7227c74c45ac4273dc9049ee6e604ef28652 Mon Sep 17 00:00:00 2001 From: eeichinger Date: Thu, 3 Dec 2009 09:20:05 +0000 Subject: [PATCH] --- .../Config/ICustomValueReferenceHolder.cs | 51 +++++++++++++++++++ .../NameMatchTransactionAttributeSource.cs | 33 ++++++++++-- 2 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 src/Spring/Spring.Core/Objects/Factory/Config/ICustomValueReferenceHolder.cs diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/ICustomValueReferenceHolder.cs b/src/Spring/Spring.Core/Objects/Factory/Config/ICustomValueReferenceHolder.cs new file mode 100644 index 00000000..ce521947 --- /dev/null +++ b/src/Spring/Spring.Core/Objects/Factory/Config/ICustomValueReferenceHolder.cs @@ -0,0 +1,51 @@ +#region License + +/* + * Copyright 2002-2009 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +using System; + +namespace Spring.Objects.Factory.Config +{ + /// + /// May be used to store custom value references in object definition properties. + /// + /// + /// Erich Eichinger + public interface ICustomValueReferenceHolder + { + /// + /// + /// + /// the object factory holding the given object definition + /// + /// + /// The name of the object that is having the value of one of its properties resolved. + /// + /// + /// The definition of the named object. + /// + /// + /// The name of the property the value of which is being resolved. + /// + /// + /// The value of the property that is being resolved. + /// + object Resolve(IObjectFactory objectFactory, string name, IObjectDefinition definition, string argumentName, object argumentValue); + } +} \ No newline at end of file diff --git a/src/Spring/Spring.Data/Transaction/Interceptor/NameMatchTransactionAttributeSource.cs b/src/Spring/Spring.Data/Transaction/Interceptor/NameMatchTransactionAttributeSource.cs index edfe4ec3..2326fda7 100644 --- a/src/Spring/Spring.Data/Transaction/Interceptor/NameMatchTransactionAttributeSource.cs +++ b/src/Spring/Spring.Data/Transaction/Interceptor/NameMatchTransactionAttributeSource.cs @@ -34,7 +34,7 @@ namespace Spring.Transaction.Interceptor /// Juergen Hoeller /// Griffin Caprio (.NET) [Serializable] - public class NameMatchTransactionAttributeSource : ITransactionAttributeSource + public class NameMatchTransactionAttributeSource : ITransactionAttributeSource, IEnumerable { /// /// Logger available to subclasses, static for optimal serialization @@ -45,7 +45,7 @@ namespace Spring.Transaction.Interceptor /// /// Keys are method names; values are ITransactionAttributes /// - private IDictionary nameMap; + private readonly IDictionary nameMap; /// /// Creates a new instance of the @@ -56,7 +56,34 @@ namespace Spring.Transaction.Interceptor nameMap = new Hashtable(); } - /// + /// + /// Enumerate the string/ mapping entries. + /// + public IEnumerator GetEnumerator() + { + return nameMap.GetEnumerator(); + } + + /// + /// Add a mapping. + /// + public void Add(string methodPattern, ITransactionAttribute txAttribute) + { + AddTransactionMethod(methodPattern, txAttribute); + } + + /// + /// Add a mapping. + /// + public void Add(string methodPattern, string txAttributeText) + { + TransactionAttributeEditor editor = new TransactionAttributeEditor(); + editor.SetAsText(txAttributeText); + ITransactionAttribute txAttribute = editor.Value; + AddTransactionMethod(methodPattern, txAttribute); + } + + /// /// Set a name/attribute map, consisting of method names (e.g. "MyMethod") and /// instances /// (or Strings to be converted to ITransactionAttribute instances).