// This is a part of the Smart PropertyGrid Library
// Copyright (C) 2001-2006 VisualHint
// All rights reserved.
//
// This source code can be used, distributed or modified
// only under terms and conditions 
// of the accompanying license agreement.

using System;

namespace VisualHint.SmartPropertyGrid
{
    internal class Utilities
    {
        public static Type GetTypeFromName(string typeName, Type valueType)
        {
            if ((typeName == null) || (typeName.Length == 0))
                return null;

            Type type = Type.GetType(typeName);
            if (type != null)
                return type;

            int pos = typeName.IndexOf(',');
            if (pos != -1)
                typeName = typeName.Substring(0, pos);

            return valueType.Assembly.GetType(typeName);
        }

        public static int GetHashCode(string[] strArray)
        {
            int hashCode = 0;
            foreach (string str in strArray)
                hashCode ^= str.GetHashCode();
            return hashCode;
        }
    }
}
