Added Generic support for Merge(object) method

This commit is contained in:
Dmitrii Bardakov
2013-10-20 00:49:10 -07:00
parent 01b1f57224
commit aac001c707

View File

@@ -1,7 +1,7 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
* Copyright <20> 2002-2011 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.
@@ -213,12 +213,16 @@ namespace Spring.Objects.Factory.Config
{
return this;
}
IDictionary pDict = parent as IDictionary;
var pDict = parent as ManagedDictionary;
if (pDict == null)
{
throw new InvalidOperationException("Cannot merge with object of type [" + parent.GetType() + "]");
}
IDictionary merged = new ManagedDictionary();
{
KeyTypeName = pDict.keyTypeName,
valueTypeName = pDict.valueTypeName
}
foreach (DictionaryEntry dictionaryEntry in pDict)
{
merged[dictionaryEntry.Key] = dictionaryEntry.Value;
@@ -230,4 +234,4 @@ namespace Spring.Objects.Factory.Config
return merged;
}
}
}
}