private static IEnumerable <ExtendedProperty> getProperties(PluginContainer pluginContainer, bool useDefaultValues) { List <ExtendedProperty> properties = new List <ExtendedProperty>(); if (pluginContainer.IsLoaded) { IEnumerable <PropertyInfo> reflectedProperties = pluginContainer.GetReflectedProperties(); foreach (PropertyInfo property in reflectedProperties) { if (property.CanRead && property.CanWrite) { object value = property.GetValue(pluginContainer.Instance, null); if (useDefaultValues) { object defaultValue = pluginContainer.GetDefaultValue(property.Name); if (defaultValue != null) { if (defaultValue.GetType() != property.PropertyType) { throw new InvalidOperationException(string.Format("DefaultValueAttribute on property {0} is invalid. Default value type '{1}' does not match property type '{2}'", property.Name, defaultValue.GetType().FullName, value.GetType().FullName)); } value = defaultValue; } } properties.Add(new ExtendedProperty(property.Name, property.PropertyType, useDefaultValues ? pluginContainer.GetDefaultValue(property.Name) ?? property.GetValue(pluginContainer.Instance, null) : property.GetValue(pluginContainer.Instance, null))); } } } return(properties); }