예제 #1
0
        private static void AddArrayMetadata(Type type)
        {
            if (ArrayData.ContainsKey(type))
            {
                return;
            }

            ArrayMetadata data = new ArrayMetadata();

            data.IsArray = type.IsArray;

            if (type.GetInterface("System.Collections.IList") != null)
            {
                data.IsList = true;
            }

            foreach (PropertyInfo p_info in type.GetProperties())
            {
                if (p_info.Name != "Item")
                {
                    continue;
                }

                ParameterInfo[] parameters = p_info.GetIndexParameters();

                if (parameters.Length != 1)
                {
                    continue;
                }

                if (parameters[0].ParameterType == typeof(int))
                {
                    data.ElementType = p_info.PropertyType;
                }
            }

            lock (arrayMetadataLock)
            {
                try
                {
                    ArrayData.Add(type, data);
                }
                catch (ArgumentException)
                {
                    return;
                }
            }
        }