Skip to content

Commit

Permalink
v0.11.1 Singleton=>dll
Browse files Browse the repository at this point in the history
  • Loading branch information
liangxiegame committed Dec 31, 2020
1 parent 24310e1 commit a3048b5
Show file tree
Hide file tree
Showing 1,427 changed files with 173,994 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ Framework/MutiFrameworkSupport.meta
.idea
Unity2017/Library
Unity2017/Temp
Unity2017/Assets/.qframework
Editor.meta
Unity2017/Assets/Plugins/Editor/JetBrains
JetBrains.meta
packages
6 changes: 6 additions & 0 deletions QFramework.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.28803.202
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QFramework.NetStandard21", "PlatformSupport\QFramework.NetStandard21.csproj", "{4C72234F-1E09-4A11-9A99-D5EA517D153F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QFramework.Unity.Runtime", "QFramework\QFramework.Unity.Runtime\QFramework.Unity.Runtime.csproj", "{97CC697F-630C-4834-9136-6A39C5F0261E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{4C72234F-1E09-4A11-9A99-D5EA517D153F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C72234F-1E09-4A11-9A99-D5EA517D153F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C72234F-1E09-4A11-9A99-D5EA517D153F}.Release|Any CPU.Build.0 = Release|Any CPU
{97CC697F-630C-4834-9136-6A39C5F0261E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97CC697F-630C-4834-9136-6A39C5F0261E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97CC697F-630C-4834-9136-6A39C5F0261E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97CC697F-630C-4834-9136-6A39C5F0261E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
49 changes: 49 additions & 0 deletions QFramework/QFramework.Unity.Runtime/Factory/CustomObjectFactory.cs
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();
}
}
}
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 QFramework/QFramework.Unity.Runtime/Factory/IObjectFactory.cs
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();
}
}
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 QFramework/QFramework.Unity.Runtime/Factory/ObjectFactory.cs
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 QFramework/QFramework.Unity.Runtime/Properties/AssemblyInfo.cs
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")]
Loading

0 comments on commit a3048b5

Please sign in to comment.