Skip to content

Commit

Permalink
Memory leaks in AttributeHelper fixed
Browse files Browse the repository at this point in the history
Interface for geoemtry created extended to allow positioning of objects
  • Loading branch information
SteveLockley committed Jul 23, 2015
1 parent 397d57b commit 10aa6f1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 34 deletions.
40 changes: 7 additions & 33 deletions Xbim.Common/Helpers/AttributeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,9 @@ public class AttributeHelper
/// <returns></returns>
public static IEnumerable<T> GetAttributes<T>(ICustomAttributeProvider mInfo, bool inherit) where T : System.Attribute
{
IEnumerable<T> result = null;

if (mInfo != null)
{
T[] attributes = (T[])mInfo.GetCustomAttributes(typeof(T), inherit);

if (attributes != null && attributes.Count() > 0)
{
result = new List<T>(attributes);
}
}

return result;
if (mInfo == null) return null;
var attributes = mInfo.GetCustomAttributes(typeof(T), inherit).OfType<T>().ToList();
return attributes.Any() ? attributes : Enumerable.Empty<T>();
}

/// <summary>
Expand All @@ -53,15 +43,7 @@ public class AttributeHelper
/// <returns></returns>
public static T GetAttribute<T>(ICustomAttributeProvider mInfo, bool inherit) where T : System.Attribute
{
IEnumerable<T> attributes = GetAttributes<T>(mInfo, inherit);
T attribute = null;

if (attributes != null)
{
attribute = attributes.First();
}

return attribute;
return GetAttributes<T>(mInfo, inherit).FirstOrDefault();
}

/// <summary>
Expand All @@ -71,17 +53,9 @@ public class AttributeHelper
/// <param name="inherit"></param>
/// <returns></returns>
public static string GetDescriptionAttributeValue(MemberInfo mInfo, bool inherit)
{
string attributeValue = string.Empty;

DescriptionAttribute attribute = GetAttribute<DescriptionAttribute>(mInfo, inherit);

if (attribute != null)
{
attributeValue = attribute.Description;
}

return attributeValue;
{
var attribute = GetAttribute<DescriptionAttribute>(mInfo, inherit);
return attribute != null ? attribute.Description : string.Empty;
}
}
}
2 changes: 1 addition & 1 deletion Xbim.Essentials.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
<metadata>
<id>Xbim.Essentials</id>
<version>3.0.23</version>
<version>3.0.24</version>
<title>xBIM Essentials</title>
<authors>xBIM team</authors>
<owners>Steve Lockley</owners>
Expand Down
1 change: 1 addition & 0 deletions Xbim.IO/IXbimGeometryCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public interface IXbimGeometryCreator
ILogger Logger { get; }

IXbimGeometryObject Create(IfcGeometricRepresentationItem ifcRepresentation);
IXbimGeometryObject Create(IfcGeometricRepresentationItem ifcRepresentation, IfcAxis2Placement3D objectLocation);
/// <summary>
///
/// </summary>
Expand Down

0 comments on commit 10aa6f1

Please sign in to comment.