コード例 #1
0
        public static ParameterKey Merge(ParameterKey key, Type ownerType, string name)
        {
            lock (keyByNames)
            {
                /*if (keyByNames.TryGetValue(name, out duplicateKey))
                 * {
                 *  if (duplicateKey.PropertyType != key.PropertyType)
                 *  {
                 *      // TODO: For now, throw an exception, but we should be nicer about it
                 *      // (log and allow the two keys to co-exist peacefully?)
                 *      throw new InvalidOperationException("Two ParameterKey with same name but different types have been initialized.");
                 *  }
                 *  return key;
                 * }*/

                if (string.IsNullOrEmpty(key.Name))
                {
                    key.SetName(name);
                }
                keyByNames[name] = key;
                keyByNamesVersion++;

                if (key.OwnerType == null && ownerType != null)
                {
                    key.SetOwnerType(ownerType);
                }
            }
            return(key);
        }