This repository has been archived by the owner on Oct 30, 2019. It is now read-only.
forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from meklu/monogame-sdl2
[FNA] Content/ directory style fixes
- Loading branch information
Showing
64 changed files
with
3,696 additions
and
4,594 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,58 @@ | ||
using System; | ||
#region License | ||
/* FNA - XNA4 Reimplementation for Desktop Platforms | ||
* Copyright 2009-2014 Ethan Lee and the MonoGame Team | ||
* | ||
* Released under the Microsoft Public License. | ||
* See LICENSE for details. | ||
*/ | ||
#endregion | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Linq; | ||
|
||
#if WINRT | ||
using System.Reflection.Emit; | ||
#endif | ||
|
||
namespace Microsoft.Xna.Framework.Content | ||
{ | ||
public static class ContentExtensions | ||
{ | ||
public static ConstructorInfo GetDefaultConstructor(this Type type) | ||
{ | ||
#if WINRT | ||
var typeInfo = type.GetTypeInfo(); | ||
var ctor = typeInfo.DeclaredConstructors.FirstOrDefault(c => !c.IsStatic && c.GetParameters().Length == 0); | ||
return ctor; | ||
#else | ||
var attrs = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance; | ||
return type.GetConstructor(attrs, null, new Type[0], null); | ||
#endif | ||
} | ||
|
||
public static PropertyInfo[] GetAllProperties(this Type type) | ||
{ | ||
|
||
// Sometimes, overridden properties of abstract classes can show up even with | ||
// BindingFlags.DeclaredOnly is passed to GetProperties. Make sure that | ||
// all properties in this list are defined in this class by comparing | ||
// its get method with that of it's base class. If they're the same | ||
// Then it's an overridden property. | ||
#if WINRT | ||
PropertyInfo[] infos= type.GetTypeInfo().DeclaredProperties.ToArray(); | ||
var nonStaticPropertyInfos = from p in infos | ||
where (p.GetMethod != null) && (!p.GetMethod.IsStatic) && | ||
(p.GetMethod == p.GetMethod.GetRuntimeBaseDefinition()) | ||
select p; | ||
return nonStaticPropertyInfos.ToArray(); | ||
#else | ||
var attrs = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; | ||
var allProps = type.GetProperties(attrs).ToList(); | ||
public static class ContentExtensions | ||
{ | ||
public static ConstructorInfo GetDefaultConstructor(this Type type) | ||
{ | ||
BindingFlags attrs = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance; | ||
return type.GetConstructor(attrs, null, new Type[0], null); | ||
} | ||
|
||
var props = allProps.FindAll(p => p.GetGetMethod(true) == p.GetGetMethod(true).GetBaseDefinition()).ToArray(); | ||
return props; | ||
#endif | ||
} | ||
public static PropertyInfo[] GetAllProperties(this Type type) | ||
{ | ||
|
||
/* Sometimes, overridden properties of abstract classes can show up even with | ||
* BindingFlags.DeclaredOnly is passed to GetProperties. Make sure that | ||
* all properties in this list are defined in this class by comparing | ||
* its get method with that of its base class. If they're the same | ||
* Then it's an overridden property. | ||
*/ | ||
BindingFlags attrs = ( | ||
BindingFlags.NonPublic | | ||
BindingFlags.Public | | ||
BindingFlags.Instance | | ||
BindingFlags.DeclaredOnly | ||
); | ||
List<PropertyInfo> allProps = type.GetProperties(attrs).ToList(); | ||
PropertyInfo[] props = allProps.FindAll( | ||
p => p.GetGetMethod(true) == p.GetGetMethod(true).GetBaseDefinition() | ||
).ToArray(); | ||
return props; | ||
} | ||
|
||
public static FieldInfo[] GetAllFields(this Type type) | ||
{ | ||
#if WINRT | ||
FieldInfo[] fields= type.GetTypeInfo().DeclaredFields.ToArray(); | ||
var nonStaticFields = from field in fields | ||
where !field.IsStatic | ||
select field; | ||
return nonStaticFields.ToArray(); | ||
#else | ||
var attrs = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; | ||
return type.GetFields(attrs); | ||
#endif | ||
} | ||
} | ||
public static FieldInfo[] GetAllFields(this Type type) | ||
{ | ||
BindingFlags attrs = ( | ||
BindingFlags.NonPublic | | ||
BindingFlags.Public | | ||
BindingFlags.Instance | | ||
BindingFlags.DeclaredOnly | ||
); | ||
return type.GetFields(attrs); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,29 @@ | ||
#region License | ||
/* | ||
Microsoft Public License (Ms-PL) | ||
MonoGame - Copyright © 2009 The MonoGame Team | ||
All rights reserved. | ||
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not | ||
accept the license, do not use the software. | ||
1. Definitions | ||
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under | ||
U.S. copyright law. | ||
A "contribution" is the original software, or any additions or changes to the software. | ||
A "contributor" is any person that distributes its contribution under this license. | ||
"Licensed patents" are a contributor's patent claims that read directly on its contribution. | ||
2. Grant of Rights | ||
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, | ||
each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. | ||
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, | ||
each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. | ||
3. Conditions and Limitations | ||
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. | ||
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, | ||
your patent license from such contributor to the software ends automatically. | ||
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution | ||
notices that are present in the software. | ||
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including | ||
a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object | ||
code form, you may only do so under a license that complies with this license. | ||
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees | ||
or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent | ||
permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular | ||
purpose and non-infringement. | ||
*/ | ||
#endregion License | ||
|
||
using System; | ||
|
||
namespace Microsoft.Xna.Framework.Content | ||
{ | ||
public class ContentLoadException : Exception | ||
{ | ||
public ContentLoadException() : base() | ||
{ | ||
} | ||
|
||
public ContentLoadException(string message) : base(message) | ||
{ | ||
} | ||
|
||
public ContentLoadException(string message, Exception innerException) : base(message,innerException) | ||
{ | ||
} | ||
} | ||
} | ||
|
||
#region License | ||
/* FNA - XNA4 Reimplementation for Desktop Platforms | ||
* Copyright 2009-2014 Ethan Lee and the MonoGame Team | ||
* | ||
* Released under the Microsoft Public License. | ||
* See LICENSE for details. | ||
*/ | ||
#endregion | ||
|
||
using System; | ||
|
||
namespace Microsoft.Xna.Framework.Content | ||
{ | ||
public class ContentLoadException : Exception | ||
{ | ||
public ContentLoadException() : base() | ||
{ | ||
} | ||
|
||
public ContentLoadException(string message) : base(message) | ||
{ | ||
} | ||
|
||
public ContentLoadException(string message, Exception innerException) : base(message,innerException) | ||
{ | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.