-
Notifications
You must be signed in to change notification settings - Fork 783
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24310e1
commit a3048b5
Showing
1,427 changed files
with
173,994 additions
and
0 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
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
49 changes: 49 additions & 0 deletions
49
QFramework/QFramework.Unity.Runtime/Factory/CustomObjectFactory.cs
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/**************************************************************************** | ||
* Copyright (c) 2020.10 liangxie | ||
* | ||
* https://qframework.cn | ||
* https://github.com/liangxiegame/QFramework | ||
* https://gitee.com/liangxiegame/QFramework | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
****************************************************************************/ | ||
|
||
using System; | ||
|
||
namespace QFramework | ||
{ | ||
/// <summary> | ||
/// 自定义对象工厂:相关对象是 自己定义 | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public class CustomObjectFactory<T> : IObjectFactory<T> | ||
{ | ||
public CustomObjectFactory(Func<T> factoryMethod) | ||
{ | ||
mFactoryMethod = factoryMethod; | ||
} | ||
|
||
protected Func<T> mFactoryMethod; | ||
|
||
public T Create() | ||
{ | ||
return mFactoryMethod(); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
QFramework/QFramework.Unity.Runtime/Factory/DefaultObjectFactory.cs
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/**************************************************************************** | ||
* Copyright (c) 2020.10 liangxie | ||
* | ||
* https://qframework.cn | ||
* https://github.com/liangxiegame/QFramework | ||
* https://gitee.com/liangxiegame/QFramework | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
****************************************************************************/ | ||
|
||
namespace QFramework | ||
{ | ||
/// <summary> | ||
/// 默认对象工厂:相关对象是通过New 出来的 | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public class DefaultObjectFactory<T> : IObjectFactory<T> where T : new() | ||
{ | ||
public T Create() | ||
{ | ||
return new T(); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
QFramework/QFramework.Unity.Runtime/Factory/IObjectFactory.cs
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/**************************************************************************** | ||
* Copyright (c) 2020.10 liangxie | ||
* | ||
* https://qframework.cn | ||
* https://github.com/liangxiegame/QFramework | ||
* https://gitee.com/liangxiegame/QFramework | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
****************************************************************************/ | ||
|
||
namespace QFramework | ||
{ | ||
/// <summary> | ||
/// 对象工厂接口 | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public interface IObjectFactory<T> | ||
{ | ||
/// <summary> | ||
/// 创建对象 | ||
/// </summary> | ||
/// <returns></returns> | ||
T Create(); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
QFramework/QFramework.Unity.Runtime/Factory/NonPublicObjectFactory.cs
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/**************************************************************************** | ||
* Copyright (c) 2020.10 liangxie | ||
* | ||
* https://qframework.cn | ||
* https://github.com/liangxiegame/QFramework | ||
* https://gitee.com/liangxiegame/QFramework | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
****************************************************************************/ | ||
|
||
using System; | ||
using System.Reflection; | ||
|
||
namespace QFramework | ||
{ | ||
/// <summary> | ||
/// 没有公共构造函数的对象工厂:相关对象只能通过反射获得 | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public class NonPublicObjectFactory<T> : IObjectFactory<T> where T : class | ||
{ | ||
public T Create() | ||
{ | ||
var ctors = typeof(T).GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic); | ||
var ctor = Array.Find(ctors, c => c.GetParameters().Length == 0); | ||
|
||
if (ctor == null) | ||
{ | ||
throw new Exception("Non-Public Constructor() not found! in " + typeof(T)); | ||
} | ||
|
||
return ctor.Invoke(null) as T; | ||
} | ||
} | ||
|
||
} |
120 changes: 120 additions & 0 deletions
120
QFramework/QFramework.Unity.Runtime/Factory/ObjectFactory.cs
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 |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/**************************************************************************** | ||
* Copyright (c) 2020.10 liangxie | ||
* | ||
* https://qframework.cn | ||
* https://github.com/liangxiegame/QFramework | ||
* https://gitee.com/liangxiegame/QFramework | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
****************************************************************************/ | ||
|
||
using System; | ||
using System.Reflection; | ||
|
||
namespace QFramework | ||
{ | ||
/// <summary> | ||
/// 对象工厂 | ||
/// </summary> | ||
public class ObjectFactory | ||
{ | ||
/// <summary> | ||
/// 动态创建类的实例:创建有参的构造函数 | ||
/// </summary> | ||
/// <param name="type"></param> | ||
/// <param name="constructorArgs"></param> | ||
/// <returns></returns> | ||
public static object Create(Type type, params object[] constructorArgs) | ||
{ | ||
return Activator.CreateInstance(type, constructorArgs); | ||
} | ||
|
||
/// <summary> | ||
/// 动态创建类的实例:泛型扩展 | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
/// <param name="constructorArgs"></param> | ||
/// <returns></returns> | ||
public static T Create<T>(params object[] constructorArgs) | ||
{ | ||
return (T) Create(typeof(T), constructorArgs); | ||
} | ||
|
||
/// <summary> | ||
/// 动态创建类的实例:创建无参/私有的构造函数 | ||
/// </summary> | ||
/// <param name="type"></param> | ||
/// <returns></returns> | ||
public static object CreateNonPublicConstructorObject(Type type) | ||
{ | ||
// 获取私有构造函数 | ||
var constructorInfos = type.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic); | ||
|
||
// 获取无参构造函数 | ||
var ctor = Array.Find(constructorInfos, c => c.GetParameters().Length == 0); | ||
|
||
if (ctor == null) | ||
{ | ||
throw new Exception("Non-Public Constructor() not found! in " + type); | ||
} | ||
|
||
return ctor.Invoke(null); | ||
} | ||
|
||
/// <summary> | ||
/// 动态创建类的实例:创建无参/私有的构造函数 泛型扩展 | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
/// <returns></returns> | ||
public static T CreateNonPublicConstructorObject<T>() | ||
{ | ||
return (T) CreateNonPublicConstructorObject(typeof(T)); | ||
} | ||
|
||
/// <summary> | ||
/// 创建带有初始化回调的 对象 | ||
/// </summary> | ||
/// <param name="type"></param> | ||
/// <param name="onObjectCreate"></param> | ||
/// <param name="constructorArgs"></param> | ||
/// <returns></returns> | ||
public static object CreateWithInitialAction(Type type, Action<object> onObjectCreate, | ||
params object[] constructorArgs) | ||
{ | ||
var obj = Create(type, constructorArgs); | ||
onObjectCreate(obj); | ||
return obj; | ||
} | ||
|
||
/// <summary> | ||
/// 创建带有初始化回调的 对象:泛型扩展 | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
/// <param name="onObjectCreate"></param> | ||
/// <param name="constructorArgs"></param> | ||
/// <returns></returns> | ||
public static T CreateWithInitialAction<T>(Action<T> onObjectCreate, | ||
params object[] constructorArgs) | ||
{ | ||
var obj = Create<T>(constructorArgs); | ||
onObjectCreate(obj); | ||
return obj; | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
QFramework/QFramework.Unity.Runtime/Properties/AssemblyInfo.cs
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("QFramework.Unity.Runtime")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("QFramework.Unity.Runtime")] | ||
[assembly: AssemblyCopyright("Copyright © 2020")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("97CC697F-630C-4834-9136-6A39C5F0261E")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Oops, something went wrong.