Update Project

This commit is contained in:
2026-03-20 13:04:43 +02:00
parent 9b587e6cba
commit beae2dea89
2295 changed files with 251259 additions and 33 deletions
@@ -0,0 +1,72 @@
#if !(UNITY_WSA && ENABLE_DOTNET)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Zenject
{
[NoReflectionBaking]
public class ConventionAssemblySelectionBinder
{
public ConventionAssemblySelectionBinder(ConventionBindInfo bindInfo)
{
BindInfo = bindInfo;
}
protected ConventionBindInfo BindInfo
{
get;
private set;
}
public void FromAllAssemblies()
{
// Do nothing
// This is the default
}
public void FromAssemblyContaining<T>()
{
FromAssembliesContaining(typeof(T));
}
public void FromAssembliesContaining(params Type[] types)
{
FromAssembliesContaining((IEnumerable<Type>)types);
}
public void FromAssembliesContaining(IEnumerable<Type> types)
{
FromAssemblies(types.Select(t => t.Assembly).Distinct());
}
public void FromThisAssembly()
{
FromAssemblies(Assembly.GetCallingAssembly());
}
public void FromAssembly(Assembly assembly)
{
FromAssemblies(assembly);
}
public void FromAssemblies(params Assembly[] assemblies)
{
FromAssemblies((IEnumerable<Assembly>)assemblies);
}
public void FromAssemblies(IEnumerable<Assembly> assemblies)
{
BindInfo.AddAssemblyFilter(assembly => assemblies.Contains(assembly));
}
public void FromAssembliesWhere(Func<Assembly, bool> predicate)
{
BindInfo.AddAssemblyFilter(predicate);
}
}
}
#endif
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5229c122d45b5634ebd4b9bccee749ac
timeCreated: 1462127487
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,77 @@
#if !(UNITY_WSA && ENABLE_DOTNET)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Zenject
{
[NoReflectionBaking]
public class ConventionBindInfo
{
readonly List<Func<Type, bool>> _typeFilters = new List<Func<Type, bool>>();
readonly List<Func<Assembly, bool>> _assemblyFilters = new List<Func<Assembly, bool>>();
#if ZEN_MULTITHREADING
readonly object _locker = new object();
#endif
static Dictionary<Assembly, Type[]> _assemblyTypeCache = new Dictionary<Assembly, Type[]>();
public void AddAssemblyFilter(Func<Assembly, bool> predicate)
{
_assemblyFilters.Add(predicate);
}
public void AddTypeFilter(Func<Type, bool> predicate)
{
_typeFilters.Add(predicate);
}
IEnumerable<Assembly> GetAllAssemblies()
{
// This seems fast enough that it's not worth caching
// We also want to allow dynamically loading assemblies
return AppDomain.CurrentDomain.GetAssemblies();
}
bool ShouldIncludeAssembly(Assembly assembly)
{
return _assemblyFilters.All(predicate => predicate(assembly));
}
bool ShouldIncludeType(Type type)
{
return _typeFilters.All(predicate => predicate(type));
}
Type[] GetTypes(Assembly assembly)
{
Type[] types;
#if ZEN_MULTITHREADING
lock (_locker)
#endif
{
// This is much faster than calling assembly.GetTypes() every time
if (!_assemblyTypeCache.TryGetValue(assembly, out types))
{
types = assembly.GetTypes();
_assemblyTypeCache[assembly] = types;
}
}
return types;
}
public List<Type> ResolveTypes()
{
return GetAllAssemblies()
.Where(ShouldIncludeAssembly)
.SelectMany(assembly => GetTypes(assembly))
.Where(ShouldIncludeType).ToList();
}
}
}
#endif
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f1e908965ce63ab40b271724cb5490aa
timeCreated: 1462127523
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,139 @@
#if !(UNITY_WSA && ENABLE_DOTNET)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using ModestTree;
namespace Zenject
{
[NoReflectionBaking]
public class ConventionFilterTypesBinder : ConventionAssemblySelectionBinder
{
public ConventionFilterTypesBinder(ConventionBindInfo bindInfo)
: base(bindInfo)
{
}
public ConventionFilterTypesBinder DerivingFromOrEqual<T>()
{
return DerivingFromOrEqual(typeof(T));
}
public ConventionFilterTypesBinder DerivingFromOrEqual(Type parentType)
{
BindInfo.AddTypeFilter(type => type.DerivesFromOrEqual(parentType));
return this;
}
public ConventionFilterTypesBinder DerivingFrom<T>()
{
return DerivingFrom(typeof(T));
}
public ConventionFilterTypesBinder DerivingFrom(Type parentType)
{
BindInfo.AddTypeFilter(type => type.DerivesFrom(parentType));
return this;
}
public ConventionFilterTypesBinder WithAttribute<T>()
where T : Attribute
{
return WithAttribute(typeof(T));
}
public ConventionFilterTypesBinder WithAttribute(Type attribute)
{
Assert.That(attribute.DerivesFrom<Attribute>());
BindInfo.AddTypeFilter(t => t.HasAttribute(attribute));
return this;
}
public ConventionFilterTypesBinder WithoutAttribute<T>()
where T : Attribute
{
return WithoutAttribute(typeof(T));
}
public ConventionFilterTypesBinder WithoutAttribute(Type attribute)
{
Assert.That(attribute.DerivesFrom<Attribute>());
BindInfo.AddTypeFilter(t => !t.HasAttribute(attribute));
return this;
}
public ConventionFilterTypesBinder WithAttributeWhere<T>(Func<T, bool> predicate)
where T : Attribute
{
BindInfo.AddTypeFilter(t => t.HasAttribute<T>() && t.AllAttributes<T>().All(predicate));
return this;
}
public ConventionFilterTypesBinder Where(Func<Type, bool> predicate)
{
BindInfo.AddTypeFilter(predicate);
return this;
}
public ConventionFilterTypesBinder InNamespace(string ns)
{
return InNamespaces(ns);
}
public ConventionFilterTypesBinder InNamespaces(params string[] namespaces)
{
return InNamespaces((IEnumerable<string>)namespaces);
}
public ConventionFilterTypesBinder InNamespaces(IEnumerable<string> namespaces)
{
BindInfo.AddTypeFilter(t => namespaces.Any(n => IsInNamespace(t, n)));
return this;
}
public ConventionFilterTypesBinder WithSuffix(string suffix)
{
BindInfo.AddTypeFilter(t => t.Name.EndsWith(suffix));
return this;
}
public ConventionFilterTypesBinder WithPrefix(string prefix)
{
BindInfo.AddTypeFilter(t => t.Name.StartsWith(prefix));
return this;
}
public ConventionFilterTypesBinder MatchingRegex(string pattern)
{
return MatchingRegex(pattern, RegexOptions.None);
}
public ConventionFilterTypesBinder MatchingRegex(string pattern, RegexOptions options)
{
return MatchingRegex(new Regex(pattern, options));
}
public ConventionFilterTypesBinder MatchingRegex(Regex regex)
{
BindInfo.AddTypeFilter(t => regex.IsMatch(t.Name));
return this;
}
static bool IsInNamespace(Type type, string requiredNs)
{
var actualNs = type.Namespace ?? "";
if (requiredNs.Length > actualNs.Length)
{
return false;
}
return actualNs.StartsWith(requiredNs)
&& (actualNs.Length == requiredNs.Length || actualNs[requiredNs.Length] == '.');
}
}
}
#endif
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fc3e9c89606ca52458403153ad0d9b3e
timeCreated: 1462127525
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,52 @@
#if !(UNITY_WSA && ENABLE_DOTNET)
namespace Zenject
{
[NoReflectionBaking]
public class ConventionSelectTypesBinder
{
readonly ConventionBindInfo _bindInfo;
public ConventionSelectTypesBinder(ConventionBindInfo bindInfo)
{
_bindInfo = bindInfo;
}
ConventionFilterTypesBinder CreateNextBinder()
{
return new ConventionFilterTypesBinder(_bindInfo);
}
public ConventionFilterTypesBinder AllTypes()
{
// Do nothing (this is the default)
return CreateNextBinder();
}
public ConventionFilterTypesBinder AllClasses()
{
_bindInfo.AddTypeFilter(t => t.IsClass);
return CreateNextBinder();
}
public ConventionFilterTypesBinder AllNonAbstractClasses()
{
_bindInfo.AddTypeFilter(t => t.IsClass && !t.IsAbstract);
return CreateNextBinder();
}
public ConventionFilterTypesBinder AllAbstractClasses()
{
_bindInfo.AddTypeFilter(t => t.IsClass && t.IsAbstract);
return CreateNextBinder();
}
public ConventionFilterTypesBinder AllInterfaces()
{
_bindInfo.AddTypeFilter(t => t.IsInterface);
return CreateNextBinder();
}
}
}
#endif
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 05d17b3e7f09bc44f8be86e01642ee8d
timeCreated: 1462127469
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: