Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #47 from uurha/dev
Browse files Browse the repository at this point in the history
Add GetDefault for ReflectionExtensions.cs
  • Loading branch information
uurha committed Sep 9, 2023
1 parent 2f2cf88 commit 41672d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Runtime/Extension/ReflectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ public static bool IsArrayOrList(this Type listType)
return false;
}

public static object GetDefault(this Type type)
{
if (type.IsValueType)
{
return Activator.CreateInstance(type);
}

if (type == typeof(string))
{
return string.Empty;
}

return null;
}

public static Type[] GetAllInheritedType(this Type baseType)
{
return AppDomain.CurrentDomain.GetAssemblies().SelectMany(s => s.GetTypes()).Where(p => ValidateType(baseType, p)).ToArray();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.uurha.betterextensions",
"displayName": "Better Extensions",
"description": "Unity extensions, serialize extension, async extension, string extension and UI extensions",
"version": "1.1.91",
"version": "1.1.92",
"unity": "2020.1",
"author": {
"name": "Arcueid D'athemon",
Expand Down

0 comments on commit 41672d1

Please sign in to comment.