private bool TrySetCollectionProperty(PropertyInfo clrProperty, object clrObject, IEdmPropertyValue propertyValue)
        {
            Type type;
            Type propertyType = clrProperty.PropertyType;

            if (propertyType.IsGenericType() && propertyType.IsInterface())
            {
                Type genericTypeDefinition = propertyType.GetGenericTypeDefinition();
                bool typeIEnumerableOfT    = genericTypeDefinition == EdmToClrConverter.TypeIEnumerableOfT;
                if (typeIEnumerableOfT || genericTypeDefinition == EdmToClrConverter.TypeICollectionOfT || genericTypeDefinition == EdmToClrConverter.TypeIListOfT)
                {
                    object value = clrProperty.GetValue(clrObject, null);
                    Type   type1 = propertyType.GetGenericArguments().Single <Type>();
                    if (value != null)
                    {
                        if (!typeIEnumerableOfT)
                        {
                            type = value.GetType();
                        }
                        else
                        {
                            throw new InvalidCastException(Strings.EdmToClr_IEnumerableOfTPropertyAlreadyHasValue(clrProperty.Name, clrProperty.DeclaringType.FullName));
                        }
                    }
                    else
                    {
                        Type[] typeArray = new Type[1];
                        typeArray[0] = type1;
                        type         = EdmToClrConverter.TypeListOfT.MakeGenericType(typeArray);
                        value        = Activator.CreateInstance(type);
                        clrProperty.SetValue(clrObject, value, null);
                    }
                    MethodInfo methodInfo = EdmToClrConverter.FindICollectionOfElementTypeAddMethod(type, type1);
                    foreach (object obj in this.AsIEnumerable(propertyValue.Value, type1))
                    {
                        try
                        {
                            object[] objArray = new object[1];
                            objArray[0] = obj;
                            methodInfo.Invoke(value, objArray);
                        }
                        catch (TargetInvocationException targetInvocationException1)
                        {
                            TargetInvocationException targetInvocationException = targetInvocationException1;
                            if (targetInvocationException.InnerException == null || targetInvocationException.InnerException as InvalidCastException == null)
                            {
                                throw;
                            }
                            else
                            {
                                throw targetInvocationException.InnerException;
                            }
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }