diff --git a/.gitignore b/.gitignore index fad728d..48be77e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,9 @@ **.idea/ +# Unity Engine + +!/[Aa]ssets/**/*.meta +[Aa]ssets/**/csc.* + /[Ll]ibrary/ /[Tt]emp/ /[Oo]bj/ @@ -6,22 +11,76 @@ /[Bb]uilds/ /[Ll]ogs/ /[Uu]ser[Ss]ettings/ - -# MemoryCaptures can get excessive in size. -# They also could contain extremely sensitive data /[Mm]emoryCaptures/ - -# Recordings can get excessive in size /[Rr]ecordings/ +/[Aa]ssets/AssetStoreTools* +/[Aa]ssets/Plugins/Editor/JetBrains* +/[Bb]uild/ +/[Kk]eys/ +/[Tt]rash/ +/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* +/[Aa]ssets/[Ss]treamingAssets/aa.meta +/[Aa]ssets/[Ss]treamingAssets/aa/* +crashlytics-build.properties + +*/[Uu]ser[Ss]ettings/ +*/Library/ +*/[Ll]ibrary/ +*/[Tt]emp/ +*/[Oo]bj/ +*/[Bb]uild/ +*/[Bb]uilds/ +*/[Ll]ogs/ +*/[Aa]ssets/[Ll]ogs/* +*/[Aa]ssets/[Ll]og/* +*/[Mm]emoryCaptures/ +*/Logs/ +*/.vs/ +*ExportedObj/ +.consulo/ +*.csproj +*.unityproj +*.sln +*.suo +*.tmp +*.user +*.userprefs +*.pidb +*.booproj +*.svd +*.pdb +*.mdb +*.opendb +*.VC.db +*.pidb.meta +*.pdb.meta +*.mdb.meta +*/sysinfo.txt +*.apk +*.unitypackage +crashlytics-build.properties -# Uncomment this line if you wish to ignore the asset store tools plugin -# /[Aa]ssets/AssetStoreTools* +**Logs/ +**Examples/ +**Builds/ +**Samples/ +**/Samples.meta +*/Examples/ +*/Examples.meta -# Autogenerated Jetbrains Rider plugin -/[Aa]ssets/Plugins/Editor/JetBrains* +#### Trash folder for temperary solution and removed mechanics. #### +**[Tt]rash/ +**[Tt]rash/**/*.meta +SpaceSuspect/Assets/Trash.meta + +# Unity Spine +**/Spine Examples/ +/[Ss]pine Examples/* -# Visual Studio cache directory +# Visual Strudio .vs/ +*.vsconfig +.vsconfig # Gradle cache directory .gradle/ @@ -58,11 +117,550 @@ sysinfo.txt *.unitypackage *.app -# Crashlytics generated file + +# Exceptions +!*.dll +!*.obj + +#Auto +/UnityLockfile + +#VS Code +.vscode +*.vscode/* +*.vscode +.vscode/ +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +.history + +# Windows +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Rider +**/.idea/ + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +#Visual Studio files +*.[Oo]bj +*.user +*.aps +*.pch +*.vspscc +*.vssscc +*_i.c +*_p.c +*.ncb +*.suo +*.tlb +*.tlh +*.bak +*.[Cc]ache +*.ilk +*.log +*.lib +*.sbr +*.sdf +.pyc +.xml +ipch/ +obj/ +[Bb]in +[Dd]ebug/ +[Rr]elease/ +Ankh.NoLoad + +#Tooling +_ReSharper*/ +.resharper +[Tt]est[Rr]esult + +#Project files +[Bb]uild/ + +#Subversion files +.svn + +#macOS +# Created by https://www.gitignore.io/api/git,unity,macos,csharp,windows,visualstudio,visualstudiocode +# Edit at https://www.gitignore.io/?templates=git,unity,macos,csharp,windows,visualstudio,visualstudiocode + +### Csharp ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +#**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +### Git ### +# Created by git for backups. To disable backups in Git: +# $ git config --global mergetool.keepBackup false +*.orig + +# Created by git when using merge tools for conflicts +*.BACKUP.* +*.BASE.* +*.LOCAL.* +*.REMOTE.* +*_BACKUP_*.txt +*_BASE_*.txt +*_LOCAL_*.txt +*_REMOTE_*.txt + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk -# Packed Addressables -/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* # Temporary auto-generated Android Assets /[Aa]ssets/[Ss]treamingAssets/aa.meta diff --git a/UnityActionUpdaterService/Assets/Internal.meta b/UnityActionUpdaterService/Assets/Internal.meta new file mode 100644 index 0000000..f056b6a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9f642e664a97e6c45b8f3d641c8b7ce9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase.meta b/UnityActionUpdaterService/Assets/Internal/Codebase.meta new file mode 100644 index 0000000..2b45e48 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 175e3bd80f9351f49b6d48a822cfa99a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater.meta b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater.meta new file mode 100644 index 0000000..43a3433 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f04f59c827ada854596cba6caa270a7f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Dispatcher.meta b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Dispatcher.meta new file mode 100644 index 0000000..97491d8 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Dispatcher.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2a20ebd80e35454ca2b2f96fcc0568d9 +timeCreated: 1700078481 \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Dispatcher/ActionUpdateDispatcher.cs b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Dispatcher/ActionUpdateDispatcher.cs new file mode 100644 index 0000000..658dd31 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Dispatcher/ActionUpdateDispatcher.cs @@ -0,0 +1,72 @@ +// Resharper disable all +// **************************************************************** // +// +// Copyright (c) RimuruDev. All rights reserved. +// Contact me: +// - Gmail: rimuru.dev@gmail.com +// - GitHub: https://github.com/RimuruDev +// - LinkedIn: https://www.linkedin.com/in/rimuru/ +// - GitHub Organizations: https://github.com/Rimuru-Dev +// +// **************************************************************** // + +using Zenject; +using UnityEngine; +using RimuruDev.Internal.Codebase.ActionUpdater.Service; + +namespace RimuruDev.Internal.Codebase.ActionUpdater.Dispatcher +{ + /// + /// The ActionUpdateDispatcher is responsible for dispatching update calls + /// to the IActionUpdaterService. It ensures that these updates continue + /// across different scenes, as it persists across scene loads. + /// + [DisallowMultipleComponent] + public sealed class ActionUpdateDispatcher : MonoBehaviour + { + private IActionUpdaterService actionUpdater; + + /// + /// Injects the IActionUpdaterService dependency. + /// This method is called by Zenject to provide the service instance. + /// + /// The action updater service to be used for dispatching update events. + [Inject] + private void Constructor(IActionUpdaterService actionUpdater) => + this.actionUpdater = actionUpdater; + + /// + /// Called when the script instance is being loaded. + /// Ensures this object is not destroyed when loading a new scene. + /// + private void Awake() + { + transform.SetParent(null); + DontDestroyOnLoad(gameObject); + } + + /// + /// Called every fixed framerate frame. Delegates the call to the action updater service. + /// + private void FixedUpdate() => + actionUpdater?.FixedUpdate(); + + /// + /// Called every frame. Delegates the call to the action updater service. + /// + private void Update() => + actionUpdater?.Update(); + + /// + /// Called every frame after Update. Delegates the call to the action updater service. + /// + private void LateUpdate() => + actionUpdater?.LateUpdate(); + + /// + /// Called when the application is quitting. Disposes the action updater service. + /// + private void OnApplicationQuit() => + actionUpdater?.Dispose(); + } +} \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Dispatcher/ActionUpdateDispatcher.cs.meta b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Dispatcher/ActionUpdateDispatcher.cs.meta new file mode 100644 index 0000000..da8b185 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Dispatcher/ActionUpdateDispatcher.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 64fe7a25dc404739b3df57dbe5447840 +timeCreated: 1700078207 \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Enum.meta b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Enum.meta new file mode 100644 index 0000000..3746314 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Enum.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c228d094dab04d49b59679c9c5d7276f +timeCreated: 1700078521 \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Enum/UpdateType.cs b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Enum/UpdateType.cs new file mode 100644 index 0000000..b247a35 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Enum/UpdateType.cs @@ -0,0 +1,40 @@ +// **************************************************************** // +// +// Copyright (c) RimuruDev. All rights reserved. +// Contact me: +// - Gmail: rimuru.dev@gmail.com +// - GitHub: https://github.com/RimuruDev +// - LinkedIn: https://www.linkedin.com/in/rimuru/ +// - GitHub Organizations: https://github.com/Rimuru-Dev +// +// **************************************************************** // + +using System; + +namespace RimuruDev.Internal.Codebase.ActionUpdater.Enum +{ + /// + /// Specifies the type of update method to which an action can be subscribed. + /// + [Serializable] + public enum UpdateType : byte + { + /// + /// Subscribe to the FixedUpdate method, which is called every fixed framerate frame. + /// Suitable for updates in physics calculations. + /// + FixedUpdate = 0, + + /// + /// Subscribe to the Update method, which is called once per frame. + /// Suitable for most game logic. + /// + Update = 1, + + /// + /// Subscribe to the LateUpdate method, which is called once per frame after Update. + /// Suitable for actions that require objects to be updated first. + /// + LateUpdate = 2, + } +} \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Enum/UpdateType.cs.meta b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Enum/UpdateType.cs.meta new file mode 100644 index 0000000..ac74d21 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Enum/UpdateType.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: bdfdd938168f48cd80d6a06005143a0d +timeCreated: 1700077180 \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service.meta b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service.meta new file mode 100644 index 0000000..d91bc89 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f58f598be3d047d98e189a0e7b560336 +timeCreated: 1700078494 \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service/ActionUpdaterService.cs b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service/ActionUpdaterService.cs new file mode 100644 index 0000000..5e4e033 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service/ActionUpdaterService.cs @@ -0,0 +1,149 @@ +// Resharper disable all +// **************************************************************** // +// +// Copyright (c) RimuruDev. All rights reserved. +// Contact me: +// - Gmail: rimuru.dev@gmail.com +// - GitHub: https://github.com/RimuruDev +// - LinkedIn: https://www.linkedin.com/in/rimuru/ +// - GitHub Organizations: https://github.com/Rimuru-Dev +// +// **************************************************************** // + +using System; +using UnityEngine; +using System.Linq; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using RimuruDev.Internal.Codebase.ActionUpdater.Enum; + +namespace RimuruDev.Internal.Codebase.ActionUpdater.Service +{ + /// + /// Manages the subscription of actions to Unity's update methods (FixedUpdate, Update, LateUpdate). + /// Allows for centralized control of update logic, with the ability to pause all actions. + /// + public sealed class ActionUpdaterService : IActionUpdaterService + { + private readonly List fixedUpdateActionCache = new(); + private readonly List updateActionCache = new(); + private readonly List lateUpdateActionCache = new(); + + private event Action OnFixedUpdate; + private event Action OnUpdate; + private event Action OnLateUpdate; + + private bool isPause; + + /// + /// Subscribes an action to a specified update method. + /// + /// The action to subscribe. + /// The type of update method to subscribe to (FixedUpdate, Update, or LateUpdate). + public void Subscribe([NotNull] Action updateable, UpdateType updateType) + { + switch (updateType) + { + case UpdateType.FixedUpdate: + OnFixedUpdate += updateable; + fixedUpdateActionCache.Add(updateable); + break; + case UpdateType.Update: + OnUpdate += updateable; + updateActionCache.Add(updateable); + break; + case UpdateType.LateUpdate: + OnLateUpdate += updateable; + lateUpdateActionCache.Add(updateable); + break; + default: + Debug.LogError($"ArgumentOutOfRangeException: {nameof(updateType)}, {updateType}"); + break; + } + } + + /// + /// Unsubscribes an action from a specified update method. + /// + /// The action to unsubscribe. + /// The type of update method to unsubscribe from. + public void Unsubscribe([NotNull] Action updateable, UpdateType updateType) + { + switch (updateType) + { + case UpdateType.FixedUpdate: + OnFixedUpdate -= updateable; + fixedUpdateActionCache.Remove(updateable); + break; + case UpdateType.Update: + OnUpdate -= updateable; + updateActionCache.Remove(updateable); + break; + case UpdateType.LateUpdate: + OnLateUpdate -= updateable; + lateUpdateActionCache.Remove(updateable); + break; + default: + Debug.LogError($"ArgumentOutOfRangeException: {nameof(updateType)}, {updateType}"); + break; + } + } + + /// + /// Invokes all actions subscribed to FixedUpdate. + /// + public void FixedUpdate() + { + if (isPause) + return; + + OnFixedUpdate?.Invoke(); + } + + /// + /// Invokes all actions subscribed to Update. + /// + public void Update() + { + if (isPause) + return; + + OnUpdate?.Invoke(); + } + + /// + /// Invokes all actions subscribed to LateUpdate. + /// + public void LateUpdate() + { + if (isPause) + return; + + OnLateUpdate?.Invoke(); + } + + /// + /// Sets or unsets the pause state of the update actions. + /// + /// True to pause, false to resume. + public void SetPause(bool pause) => + isPause = pause; + + /// + /// Unsubscribes all actions from their respective update methods. + /// + public void Dispose() + { + UnsubscribeAll(fixedUpdateActionCache, ref OnFixedUpdate); + UnsubscribeAll(updateActionCache, ref OnUpdate); + UnsubscribeAll(lateUpdateActionCache, ref OnLateUpdate); + } + + private static void UnsubscribeAll(ICollection actionList, ref Action eventDelegate) + { + eventDelegate = actionList.Aggregate(eventDelegate, (current, action) => current - action); + + actionList.Clear(); + } + } +} \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service/ActionUpdaterService.cs.meta b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service/ActionUpdaterService.cs.meta new file mode 100644 index 0000000..8b2031a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service/ActionUpdaterService.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: bcccbe046a054fb8a91bb959416a0184 +timeCreated: 1700075330 \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service/IActionUpdaterService.cs b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service/IActionUpdaterService.cs new file mode 100644 index 0000000..8c8d73e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service/IActionUpdaterService.cs @@ -0,0 +1,59 @@ +// Resharper disable all +// **************************************************************** // +// +// Copyright (c) RimuruDev. All rights reserved. +// Contact me: +// - Gmail: rimuru.dev@gmail.com +// - GitHub: https://github.com/RimuruDev +// - LinkedIn: https://www.linkedin.com/in/rimuru/ +// - GitHub Organizations: https://github.com/Rimuru-Dev +// +// **************************************************************** // + +using System; +using System.Diagnostics.CodeAnalysis; +using RimuruDev.Internal.Codebase.ActionUpdater.Enum; + +namespace RimuruDev.Internal.Codebase.ActionUpdater.Service +{ + /// + /// Provides a service for subscribing actions to Unity's lifecycle methods. + /// + public interface IActionUpdaterService : IDisposable + { + /// + /// Subscribes an action to a specified update type. + /// + /// The action to subscribe. + /// The type of update to subscribe to (FixedUpdate, Update, or LateUpdate). + public void Subscribe([NotNull] Action updateable, UpdateType updateType); + + /// + /// Unsubscribes an action from a specified update type. + /// + /// The action to unsubscribe. + /// The type of update to unsubscribe from. + public void Unsubscribe([NotNull] Action updateable, UpdateType updateType); + + /// + /// Invokes actions subscribed to FixedUpdate. + /// + public void FixedUpdate(); + + /// + /// Invokes actions subscribed to Update. + /// + public void Update(); + + /// + /// Invokes actions subscribed to LateUpdate. + /// + public void LateUpdate(); + + /// + /// Pauses or resumes the execution of subscribed actions. + /// + /// True to pause actions, false to resume. + public void SetPause(bool pause); + } +} \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service/IActionUpdaterService.cs.meta b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service/IActionUpdaterService.cs.meta new file mode 100644 index 0000000..9d54421 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/ActionUpdater/Service/IActionUpdaterService.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 778dae435f234497a2c5a9935d36a823 +timeCreated: 1700077175 \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/Example.meta b/UnityActionUpdaterService/Assets/Internal/Codebase/Example.meta new file mode 100644 index 0000000..8b9ec9b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/Example.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2f27a36986e347bb9fc51576c387e4ad +timeCreated: 1700078604 \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/Example/ExampleBehaviour.cs b/UnityActionUpdaterService/Assets/Internal/Codebase/Example/ExampleBehaviour.cs new file mode 100644 index 0000000..1c709c8 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/Example/ExampleBehaviour.cs @@ -0,0 +1,48 @@ +// Resharper disable all +// **************************************************************** // +// +// Copyright (c) RimuruDev. All rights reserved. +// Contact me: +// - Gmail: rimuru.dev@gmail.com +// - GitHub: https://github.com/RimuruDev +// - LinkedIn: https://www.linkedin.com/in/rimuru/ +// - GitHub Organizations: https://github.com/Rimuru-Dev +// +// **************************************************************** // + +using Zenject; +using UnityEngine; +using RimuruDev.Internal.Codebase.ActionUpdater.Service; + +namespace RimuruDev.Internal.Codebase.Example +{ + /// + /// ExampleBehaviour demonstrates how to use the IActionUpdaterService in a MonoBehaviour. + /// It initializes and uses a Hero object which is not a MonoBehaviour. + /// + [DisallowMultipleComponent] + public sealed class ExampleBehaviour : MonoBehaviour + { + private Hero hero; + private IActionUpdaterService actionUpdater; + + /// + /// Injects the IActionUpdaterService dependency. + /// This method is called by Zenject to provide the service instance. + /// + /// The action updater service to be used. + [Inject] + private void Constructor(IActionUpdaterService actionUpdater) => + this.actionUpdater = actionUpdater; + + /// + /// Called when the script instance is being loaded. + /// Initializes the Hero object and prepares it for updates. + /// + private void Start() + { + hero = new Hero(actionUpdater); + hero.Prepare(); + } + } +} \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/Example/ExampleBehaviour.cs.meta b/UnityActionUpdaterService/Assets/Internal/Codebase/Example/ExampleBehaviour.cs.meta new file mode 100644 index 0000000..0a97ab9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/Example/ExampleBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c77685354f2b408c952b912974615fbe +timeCreated: 1700078812 \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/Example/Hero.cs b/UnityActionUpdaterService/Assets/Internal/Codebase/Example/Hero.cs new file mode 100644 index 0000000..c58ca69 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/Example/Hero.cs @@ -0,0 +1,62 @@ +// Resharper disable all +// **************************************************************** // +// +// Copyright (c) RimuruDev. All rights reserved. +// Contact me: +// - Gmail: rimuru.dev@gmail.com +// - GitHub: https://github.com/RimuruDev +// - LinkedIn: https://www.linkedin.com/in/rimuru/ +// - GitHub Organizations: https://github.com/Rimuru-Dev +// +// **************************************************************** // + + +using UnityEngine; +using RimuruDev.Internal.Codebase.ActionUpdater.Enum; +using RimuruDev.Internal.Codebase.ActionUpdater.Service; + +namespace RimuruDev.Internal.Codebase.Example +{ + /// + /// Hero class that demonstrates how to subscribe to update events using the IActionUpdaterService. + /// It logs different types of updates: FixedUpdate, Update, and LateUpdate. + /// + public sealed class Hero + { + private const string DebugFormat = "{0}"; + private readonly IActionUpdaterService updaterService; + + /// + /// Initializes a new instance of the Hero class. + /// + /// The IActionUpdaterService instance to use for subscribing to update events. + public Hero(IActionUpdaterService updaterService) => + this.updaterService = updaterService; + + /// + /// Prepares the Hero by subscribing to various update types. + /// + public void Prepare() + { + updaterService.Subscribe(OnFixedUpdate, UpdateType.FixedUpdate); + updaterService.Subscribe(OnUpdate, UpdateType.Update); + updaterService.Subscribe(OnLateUpdate, UpdateType.LateUpdate); + } + + private void OnFixedUpdate() => + LogFormat("OnFixedUpdate"); + + private void OnUpdate() => + LogFormat("OnUpdate"); + + private void OnLateUpdate() => + LogFormat("OnLateUpdate"); + + /// + /// Logs the specified message in a formatted manner. + /// + /// The message to log. + private void LogFormat(string message) => + Debug.LogFormat(DebugFormat, message); + } +} \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/Example/Hero.cs.meta b/UnityActionUpdaterService/Assets/Internal/Codebase/Example/Hero.cs.meta new file mode 100644 index 0000000..4a74d7a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/Example/Hero.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 903a2dde4bbe4006bbddf3cbc645b3a1 +timeCreated: 1700079254 \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/Example/ServicesInstaller.cs b/UnityActionUpdaterService/Assets/Internal/Codebase/Example/ServicesInstaller.cs new file mode 100644 index 0000000..4affb45 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/Example/ServicesInstaller.cs @@ -0,0 +1,22 @@ +// Resharper disable all +// **************************************************************** // +// +// Copyright (c) RimuruDev. All rights reserved. +// Contact me: +// - Gmail: rimuru.dev@gmail.com +// - GitHub: https://github.com/RimuruDev +// - LinkedIn: https://www.linkedin.com/in/rimuru/ +// - GitHub Organizations: https://github.com/Rimuru-Dev +// +// **************************************************************** // + +using Zenject; +using RimuruDev.Internal.Codebase.ActionUpdater.Service; + +namespace RimuruDev.Internal.Codebase.Example +{ + public sealed class ServicesInstaller : MonoInstaller + { + public override void InstallBindings() => Container.Bind().To().AsSingle(); + } +} \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Codebase/Example/ServicesInstaller.cs.meta b/UnityActionUpdaterService/Assets/Internal/Codebase/Example/ServicesInstaller.cs.meta new file mode 100644 index 0000000..f2a4a3b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Codebase/Example/ServicesInstaller.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c8a5b6d620b74e5299d770435fc5cd30 +timeCreated: 1700078659 \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Internal/Scenes.meta b/UnityActionUpdaterService/Assets/Internal/Scenes.meta new file mode 100644 index 0000000..bcdd36e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Scenes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 59cff8f52240ff94096ca3c08f4e12c0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Internal/Scenes/SampleScene.unity b/UnityActionUpdaterService/Assets/Internal/Scenes/SampleScene.unity new file mode 100644 index 0000000..c0b83be --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Scenes/SampleScene.unity @@ -0,0 +1,490 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 705507994} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &167001496 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 167001497} + m_Layer: 0 + m_Name: Default + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &167001497 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 167001496} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 963194228} + - {fileID: 705507995} + m_Father: {fileID: 483265470} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &483265469 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 483265470} + m_Layer: 0 + m_Name: '[=== Level ===]' + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &483265470 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 483265469} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 167001497} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &705507993 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 705507995} + - component: {fileID: 705507994} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &705507994 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 705507993} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 1 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &705507995 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 705507993} + serializedVersion: 2 + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 167001497} + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &731004644 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 731004645} + m_Layer: 0 + m_Name: '[ === Logic ===]' + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &731004645 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 731004644} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1592165483} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &963194225 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 963194228} + - component: {fileID: 963194227} + - component: {fileID: 963194226} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &963194226 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_Enabled: 1 +--- !u!20 &963194227 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &963194228 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 167001497} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1592165482 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1592165483} + - component: {fileID: 1592165484} + - component: {fileID: 1592165485} + m_Layer: 0 + m_Name: Example + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1592165483 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1592165482} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 731004645} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1592165484 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1592165482} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c77685354f2b408c952b912974615fbe, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &1592165485 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1592165482} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 89715ad69b973a14899afa2c6730b30b, type: 3} + m_Name: + m_EditorClassIdentifier: + _scriptableObjectInstallers: [] + _monoInstallers: [] + _installerPrefabs: [] + _autoRun: 1 + OnPreInstall: + m_PersistentCalls: + m_Calls: [] + OnPostInstall: + m_PersistentCalls: + m_Calls: [] + OnPreResolve: + m_PersistentCalls: + m_Calls: [] + OnPostResolve: + m_PersistentCalls: + m_Calls: [] + _parentNewObjectsUnderSceneContext: 0 + _contractNames: [] + _parentContractNames: [] +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 731004645} + - {fileID: 483265470} diff --git a/UnityActionUpdaterService/Assets/Internal/Scenes/SampleScene.unity.meta b/UnityActionUpdaterService/Assets/Internal/Scenes/SampleScene.unity.meta new file mode 100644 index 0000000..952bd1e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Internal/Scenes/SampleScene.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9fc0d4010bbf28b4594072e72b8655ab +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins.meta b/UnityActionUpdaterService/Assets/Plugins.meta new file mode 100644 index 0000000..620f704 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f2fbb4840767b2f40aea5c5af3dcb040 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject.meta new file mode 100644 index 0000000..c17969c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4a7d1a42c093ce541aa4be581b78bedf +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/LICENSE.txt b/UnityActionUpdaterService/Assets/Plugins/Zenject/LICENSE.txt new file mode 100644 index 0000000..4602c9f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/LICENSE.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) 2010-2015 Modest Tree Media http://www.modesttree.com + +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. + +https://github.com/svermeulen/Extenject/blob/master/License.md diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/LICENSE.txt.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/LICENSE.txt.meta new file mode 100644 index 0000000..93b9dcd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/LICENSE.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 75406829aaca6154491302d85b26270a +timeCreated: 1427860624 +licenseType: Store +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/ReadMe.url b/UnityActionUpdaterService/Assets/Plugins/Zenject/ReadMe.url new file mode 100644 index 0000000..7fecc01 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/ReadMe.url @@ -0,0 +1,2 @@ +[InternetShortcut] +URL=https://github.com/svermeulen/Extenject diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/ReadMe.url.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/ReadMe.url.meta new file mode 100644 index 0000000..088afbe --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/ReadMe.url.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 937aea47cf7f0864cb39571ca85e205d +timeCreated: 1529238438 +licenseType: Store +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source.meta new file mode 100644 index 0000000..2cf0cda --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9180a9720c42cb94f9b30a7c0c938d90 +folderAsset: yes +timeCreated: 1452188407 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding.meta new file mode 100644 index 0000000..2a9e72c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e92094ea8d3ee634f858163622b6abbb +folderAsset: yes +timeCreated: 1459463884 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo.meta new file mode 100644 index 0000000..d78bc8b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a78a183f887b72e45b2ec6d77fb514d8 +folderAsset: yes +timeCreated: 1461708046 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/BindInfo.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/BindInfo.cs new file mode 100644 index 0000000..6d0c754 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/BindInfo.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using Zenject.Internal; + +namespace Zenject +{ + public enum ScopeTypes + { + Unset, + Transient, + Singleton + } + + public enum ToChoices + { + Self, + Concrete + } + + public enum InvalidBindResponses + { + Assert, + Skip + } + + public enum BindingInheritanceMethods + { + None, + CopyIntoAll, + CopyDirectOnly, + MoveIntoAll, + MoveDirectOnly + } + + [NoReflectionBaking] + public class BindInfo : IDisposable + { + public bool MarkAsCreationBinding; + public bool MarkAsUniqueSingleton; + public object ConcreteIdentifier; + public bool SaveProvider; + public bool OnlyBindIfNotBound; + public bool RequireExplicitScope; + public object Identifier; + public readonly List ContractTypes; + public BindingInheritanceMethods BindingInheritanceMethod; + public InvalidBindResponses InvalidBindResponse; + public bool NonLazy; + public BindingCondition Condition; + public ToChoices ToChoice; + public string ContextInfo; + public readonly List ToTypes; // Only relevant with ToChoices.Concrete + public ScopeTypes Scope; + public readonly List Arguments; + public Action InstantiatedCallback; + + public BindInfo() + { + ContractTypes = new List(); + ToTypes = new List(); + Arguments = new List(); + + Reset(); + } + + public void Dispose() + { + ZenPools.DespawnBindInfo(this); + } + + [Conditional("UNITY_EDITOR")] + public void SetContextInfo(string contextInfo) + { + ContextInfo = contextInfo; + } + + public void Reset() + { + MarkAsCreationBinding = true; + MarkAsUniqueSingleton = false; + ConcreteIdentifier = null; + SaveProvider = false; + OnlyBindIfNotBound = false; + RequireExplicitScope = false; + Identifier = null; + ContractTypes.Clear(); + BindingInheritanceMethod = BindingInheritanceMethods.None; + InvalidBindResponse = InvalidBindResponses.Assert; + NonLazy = false; + Condition = null; + ToChoice = ToChoices.Self; + ContextInfo = null; + ToTypes.Clear(); + Scope = ScopeTypes.Unset; + Arguments.Clear(); + InstantiatedCallback = null; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/BindInfo.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/BindInfo.cs.meta new file mode 100644 index 0000000..5732ba9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/BindInfo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 647e28e377c50e549b443131ce6163fc +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/BindStatement.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/BindStatement.cs new file mode 100644 index 0000000..c3e9993 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/BindStatement.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using ModestTree; +using Zenject.Internal; + +namespace Zenject +{ + [NoReflectionBaking] + public class BindStatement : IDisposable + { + readonly List _disposables; + IBindingFinalizer _bindingFinalizer; + + public BindStatement() + { + _disposables = new List(); + Reset(); + } + + public BindingInheritanceMethods BindingInheritanceMethod + { + get + { + AssertHasFinalizer(); + return _bindingFinalizer.BindingInheritanceMethod; + } + } + + public bool HasFinalizer + { + get { return _bindingFinalizer != null; } + } + + public void SetFinalizer(IBindingFinalizer bindingFinalizer) + { + _bindingFinalizer = bindingFinalizer; + } + + void AssertHasFinalizer() + { + if (_bindingFinalizer == null) + { + throw Assert.CreateException( + "Unfinished binding! Some required information was left unspecified."); + } + } + + public void AddDisposable(IDisposable disposable) + { + _disposables.Add(disposable); + } + + public BindInfo SpawnBindInfo() + { + var bindInfo = ZenPools.SpawnBindInfo(); + AddDisposable(bindInfo); + return bindInfo; + } + + public void FinalizeBinding(DiContainer container) + { + AssertHasFinalizer(); + _bindingFinalizer.FinalizeBinding(container); + } + + public void Reset() + { + _bindingFinalizer = null; + + for (int i = 0; i < _disposables.Count; i++) + { + _disposables[i].Dispose(); + } + + _disposables.Clear(); + } + + public void Dispose() + { + ZenPools.DespawnStatement(this); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/BindStatement.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/BindStatement.cs.meta new file mode 100644 index 0000000..d563e24 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/BindStatement.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 63a8f1068d150404f820c8cc9057dbc8 +timeCreated: 1535868299 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/FactoryBindInfo.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/FactoryBindInfo.cs new file mode 100644 index 0000000..c15cf2e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/FactoryBindInfo.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryBindInfo + { + public FactoryBindInfo(Type factoryType) + { + FactoryType = factoryType; + Arguments = new List(); + } + + public Type FactoryType + { + get; private set; + } + + public Func ProviderFunc + { + get; set; + } + + public List Arguments + { + get; + set; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/FactoryBindInfo.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/FactoryBindInfo.cs.meta new file mode 100644 index 0000000..80e44ba --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/FactoryBindInfo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e69b2b4566e331e44a9f92e4e309816a +timeCreated: 1484520532 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/GameObjectCreationParameters.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/GameObjectCreationParameters.cs new file mode 100644 index 0000000..ab1774c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/GameObjectCreationParameters.cs @@ -0,0 +1,93 @@ +#if !NOT_UNITY3D + +using System; +using UnityEngine; + +namespace Zenject +{ + [NoReflectionBaking] + public class GameObjectCreationParameters + { + public string Name + { + get; + set; + } + + public string GroupName + { + get; + set; + } + + public Transform ParentTransform + { + get; + set; + } + + public Func ParentTransformGetter + { + get; + set; + } + + public Vector3? Position + { + get; + set; + } + + public Quaternion? Rotation + { + get; + set; + } + + public static readonly GameObjectCreationParameters Default = new GameObjectCreationParameters(); + + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hash = 17; + hash = hash * 29 + (Name == null ? 0 : Name.GetHashCode()); + hash = hash * 29 + (GroupName == null ? 0 : GroupName.GetHashCode()); + hash = hash * 29 + (ParentTransform == null ? 0 : ParentTransform.GetHashCode()); + hash = hash * 29 + (ParentTransformGetter == null ? 0 : ParentTransformGetter.GetHashCode()); + hash = hash * 29 + (!Position.HasValue ? 0 : Position.Value.GetHashCode()); + hash = hash * 29 + (!Rotation.HasValue ? 0 : Rotation.Value.GetHashCode()); + return hash; + } + } + + public override bool Equals(object other) + { + if (other is GameObjectCreationParameters) + { + GameObjectCreationParameters otherId = (GameObjectCreationParameters)other; + return otherId == this; + } + + return false; + } + + public bool Equals(GameObjectCreationParameters that) + { + return this == that; + } + + public static bool operator ==(GameObjectCreationParameters left, GameObjectCreationParameters right) + { + return Equals(left.Name, right.Name) + && Equals(left.GroupName, right.GroupName); + } + + public static bool operator !=(GameObjectCreationParameters left, GameObjectCreationParameters right) + { + return !left.Equals(right); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/GameObjectCreationParameters.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/GameObjectCreationParameters.cs.meta new file mode 100644 index 0000000..5a28c63 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/GameObjectCreationParameters.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2b708f7f76ea5574e9a39b60cc5a8238 +timeCreated: 1477163090 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/MemoryPoolBindInfo.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/MemoryPoolBindInfo.cs new file mode 100644 index 0000000..5ca06a3 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/MemoryPoolBindInfo.cs @@ -0,0 +1,35 @@ +namespace Zenject +{ + public enum PoolExpandMethods + { + OneAtATime, + Double, + Disabled + } + + [NoReflectionBaking] + public class MemoryPoolBindInfo + { + public MemoryPoolBindInfo() + { + ExpandMethod = PoolExpandMethods.OneAtATime; + MaxSize = int.MaxValue; + } + + public PoolExpandMethods ExpandMethod + { + get; set; + } + + public int InitialSize + { + get; set; + } + + public int MaxSize + { + get; set; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/MemoryPoolBindInfo.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/MemoryPoolBindInfo.cs.meta new file mode 100644 index 0000000..22d71e5 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindInfo/MemoryPoolBindInfo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3f8798fbf64bca945a7be04615c08c4f +timeCreated: 1485711462 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders.meta new file mode 100644 index 0000000..b33afc1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 3e0d343c02f9d0a488a62abffae00ceb +folderAsset: yes +timeCreated: 1461708046 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ArgConditionCopyNonLazyBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ArgConditionCopyNonLazyBinder.cs new file mode 100644 index 0000000..21bb923 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ArgConditionCopyNonLazyBinder.cs @@ -0,0 +1,106 @@ +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class ArgConditionCopyNonLazyBinder : InstantiateCallbackConditionCopyNonLazyBinder + { + public ArgConditionCopyNonLazyBinder(BindInfo bindInfo) + : base(bindInfo) + { + } + + // We use generics instead of params object[] so that we preserve type info + // So that you can for example pass in a variable that is null and the type info will + // still be used to map null on to the correct field + public InstantiateCallbackConditionCopyNonLazyBinder WithArguments(T param) + { + BindInfo.Arguments.Clear(); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param)); + return this; + } + + public InstantiateCallbackConditionCopyNonLazyBinder WithArguments(TParam1 param1, TParam2 param2) + { + BindInfo.Arguments.Clear(); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param1)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param2)); + return this; + } + + public InstantiateCallbackConditionCopyNonLazyBinder WithArguments( + TParam1 param1, TParam2 param2, TParam3 param3) + { + BindInfo.Arguments.Clear(); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param1)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param2)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param3)); + return this; + } + + public InstantiateCallbackConditionCopyNonLazyBinder WithArguments( + TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4) + { + BindInfo.Arguments.Clear(); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param1)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param2)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param3)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param4)); + return this; + } + + public InstantiateCallbackConditionCopyNonLazyBinder WithArguments( + TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5) + { + BindInfo.Arguments.Clear(); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param1)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param2)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param3)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param4)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param5)); + return this; + } + + public InstantiateCallbackConditionCopyNonLazyBinder WithArguments( + TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6) + { + BindInfo.Arguments.Clear(); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param1)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param2)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param3)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param4)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param5)); + BindInfo.Arguments.Add(InjectUtil.CreateTypePair(param6)); + return this; + } + + public InstantiateCallbackConditionCopyNonLazyBinder WithArguments(object[] args) + { + BindInfo.Arguments.Clear(); + + for (int i = 0; i < args.Length; i++) + { + var arg = args[i]; + + Assert.IsNotNull(arg, + "Cannot include null values when creating a zenject argument list because zenject has no way of deducing the type from a null value. If you want to allow null, use the Explicit form."); + + BindInfo.Arguments.Add( + new TypeValuePair(arg.GetType(), arg)); + } + return this; + } + + public InstantiateCallbackConditionCopyNonLazyBinder WithArgumentsExplicit(IEnumerable extraArgs) + { + BindInfo.Arguments.Clear(); + + foreach (var arg in extraArgs) + { + BindInfo.Arguments.Add(arg); + } + return this; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ArgConditionCopyNonLazyBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ArgConditionCopyNonLazyBinder.cs.meta new file mode 100644 index 0000000..89f9067 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ArgConditionCopyNonLazyBinder.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d0eff25a90fc7a4479dbb9a1f74dddc2 +timeCreated: 1483833202 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders.meta new file mode 100644 index 0000000..7087823 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b3b29de51c8625443984cbd926505d00 +folderAsset: yes +timeCreated: 1461708047 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteBinderGeneric.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteBinderGeneric.cs new file mode 100644 index 0000000..957f69c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteBinderGeneric.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class ConcreteBinderGeneric : FromBinderGeneric + { + public ConcreteBinderGeneric( + DiContainer bindContainer, BindInfo bindInfo, + BindStatement bindStatement) + : base(bindContainer, bindInfo, bindStatement) + { + ToSelf(); + } + + // Note that this is the default, so not necessary to call + public FromBinderGeneric ToSelf() + { + Assert.IsEqual(BindInfo.ToChoice, ToChoices.Self); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, (container, type) => new TransientProvider( + type, container, BindInfo.Arguments, + BindInfo.ContextInfo, BindInfo.ConcreteIdentifier, + BindInfo.InstantiatedCallback)); + + return this; + } + + public FromBinderGeneric To() + where TConcrete : TContract + { + BindInfo.ToChoice = ToChoices.Concrete; + BindInfo.ToTypes.Clear(); + BindInfo.ToTypes.Add(typeof(TConcrete)); + + return new FromBinderGeneric( + BindContainer, BindInfo, BindStatement); + } + + public FromBinderNonGeneric To(params Type[] concreteTypes) + { + return To((IEnumerable)concreteTypes); + } + + public FromBinderNonGeneric To(IEnumerable concreteTypes) + { + BindingUtil.AssertIsDerivedFromTypes( + concreteTypes, BindInfo.ContractTypes, BindInfo.InvalidBindResponse); + + BindInfo.ToChoice = ToChoices.Concrete; + BindInfo.ToTypes.Clear(); + BindInfo.ToTypes.AddRange(concreteTypes); + + return new FromBinderNonGeneric( + BindContainer, BindInfo, BindStatement); + } + +#if !(UNITY_WSA && ENABLE_DOTNET) + public FromBinderNonGeneric To( + Action generator) + { + var bindInfo = new ConventionBindInfo(); + + // Automatically filter by the given contract types + bindInfo.AddTypeFilter( + concreteType => BindInfo.ContractTypes.All(contractType => concreteType.DerivesFromOrEqual(contractType))); + + generator(new ConventionSelectTypesBinder(bindInfo)); + return To(bindInfo.ResolveTypes()); + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteBinderGeneric.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteBinderGeneric.cs.meta new file mode 100644 index 0000000..a8ddd43 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteBinderGeneric.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 62ec581e8d820a74797d1dabf19d85c3 +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteBinderNonGeneric.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteBinderNonGeneric.cs new file mode 100644 index 0000000..3bf7135 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteBinderNonGeneric.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class ConcreteBinderNonGeneric : FromBinderNonGeneric + { + public ConcreteBinderNonGeneric( + DiContainer bindContainer, BindInfo bindInfo, + BindStatement bindStatement) + : base(bindContainer, bindInfo, bindStatement) + { + ToSelf(); + } + + // Note that this is the default, so not necessary to call + public FromBinderNonGeneric ToSelf() + { + Assert.IsEqual(BindInfo.ToChoice, ToChoices.Self); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, (container, type) => new TransientProvider( + type, container, BindInfo.Arguments, BindInfo.ContextInfo, BindInfo.ConcreteIdentifier, + BindInfo.InstantiatedCallback)); + + return this; + } + + public FromBinderNonGeneric To() + { + return To(typeof(TConcrete)); + } + + public FromBinderNonGeneric To(params Type[] concreteTypes) + { + return To((IEnumerable)concreteTypes); + } + + public FromBinderNonGeneric To(IEnumerable concreteTypes) + { + BindInfo.ToChoice = ToChoices.Concrete; + BindInfo.ToTypes.Clear(); + BindInfo.ToTypes.AddRange(concreteTypes); + + if (BindInfo.ToTypes.Count > 1 && BindInfo.ContractTypes.Count > 1) + { + // Be more lenient in this case to behave similar to convention based bindings + BindInfo.InvalidBindResponse = InvalidBindResponses.Skip; + } + else + { + BindingUtil.AssertIsDerivedFromTypes(concreteTypes, BindInfo.ContractTypes, BindInfo.InvalidBindResponse); + } + + return this; + } + +#if !(UNITY_WSA && ENABLE_DOTNET) + public FromBinderNonGeneric To( + Action generator) + { + var bindInfo = new ConventionBindInfo(); + + // This is nice because it allows us to do things like Bind(all interfaces).To(specific types) + // instead of having to do Bind(all interfaces).To(specific types that inherit from one of these interfaces) + BindInfo.InvalidBindResponse = InvalidBindResponses.Skip; + + generator(new ConventionSelectTypesBinder(bindInfo)); + + BindInfo.ToChoice = ToChoices.Concrete; + BindInfo.ToTypes.Clear(); + BindInfo.ToTypes.AddRange(bindInfo.ResolveTypes()); + + return this; + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteBinderNonGeneric.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteBinderNonGeneric.cs.meta new file mode 100644 index 0000000..783b034 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteBinderNonGeneric.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b04935d23b1499e42a242d63a3fe248b +timeCreated: 1461708052 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteIdBinderGeneric.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteIdBinderGeneric.cs new file mode 100644 index 0000000..f351e2a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteIdBinderGeneric.cs @@ -0,0 +1,20 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class ConcreteIdBinderGeneric : ConcreteBinderGeneric + { + public ConcreteIdBinderGeneric( + DiContainer bindContainer, BindInfo bindInfo, + BindStatement bindStatement) + : base(bindContainer, bindInfo, bindStatement) + { + } + + public ConcreteBinderGeneric WithId(object identifier) + { + BindInfo.Identifier = identifier; + return this; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteIdBinderGeneric.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteIdBinderGeneric.cs.meta new file mode 100644 index 0000000..5b29cbd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteIdBinderGeneric.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 358cdf402ef00ff40ac81f3bbe7018f0 +timeCreated: 1463318690 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteIdBinderNonGeneric.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteIdBinderNonGeneric.cs new file mode 100644 index 0000000..d80f2ca --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteIdBinderNonGeneric.cs @@ -0,0 +1,20 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class ConcreteIdBinderNonGeneric : ConcreteBinderNonGeneric + { + public ConcreteIdBinderNonGeneric( + DiContainer bindContainer, BindInfo bindInfo, + BindStatement bindStatement) + : base(bindContainer, bindInfo, bindStatement) + { + } + + public ConcreteBinderNonGeneric WithId(object identifier) + { + BindInfo.Identifier = identifier; + return this; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteIdBinderNonGeneric.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteIdBinderNonGeneric.cs.meta new file mode 100644 index 0000000..7179ace --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteBinders/ConcreteIdBinderNonGeneric.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1251d518904c9574897614d756f76756 +timeCreated: 1463318690 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteIdArgConditionCopyNonLazyBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteIdArgConditionCopyNonLazyBinder.cs new file mode 100644 index 0000000..4b84dbf --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteIdArgConditionCopyNonLazyBinder.cs @@ -0,0 +1,17 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class ConcreteIdArgConditionCopyNonLazyBinder : ArgConditionCopyNonLazyBinder + { + public ConcreteIdArgConditionCopyNonLazyBinder(BindInfo bindInfo) + : base(bindInfo) + { + } + + public ArgConditionCopyNonLazyBinder WithConcreteId(object id) + { + BindInfo.ConcreteIdentifier = id; + return this; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteIdArgConditionCopyNonLazyBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteIdArgConditionCopyNonLazyBinder.cs.meta new file mode 100644 index 0000000..26a444b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConcreteIdArgConditionCopyNonLazyBinder.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 5803a20c252d8ae4498e79e8b3bb09e0 +timeCreated: 1523257672 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConditionCopyNonLazyBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConditionCopyNonLazyBinder.cs new file mode 100644 index 0000000..27feedd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConditionCopyNonLazyBinder.cs @@ -0,0 +1,41 @@ +using System; +using System.Linq; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class ConditionCopyNonLazyBinder : CopyNonLazyBinder + { + public ConditionCopyNonLazyBinder(BindInfo bindInfo) + : base(bindInfo) + { + } + + public CopyNonLazyBinder When(BindingCondition condition) + { + BindInfo.Condition = condition; + return this; + } + + public CopyNonLazyBinder WhenInjectedIntoInstance(object instance) + { + return When(r => ReferenceEquals(r.ObjectInstance, instance)); + } + + public CopyNonLazyBinder WhenInjectedInto(params Type[] targets) + { + return When(r => targets.Where(x => r.ObjectType != null && r.ObjectType.DerivesFromOrEqual(x)).Any()); + } + + public CopyNonLazyBinder WhenInjectedInto() + { + return When(r => r.ObjectType != null && r.ObjectType.DerivesFromOrEqual(typeof(T))); + } + + public CopyNonLazyBinder WhenNotInjectedInto() + { + return When(r => r.ObjectType == null || !r.ObjectType.DerivesFromOrEqual(typeof(T))); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConditionCopyNonLazyBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConditionCopyNonLazyBinder.cs.meta new file mode 100644 index 0000000..ad17b93 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ConditionCopyNonLazyBinder.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a638543bf618ed94fb418f48d9ea9329 +timeCreated: 1483833202 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions.meta new file mode 100644 index 0000000..58cc4d2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: cecd58a5468ced54aabe6cc4d2eed9a8 +folderAsset: yes +timeCreated: 1462127452 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionAssemblySelectionBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionAssemblySelectionBinder.cs new file mode 100644 index 0000000..4f560c9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionAssemblySelectionBinder.cs @@ -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() + { + FromAssembliesContaining(typeof(T)); + } + + public void FromAssembliesContaining(params Type[] types) + { + FromAssembliesContaining((IEnumerable)types); + } + + public void FromAssembliesContaining(IEnumerable 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)assemblies); + } + + public void FromAssemblies(IEnumerable assemblies) + { + BindInfo.AddAssemblyFilter(assembly => assemblies.Contains(assembly)); + } + + public void FromAssembliesWhere(Func predicate) + { + BindInfo.AddAssemblyFilter(predicate); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionAssemblySelectionBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionAssemblySelectionBinder.cs.meta new file mode 100644 index 0000000..5b056fd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionAssemblySelectionBinder.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5229c122d45b5634ebd4b9bccee749ac +timeCreated: 1462127487 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionBindInfo.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionBindInfo.cs new file mode 100644 index 0000000..6a9662f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionBindInfo.cs @@ -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> _typeFilters = new List>(); + readonly List> _assemblyFilters = new List>(); + +#if ZEN_MULTITHREADING + readonly object _locker = new object(); +#endif + static Dictionary _assemblyTypeCache = new Dictionary(); + + public void AddAssemblyFilter(Func predicate) + { + _assemblyFilters.Add(predicate); + } + + public void AddTypeFilter(Func predicate) + { + _typeFilters.Add(predicate); + } + + IEnumerable 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 ResolveTypes() + { + return GetAllAssemblies() + .Where(ShouldIncludeAssembly) + .SelectMany(assembly => GetTypes(assembly)) + .Where(ShouldIncludeType).ToList(); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionBindInfo.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionBindInfo.cs.meta new file mode 100644 index 0000000..6acbf25 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionBindInfo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f1e908965ce63ab40b271724cb5490aa +timeCreated: 1462127523 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionFilterTypesBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionFilterTypesBinder.cs new file mode 100644 index 0000000..2fe5cb0 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionFilterTypesBinder.cs @@ -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() + { + return DerivingFromOrEqual(typeof(T)); + } + + public ConventionFilterTypesBinder DerivingFromOrEqual(Type parentType) + { + BindInfo.AddTypeFilter(type => type.DerivesFromOrEqual(parentType)); + return this; + } + + public ConventionFilterTypesBinder DerivingFrom() + { + return DerivingFrom(typeof(T)); + } + + public ConventionFilterTypesBinder DerivingFrom(Type parentType) + { + BindInfo.AddTypeFilter(type => type.DerivesFrom(parentType)); + return this; + } + + public ConventionFilterTypesBinder WithAttribute() + where T : Attribute + { + return WithAttribute(typeof(T)); + } + + public ConventionFilterTypesBinder WithAttribute(Type attribute) + { + Assert.That(attribute.DerivesFrom()); + BindInfo.AddTypeFilter(t => t.HasAttribute(attribute)); + return this; + } + + public ConventionFilterTypesBinder WithoutAttribute() + where T : Attribute + { + return WithoutAttribute(typeof(T)); + } + + public ConventionFilterTypesBinder WithoutAttribute(Type attribute) + { + Assert.That(attribute.DerivesFrom()); + BindInfo.AddTypeFilter(t => !t.HasAttribute(attribute)); + return this; + } + + public ConventionFilterTypesBinder WithAttributeWhere(Func predicate) + where T : Attribute + { + BindInfo.AddTypeFilter(t => t.HasAttribute() && t.AllAttributes().All(predicate)); + return this; + } + + public ConventionFilterTypesBinder Where(Func predicate) + { + BindInfo.AddTypeFilter(predicate); + return this; + } + + public ConventionFilterTypesBinder InNamespace(string ns) + { + return InNamespaces(ns); + } + + public ConventionFilterTypesBinder InNamespaces(params string[] namespaces) + { + return InNamespaces((IEnumerable)namespaces); + } + + public ConventionFilterTypesBinder InNamespaces(IEnumerable 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 diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionFilterTypesBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionFilterTypesBinder.cs.meta new file mode 100644 index 0000000..525d91b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionFilterTypesBinder.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fc3e9c89606ca52458403153ad0d9b3e +timeCreated: 1462127525 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionSelectTypesBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionSelectTypesBinder.cs new file mode 100644 index 0000000..fee1245 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionSelectTypesBinder.cs @@ -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 diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionSelectTypesBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionSelectTypesBinder.cs.meta new file mode 100644 index 0000000..3965875 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Conventions/ConventionSelectTypesBinder.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 05d17b3e7f09bc44f8be86e01642ee8d +timeCreated: 1462127469 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/CopyNonLazyBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/CopyNonLazyBinder.cs new file mode 100644 index 0000000..0688112 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/CopyNonLazyBinder.cs @@ -0,0 +1,66 @@ +using System.Collections.Generic; + +namespace Zenject +{ + [NoReflectionBaking] + public class CopyNonLazyBinder : NonLazyBinder + { + List _secondaryBindInfos; + + public CopyNonLazyBinder(BindInfo bindInfo) + : base(bindInfo) + { + } + + // This is used in cases where you have multiple bindings that depend on each other so should + // be inherited together (eg. FromIFactory) + internal void AddSecondaryCopyBindInfo(BindInfo bindInfo) + { + if (_secondaryBindInfos == null) + { + _secondaryBindInfos = new List(); + } + _secondaryBindInfos.Add(bindInfo); + } + + public NonLazyBinder CopyIntoAllSubContainers() + { + SetInheritanceMethod(BindingInheritanceMethods.CopyIntoAll); + return this; + } + + // Only copy the binding into children and not grandchildren + public NonLazyBinder CopyIntoDirectSubContainers() + { + SetInheritanceMethod(BindingInheritanceMethods.CopyDirectOnly); + return this; + } + + // Do not apply the binding on the current container + public NonLazyBinder MoveIntoAllSubContainers() + { + SetInheritanceMethod(BindingInheritanceMethods.MoveIntoAll); + return this; + } + + // Do not apply the binding on the current container + public NonLazyBinder MoveIntoDirectSubContainers() + { + SetInheritanceMethod(BindingInheritanceMethods.MoveDirectOnly); + return this; + } + + void SetInheritanceMethod(BindingInheritanceMethods method) + { + BindInfo.BindingInheritanceMethod = method; + + if (_secondaryBindInfos != null) + { + foreach (var secondaryBindInfo in _secondaryBindInfos) + { + secondaryBindInfo.BindingInheritanceMethod = method; + } + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/CopyNonLazyBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/CopyNonLazyBinder.cs.meta new file mode 100644 index 0000000..099b4cb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/CopyNonLazyBinder.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6cf2e5d7a11cf6c418960ff59949b5fa +timeCreated: 1483833202 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/DefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/DefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder.cs new file mode 100644 index 0000000..e47c270 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/DefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder.cs @@ -0,0 +1,24 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class DefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder : ScopeConcreteIdArgConditionCopyNonLazyBinder + { + public DefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder( + SubContainerCreatorBindInfo subContainerBindInfo, BindInfo bindInfo) + : base(bindInfo) + { + SubContainerCreatorBindInfo = subContainerBindInfo; + } + + protected SubContainerCreatorBindInfo SubContainerCreatorBindInfo + { + get; private set; + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder WithDefaultGameObjectParent(string defaultParentName) + { + SubContainerCreatorBindInfo.DefaultParentName = defaultParentName; + return this; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/DefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/DefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta new file mode 100644 index 0000000..e21fa65 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/DefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f6b4e164706b85c408cd7e8f28266747 +timeCreated: 1535254660 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory.meta new file mode 100644 index 0000000..85d5ce2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 580f48a64cf849041937c7ad570aaf89 +folderAsset: yes +timeCreated: 1461708047 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder.meta new file mode 100644 index 0000000..7b73054 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 3fd0e848e31df144fbbeab59a2c137e2 +folderAsset: yes +timeCreated: 1528637818 +licenseType: Store +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder0.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder0.cs new file mode 100644 index 0000000..70eaa44 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder0.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryArgumentsToChoiceBinder : FactoryToChoiceBinder + { + public FactoryArgumentsToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // We use generics instead of params object[] so that we preserve type info + // So that you can for example pass in a variable that is null and the type info will + // still be used to map null on to the correct field + public FactoryToChoiceBinder WithFactoryArguments(T param) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(TParam1 param1, TParam2 param2) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TParam1 param1, TParam2 param2, TParam3 param3) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5, param6); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(object[] args) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgList(args); + return this; + } + + public FactoryToChoiceBinder WithFactoryArgumentsExplicit(IEnumerable extraArgs) + { + FactoryBindInfo.Arguments = extraArgs.ToList(); + return this; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder0.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder0.cs.meta new file mode 100644 index 0000000..244958b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder0.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ca3197650e9628a45b99e79b8dea27d9 +timeCreated: 1528637818 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder1.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder1.cs new file mode 100644 index 0000000..480e4a4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder1.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryArgumentsToChoiceBinder : FactoryToChoiceBinder + { + public FactoryArgumentsToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // We use generics instead of params object[] so that we preserve type info + // So that you can for example pass in a variable that is null and the type info will + // still be used to map null on to the correct field + public FactoryToChoiceBinder WithFactoryArguments(T param) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(TFactoryParam1 param1, TFactoryParam2 param2) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4, TFactoryParam5 param5) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4, TFactoryParam5 param5, TFactoryParam6 param6) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5, param6); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(object[] args) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgList(args); + return this; + } + + public FactoryToChoiceBinder WithFactoryArgumentsExplicit(IEnumerable extraArgs) + { + FactoryBindInfo.Arguments = extraArgs.ToList(); + return this; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder1.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder1.cs.meta new file mode 100644 index 0000000..4c7af67 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder1.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: a37e124df695f644e87579f08ea443f7 +timeCreated: 1528637818 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder10.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder10.cs new file mode 100644 index 0000000..d8d043f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder10.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryArgumentsToChoiceBinder : FactoryToChoiceBinder + { + public FactoryArgumentsToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // We use generics instead of params object[] so that we preserve type info + // So that you can for example pass in a variable that is null and the type info will + // still be used to map null on to the correct field + public FactoryToChoiceBinder WithFactoryArguments(T param) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(TFactoryParam1 param1, TFactoryParam2 param2) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4, TFactoryParam5 param5) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4, TFactoryParam5 param5, TFactoryParam6 param6) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5, param6); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(object[] args) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgList(args); + return this; + } + + public FactoryToChoiceBinder WithFactoryArgumentsExplicit(IEnumerable extraArgs) + { + FactoryBindInfo.Arguments = extraArgs.ToList(); + return this; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder10.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder10.cs.meta new file mode 100644 index 0000000..c506e1c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder10.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 614bb4e31afa5154487c94e128e9461a +timeCreated: 1528637818 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder2.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder2.cs new file mode 100644 index 0000000..48b49b5 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder2.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryArgumentsToChoiceBinder : FactoryToChoiceBinder + { + public FactoryArgumentsToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // We use generics instead of params object[] so that we preserve type info + // So that you can for example pass in a variable that is null and the type info will + // still be used to map null on to the correct field + public FactoryToChoiceBinder WithFactoryArguments(T param) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(TFactoryParam1 param1, TFactoryParam2 param2) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4, TFactoryParam5 param5) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4, TFactoryParam5 param5, TFactoryParam6 param6) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5, param6); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(object[] args) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgList(args); + return this; + } + + public FactoryToChoiceBinder WithFactoryArgumentsExplicit(IEnumerable extraArgs) + { + FactoryBindInfo.Arguments = extraArgs.ToList(); + return this; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder2.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder2.cs.meta new file mode 100644 index 0000000..308748d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder2.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 3b450191ad6422c4f841a99cdf3d108a +timeCreated: 1528637818 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder3.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder3.cs new file mode 100644 index 0000000..f0f5b46 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder3.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryArgumentsToChoiceBinder : FactoryToChoiceBinder + { + public FactoryArgumentsToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // We use generics instead of params object[] so that we preserve type info + // So that you can for example pass in a variable that is null and the type info will + // still be used to map null on to the correct field + public FactoryToChoiceBinder WithFactoryArguments(T param) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(TFactoryParam1 param1, TFactoryParam2 param2) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4, TFactoryParam5 param5) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4, TFactoryParam5 param5, TFactoryParam6 param6) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5, param6); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(object[] args) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgList(args); + return this; + } + + public FactoryToChoiceBinder WithFactoryArgumentsExplicit(IEnumerable extraArgs) + { + FactoryBindInfo.Arguments = extraArgs.ToList(); + return this; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder3.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder3.cs.meta new file mode 100644 index 0000000..ef3e973 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder3.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 667d9c959f8ba004f86c8202d637f9ce +timeCreated: 1528637818 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder4.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder4.cs new file mode 100644 index 0000000..eee66e6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder4.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryArgumentsToChoiceBinder : FactoryToChoiceBinder + { + public FactoryArgumentsToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // We use generics instead of params object[] so that we preserve type info + // So that you can for example pass in a variable that is null and the type info will + // still be used to map null on to the correct field + public FactoryToChoiceBinder WithFactoryArguments(T param) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(TFactoryParam1 param1, TFactoryParam2 param2) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4, TFactoryParam5 param5) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4, TFactoryParam5 param5, TFactoryParam6 param6) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5, param6); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(object[] args) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgList(args); + return this; + } + + public FactoryToChoiceBinder WithFactoryArgumentsExplicit(IEnumerable extraArgs) + { + FactoryBindInfo.Arguments = extraArgs.ToList(); + return this; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder4.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder4.cs.meta new file mode 100644 index 0000000..c29c8a2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder4.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ce44f168dd48e1442b43a43c925abc47 +timeCreated: 1528637818 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder5.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder5.cs new file mode 100644 index 0000000..dbd7ffd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder5.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryArgumentsToChoiceBinder : FactoryToChoiceBinder + { + public FactoryArgumentsToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // We use generics instead of params object[] so that we preserve type info + // So that you can for example pass in a variable that is null and the type info will + // still be used to map null on to the correct field + public FactoryToChoiceBinder WithFactoryArguments(T param) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(TFactoryParam1 param1, TFactoryParam2 param2) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4, TFactoryParam5 param5) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4, TFactoryParam5 param5, TFactoryParam6 param6) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5, param6); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(object[] args) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgList(args); + return this; + } + + public FactoryToChoiceBinder WithFactoryArgumentsExplicit(IEnumerable extraArgs) + { + FactoryBindInfo.Arguments = extraArgs.ToList(); + return this; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder5.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder5.cs.meta new file mode 100644 index 0000000..25b31c4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder5.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f3c4d5776729d2d4abae523dd6dce595 +timeCreated: 1528637818 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder6.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder6.cs new file mode 100644 index 0000000..304e9eb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder6.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryArgumentsToChoiceBinder : FactoryToChoiceBinder + { + public FactoryArgumentsToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // We use generics instead of params object[] so that we preserve type info + // So that you can for example pass in a variable that is null and the type info will + // still be used to map null on to the correct field + public FactoryToChoiceBinder WithFactoryArguments(T param) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(TFactoryParam1 param1, TFactoryParam2 param2) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4, TFactoryParam5 param5) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments( + TFactoryParam1 param1, TFactoryParam2 param2, TFactoryParam3 param3, TFactoryParam4 param4, TFactoryParam5 param5, TFactoryParam6 param6) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgListExplicit(param1, param2, param3, param4, param5, param6); + return this; + } + + public FactoryToChoiceBinder WithFactoryArguments(object[] args) + { + FactoryBindInfo.Arguments = InjectUtil.CreateArgList(args); + return this; + } + + public FactoryToChoiceBinder WithFactoryArgumentsExplicit(IEnumerable extraArgs) + { + FactoryBindInfo.Arguments = extraArgs.ToList(); + return this; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder6.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder6.cs.meta new file mode 100644 index 0000000..2a5ee44 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryArgumentsToChoiceBinder/FactoryArgumentsToChoiceBinder6.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 22836272211e07a459544765e2e7c098 +timeCreated: 1528637818 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder.meta new file mode 100644 index 0000000..65655dd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: aa754ab1fdfa8714fb6eddd17108e5c6 +folderAsset: yes +timeCreated: 1461708047 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder0.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder0.cs new file mode 100644 index 0000000..28338a4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder0.cs @@ -0,0 +1,182 @@ +using System; +using System.Collections.Generic; +using System.Linq; +#if !NOT_UNITY3D +using UnityEngine; +#endif +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryFromBinder : FactoryFromBinderBase + { + public FactoryFromBinder( + DiContainer container, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(container, typeof(TContract), bindInfo, factoryBindInfo) + { + } + + public ConditionCopyNonLazyBinder FromResolveGetter(Func method) + { + return FromResolveGetter(null, method); + } + + public ConditionCopyNonLazyBinder FromResolveGetter( + object subIdentifier, Func method) + { + return FromResolveGetter(subIdentifier, method, InjectSources.Any); + } + + public ConditionCopyNonLazyBinder FromResolveGetter( + object subIdentifier, Func method, InjectSources source) + { + FactoryBindInfo.ProviderFunc = + (container) => new GetterProvider(subIdentifier, method, container, source, false); + + return this; + } + + public ConditionCopyNonLazyBinder FromMethod(Func method) + { + ProviderFunc = + (container) => new MethodProviderWithContainer(method); + + return this; + } + + // Shortcut for FromIFactory and also for backwards compatibility + public ArgConditionCopyNonLazyBinder FromFactory() + where TSubFactory : IFactory + { + return this.FromIFactory(x => x.To().AsCached()); + } + + public FactorySubContainerBinder FromSubContainerResolve() + { + return FromSubContainerResolve(null); + } + + public FactorySubContainerBinder FromSubContainerResolve(object subIdentifier) + { + return new FactorySubContainerBinder( + BindContainer, BindInfo, FactoryBindInfo, subIdentifier); + } + +#if !NOT_UNITY3D + + public ConditionCopyNonLazyBinder FromComponentInHierarchy( + bool includeInactive = true) + { + BindingUtil.AssertIsInterfaceOrComponent(ContractType); + + return FromMethod(_ => + { + var res = BindContainer.Resolve().GetRootGameObjects() + .Select(x => x.GetComponentInChildren(includeInactive)) + .Where(x => x != null).FirstOrDefault(); + + Assert.IsNotNull(res, + "Could not find component '{0}' through FromComponentInHierarchy factory binding", typeof(TContract)); + + return res; + }); + } +#endif + } + + // These methods have to be extension methods for the UWP build (with .NET backend) to work correctly + // When these are instance methods it takes a really long time then fails with StackOverflowException + public static class FactoryFromBinder0Extensions + { + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + // Use a random ID so that our provider is the only one that can find it and so it doesn't + // conflict with anything else + var poolId = Guid.NewGuid(); + + // Important to use NoFlush otherwise the binding will be finalized early + var binder = fromBinder.BindContainer.BindMemoryPoolCustomInterfaceNoFlush().WithId(poolId); + + // Always make it non lazy by default in case the user sets an InitialSize + binder.NonLazy(); + + poolBindGenerator(binder); + + fromBinder.ProviderFunc = + (container) => { return new PoolableMemoryPoolProvider(container, poolId); }; + + return new ArgConditionCopyNonLazyBinder(fromBinder.BindInfo); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + { + return fromBinder.FromPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + { + return fromBinder.FromPoolableMemoryPool>(poolBindGenerator); + } + +#if !NOT_UNITY3D + public static ArgConditionCopyNonLazyBinder FromMonoPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : Component, IPoolable + { + return fromBinder.FromMonoPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromMonoPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : Component, IPoolable + { + return fromBinder.FromPoolableMemoryPool>(poolBindGenerator); + } +#endif + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + return fromBinder.FromPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromIFactory( + this FactoryFromBinder fromBinder, + Action>> factoryBindGenerator) + { + Guid factoryId; + factoryBindGenerator( + fromBinder.CreateIFactoryBinder>(out factoryId)); + + fromBinder.ProviderFunc = + (container) => { return new IFactoryProvider(container, factoryId); }; + + return new ArgConditionCopyNonLazyBinder(fromBinder.BindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder0.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder0.cs.meta new file mode 100644 index 0000000..362a1ea --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder0.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fd0f7feaafd2cc44da895162de285da7 +timeCreated: 1461708055 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder1.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder1.cs new file mode 100644 index 0000000..d97fb52 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder1.cs @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +#if !NOT_UNITY3D +using UnityEngine; +#endif +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryFromBinder : FactoryFromBinderBase + { + public FactoryFromBinder( + DiContainer container, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(container, typeof(TContract), bindInfo, factoryBindInfo) + { + } + + public ConditionCopyNonLazyBinder FromMethod(Func method) + { + ProviderFunc = + (container) => new MethodProviderWithContainer(method); + + return this; + } + + // Shortcut for FromIFactory and also for backwards compatibility + public ConditionCopyNonLazyBinder FromFactory() + where TSubFactory : IFactory + { + return this.FromIFactory(x => x.To().AsCached()); + } + + public FactorySubContainerBinder FromSubContainerResolve() + { + return FromSubContainerResolve(null); + } + + public FactorySubContainerBinder FromSubContainerResolve(object subIdentifier) + { + return new FactorySubContainerBinder( + BindContainer, BindInfo, FactoryBindInfo, subIdentifier); + } + } + + // These methods have to be extension methods for the UWP build (with .NET backend) to work correctly + // When these are instance methods it takes a really long time then fails with StackOverflowException + public static class FactoryFromBinder1Extensions + { + public static ArgConditionCopyNonLazyBinder FromIFactory( + this FactoryFromBinder fromBinder, + Action>> factoryBindGenerator) + { + Guid factoryId; + factoryBindGenerator( + fromBinder.CreateIFactoryBinder>(out factoryId)); + + fromBinder.ProviderFunc = + (container) => { return new IFactoryProvider(container, factoryId); }; + + return new ArgConditionCopyNonLazyBinder(fromBinder.BindInfo); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + { + return fromBinder.FromPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + { + return fromBinder.FromPoolableMemoryPool>(poolBindGenerator); + } + +#if !NOT_UNITY3D + public static ArgConditionCopyNonLazyBinder FromMonoPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : Component, IPoolable + { + return fromBinder.FromMonoPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromMonoPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : Component, IPoolable + { + return fromBinder.FromPoolableMemoryPool>(poolBindGenerator); + } +#endif + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + return fromBinder.FromPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + // Use a random ID so that our provider is the only one that can find it and so it doesn't + // conflict with anything else + var poolId = Guid.NewGuid(); + + // Important to use NoFlush otherwise the binding will be finalized early + var binder = fromBinder.BindContainer.BindMemoryPoolCustomInterfaceNoFlush().WithId(poolId); + + // Always make it non lazy by default in case the user sets an InitialSize + binder.NonLazy(); + + poolBindGenerator(binder); + + fromBinder.ProviderFunc = + (container) => { return new PoolableMemoryPoolProvider(container, poolId); }; + + return new ArgConditionCopyNonLazyBinder(fromBinder.BindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder1.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder1.cs.meta new file mode 100644 index 0000000..962f649 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder1.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 57ab0b3d05763f14fb530d07a5acd481 +timeCreated: 1461708050 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder10.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder10.cs new file mode 100644 index 0000000..a5fa13a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder10.cs @@ -0,0 +1,62 @@ +using System; + +#if !NOT_UNITY3D + +#endif + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryFromBinder + : FactoryFromBinderBase + { + public FactoryFromBinder( + DiContainer container, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(container, typeof(TContract), bindInfo, factoryBindInfo) + { + } + + public ConditionCopyNonLazyBinder FromMethod( +#if !NET_4_6 + ModestTree.Util. +#endif + Func method) + { + ProviderFunc = + container => new MethodProviderWithContainer(method); + + return this; + } + + // Shortcut for FromIFactory and also for backwards compatibility + public ConditionCopyNonLazyBinder FromFactory() + where TSubFactory : IFactory + { + return FromIFactory(x => x.To().AsCached()); + } + + public ArgConditionCopyNonLazyBinder FromIFactory( + Action>> factoryBindGenerator) + { + Guid factoryId; + factoryBindGenerator( + CreateIFactoryBinder>(out factoryId)); + + ProviderFunc = + container => { return new IFactoryProvider(container, factoryId); }; + + return new ArgConditionCopyNonLazyBinder(BindInfo); + } + + public FactorySubContainerBinder FromSubContainerResolve() + { + return FromSubContainerResolve(null); + } + + public FactorySubContainerBinder FromSubContainerResolve(object subIdentifier) + { + return new FactorySubContainerBinder( + BindContainer, BindInfo, FactoryBindInfo, subIdentifier); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder10.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder10.cs.meta new file mode 100644 index 0000000..f18d489 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder10.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d835e30b6131d754e892d6f397e9921a +timeCreated: 1507270780 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder2.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder2.cs new file mode 100644 index 0000000..0793774 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder2.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +#if !NOT_UNITY3D +using UnityEngine; +#endif +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryFromBinder : FactoryFromBinderBase + { + public FactoryFromBinder( + DiContainer container, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(container, typeof(TContract), bindInfo, factoryBindInfo) + { + } + + public ConditionCopyNonLazyBinder FromMethod(Func method) + { + ProviderFunc = + (container) => new MethodProviderWithContainer(method); + + return this; + } + + // Shortcut for FromIFactory and also for backwards compatibility + public ConditionCopyNonLazyBinder FromFactory() + where TSubFactory : IFactory + { + return this.FromIFactory(x => x.To().AsCached()); + } + + public FactorySubContainerBinder FromSubContainerResolve() + { + return FromSubContainerResolve(null); + } + + public FactorySubContainerBinder FromSubContainerResolve(object subIdentifier) + { + return new FactorySubContainerBinder( + BindContainer, BindInfo, FactoryBindInfo, subIdentifier); + } + } + + // These methods have to be extension methods for the UWP build (with .NET backend) to work correctly + // When these are instance methods it takes a really long time then fails with StackOverflowException + public static class FactoryFromBinder2Extensions + { + public static ArgConditionCopyNonLazyBinder FromIFactory( + this FactoryFromBinder fromBinder, + Action>> factoryBindGenerator) + { + Guid factoryId; + factoryBindGenerator( + fromBinder.CreateIFactoryBinder>(out factoryId)); + + fromBinder.ProviderFunc = + (container) => { return new IFactoryProvider(container, factoryId); }; + + return new ArgConditionCopyNonLazyBinder(fromBinder.BindInfo); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + { + return fromBinder.FromPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + { + return fromBinder.FromPoolableMemoryPool>(poolBindGenerator); + } + +#if !NOT_UNITY3D + public static ArgConditionCopyNonLazyBinder FromMonoPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : Component, IPoolable + { + return fromBinder.FromMonoPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromMonoPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : Component, IPoolable + { + return fromBinder.FromPoolableMemoryPool>(poolBindGenerator); + } +#endif + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + return fromBinder.FromPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + // Use a random ID so that our provider is the only one that can find it and so it doesn't + // conflict with anything else + var poolId = Guid.NewGuid(); + + // Important to use NoFlush otherwise the binding will be finalized early + var binder = fromBinder.BindContainer.BindMemoryPoolCustomInterfaceNoFlush() + .WithId(poolId); + + // Always make it non lazy by default in case the user sets an InitialSize + binder.NonLazy(); + + poolBindGenerator(binder); + + fromBinder.ProviderFunc = + (container) => { return new PoolableMemoryPoolProvider(container, poolId); }; + + return new ArgConditionCopyNonLazyBinder(fromBinder.BindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder2.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder2.cs.meta new file mode 100644 index 0000000..521cc87 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder2.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a36f88760754c1c498ab3270dfb88b72 +timeCreated: 1461708052 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder3.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder3.cs new file mode 100644 index 0000000..c840a8a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder3.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +#if !NOT_UNITY3D +using UnityEngine; +#endif +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryFromBinder : FactoryFromBinderBase + { + public FactoryFromBinder( + DiContainer container, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(container, typeof(TContract), bindInfo, factoryBindInfo) + { + } + + public ConditionCopyNonLazyBinder FromMethod(Func method) + { + ProviderFunc = + (container) => new MethodProviderWithContainer(method); + + return this; + } + + // Shortcut for FromIFactory and also for backwards compatibility + public ConditionCopyNonLazyBinder FromFactory() + where TSubFactory : IFactory + { + return this.FromIFactory(x => x.To().AsCached()); + } + + public FactorySubContainerBinder FromSubContainerResolve() + { + return FromSubContainerResolve(null); + } + + public FactorySubContainerBinder FromSubContainerResolve(object subIdentifier) + { + return new FactorySubContainerBinder( + BindContainer, BindInfo, FactoryBindInfo, subIdentifier); + } + } + + // These methods have to be extension methods for the UWP build (with .NET backend) to work correctly + // When these are instance methods it takes a really long time then fails with StackOverflowException + public static class FactoryFromBinder3Extensions + { + public static ArgConditionCopyNonLazyBinder FromIFactory( + this FactoryFromBinder fromBinder, + Action>> factoryBindGenerator) + { + Guid factoryId; + factoryBindGenerator( + fromBinder.CreateIFactoryBinder>(out factoryId)); + + fromBinder.ProviderFunc = + (container) => { return new IFactoryProvider(container, factoryId); }; + + return new ArgConditionCopyNonLazyBinder(fromBinder.BindInfo); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + { + return fromBinder.FromPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + { + return fromBinder.FromPoolableMemoryPool>(poolBindGenerator); + } + +#if !NOT_UNITY3D + public static ArgConditionCopyNonLazyBinder FromMonoPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : Component, IPoolable + { + return fromBinder.FromMonoPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromMonoPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : Component, IPoolable + { + return fromBinder.FromPoolableMemoryPool>(poolBindGenerator); + } +#endif + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + return fromBinder.FromPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + // Use a random ID so that our provider is the only one that can find it and so it doesn't + // conflict with anything else + var poolId = Guid.NewGuid(); + + // Important to use NoFlush otherwise the binding will be finalized early + var binder = fromBinder.BindContainer.BindMemoryPoolCustomInterfaceNoFlush() + .WithId(poolId); + + // Always make it non lazy by default in case the user sets an InitialSize + binder.NonLazy(); + + poolBindGenerator(binder); + + fromBinder.ProviderFunc = + (container) => { return new PoolableMemoryPoolProvider(container, poolId); }; + + return new ArgConditionCopyNonLazyBinder(fromBinder.BindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder3.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder3.cs.meta new file mode 100644 index 0000000..a751958 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder3.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4eb3a4d5d01c55748b43f48a1da3c7b6 +timeCreated: 1461708050 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder4.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder4.cs new file mode 100644 index 0000000..7d1bdc6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder4.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +#if !NOT_UNITY3D +using UnityEngine; +#endif +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryFromBinder : FactoryFromBinderBase + { + public FactoryFromBinder( + DiContainer container, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(container, typeof(TContract), bindInfo, factoryBindInfo) + { + } + + public ConditionCopyNonLazyBinder FromMethod( +#if !NET_4_6 + ModestTree.Util. +#endif + Func method) + { + ProviderFunc = + (container) => new MethodProviderWithContainer(method); + + return this; + } + + // Shortcut for FromIFactory and also for backwards compatibility + public ConditionCopyNonLazyBinder FromFactory() + where TSubFactory : IFactory + { + return this.FromIFactory(x => x.To().AsCached()); + } + + public FactorySubContainerBinder FromSubContainerResolve() + { + return FromSubContainerResolve(null); + } + + public FactorySubContainerBinder FromSubContainerResolve(object subIdentifier) + { + return new FactorySubContainerBinder( + BindContainer, BindInfo, FactoryBindInfo, subIdentifier); + } + } + + // These methods have to be extension methods for the UWP build (with .NET backend) to work correctly + // When these are instance methods it takes a really long time then fails with StackOverflowException + public static class FactoryFromBinder4Extensions + { + public static ArgConditionCopyNonLazyBinder FromIFactory( + this FactoryFromBinder fromBinder, + Action>> factoryBindGenerator) + { + Guid factoryId; + factoryBindGenerator( + fromBinder.CreateIFactoryBinder>(out factoryId)); + + fromBinder.ProviderFunc = + (container) => { return new IFactoryProvider(container, factoryId); }; + + return new ArgConditionCopyNonLazyBinder(fromBinder.BindInfo); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + { + return fromBinder.FromPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + { + return fromBinder.FromPoolableMemoryPool>(poolBindGenerator); + } + +#if !NOT_UNITY3D + public static ArgConditionCopyNonLazyBinder FromMonoPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : Component, IPoolable + { + return fromBinder.FromMonoPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromMonoPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : Component, IPoolable + { + return fromBinder.FromPoolableMemoryPool>(poolBindGenerator); + } +#endif + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + return fromBinder.FromPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + // Use a random ID so that our provider is the only one that can find it and so it doesn't + // conflict with anything else + var poolId = Guid.NewGuid(); + + // Important to use NoFlush otherwise the binding will be finalized early + var binder = fromBinder.BindContainer.BindMemoryPoolCustomInterfaceNoFlush() + .WithId(poolId); + + // Always make it non lazy by default in case the user sets an InitialSize + binder.NonLazy(); + + poolBindGenerator(binder); + + fromBinder.ProviderFunc = + (container) => { return new PoolableMemoryPoolProvider(container, poolId); }; + + return new ArgConditionCopyNonLazyBinder(fromBinder.BindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder4.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder4.cs.meta new file mode 100644 index 0000000..457aa64 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder4.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e67ee9caa78de914a9c727a607c3d8c0 +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder5.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder5.cs new file mode 100644 index 0000000..74783a1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder5.cs @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +#if !NOT_UNITY3D +using UnityEngine; +#endif +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryFromBinder + : FactoryFromBinderBase + { + public FactoryFromBinder( + DiContainer container, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(container, typeof(TContract), bindInfo, factoryBindInfo) + { + } + + public ConditionCopyNonLazyBinder FromMethod( +#if !NET_4_6 + ModestTree.Util. +#endif + Func method) + { + ProviderFunc = + (container) => new MethodProviderWithContainer(method); + + return this; + } + + // Shortcut for FromIFactory and also for backwards compatibility + public ConditionCopyNonLazyBinder FromFactory() + where TSubFactory : IFactory + { + return this.FromIFactory(x => x.To().AsCached()); + } + + public FactorySubContainerBinder FromSubContainerResolve() + { + return FromSubContainerResolve(null); + } + + public FactorySubContainerBinder FromSubContainerResolve(object subIdentifier) + { + return new FactorySubContainerBinder( + BindContainer, BindInfo, FactoryBindInfo, subIdentifier); + } + } + + // These methods have to be extension methods for the UWP build (with .NET backend) to work correctly + // When these are instance methods it takes a really long time then fails with StackOverflowException + public static class FactoryFromBinder5Extensions + { + public static ArgConditionCopyNonLazyBinder FromIFactory( + this FactoryFromBinder fromBinder, + Action>> factoryBindGenerator) + { + Guid factoryId; + factoryBindGenerator( + fromBinder.CreateIFactoryBinder>(out factoryId)); + + fromBinder.ProviderFunc = + (container) => { return new IFactoryProvider(container, factoryId); }; + + return new ArgConditionCopyNonLazyBinder(fromBinder.BindInfo); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + { + return fromBinder.FromPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + { + return fromBinder.FromPoolableMemoryPool>(poolBindGenerator); + } + +#if !NOT_UNITY3D + public static ArgConditionCopyNonLazyBinder FromMonoPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : Component, IPoolable + { + return fromBinder.FromMonoPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromMonoPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : Component, IPoolable + { + return fromBinder.FromPoolableMemoryPool>(poolBindGenerator); + } +#endif + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + return fromBinder.FromPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + // Use a random ID so that our provider is the only one that can find it and so it doesn't + // conflict with anything else + var poolId = Guid.NewGuid(); + + // Important to use NoFlush otherwise the binding will be finalized early + var binder = fromBinder.BindContainer.BindMemoryPoolCustomInterfaceNoFlush() + .WithId(poolId); + + // Always make it non lazy by default in case the user sets an InitialSize + binder.NonLazy(); + + poolBindGenerator(binder); + + fromBinder.ProviderFunc = + (container) => { return new PoolableMemoryPoolProvider(container, poolId); }; + + return new ArgConditionCopyNonLazyBinder(fromBinder.BindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder5.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder5.cs.meta new file mode 100644 index 0000000..a1987ed --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder5.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 901200be3b8d1cc40876aa50a03103b8 +timeCreated: 1461708052 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder6.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder6.cs new file mode 100644 index 0000000..605be66 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder6.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +#if !NOT_UNITY3D +using UnityEngine; +#endif +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryFromBinder + : FactoryFromBinderBase + { + public FactoryFromBinder( + DiContainer container, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(container, typeof(TContract), bindInfo, factoryBindInfo) + { + } + + public ConditionCopyNonLazyBinder FromMethod( +#if !NET_4_6 + ModestTree.Util. +#endif + Func method) + { + ProviderFunc = + (container) => new MethodProviderWithContainer(method); + + return this; + } + + // Shortcut for FromIFactory and also for backwards compatibility + public ConditionCopyNonLazyBinder FromFactory() + where TSubFactory : IFactory + { + return this.FromIFactory(x => x.To().AsCached()); + } + + public FactorySubContainerBinder FromSubContainerResolve() + { + return FromSubContainerResolve(null); + } + + public FactorySubContainerBinder FromSubContainerResolve(object subIdentifier) + { + return new FactorySubContainerBinder( + BindContainer, BindInfo, FactoryBindInfo, subIdentifier); + } + } + + // These methods have to be extension methods for the UWP build (with .NET backend) to work correctly + // When these are instance methods it takes a really long time then fails with StackOverflowException + public static class FactoryFromBinder6Extensions + { + public static ArgConditionCopyNonLazyBinder FromIFactory( + this FactoryFromBinder fromBinder, + Action>> factoryBindGenerator) + { + Guid factoryId; + factoryBindGenerator( + fromBinder.CreateIFactoryBinder>(out factoryId)); + + fromBinder.ProviderFunc = + (container) => { return new IFactoryProvider(container, factoryId); }; + + return new ArgConditionCopyNonLazyBinder(fromBinder.BindInfo); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + { + return fromBinder.FromPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + { + return fromBinder.FromPoolableMemoryPool>(poolBindGenerator); + } + +#if !NOT_UNITY3D + public static ArgConditionCopyNonLazyBinder FromMonoPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : Component, IPoolable + { + return fromBinder.FromMonoPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromMonoPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : Component, IPoolable + { + return fromBinder.FromPoolableMemoryPool>(poolBindGenerator); + } +#endif + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + return fromBinder.FromPoolableMemoryPool(x => {}); + } + + public static ArgConditionCopyNonLazyBinder FromPoolableMemoryPool( + this FactoryFromBinder fromBinder, + Action> poolBindGenerator) + // Unfortunately we have to pass the same contract in again to satisfy the generic + // constraints below + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + Assert.IsEqual(typeof(TContract), typeof(TContract)); + + // Use a random ID so that our provider is the only one that can find it and so it doesn't + // conflict with anything else + var poolId = Guid.NewGuid(); + + // Important to use NoFlush otherwise the binding will be finalized early + var binder = fromBinder.BindContainer.BindMemoryPoolCustomInterfaceNoFlush() + .WithId(poolId); + + // Always make it non lazy by default in case the user sets an InitialSize + binder.NonLazy(); + + poolBindGenerator(binder); + + fromBinder.ProviderFunc = + (container) => { return new PoolableMemoryPoolProvider(container, poolId); }; + + return new ArgConditionCopyNonLazyBinder(fromBinder.BindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder6.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder6.cs.meta new file mode 100644 index 0000000..a073ec5 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/FactoryFromBinder6.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b79f4e548e208b1418f013d2fdb0e076 +timeCreated: 1528529860 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder.meta new file mode 100644 index 0000000..6883712 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 17d1fc460074cfc419ffecab2a7e97e8 +folderAsset: yes +timeCreated: 1461708047 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder0.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder0.cs new file mode 100644 index 0000000..93c71bd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder0.cs @@ -0,0 +1,143 @@ +using System; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactorySubContainerBinder + : FactorySubContainerBinderBase + { + public FactorySubContainerBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo, object subIdentifier) + : base(bindContainer, bindInfo, factoryBindInfo, subIdentifier) + { + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder ByMethod(Action installerMethod) + { + var subcontainerBindInfo = new SubContainerCreatorBindInfo(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByMethod( + container, subcontainerBindInfo, installerMethod), false); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + +#if !NOT_UNITY3D + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewGameObjectMethod(Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewGameObjectMethod( + container, gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + Func prefabGetter, Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderCustom(prefabGetter), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + UnityEngine.Object prefab, Action installerMethod) + { + BindingUtil.AssertIsValidPrefab(prefab); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProvider(prefab), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResourceMethod( + string resourcePath, Action installerMethod) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderResource(resourcePath), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + [System.Obsolete("ByNewPrefab has been renamed to ByNewContextPrefab to avoid confusion with ByNewPrefabInstaller and ByNewPrefabMethod")] + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefab(UnityEngine.Object prefab) + { + return ByNewContextPrefab(prefab); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewContextPrefab(UnityEngine.Object prefab) + { + BindingUtil.AssertIsValidPrefab(prefab); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefab( + container, + new PrefabProvider(prefab), + gameObjectInfo), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + [System.Obsolete("ByNewPrefabResource has been renamed to ByNewContextPrefabResource to avoid confusion with ByNewPrefabResourceInstaller and ByNewPrefabResourceMethod")] + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResource(string resourcePath) + { + return ByNewContextPrefabResource(resourcePath); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewContextPrefabResource(string resourcePath) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefab( + container, + new PrefabProviderResource(resourcePath), + gameObjectInfo), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder0.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder0.cs.meta new file mode 100644 index 0000000..d2b8d1f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder0.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3c12d5eb6ac4cc8449986d020ef27e4f +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder1.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder1.cs new file mode 100644 index 0000000..d600346 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder1.cs @@ -0,0 +1,97 @@ +using System; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactorySubContainerBinder + : FactorySubContainerBinderWithParams + { + public FactorySubContainerBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo, object subIdentifier) + : base(bindContainer, bindInfo, factoryBindInfo, subIdentifier) + { + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder ByMethod(Action installerMethod) + { + var subcontainerBindInfo = new SubContainerCreatorBindInfo(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByMethod( + container, subcontainerBindInfo, installerMethod), false); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + +#if !NOT_UNITY3D + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewGameObjectMethod( + Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewGameObjectMethod( + container, gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + Func prefabGetter, Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderCustom(prefabGetter), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + UnityEngine.Object prefab, Action installerMethod) + { + BindingUtil.AssertIsValidPrefab(prefab); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProvider(prefab), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResourceMethod( + string resourcePath, Action installerMethod) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderResource(resourcePath), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder1.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder1.cs.meta new file mode 100644 index 0000000..ca7224b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder1.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b119fe818c4bae143ab8f9a4f2a1b0fd +timeCreated: 1461708053 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder10.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder10.cs new file mode 100644 index 0000000..8d359a4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder10.cs @@ -0,0 +1,113 @@ +using System; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactorySubContainerBinder + : FactorySubContainerBinderWithParams + { + public FactorySubContainerBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo, object subIdentifier) + : base(bindContainer, bindInfo, factoryBindInfo, subIdentifier) + { + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder ByMethod( +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + var subcontainerBindInfo = new SubContainerCreatorBindInfo(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByMethod( + container, subcontainerBindInfo, installerMethod), false); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + +#if !NOT_UNITY3D + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewGameObjectMethod( +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewGameObjectMethod( container, + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + Func prefabGetter, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( container, + new PrefabProviderCustom(prefabGetter), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + UnityEngine.Object prefab, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + BindingUtil.AssertIsValidPrefab(prefab); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( container, + new PrefabProvider(prefab), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResourceMethod( + string resourcePath, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( container, + new PrefabProviderResource(resourcePath), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder10.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder10.cs.meta new file mode 100644 index 0000000..f4b62a6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder10.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 3b6136acd174dfc4d9b9d3f2b9e110e4 +timeCreated: 1507270779 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder2.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder2.cs new file mode 100644 index 0000000..b3f6e18 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder2.cs @@ -0,0 +1,97 @@ +using System; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactorySubContainerBinder + : FactorySubContainerBinderWithParams + { + public FactorySubContainerBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo, object subIdentifier) + : base(bindContainer, bindInfo, factoryBindInfo, subIdentifier) + { + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder ByMethod(Action installerMethod) + { + var subcontainerBindInfo = new SubContainerCreatorBindInfo(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByMethod( + container, subcontainerBindInfo, installerMethod), false); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + +#if !NOT_UNITY3D + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewGameObjectMethod( + Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewGameObjectMethod( + container, gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + Func prefabGetter, Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderCustom(prefabGetter), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + UnityEngine.Object prefab, Action installerMethod) + { + BindingUtil.AssertIsValidPrefab(prefab); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProvider(prefab), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResourceMethod( + string resourcePath, Action installerMethod) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderResource(resourcePath), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } +#endif + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder2.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder2.cs.meta new file mode 100644 index 0000000..643e71f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder2.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5f32bdc495dbe204caab18bace045515 +timeCreated: 1461708050 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder3.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder3.cs new file mode 100644 index 0000000..66ecc33 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder3.cs @@ -0,0 +1,98 @@ +using System; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactorySubContainerBinder + : FactorySubContainerBinderWithParams + { + public FactorySubContainerBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo, object subIdentifier) + : base(bindContainer, bindInfo, factoryBindInfo, subIdentifier) + { + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder ByMethod(Action installerMethod) + { + var subcontainerBindInfo = new SubContainerCreatorBindInfo(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByMethod( + container, subcontainerBindInfo, installerMethod), false); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + +#if !NOT_UNITY3D + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewGameObjectMethod( + Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewGameObjectMethod( + container, gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + Func prefabGetter, Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderCustom(prefabGetter), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + UnityEngine.Object prefab, Action installerMethod) + { + BindingUtil.AssertIsValidPrefab(prefab); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProvider(prefab), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResourceMethod( + string resourcePath, Action installerMethod) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderResource(resourcePath), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } +#endif + } +} + + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder3.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder3.cs.meta new file mode 100644 index 0000000..099d98e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder3.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fdb97e2862ca0a24e8f87c081ea05727 +timeCreated: 1461708055 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder4.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder4.cs new file mode 100644 index 0000000..3507bfa --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder4.cs @@ -0,0 +1,116 @@ +using System; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactorySubContainerBinder + : FactorySubContainerBinderWithParams + { + public FactorySubContainerBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo, object subIdentifier) + : base(bindContainer, bindInfo, factoryBindInfo, subIdentifier) + { + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder ByMethod( +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + var subcontainerBindInfo = new SubContainerCreatorBindInfo(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByMethod( + container, subcontainerBindInfo, installerMethod), false); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + +#if !NOT_UNITY3D + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewGameObjectMethod( +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewGameObjectMethod( + container, gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + Func prefabGetter, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderCustom(prefabGetter), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + UnityEngine.Object prefab, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + BindingUtil.AssertIsValidPrefab(prefab); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProvider(prefab), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResourceMethod( + string resourcePath, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderResource(resourcePath), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } +#endif + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder4.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder4.cs.meta new file mode 100644 index 0000000..9d8d10e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder4.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b0f061434819b334289a066ab685ab37 +timeCreated: 1461708053 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder5.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder5.cs new file mode 100644 index 0000000..8539ac4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder5.cs @@ -0,0 +1,115 @@ +using System; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactorySubContainerBinder + : FactorySubContainerBinderWithParams + { + public FactorySubContainerBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo, object subIdentifier) + : base(bindContainer, bindInfo, factoryBindInfo, subIdentifier) + { + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder ByMethod( +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + var subcontainerBindInfo = new SubContainerCreatorBindInfo(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByMethod( + container, subcontainerBindInfo, installerMethod), false); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + +#if !NOT_UNITY3D + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewGameObjectMethod( +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewGameObjectMethod( + container, gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + Func prefabGetter, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderCustom(prefabGetter), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + UnityEngine.Object prefab, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + BindingUtil.AssertIsValidPrefab(prefab); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProvider(prefab), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResourceMethod( + string resourcePath, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderResource(resourcePath), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder5.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder5.cs.meta new file mode 100644 index 0000000..31743b6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder5.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e562a021e16d4a2418f6c47de105c64e +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder6.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder6.cs new file mode 100644 index 0000000..e192bbb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder6.cs @@ -0,0 +1,115 @@ +using System; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactorySubContainerBinder + : FactorySubContainerBinderWithParams + { + public FactorySubContainerBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo, object subIdentifier) + : base(bindContainer, bindInfo, factoryBindInfo, subIdentifier) + { + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder ByMethod( +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + var subcontainerBindInfo = new SubContainerCreatorBindInfo(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByMethod( + container, subcontainerBindInfo, installerMethod), false); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + +#if !NOT_UNITY3D + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewGameObjectMethod( +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewGameObjectMethod( + container, gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + Func prefabGetter, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderCustom(prefabGetter), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + UnityEngine.Object prefab, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + BindingUtil.AssertIsValidPrefab(prefab); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProvider(prefab), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResourceMethod( + string resourcePath, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderResource(resourcePath), + gameObjectInfo, installerMethod), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder6.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder6.cs.meta new file mode 100644 index 0000000..f5fd6ec --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinder6.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 6bc525cf91bd29644ab941902ab4a8d2 +timeCreated: 1528529860 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinderBase.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinderBase.cs new file mode 100644 index 0000000..a5b7a27 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinderBase.cs @@ -0,0 +1,179 @@ +using System; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactorySubContainerBinderBase + { + public FactorySubContainerBinderBase( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo, object subIdentifier) + { + FactoryBindInfo = factoryBindInfo; + SubIdentifier = subIdentifier; + BindInfo = bindInfo; + BindContainer = bindContainer; + + // Reset so we get errors if we end here + factoryBindInfo.ProviderFunc = null; + } + + protected DiContainer BindContainer + { + get; private set; + } + + protected FactoryBindInfo FactoryBindInfo + { + get; private set; + } + + protected Func ProviderFunc + { + get { return FactoryBindInfo.ProviderFunc; } + set { FactoryBindInfo.ProviderFunc = value; } + } + + protected BindInfo BindInfo + { + get; + private set; + } + + protected object SubIdentifier + { + get; + private set; + } + + protected Type ContractType + { + get { return typeof(TContract); } + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder ByInstaller() + where TInstaller : InstallerBase + { + return ByInstaller(typeof(TInstaller)); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder ByInstaller(Type installerType) + { + Assert.That(installerType.DerivesFrom(), + "Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType); + + var subcontainerBindInfo = new SubContainerCreatorBindInfo(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByInstaller( + container, subcontainerBindInfo, installerType, BindInfo.Arguments), false); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + +#if !NOT_UNITY3D + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewGameObjectInstaller() + where TInstaller : InstallerBase + { + return ByNewGameObjectInstaller(typeof(TInstaller)); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewGameObjectInstaller(Type installerType) + { + Assert.That(installerType.DerivesFrom(), + "Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewGameObjectInstaller( + container, gameObjectInfo, installerType, BindInfo.Arguments), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabInstaller( + Func prefabGetter) + where TInstaller : InstallerBase + { + return ByNewPrefabInstaller(prefabGetter, typeof(TInstaller)); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabInstaller( + Func prefabGetter, Type installerType) + { + Assert.That(installerType.DerivesFrom(), + "Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabInstaller( + container, + new PrefabProviderCustom(prefabGetter), + gameObjectInfo, installerType, BindInfo.Arguments), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabInstaller( + UnityEngine.Object prefab) + where TInstaller : InstallerBase + { + return ByNewPrefabInstaller(prefab, typeof(TInstaller)); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabInstaller( + UnityEngine.Object prefab, Type installerType) + { + Assert.That(installerType.DerivesFrom(), + "Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabInstaller( + container, + new PrefabProvider(prefab), + gameObjectInfo, installerType, BindInfo.Arguments), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResourceInstaller( + string resourcePath) + where TInstaller : InstallerBase + { + return ByNewPrefabResourceInstaller(resourcePath, typeof(TInstaller)); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResourceInstaller( + string resourcePath, Type installerType) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + Assert.That(installerType.DerivesFrom(), + "Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabInstaller( + container, + new PrefabProviderResource(resourcePath), + gameObjectInfo, installerType, BindInfo.Arguments), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinderBase.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinderBase.cs.meta new file mode 100644 index 0000000..8bfb841 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinderBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 387c12fd770c48e49bcefe4c0723d511 +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinderWithParams.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinderWithParams.cs new file mode 100644 index 0000000..a07d20c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinderWithParams.cs @@ -0,0 +1,96 @@ +using System; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactorySubContainerBinderWithParams : FactorySubContainerBinderBase + { + public FactorySubContainerBinderWithParams( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo, object subIdentifier) + : base(bindContainer, bindInfo, factoryBindInfo, subIdentifier) + { + } + +#if !NOT_UNITY3D + + [System.Obsolete("ByNewPrefab has been renamed to ByNewContextPrefab to avoid confusion with ByNewPrefabInstaller and ByNewPrefabMethod")] + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefab(Type installerType, UnityEngine.Object prefab) + { + return ByNewContextPrefab(installerType, prefab); + } + + [System.Obsolete("ByNewPrefab has been renamed to ByNewContextPrefab to avoid confusion with ByNewPrefabInstaller and ByNewPrefabMethod")] + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefab(UnityEngine.Object prefab) + where TInstaller : IInstaller + { + return ByNewContextPrefab(prefab); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewContextPrefab(UnityEngine.Object prefab) + where TInstaller : IInstaller + { + return ByNewContextPrefab(typeof(TInstaller), prefab); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewContextPrefab(Type installerType, UnityEngine.Object prefab) + { + BindingUtil.AssertIsValidPrefab(prefab); + + Assert.That(installerType.DerivesFrom(), + "Invalid installer type given during bind command. Expected type '{0}' to derive from 'MonoInstaller'", installerType); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabWithParams( + installerType, + container, + new PrefabProvider(prefab), + gameObjectInfo), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + [System.Obsolete("ByNewPrefabResource has been renamed to ByNewContextPrefabResource to avoid confusion with ByNewPrefabResourceInstaller and ByNewPrefabResourceMethod")] + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResource(string resourcePath) + where TInstaller : IInstaller + { + return ByNewContextPrefabResource(resourcePath); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResource( + Type installerType, string resourcePath) + { + return ByNewContextPrefabResource(installerType, resourcePath); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewContextPrefabResource(string resourcePath) + where TInstaller : IInstaller + { + return ByNewContextPrefabResource(typeof(TInstaller), resourcePath); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewContextPrefabResource( + Type installerType, string resourcePath) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new SubContainerDependencyProvider( + ContractType, SubIdentifier, + new SubContainerCreatorByNewPrefabWithParams( + installerType, + container, + new PrefabProviderResource(resourcePath), + gameObjectInfo), false); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinderWithParams.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinderWithParams.cs.meta new file mode 100644 index 0000000..2f6c74f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/SubContainerBinder/FactorySubContainerBinderWithParams.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a002e9dce4e8af54d948529d6beda84b +timeCreated: 1461708052 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/Untyped.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/Untyped.meta new file mode 100644 index 0000000..3120185 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/Untyped.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 97d57d9da80f7414a8fed9f2a04621b8 +folderAsset: yes +timeCreated: 1512304190 +licenseType: Store +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/Untyped/FactoryFromBinderUntyped.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/Untyped/FactoryFromBinderUntyped.cs new file mode 100644 index 0000000..bc8dc0b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/Untyped/FactoryFromBinderUntyped.cs @@ -0,0 +1,16 @@ +using System; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryFromBinderUntyped : FactoryFromBinderBase + { + public FactoryFromBinderUntyped( + DiContainer bindContainer, Type contractType, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, contractType, bindInfo, factoryBindInfo) + { + } + + // TODO - add similar methods found in FactoryFromBinder<> + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/Untyped/FactoryFromBinderUntyped.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/Untyped/FactoryFromBinderUntyped.cs.meta new file mode 100644 index 0000000..244fb1f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinder/Untyped/FactoryFromBinderUntyped.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ed1989ebc010d0746ab301cc5747f5c8 +timeCreated: 1512304191 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinderBase.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinderBase.cs new file mode 100644 index 0000000..6a99753 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinderBase.cs @@ -0,0 +1,297 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +#if !NOT_UNITY3D +using UnityEngine; +#endif + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryFromBinderBase : ScopeConcreteIdArgConditionCopyNonLazyBinder + { + public FactoryFromBinderBase( + DiContainer bindContainer, Type contractType, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindInfo) + { + FactoryBindInfo = factoryBindInfo; + BindContainer = bindContainer; + ContractType = contractType; + factoryBindInfo.ProviderFunc = + (container) => new TransientProvider( + ContractType, container, BindInfo.Arguments, BindInfo.ContextInfo, BindInfo.ConcreteIdentifier, + BindInfo.InstantiatedCallback); + } + + // Don't use this + internal DiContainer BindContainer + { + get; private set; + } + + protected FactoryBindInfo FactoryBindInfo + { + get; private set; + } + + // Don't use this + internal Func ProviderFunc + { + get { return FactoryBindInfo.ProviderFunc; } + set { FactoryBindInfo.ProviderFunc = value; } + } + + protected Type ContractType + { + get; private set; + } + + public IEnumerable AllParentTypes + { + get + { + yield return ContractType; + + foreach (var type in BindInfo.ToTypes) + { + yield return type; + } + } + } + + // Note that this isn't necessary to call since it's the default + public ConditionCopyNonLazyBinder FromNew() + { + BindingUtil.AssertIsNotComponent(ContractType); + BindingUtil.AssertIsNotAbstract(ContractType); + + return this; + } + + public ConditionCopyNonLazyBinder FromResolve() + { + return FromResolve(null); + } + + public ConditionCopyNonLazyBinder FromInstance(object instance) + { + BindingUtil.AssertInstanceDerivesFromOrEqual(instance, AllParentTypes); + + ProviderFunc = + (container) => new InstanceProvider(ContractType, instance, container, null); + + return this; + } + + public ConditionCopyNonLazyBinder FromResolve(object subIdentifier) + { + ProviderFunc = + (container) => new ResolveProvider( + ContractType, container, + subIdentifier, false, InjectSources.Any, false); + + return this; + } + + // Don't use this + internal ConcreteBinderGeneric CreateIFactoryBinder(out Guid factoryId) + { + // Use a random ID so that our provider is the only one that can find it and so it doesn't + // conflict with anything else + factoryId = Guid.NewGuid(); + + // Very important here that we use NoFlush otherwise the main binding will be finalized early + return BindContainer.BindNoFlush().WithId(factoryId); + } + +#if !NOT_UNITY3D + + public ConditionCopyNonLazyBinder FromComponentOn(GameObject gameObject) + { + BindingUtil.AssertIsValidGameObject(gameObject); + BindingUtil.AssertIsComponent(ContractType); + BindingUtil.AssertIsNotAbstract(ContractType); + + ProviderFunc = + (container) => new GetFromGameObjectComponentProvider( + ContractType, gameObject, true); + + return this; + } + + public ConditionCopyNonLazyBinder FromComponentOn(Func gameObjectGetter) + { + BindingUtil.AssertIsComponent(ContractType); + BindingUtil.AssertIsNotAbstract(ContractType); + + ProviderFunc = + (container) => new GetFromGameObjectGetterComponentProvider( + ContractType, gameObjectGetter, true); + + return this; + } + + public ConditionCopyNonLazyBinder FromComponentOnRoot() + { + return FromComponentOn( + ctx => BindContainer.Resolve().gameObject); + } + + public ConditionCopyNonLazyBinder FromNewComponentOn(GameObject gameObject) + { + BindingUtil.AssertIsValidGameObject(gameObject); + BindingUtil.AssertIsComponent(ContractType); + BindingUtil.AssertIsNotAbstract(ContractType); + + ProviderFunc = + (container) => new AddToExistingGameObjectComponentProvider( + gameObject, container, ContractType, + new List(), BindInfo.ConcreteIdentifier, BindInfo.InstantiatedCallback); + + return this; + } + + public ConditionCopyNonLazyBinder FromNewComponentOn( + Func gameObjectGetter) + { + BindingUtil.AssertIsComponent(ContractType); + BindingUtil.AssertIsNotAbstract(ContractType); + + ProviderFunc = + (container) => new AddToExistingGameObjectComponentProviderGetter( + gameObjectGetter, container, ContractType, + new List(), BindInfo.ConcreteIdentifier, BindInfo.InstantiatedCallback); + + return this; + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromNewComponentOnNewGameObject() + { + BindingUtil.AssertIsComponent(ContractType); + BindingUtil.AssertIsNotAbstract(ContractType); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new AddToNewGameObjectComponentProvider( + container, ContractType, + new List(), gameObjectInfo, BindInfo.ConcreteIdentifier, BindInfo.InstantiatedCallback); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromNewComponentOnNewPrefab(UnityEngine.Object prefab) + { + BindingUtil.AssertIsValidPrefab(prefab); + BindingUtil.AssertIsComponent(ContractType); + BindingUtil.AssertIsNotAbstract(ContractType); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new InstantiateOnPrefabComponentProvider( + ContractType, + new PrefabInstantiator( + container, gameObjectInfo, + ContractType, new [] { ContractType }, new List(), + new PrefabProvider(prefab), BindInfo.InstantiatedCallback)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentInNewPrefab(UnityEngine.Object prefab) + { + BindingUtil.AssertIsValidPrefab(prefab); + BindingUtil.AssertIsInterfaceOrComponent(ContractType); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new GetFromPrefabComponentProvider( + ContractType, + new PrefabInstantiator( + container, gameObjectInfo, + ContractType, new [] { ContractType }, new List(), + new PrefabProvider(prefab), + BindInfo.InstantiatedCallback), true); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentInNewPrefabResource(string resourcePath) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + BindingUtil.AssertIsInterfaceOrComponent(ContractType); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new GetFromPrefabComponentProvider( + ContractType, + new PrefabInstantiator( + container, gameObjectInfo, + ContractType, new [] { ContractType }, new List(), + new PrefabProviderResource(resourcePath), BindInfo.InstantiatedCallback), true); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromNewComponentOnNewPrefabResource(string resourcePath) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + BindingUtil.AssertIsComponent(ContractType); + BindingUtil.AssertIsNotAbstract(ContractType); + + var gameObjectInfo = new GameObjectCreationParameters(); + + ProviderFunc = + (container) => new InstantiateOnPrefabComponentProvider( + ContractType, + new PrefabInstantiator( + container, gameObjectInfo, + ContractType, new [] { ContractType }, new List(), + new PrefabProviderResource(resourcePath), + BindInfo.InstantiatedCallback)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public ConditionCopyNonLazyBinder FromNewScriptableObjectResource(string resourcePath) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + BindingUtil.AssertIsInterfaceOrScriptableObject(ContractType); + + ProviderFunc = + (container) => new ScriptableObjectResourceProvider( + resourcePath, ContractType, container, new List(), + true, null, BindInfo.InstantiatedCallback); + + return this; + } + + public ConditionCopyNonLazyBinder FromScriptableObjectResource(string resourcePath) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + BindingUtil.AssertIsInterfaceOrScriptableObject(ContractType); + + ProviderFunc = + (container) => new ScriptableObjectResourceProvider( + resourcePath, ContractType, container, new List(), + false, null, BindInfo.InstantiatedCallback); + + return this; + } + + public ConditionCopyNonLazyBinder FromResource(string resourcePath) + { + BindingUtil.AssertDerivesFromUnityObject(ContractType); + + ProviderFunc = + (container) => new ResourceProvider(resourcePath, ContractType, true); + + return this; + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinderBase.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinderBase.cs.meta new file mode 100644 index 0000000..86b5c1a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryFromBinderBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1cdc9466c4b6c7f4f81675e8f546672f +timeCreated: 1461708048 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder.meta new file mode 100644 index 0000000..7eb5d31 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e1f8d57baff273344a3f10da1e51b772 +folderAsset: yes +timeCreated: 1461708047 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/DecoratorToChoiceFromBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/DecoratorToChoiceFromBinder.cs new file mode 100644 index 0000000..ef2d56a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/DecoratorToChoiceFromBinder.cs @@ -0,0 +1,29 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class DecoratorToChoiceFromBinder + { + DiContainer _bindContainer; + BindInfo _bindInfo; + FactoryBindInfo _factoryBindInfo; + + public DecoratorToChoiceFromBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + { + _bindContainer = bindContainer; + _bindInfo = bindInfo; + _factoryBindInfo = factoryBindInfo; + } + + public FactoryFromBinder With() + where TConcrete : TContract + { + _bindInfo.ToChoice = ToChoices.Concrete; + _bindInfo.ToTypes.Clear(); + _bindInfo.ToTypes.Add(typeof(TConcrete)); + + return new FactoryFromBinder( + _bindContainer, _bindInfo, _factoryBindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/DecoratorToChoiceFromBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/DecoratorToChoiceFromBinder.cs.meta new file mode 100644 index 0000000..746fbb7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/DecoratorToChoiceFromBinder.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: e70f91cb77703ce42ae6ad721b89d35c +timeCreated: 1528372067 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder0.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder0.cs new file mode 100644 index 0000000..55f7c6a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder0.cs @@ -0,0 +1,42 @@ +using System; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceBinder : FactoryFromBinder + { + public FactoryToChoiceBinder( + DiContainer container, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(container, bindInfo, factoryBindInfo) + { + } + + // Note that this is the default, so not necessary to call + public FactoryFromBinder ToSelf() + { + Assert.IsEqual(BindInfo.ToChoice, ToChoices.Self); + return this; + } + + public FactoryFromBinderUntyped To(Type concreteType) + { + BindInfo.ToChoice = ToChoices.Concrete; + BindInfo.ToTypes.Clear(); + BindInfo.ToTypes.Add(concreteType); + + return new FactoryFromBinderUntyped( + BindContainer, concreteType, BindInfo, FactoryBindInfo); + } + + public FactoryFromBinder To() + where TConcrete : TContract + { + BindInfo.ToChoice = ToChoices.Concrete; + BindInfo.ToTypes.Clear(); + BindInfo.ToTypes.Add(typeof(TConcrete)); + + return new FactoryFromBinder(BindContainer, BindInfo, FactoryBindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder0.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder0.cs.meta new file mode 100644 index 0000000..afd16cd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder0.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 98bc5c26f28a00544afe116adee67cc2 +timeCreated: 1461708052 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder1.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder1.cs new file mode 100644 index 0000000..a840fe1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder1.cs @@ -0,0 +1,31 @@ +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceBinder : FactoryFromBinder + { + public FactoryToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // Note that this is the default, so not necessary to call + public FactoryFromBinder ToSelf() + { + Assert.IsEqual(BindInfo.ToChoice, ToChoices.Self); + return this; + } + + public FactoryFromBinder To() + where TConcrete : TContract + { + BindInfo.ToChoice = ToChoices.Concrete; + BindInfo.ToTypes.Clear(); + BindInfo.ToTypes.Add(typeof(TConcrete)); + + return new FactoryFromBinder(BindContainer, BindInfo, FactoryBindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder1.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder1.cs.meta new file mode 100644 index 0000000..c0e01a1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder1.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 388c17c735861d145903203b31cb190d +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder10.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder10.cs new file mode 100644 index 0000000..dfad70e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder10.cs @@ -0,0 +1,32 @@ +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceBinder + : FactoryFromBinder + { + public FactoryToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // Note that this is the default, so not necessary to call + public FactoryFromBinder ToSelf() + { + Assert.IsEqual(BindInfo.ToChoice, ToChoices.Self); + return this; + } + + public FactoryFromBinder To() + where TConcrete : TContract + { + BindInfo.ToChoice = ToChoices.Concrete; + BindInfo.ToTypes.Clear(); + BindInfo.ToTypes.Add(typeof(TConcrete)); + + return new FactoryFromBinder(BindContainer, BindInfo, FactoryBindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder10.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder10.cs.meta new file mode 100644 index 0000000..c4d47c0 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder10.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 4cdcd151f6d139642b7a2a6968c6ebd8 +timeCreated: 1507270779 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder2.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder2.cs new file mode 100644 index 0000000..24ee228 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder2.cs @@ -0,0 +1,32 @@ +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceBinder : FactoryFromBinder + { + public FactoryToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // Note that this is the default, so not necessary to call + public FactoryFromBinder ToSelf() + { + Assert.IsEqual(BindInfo.ToChoice, ToChoices.Self); + return this; + } + + public FactoryFromBinder To() + where TConcrete : TContract + { + BindInfo.ToChoice = ToChoices.Concrete; + BindInfo.ToTypes.Clear(); + BindInfo.ToTypes.Add(typeof(TConcrete)); + + return new FactoryFromBinder(BindContainer, BindInfo, FactoryBindInfo); + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder2.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder2.cs.meta new file mode 100644 index 0000000..afa8ddb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder2.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 59c18bddf62adaf46b1de0564bf02388 +timeCreated: 1461708050 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder3.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder3.cs new file mode 100644 index 0000000..add26ce --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder3.cs @@ -0,0 +1,33 @@ +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceBinder : FactoryFromBinder + { + public FactoryToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // Note that this is the default, so not necessary to call + public FactoryFromBinder ToSelf() + { + Assert.IsEqual(BindInfo.ToChoice, ToChoices.Self); + return this; + } + + public FactoryFromBinder To() + where TConcrete : TContract + { + BindInfo.ToChoice = ToChoices.Concrete; + BindInfo.ToTypes.Clear(); + BindInfo.ToTypes.Add(typeof(TConcrete)); + + return new FactoryFromBinder(BindContainer, BindInfo, FactoryBindInfo); + } + } +} + + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder3.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder3.cs.meta new file mode 100644 index 0000000..988c985 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder3.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a71cc77bd306cca459126294c63080b1 +timeCreated: 1461708052 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder4.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder4.cs new file mode 100644 index 0000000..07bcfa2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder4.cs @@ -0,0 +1,31 @@ +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceBinder : FactoryFromBinder + { + public FactoryToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // Note that this is the default, so not necessary to call + public FactoryFromBinder ToSelf() + { + Assert.IsEqual(BindInfo.ToChoice, ToChoices.Self); + return this; + } + + public FactoryFromBinder To() + where TConcrete : TContract + { + BindInfo.ToChoice = ToChoices.Concrete; + BindInfo.ToTypes.Clear(); + BindInfo.ToTypes.Add(typeof(TConcrete)); + + return new FactoryFromBinder(BindContainer, BindInfo, FactoryBindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder4.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder4.cs.meta new file mode 100644 index 0000000..736dd2c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder4.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fee2c810a2ee8d2489a6a29177b48d82 +timeCreated: 1461708055 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder5.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder5.cs new file mode 100644 index 0000000..887ccea --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder5.cs @@ -0,0 +1,32 @@ +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceBinder + : FactoryFromBinder + { + public FactoryToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // Note that this is the default, so not necessary to call + public FactoryFromBinder ToSelf() + { + Assert.IsEqual(BindInfo.ToChoice, ToChoices.Self); + return this; + } + + public FactoryFromBinder To() + where TConcrete : TContract + { + BindInfo.ToChoice = ToChoices.Concrete; + BindInfo.ToTypes.Clear(); + BindInfo.ToTypes.Add(typeof(TConcrete)); + + return new FactoryFromBinder(BindContainer, BindInfo, FactoryBindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder5.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder5.cs.meta new file mode 100644 index 0000000..d1f929e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder5.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: dc472af8f2bc5bf498b8e85704193aac +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder6.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder6.cs new file mode 100644 index 0000000..74a999d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder6.cs @@ -0,0 +1,32 @@ +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceBinder + : FactoryFromBinder + { + public FactoryToChoiceBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + // Note that this is the default, so not necessary to call + public FactoryFromBinder ToSelf() + { + Assert.IsEqual(BindInfo.ToChoice, ToChoices.Self); + return this; + } + + public FactoryFromBinder To() + where TConcrete : TContract + { + BindInfo.ToChoice = ToChoices.Concrete; + BindInfo.ToTypes.Clear(); + BindInfo.ToTypes.Add(typeof(TConcrete)); + + return new FactoryFromBinder(BindContainer, BindInfo, FactoryBindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder6.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder6.cs.meta new file mode 100644 index 0000000..9115fda --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceBinder/FactoryToChoiceBinder6.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 4c738f3e9159a7e4f8450de246530f96 +timeCreated: 1528529860 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder.meta new file mode 100644 index 0000000..91d9597 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ad3cf76cc0b1c154e868ae8b570a78b8 +folderAsset: yes +timeCreated: 1484511595 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder0.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder0.cs new file mode 100644 index 0000000..8b25c26 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder0.cs @@ -0,0 +1,20 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceIdBinder : FactoryArgumentsToChoiceBinder + { + public FactoryToChoiceIdBinder( + DiContainer container, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(container, bindInfo, factoryBindInfo) + { + } + + public FactoryArgumentsToChoiceBinder WithId(object identifier) + { + BindInfo.Identifier = identifier; + return this; + } + } +} + + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder0.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder0.cs.meta new file mode 100644 index 0000000..dc3536d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder0.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: dca817e151a0eac4480344dcf838b949 +timeCreated: 1484511596 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder1.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder1.cs new file mode 100644 index 0000000..8032001 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder1.cs @@ -0,0 +1,18 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceIdBinder : FactoryArgumentsToChoiceBinder + { + public FactoryToChoiceIdBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + public FactoryArgumentsToChoiceBinder WithId(object identifier) + { + BindInfo.Identifier = identifier; + return this; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder1.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder1.cs.meta new file mode 100644 index 0000000..0313c32 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder1.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a005e8d2a91ae2647927c047c663d046 +timeCreated: 1484511596 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder10.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder10.cs new file mode 100644 index 0000000..ff2e195 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder10.cs @@ -0,0 +1,19 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceIdBinder + : FactoryArgumentsToChoiceBinder + { + public FactoryToChoiceIdBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + public FactoryArgumentsToChoiceBinder WithId(object identifier) + { + BindInfo.Identifier = identifier; + return this; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder10.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder10.cs.meta new file mode 100644 index 0000000..490d6ce --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder10.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 3e0b2700788fac54698446fcfad2b705 +timeCreated: 1507270779 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder2.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder2.cs new file mode 100644 index 0000000..9c25cf6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder2.cs @@ -0,0 +1,19 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceIdBinder : FactoryArgumentsToChoiceBinder + { + public FactoryToChoiceIdBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + public FactoryArgumentsToChoiceBinder WithId(object identifier) + { + BindInfo.Identifier = identifier; + return this; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder2.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder2.cs.meta new file mode 100644 index 0000000..4b1eaba --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder2.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c109e2a5fd72a004e83beae958fa888a +timeCreated: 1484511596 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder3.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder3.cs new file mode 100644 index 0000000..a15c462 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder3.cs @@ -0,0 +1,20 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceIdBinder : FactoryArgumentsToChoiceBinder + { + public FactoryToChoiceIdBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + public FactoryArgumentsToChoiceBinder WithId(object identifier) + { + BindInfo.Identifier = identifier; + return this; + } + } +} + + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder3.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder3.cs.meta new file mode 100644 index 0000000..51bd54d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder3.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: be02341a689ce654ab7160ce4eb5ed0e +timeCreated: 1484511596 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder4.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder4.cs new file mode 100644 index 0000000..9ddd8e9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder4.cs @@ -0,0 +1,18 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceIdBinder : FactoryArgumentsToChoiceBinder + { + public FactoryToChoiceIdBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + public FactoryArgumentsToChoiceBinder WithId(object identifier) + { + BindInfo.Identifier = identifier; + return this; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder4.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder4.cs.meta new file mode 100644 index 0000000..6081f23 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder4.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e65744c901e080744aada3988bfdf11c +timeCreated: 1484511596 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder5.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder5.cs new file mode 100644 index 0000000..0dd45b3 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder5.cs @@ -0,0 +1,19 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceIdBinder + : FactoryArgumentsToChoiceBinder + { + public FactoryToChoiceIdBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + public FactoryArgumentsToChoiceBinder WithId(object identifier) + { + BindInfo.Identifier = identifier; + return this; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder5.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder5.cs.meta new file mode 100644 index 0000000..a606600 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder5.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 20b01a4cfa147764a9e52134e2a32bb4 +timeCreated: 1484511595 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder6.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder6.cs new file mode 100644 index 0000000..05e63e9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder6.cs @@ -0,0 +1,19 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class FactoryToChoiceIdBinder + : FactoryArgumentsToChoiceBinder + { + public FactoryToChoiceIdBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + } + + public FactoryArgumentsToChoiceBinder WithId(object identifier) + { + BindInfo.Identifier = identifier; + return this; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder6.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder6.cs.meta new file mode 100644 index 0000000..0d06f89 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/FactoryToChoiceIdBinder/FactoryToChoiceIdBinder6.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b60ae0cff4748ec43b6cb040b0f3a728 +timeCreated: 1528529860 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/PlaceholderFactoryBindingFinalizer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/PlaceholderFactoryBindingFinalizer.cs new file mode 100644 index 0000000..fb8c67c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/PlaceholderFactoryBindingFinalizer.cs @@ -0,0 +1,50 @@ +using System.Linq; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class PlaceholderFactoryBindingFinalizer : ProviderBindingFinalizer + { + readonly FactoryBindInfo _factoryBindInfo; + + public PlaceholderFactoryBindingFinalizer( + BindInfo bindInfo, FactoryBindInfo factoryBindInfo) + : base(bindInfo) + { + // Note that it doesn't derive from PlaceholderFactory + // when used with To<>, so we can only check IPlaceholderFactory + Assert.That(factoryBindInfo.FactoryType.DerivesFrom()); + + _factoryBindInfo = factoryBindInfo; + } + + protected override void OnFinalizeBinding(DiContainer container) + { + var provider = _factoryBindInfo.ProviderFunc(container); + + var transientProvider = new TransientProvider( + _factoryBindInfo.FactoryType, + container, + _factoryBindInfo.Arguments.Concat( + InjectUtil.CreateArgListExplicit( + provider, + new InjectContext(container, typeof(TContract)))).ToList(), + BindInfo.ContextInfo, BindInfo.ConcreteIdentifier, null); + + IProvider mainProvider; + + if (BindInfo.Scope == ScopeTypes.Unset || BindInfo.Scope == ScopeTypes.Singleton) + { + mainProvider = BindingUtil.CreateCachedProvider(transientProvider); + } + else + { + Assert.IsEqual(BindInfo.Scope, ScopeTypes.Transient); + mainProvider = transientProvider; + } + + RegisterProviderForAllContracts(container, mainProvider); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/PlaceholderFactoryBindingFinalizer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/PlaceholderFactoryBindingFinalizer.cs.meta new file mode 100644 index 0000000..b210575 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/PlaceholderFactoryBindingFinalizer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2a3880a3063c56747b32995b66a8a1ca +timeCreated: 1486691381 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling.meta new file mode 100644 index 0000000..fa35bd0 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a019116e68c18f342995df14d6fbcf87 +folderAsset: yes +timeCreated: 1484511595 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolBindingFinalizer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolBindingFinalizer.cs new file mode 100644 index 0000000..3c1ba29 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolBindingFinalizer.cs @@ -0,0 +1,55 @@ +using System.Linq; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class MemoryPoolBindingFinalizer : ProviderBindingFinalizer + { + readonly MemoryPoolBindInfo _poolBindInfo; + readonly FactoryBindInfo _factoryBindInfo; + + public MemoryPoolBindingFinalizer( + BindInfo bindInfo, FactoryBindInfo factoryBindInfo, MemoryPoolBindInfo poolBindInfo) + : base(bindInfo) + { + // Note that it doesn't derive from MemoryPool + // when used with To<>, so we can only check IMemoryPoolBase + Assert.That(factoryBindInfo.FactoryType.DerivesFrom()); + + _factoryBindInfo = factoryBindInfo; + _poolBindInfo = poolBindInfo; + } + + protected override void OnFinalizeBinding(DiContainer container) + { + var factory = new FactoryProviderWrapper( + _factoryBindInfo.ProviderFunc(container), new InjectContext(container, typeof(TContract))); + + var settings = new MemoryPoolSettings( + _poolBindInfo.InitialSize, _poolBindInfo.MaxSize, _poolBindInfo.ExpandMethod); + + var transientProvider = new TransientProvider( + _factoryBindInfo.FactoryType, + container, + _factoryBindInfo.Arguments.Concat( + InjectUtil.CreateArgListExplicit(factory, settings)).ToList(), + BindInfo.ContextInfo, BindInfo.ConcreteIdentifier, null); + + IProvider mainProvider; + + if (BindInfo.Scope == ScopeTypes.Unset || BindInfo.Scope == ScopeTypes.Singleton) + { + mainProvider = BindingUtil.CreateCachedProvider(transientProvider); + } + else + { + Assert.IsEqual(BindInfo.Scope, ScopeTypes.Transient); + mainProvider = transientProvider; + } + + RegisterProviderForAllContracts(container, mainProvider); + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolBindingFinalizer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolBindingFinalizer.cs.meta new file mode 100644 index 0000000..a8697d1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolBindingFinalizer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 41eb30ac64078db4090dd136ccaf1fbe +timeCreated: 1485699960 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolExpandBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolExpandBinder.cs new file mode 100644 index 0000000..75cce20 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolExpandBinder.cs @@ -0,0 +1,33 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class MemoryPoolExpandBinder : FactoryArgumentsToChoiceBinder + { + public MemoryPoolExpandBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo, MemoryPoolBindInfo poolBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo) + { + MemoryPoolBindInfo = poolBindInfo; + + ExpandByOneAtATime(); + } + + protected MemoryPoolBindInfo MemoryPoolBindInfo + { + get; private set; + } + + public FactoryArgumentsToChoiceBinder ExpandByOneAtATime() + { + MemoryPoolBindInfo.ExpandMethod = PoolExpandMethods.OneAtATime; + return this; + } + + public FactoryArgumentsToChoiceBinder ExpandByDoubling() + { + MemoryPoolBindInfo.ExpandMethod = PoolExpandMethods.Double; + return this; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolExpandBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolExpandBinder.cs.meta new file mode 100644 index 0000000..b2d8e56 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolExpandBinder.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 95b7c7be81364a740b952460f5a07bbf +timeCreated: 1485699961 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolInitialSizeBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolInitialSizeBinder.cs new file mode 100644 index 0000000..284f2d9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolInitialSizeBinder.cs @@ -0,0 +1,59 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class MemoryPoolMaxSizeBinder : MemoryPoolExpandBinder + { + public MemoryPoolMaxSizeBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo, MemoryPoolBindInfo poolBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo, poolBindInfo) + { + } + + public MemoryPoolExpandBinder WithMaxSize(int size) + { + MemoryPoolBindInfo.MaxSize = size; + return this; + } + } + + [NoReflectionBaking] + public class MemoryPoolInitialSizeMaxSizeBinder : MemoryPoolMaxSizeBinder + { + public MemoryPoolInitialSizeMaxSizeBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo, MemoryPoolBindInfo poolBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo, poolBindInfo) + { + } + + public MemoryPoolMaxSizeBinder WithInitialSize(int size) + { + MemoryPoolBindInfo.InitialSize = size; + return this; + } + + public FactoryArgumentsToChoiceBinder WithFixedSize(int size) + { + MemoryPoolBindInfo.InitialSize = size; + MemoryPoolBindInfo.MaxSize = size; + MemoryPoolBindInfo.ExpandMethod = PoolExpandMethods.Disabled; + return this; + } + } + + [NoReflectionBaking] + public class MemoryPoolIdInitialSizeMaxSizeBinder : MemoryPoolInitialSizeMaxSizeBinder + { + public MemoryPoolIdInitialSizeMaxSizeBinder( + DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo, MemoryPoolBindInfo poolBindInfo) + : base(bindContainer, bindInfo, factoryBindInfo, poolBindInfo) + { + } + + public MemoryPoolInitialSizeMaxSizeBinder WithId(object identifier) + { + BindInfo.Identifier = identifier; + return this; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolInitialSizeBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolInitialSizeBinder.cs.meta new file mode 100644 index 0000000..c384d8b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/Factory/Pooling/MemoryPoolInitialSizeBinder.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 80ff9e6d501d30d4a82639f4ae453712 +timeCreated: 1485699961 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders.meta new file mode 100644 index 0000000..d5bda7a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b62c8a25fc0c5d34680c100f745a80e1 +folderAsset: yes +timeCreated: 1461708047 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinder.cs new file mode 100644 index 0000000..39e5793 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinder.cs @@ -0,0 +1,880 @@ +using System; +using System.Collections.Generic; +using ModestTree; +using System.Linq; + +#if !NOT_UNITY3D +using UnityEngine; +#endif + +using Zenject.Internal; + +namespace Zenject +{ + public abstract class FromBinder : ScopeConcreteIdArgConditionCopyNonLazyBinder + { + public FromBinder( + DiContainer bindContainer, BindInfo bindInfo, + BindStatement bindStatement) + : base(bindInfo) + { + BindStatement = bindStatement; + BindContainer = bindContainer; + } + + protected DiContainer BindContainer + { + get; private set; + } + + protected BindStatement BindStatement + { + get; + private set; + } + + protected IBindingFinalizer SubFinalizer + { + set { BindStatement.SetFinalizer(value); } + } + + protected IEnumerable AllParentTypes + { + get { return BindInfo.ContractTypes.Concat(BindInfo.ToTypes); } + } + + protected IEnumerable ConcreteTypes + { + get + { + if (BindInfo.ToChoice == ToChoices.Self) + { + return BindInfo.ContractTypes; + } + + Assert.IsNotEmpty(BindInfo.ToTypes); + return BindInfo.ToTypes; + } + } + + // This is the default if nothing else is called + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromNew() + { + BindingUtil.AssertTypesAreNotComponents(ConcreteTypes); + BindingUtil.AssertTypesAreNotAbstract(ConcreteTypes); + + return this; + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolve() + { + return FromResolve(null); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolve(object subIdentifier) + { + return FromResolve(subIdentifier, InjectSources.Any); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolve(object subIdentifier, InjectSources source) + { + return FromResolveInternal(subIdentifier, false, source); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveAll() + { + return FromResolveAll(null); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveAll(object subIdentifier) + { + return FromResolveAll(subIdentifier, InjectSources.Any); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveAll(object subIdentifier, InjectSources source) + { + return FromResolveInternal(subIdentifier, true, source); + } + + ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveInternal(object subIdentifier, bool matchAll, InjectSources source) + { + BindInfo.RequireExplicitScope = false; + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new ResolveProvider( + type, container, subIdentifier, false, source, matchAll)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + + public SubContainerBinder FromSubContainerResolveAll() + { + return FromSubContainerResolveAll(null); + } + + public SubContainerBinder FromSubContainerResolveAll(object subIdentifier) + { + return FromSubContainerResolveInternal(subIdentifier, true); + } + + public SubContainerBinder FromSubContainerResolve() + { + return FromSubContainerResolve(null); + } + + public SubContainerBinder FromSubContainerResolve(object subIdentifier) + { + return FromSubContainerResolveInternal(subIdentifier, false); + } + + SubContainerBinder FromSubContainerResolveInternal( + object subIdentifier, bool resolveAll) + { + // It's unlikely they will want to create the whole subcontainer with each binding + // (aka transient) which is the default so require that they specify it + BindInfo.RequireExplicitScope = true; + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + + return new SubContainerBinder( + BindInfo, BindStatement, subIdentifier, resolveAll); + } + + protected ScopeConcreteIdArgConditionCopyNonLazyBinder FromIFactoryBase( + Action>> factoryBindGenerator) + { + // Use a random ID so that our provider is the only one that can find it and so it doesn't + // conflict with anything else + var factoryId = Guid.NewGuid(); + + // Important to use NoFlush here otherwise the main binding will finalize early + var subBinder = BindContainer.BindNoFlush>() + .WithId(factoryId); + + factoryBindGenerator(subBinder); + + // This is kind of like a look up method like FromMethod so don't enforce specifying scope + // The internal binding will require an explicit scope so should be obvious enough + BindInfo.RequireExplicitScope = false; + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new IFactoryProvider(container, factoryId)); + + var binder = new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + // Needed for example if the user uses MoveIntoDirectSubContainers + binder.AddSecondaryCopyBindInfo(subBinder.BindInfo); + return binder; + } + +#if !NOT_UNITY3D + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsOn(GameObject gameObject) + { + BindingUtil.AssertIsValidGameObject(gameObject); + BindingUtil.AssertIsComponent(ConcreteTypes); + BindingUtil.AssertTypesAreNotAbstract(ConcreteTypes); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new GetFromGameObjectComponentProvider( + type, gameObject, false)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentOn(GameObject gameObject) + { + BindingUtil.AssertIsValidGameObject(gameObject); + BindingUtil.AssertIsComponent(ConcreteTypes); + BindingUtil.AssertTypesAreNotAbstract(ConcreteTypes); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new GetFromGameObjectComponentProvider( + type, gameObject, true)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsOn(Func gameObjectGetter) + { + BindingUtil.AssertIsComponent(ConcreteTypes); + BindingUtil.AssertTypesAreNotAbstract(ConcreteTypes); + + BindInfo.RequireExplicitScope = false; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new GetFromGameObjectGetterComponentProvider( + type, gameObjectGetter, false)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentOn(Func gameObjectGetter) + { + BindingUtil.AssertIsComponent(ConcreteTypes); + BindingUtil.AssertTypesAreNotAbstract(ConcreteTypes); + + BindInfo.RequireExplicitScope = false; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new GetFromGameObjectGetterComponentProvider( + type, gameObjectGetter, true)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsOnRoot() + { + return FromComponentsOn( + ctx => ctx.Container.Resolve().gameObject); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentOnRoot() + { + return FromComponentOn( + ctx => ctx.Container.Resolve().gameObject); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromNewComponentOn(GameObject gameObject) + { + BindingUtil.AssertIsValidGameObject(gameObject); + BindingUtil.AssertIsComponent(ConcreteTypes); + BindingUtil.AssertTypesAreNotAbstract(ConcreteTypes); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new AddToExistingGameObjectComponentProvider( + gameObject, container, type, BindInfo.Arguments, BindInfo.ConcreteIdentifier, BindInfo.InstantiatedCallback)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromNewComponentOn(Func gameObjectGetter) + { + BindingUtil.AssertIsComponent(ConcreteTypes); + BindingUtil.AssertTypesAreNotAbstract(ConcreteTypes); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new AddToExistingGameObjectComponentProviderGetter( + gameObjectGetter, container, type, BindInfo.Arguments, BindInfo.ConcreteIdentifier, BindInfo.InstantiatedCallback)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromNewComponentSibling() + { + BindingUtil.AssertIsComponent(ConcreteTypes); + BindingUtil.AssertTypesAreNotAbstract(ConcreteTypes); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new SingleProviderBindingFinalizer( + BindInfo, (container, type) => new AddToCurrentGameObjectComponentProvider( + container, type, BindInfo.Arguments, BindInfo.ConcreteIdentifier, BindInfo.InstantiatedCallback)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromNewComponentOnRoot() + { + return FromNewComponentOn( + ctx => ctx.Container.Resolve().gameObject); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromNewComponentOnNewGameObject() + { + return FromNewComponentOnNewGameObject(new GameObjectCreationParameters()); + } + + internal NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromNewComponentOnNewGameObject( + GameObjectCreationParameters gameObjectInfo) + { + BindingUtil.AssertIsComponent(ConcreteTypes); + BindingUtil.AssertTypesAreNotAbstract(ConcreteTypes); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new AddToNewGameObjectComponentProvider( + container, + type, + BindInfo.Arguments, + gameObjectInfo, BindInfo.ConcreteIdentifier, BindInfo.InstantiatedCallback)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromNewComponentOnNewPrefabResource(string resourcePath) + { + return FromNewComponentOnNewPrefabResource(resourcePath, new GameObjectCreationParameters()); + } + + internal NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromNewComponentOnNewPrefabResource( + string resourcePath, GameObjectCreationParameters gameObjectInfo) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + BindingUtil.AssertIsComponent(ConcreteTypes); + BindingUtil.AssertTypesAreNotAbstract(ConcreteTypes); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new PrefabResourceBindingFinalizer( + BindInfo, gameObjectInfo, resourcePath, + (contractType, instantiator) => new InstantiateOnPrefabComponentProvider(contractType, instantiator)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromNewComponentOnNewPrefab(UnityEngine.Object prefab) + { + return FromNewComponentOnNewPrefab(prefab, new GameObjectCreationParameters()); + } + + internal NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromNewComponentOnNewPrefab( + UnityEngine.Object prefab, GameObjectCreationParameters gameObjectInfo) + { + BindingUtil.AssertIsValidPrefab(prefab); + BindingUtil.AssertIsComponent(ConcreteTypes); + BindingUtil.AssertTypesAreNotAbstract(ConcreteTypes); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new PrefabBindingFinalizer( + BindInfo, gameObjectInfo, prefab, + (contractType, instantiator) => + new InstantiateOnPrefabComponentProvider(contractType, instantiator)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentInNewPrefab(UnityEngine.Object prefab) + { + return FromComponentInNewPrefab( + prefab, new GameObjectCreationParameters()); + } + + internal NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentInNewPrefab( + UnityEngine.Object prefab, GameObjectCreationParameters gameObjectInfo) + { + BindingUtil.AssertIsValidPrefab(prefab); + BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new PrefabBindingFinalizer( + BindInfo, gameObjectInfo, prefab, + (contractType, instantiator) => new GetFromPrefabComponentProvider(contractType, instantiator, true)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInNewPrefab(UnityEngine.Object prefab) + { + return FromComponentsInNewPrefab( + prefab, new GameObjectCreationParameters()); + } + + internal NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInNewPrefab( + UnityEngine.Object prefab, GameObjectCreationParameters gameObjectInfo) + { + BindingUtil.AssertIsValidPrefab(prefab); + BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new PrefabBindingFinalizer( + BindInfo, gameObjectInfo, prefab, + (contractType, instantiator) => new GetFromPrefabComponentProvider(contractType, instantiator, false)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentInNewPrefabResource(string resourcePath) + { + return FromComponentInNewPrefabResource(resourcePath, new GameObjectCreationParameters()); + } + + internal NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentInNewPrefabResource( + string resourcePath, GameObjectCreationParameters gameObjectInfo) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new PrefabResourceBindingFinalizer( + BindInfo, gameObjectInfo, resourcePath, + (contractType, instantiator) => new GetFromPrefabComponentProvider(contractType, instantiator, true)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInNewPrefabResource(string resourcePath) + { + return FromComponentsInNewPrefabResource(resourcePath, new GameObjectCreationParameters()); + } + + internal NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInNewPrefabResource( + string resourcePath, GameObjectCreationParameters gameObjectInfo) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new PrefabResourceBindingFinalizer( + BindInfo, gameObjectInfo, resourcePath, + (contractType, instantiator) => new GetFromPrefabComponentProvider(contractType, instantiator, false)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo, gameObjectInfo); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromNewScriptableObject(ScriptableObject resource) + { + return FromScriptableObjectInternal(resource, true); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromScriptableObject(ScriptableObject resource) + { + return FromScriptableObjectInternal(resource, false); + } + + ScopeConcreteIdArgConditionCopyNonLazyBinder FromScriptableObjectInternal( + ScriptableObject resource, bool createNew) + { + BindingUtil.AssertIsInterfaceOrScriptableObject(AllParentTypes); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new ScriptableObjectInstanceProvider( + resource, type, container, BindInfo.Arguments, createNew, + BindInfo.ConcreteIdentifier, BindInfo.InstantiatedCallback)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromNewScriptableObjectResource(string resourcePath) + { + return FromScriptableObjectResourceInternal(resourcePath, true); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromScriptableObjectResource(string resourcePath) + { + return FromScriptableObjectResourceInternal(resourcePath, false); + } + + ScopeConcreteIdArgConditionCopyNonLazyBinder FromScriptableObjectResourceInternal( + string resourcePath, bool createNew) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + BindingUtil.AssertIsInterfaceOrScriptableObject(AllParentTypes); + + BindInfo.RequireExplicitScope = true; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new ScriptableObjectResourceProvider( + resourcePath, type, container, BindInfo.Arguments, createNew, + BindInfo.ConcreteIdentifier, BindInfo.InstantiatedCallback)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResource(string resourcePath) + { + BindingUtil.AssertDerivesFromUnityObject(ConcreteTypes); + + BindInfo.RequireExplicitScope = false; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (_, type) => new ResourceProvider(resourcePath, type, true)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResources(string resourcePath) + { + BindingUtil.AssertDerivesFromUnityObject(ConcreteTypes); + + BindInfo.RequireExplicitScope = false; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (_, type) => new ResourceProvider(resourcePath, type, false)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentInChildren( + bool includeInactive = true) + { + BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); + + BindInfo.RequireExplicitScope = false; + + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, concreteType) => new MethodMultipleProviderUntyped(ctx => + { + Assert.That(ctx.ObjectType.DerivesFromOrEqual(), + "Cannot use FromComponentInChildren to inject data into non monobehaviours!"); + + Assert.IsNotNull(ctx.ObjectInstance); + + var monoBehaviour = (MonoBehaviour)ctx.ObjectInstance; + + var match = monoBehaviour.GetComponentInChildren(concreteType, includeInactive); + + if (match == null) + { + Assert.That(ctx.Optional, + "Could not find any component with type '{0}' through FromComponentInChildren binding", concreteType); + return Enumerable.Empty(); + } + + return new object[] { match }; + }, + container)); + + return this; + } + + protected ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInChildrenBase( + bool excludeSelf, Func predicate, bool includeInactive) + { + BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); + + BindInfo.RequireExplicitScope = false; + + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, concreteType) => new MethodMultipleProviderUntyped(ctx => + { + Assert.That(ctx.ObjectType.DerivesFromOrEqual(), + "Cannot use FromComponentsInChildren to inject data into non monobehaviours!"); + + Assert.IsNotNull(ctx.ObjectInstance); + + var monoBehaviour = (MonoBehaviour)ctx.ObjectInstance; + + var res = monoBehaviour.GetComponentsInChildren(concreteType, includeInactive) + .Where(x => !ReferenceEquals(x, ctx.ObjectInstance)); + + if (excludeSelf) + { + res = res.Where(x => x.gameObject != monoBehaviour.gameObject); + } + + if (predicate != null) + { + res = res.Where(predicate); + } + + return res.Cast(); + }, + container)); + + return this; + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentInParents( + bool excludeSelf = false, bool includeInactive = true) + { + BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); + + BindInfo.RequireExplicitScope = false; + + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, concreteType) => new MethodMultipleProviderUntyped(ctx => + { + Assert.That(ctx.ObjectType.DerivesFromOrEqual(), + "Cannot use FromComponentSibling to inject data into non monobehaviours!"); + + Assert.IsNotNull(ctx.ObjectInstance); + + var monoBehaviour = (MonoBehaviour)ctx.ObjectInstance; + + var matches = monoBehaviour.GetComponentsInParent(concreteType, includeInactive) + .Where(x => !ReferenceEquals(x, ctx.ObjectInstance)); + + if (excludeSelf) + { + matches = matches.Where(x => x.gameObject != monoBehaviour.gameObject); + } + + var match = matches.FirstOrDefault(); + + if (match == null) + { + Assert.That(ctx.Optional, + "Could not find any component with type '{0}' through FromComponentInParents binding", concreteType); + + return Enumerable.Empty(); + } + + return new object[] { match }; + }, + container)); + + return this; + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInParents( + bool excludeSelf = false, bool includeInactive = true) + { + BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); + + BindInfo.RequireExplicitScope = false; + + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, concreteType) => new MethodMultipleProviderUntyped(ctx => + { + Assert.That(ctx.ObjectType.DerivesFromOrEqual(), + "Cannot use FromComponentSibling to inject data into non monobehaviours!"); + + Assert.IsNotNull(ctx.ObjectInstance); + + var monoBehaviour = (MonoBehaviour)ctx.ObjectInstance; + + var res = monoBehaviour.GetComponentsInParent(concreteType, includeInactive) + .Where(x => !ReferenceEquals(x, ctx.ObjectInstance)); + + if (excludeSelf) + { + res = res.Where(x => x.gameObject != monoBehaviour.gameObject); + } + + return res.Cast(); + }, + container)); + + return this; + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentSibling() + { + BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); + + BindInfo.RequireExplicitScope = false; + + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, concreteType) => new MethodMultipleProviderUntyped(ctx => + { + Assert.That(ctx.ObjectType.DerivesFromOrEqual(), + "Cannot use FromComponentSibling to inject data into non monobehaviours!"); + + Assert.IsNotNull(ctx.ObjectInstance); + + var monoBehaviour = (MonoBehaviour)ctx.ObjectInstance; + + var match = monoBehaviour.GetComponent(concreteType); + + if (match == null) + { + Assert.That(ctx.Optional, + "Could not find any component with type '{0}' through FromComponentSibling binding", concreteType); + return Enumerable.Empty(); + } + + return new object[] { match }; + }, + container)); + + return this; + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsSibling() + { + BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); + + BindInfo.RequireExplicitScope = false; + + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, concreteType) => new MethodMultipleProviderUntyped(ctx => + { + Assert.That(ctx.ObjectType.DerivesFromOrEqual(), + "Cannot use FromComponentSibling to inject data into non monobehaviours!"); + + Assert.IsNotNull(ctx.ObjectInstance); + + var monoBehaviour = (MonoBehaviour)ctx.ObjectInstance; + + return monoBehaviour.GetComponents(concreteType) + .Where(x => !ReferenceEquals(x, monoBehaviour)).Cast(); + }, + container)); + + return this; + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentInHierarchy( + bool includeInactive = true) + { + BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); + + // Since this is a pretty heavy operation, let's require an explicit scope + // Most of the time they should use AsCached or AsSingle + BindInfo.RequireExplicitScope = true; + + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, concreteType) => new MethodMultipleProviderUntyped(ctx => + { + var match = container.Resolve().GetRootGameObjects() + .Select(x => x.GetComponentInChildren(concreteType, includeInactive)) + .Where(x => x != null && !ReferenceEquals(x, ctx.ObjectInstance)).FirstOrDefault(); + + if (match == null) + { + Assert.That(ctx.Optional, + "Could not find any component with type '{0}' through FromComponentInHierarchy binding", concreteType); + return Enumerable.Empty(); + } + + return new object[] { match }; + }, + container)); + + return this; + } + + protected ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInHierarchyBase( + Func predicate = null, bool includeInactive = true) + { + BindingUtil.AssertIsInterfaceOrComponent(AllParentTypes); + + BindInfo.RequireExplicitScope = true; + + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, concreteType) => new MethodMultipleProviderUntyped(ctx => + { + var res = container.Resolve().GetRootGameObjects() + .SelectMany(x => x.GetComponentsInChildren(concreteType, includeInactive)) + .Where(x => !ReferenceEquals(x, ctx.ObjectInstance)); + + if (predicate != null) + { + res = res.Where(predicate); + } + + return res.Cast(); + }, + container)); + + return this; + } +#endif + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethodUntyped(Func method) + { + BindInfo.RequireExplicitScope = false; + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new MethodProviderUntyped(method, container)); + + return this; + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethodMultipleUntyped(Func> method) + { + BindInfo.RequireExplicitScope = false; + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new MethodMultipleProviderUntyped(method, container)); + + return this; + } + + protected ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethodBase(Func method) + { + BindingUtil.AssertIsDerivedFromTypes(typeof(TConcrete), AllParentTypes); + + BindInfo.RequireExplicitScope = false; + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new MethodProvider(method, container)); + + return this; + } + + protected ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethodMultipleBase(Func> method) + { + BindInfo.RequireExplicitScope = false; + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new MethodProviderMultiple(method, container)); + + return this; + } + + protected ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveGetterBase( + object identifier, Func method, InjectSources source, bool matchMultiple) + { + BindingUtil.AssertIsDerivedFromTypes(typeof(TResult), AllParentTypes); + + BindInfo.RequireExplicitScope = false; + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new GetterProvider(identifier, method, container, source, matchMultiple)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + + protected ScopeConcreteIdArgConditionCopyNonLazyBinder FromInstanceBase(object instance) + { + BindingUtil.AssertInstanceDerivesFromOrEqual(instance, AllParentTypes); + + BindInfo.RequireExplicitScope = false; + // Don't know how it's created so can't assume here that it violates AsSingle + BindInfo.MarkAsCreationBinding = false; + SubFinalizer = new ScopableBindingFinalizer( + BindInfo, + (container, type) => new InstanceProvider(type, instance, container, BindInfo.InstantiatedCallback)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinder.cs.meta new file mode 100644 index 0000000..096ca20 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinder.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1bfe8c7cab3320b4a818fbb97098fb11 +timeCreated: 1461708048 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinderGeneric.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinderGeneric.cs new file mode 100644 index 0000000..c23ed7e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinderGeneric.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using ModestTree; +using System.Linq; + +#if !NOT_UNITY3D +using UnityEngine; +#endif + +namespace Zenject +{ + [NoReflectionBaking] + public class FromBinderGeneric : FromBinder + { + public FromBinderGeneric( + DiContainer bindContainer, + BindInfo bindInfo, + BindStatement bindStatement) + : base(bindContainer, bindInfo, bindStatement) + { + BindingUtil.AssertIsDerivedFromTypes(typeof(TContract), BindInfo.ContractTypes); + } + + // Shortcut for FromIFactory and also for backwards compatibility + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromFactory() + where TFactory : IFactory + { + return FromIFactory(x => x.To().AsCached()); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromIFactory( + Action>> factoryBindGenerator) + { + return FromIFactoryBase(factoryBindGenerator); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethod(Func method) + { + return FromMethodBase(ctx => method()); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethod(Func method) + { + return FromMethodBase(method); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethodMultiple(Func> method) + { + BindingUtil.AssertIsDerivedFromTypes(typeof(TContract), AllParentTypes); + return FromMethodMultipleBase(method); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveGetter(Func method) + { + return FromResolveGetter(null, method); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveGetter(object identifier, Func method) + { + return FromResolveGetter(identifier, method, InjectSources.Any); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveGetter(object identifier, Func method, InjectSources source) + { + return FromResolveGetterBase(identifier, method, source, false); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveAllGetter(Func method) + { + return FromResolveAllGetter(null, method); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveAllGetter(object identifier, Func method) + { + return FromResolveAllGetter(identifier, method, InjectSources.Any); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveAllGetter(object identifier, Func method, InjectSources source) + { + return FromResolveGetterBase(identifier, method, source, true); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromInstance(TContract instance) + { + return FromInstanceBase(instance); + } + +#if !NOT_UNITY3D + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInChildren( + Func predicate, bool includeInactive = true) + { + return FromComponentsInChildren(false, predicate, includeInactive); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInChildren( + bool excludeSelf = false, Func predicate = null, bool includeInactive = true) + { + Func subPredicate; + + if (predicate != null) + { + subPredicate = component => predicate((TContract)(object)component); + } + else + { + subPredicate = null; + } + + return FromComponentsInChildrenBase( + excludeSelf, subPredicate, includeInactive); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInHierarchy( + Func predicate = null, bool includeInactive = true) + { + Func subPredicate; + + if (predicate != null) + { + subPredicate = component => predicate((TContract)(object)component); + } + else + { + subPredicate = null; + } + + return FromComponentsInHierarchyBase(subPredicate, includeInactive); + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinderGeneric.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinderGeneric.cs.meta new file mode 100644 index 0000000..9e257c1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinderGeneric.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 97eaa55248b4c824a887df4db7cf888d +timeCreated: 1461708052 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinderNonGeneric.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinderNonGeneric.cs new file mode 100644 index 0000000..a92ea9e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinderNonGeneric.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; + +#if !NOT_UNITY3D +using UnityEngine; +#endif + +namespace Zenject +{ + [NoReflectionBaking] + public class FromBinderNonGeneric : FromBinder + { + public FromBinderNonGeneric( + DiContainer bindContainer, BindInfo bindInfo, + BindStatement bindStatement) + : base(bindContainer, bindInfo, bindStatement) + { + } + + // Shortcut for FromIFactory and also for backwards compatibility + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromFactory() + where TFactory : IFactory + { + return FromIFactory(x => x.To().AsCached()); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromIFactory( + Action>> factoryBindGenerator) + { + return FromIFactoryBase(factoryBindGenerator); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethod(Func method) + { + return FromMethodBase(method); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethodMultiple(Func> method) + { + BindingUtil.AssertIsDerivedFromTypes(typeof(TConcrete), AllParentTypes); + return FromMethodMultipleBase(method); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveGetter(Func method) + { + return FromResolveGetter(null, method); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveGetter(object identifier, Func method) + { + return FromResolveGetter(identifier, method, InjectSources.Any); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveGetter(object identifier, Func method, InjectSources source) + { + return FromResolveGetterBase(identifier, method, source, false); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveAllGetter(Func method) + { + return FromResolveAllGetter(null, method); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveAllGetter(object identifier, Func method) + { + return FromResolveAllGetter(identifier, method, InjectSources.Any); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveAllGetter(object identifier, Func method, InjectSources source) + { + return FromResolveGetterBase(identifier, method, source, true); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromInstance(object instance) + { + return FromInstanceBase(instance); + } + +#if !NOT_UNITY3D + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInChildren( + Func predicate, bool includeInactive = true) + { + return FromComponentsInChildren(false, predicate, includeInactive); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInChildren( + bool excludeSelf = false, Func predicate = null, bool includeInactive = true) + { + return FromComponentsInChildrenBase(excludeSelf, predicate, includeInactive); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInHierarchy( + Func predicate = null, bool includeInactive = true) + { + return FromComponentsInHierarchyBase(predicate, includeInactive); + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinderNonGeneric.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinderNonGeneric.cs.meta new file mode 100644 index 0000000..c98268f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/FromBinders/FromBinderNonGeneric.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e54c591a4175efc4688be675528600c1 +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject.meta new file mode 100644 index 0000000..2f164bc --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6a5ff7e3b16416245acfcd6be217a53f +folderAsset: yes +timeCreated: 1461708047 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject/NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject/NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder.cs new file mode 100644 index 0000000..c9a7b73 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject/NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder.cs @@ -0,0 +1,23 @@ +#if !NOT_UNITY3D + +namespace Zenject +{ + [NoReflectionBaking] + public class NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder : TransformScopeConcreteIdArgConditionCopyNonLazyBinder + { + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder( + BindInfo bindInfo, + GameObjectCreationParameters gameObjectInfo) + : base(bindInfo, gameObjectInfo) + { + } + + public TransformScopeConcreteIdArgConditionCopyNonLazyBinder WithGameObjectName(string gameObjectName) + { + GameObjectInfo.Name = gameObjectName; + return this; + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject/NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject/NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta new file mode 100644 index 0000000..89470b9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject/NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 74c9bb72aa7484d49a39760d2246f1a3 +timeCreated: 1523257673 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject/TransformScopeConcreteIdArgConditionCopyNonLazyBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject/TransformScopeConcreteIdArgConditionCopyNonLazyBinder.cs new file mode 100644 index 0000000..31bd1f9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject/TransformScopeConcreteIdArgConditionCopyNonLazyBinder.cs @@ -0,0 +1,45 @@ +#if !NOT_UNITY3D + +using System; +using UnityEngine; + +namespace Zenject +{ + [NoReflectionBaking] + public class TransformScopeConcreteIdArgConditionCopyNonLazyBinder : ScopeConcreteIdArgConditionCopyNonLazyBinder + { + public TransformScopeConcreteIdArgConditionCopyNonLazyBinder( + BindInfo bindInfo, + GameObjectCreationParameters gameObjectInfo) + : base(bindInfo) + { + GameObjectInfo = gameObjectInfo; + } + + protected GameObjectCreationParameters GameObjectInfo + { + get; + private set; + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder UnderTransform(Transform parent) + { + GameObjectInfo.ParentTransform = parent; + return this; + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder UnderTransform(Func parentGetter) + { + GameObjectInfo.ParentTransformGetter = parentGetter; + return this; + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder UnderTransformGroup(string transformGroupname) + { + GameObjectInfo.GroupName = transformGroupname; + return this; + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject/TransformScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject/TransformScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta new file mode 100644 index 0000000..165fa12 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/GameObject/TransformScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d6441d2557329b14b8a80a6d3c490e9b +timeCreated: 1523257674 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IdBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IdBinder.cs new file mode 100644 index 0000000..620ae88 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IdBinder.cs @@ -0,0 +1,20 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class IdBinder + { + BindInfo _bindInfo; + + public IdBinder(BindInfo bindInfo) + { + _bindInfo = bindInfo; + } + + public void WithId(object identifier) + { + _bindInfo.Identifier = identifier; + } + } +} + + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IdBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IdBinder.cs.meta new file mode 100644 index 0000000..7f287a9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IdBinder.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 371e1c0b9a8ff664f993cbe2a547eeae +timeCreated: 1484790451 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IdScopeConcreteIdArgConditionCopyNonLazyBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IdScopeConcreteIdArgConditionCopyNonLazyBinder.cs new file mode 100644 index 0000000..5947289 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IdScopeConcreteIdArgConditionCopyNonLazyBinder.cs @@ -0,0 +1,17 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class IdScopeConcreteIdArgConditionCopyNonLazyBinder : ScopeConcreteIdArgConditionCopyNonLazyBinder + { + public IdScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo bindInfo) + : base(bindInfo) + { + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder WithId(object identifier) + { + BindInfo.Identifier = identifier; + return this; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IdScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IdScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta new file mode 100644 index 0000000..c4f794e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IdScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ba3894c2363faea4480796349be1c939 +timeCreated: 1535254660 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IfNotBoundBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IfNotBoundBinder.cs new file mode 100644 index 0000000..9c9aa28 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IfNotBoundBinder.cs @@ -0,0 +1,24 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class IfNotBoundBinder + { + public IfNotBoundBinder(BindInfo bindInfo) + { + BindInfo = bindInfo; + } + + // Do not use this + public BindInfo BindInfo + { + get; + private set; + } + + public void IfNotBound() + { + BindInfo.OnlyBindIfNotBound = true; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IfNotBoundBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IfNotBoundBinder.cs.meta new file mode 100644 index 0000000..0b79bae --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/IfNotBoundBinder.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b9f24b7d14dcf8441a1c2b4166a5ec9c +timeCreated: 1519465920 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/InstantiateCallbackConditionCopyNonLazyBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/InstantiateCallbackConditionCopyNonLazyBinder.cs new file mode 100644 index 0000000..162bfc6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/InstantiateCallbackConditionCopyNonLazyBinder.cs @@ -0,0 +1,37 @@ +using System; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class InstantiateCallbackConditionCopyNonLazyBinder : ConditionCopyNonLazyBinder + { + public InstantiateCallbackConditionCopyNonLazyBinder(BindInfo bindInfo) + : base(bindInfo) + { + } + + public ConditionCopyNonLazyBinder OnInstantiated( + Action callback) + { + BindInfo.InstantiatedCallback = callback; + return this; + } + + public ConditionCopyNonLazyBinder OnInstantiated( + Action callback) + { + // Can't do this here because of factory bindings + //Assert.That(BindInfo.ContractTypes.All(x => x.DerivesFromOrEqual())); + + BindInfo.InstantiatedCallback = (ctx, obj) => + { + Assert.That(obj == null || obj is T, + "Invalid generic argument to OnInstantiated! {0} must be type {1}", obj.GetType(), typeof(T)); + + callback(ctx, (T)obj); + }; + return this; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/InstantiateCallbackConditionCopyNonLazyBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/InstantiateCallbackConditionCopyNonLazyBinder.cs.meta new file mode 100644 index 0000000..cd60800 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/InstantiateCallbackConditionCopyNonLazyBinder.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 0711425cf187dd94ea21d8ed6f38d981 +timeCreated: 1535263051 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/NonLazyBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/NonLazyBinder.cs new file mode 100644 index 0000000..6214ec9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/NonLazyBinder.cs @@ -0,0 +1,23 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class NonLazyBinder : IfNotBoundBinder + { + public NonLazyBinder(BindInfo bindInfo) + : base(bindInfo) + { + } + + public IfNotBoundBinder NonLazy() + { + BindInfo.NonLazy = true; + return this; + } + + public IfNotBoundBinder Lazy() + { + BindInfo.NonLazy = false; + return this; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/NonLazyBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/NonLazyBinder.cs.meta new file mode 100644 index 0000000..2be9f3a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/NonLazyBinder.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 58c27840cbeb2fa4695b09d536809bb2 +timeCreated: 1461708050 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ScopeConcreteIdArgConditionCopyNonLazyBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ScopeConcreteIdArgConditionCopyNonLazyBinder.cs new file mode 100644 index 0000000..2c058a3 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ScopeConcreteIdArgConditionCopyNonLazyBinder.cs @@ -0,0 +1,31 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class ScopeConcreteIdArgConditionCopyNonLazyBinder : ConcreteIdArgConditionCopyNonLazyBinder + { + public ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo bindInfo) + : base(bindInfo) + { + } + + public ConcreteIdArgConditionCopyNonLazyBinder AsCached() + { + BindInfo.Scope = ScopeTypes.Singleton; + return this; + } + + public ConcreteIdArgConditionCopyNonLazyBinder AsSingle() + { + BindInfo.Scope = ScopeTypes.Singleton; + BindInfo.MarkAsUniqueSingleton = true; + return this; + } + + // Note that this is the default so it's not necessary to call this + public ConcreteIdArgConditionCopyNonLazyBinder AsTransient() + { + BindInfo.Scope = ScopeTypes.Transient; + return this; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta new file mode 100644 index 0000000..6bb82a9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/ScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 5a71e3efc6d683d4cbc3b881bc4e2772 +timeCreated: 1523257672 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/SubContainerBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/SubContainerBinder.cs new file mode 100644 index 0000000..b53373d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/SubContainerBinder.cs @@ -0,0 +1,316 @@ +using System; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class SubContainerBinder + { + readonly BindInfo _bindInfo; + readonly BindStatement _bindStatement; + readonly object _subIdentifier; + readonly bool _resolveAll; + + public SubContainerBinder( + BindInfo bindInfo, + BindStatement bindStatement, + object subIdentifier, bool resolveAll) + { + _bindInfo = bindInfo; + _bindStatement = bindStatement; + _subIdentifier = subIdentifier; + _resolveAll = resolveAll; + + // Reset in case the user ends the binding here + bindStatement.SetFinalizer(null); + } + + protected IBindingFinalizer SubFinalizer + { + set { _bindStatement.SetFinalizer(value); } + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder ByInstance(DiContainer subContainer) + { + SubFinalizer = new SubContainerBindingFinalizer( + _bindInfo, _subIdentifier, _resolveAll, + (_) => new SubContainerCreatorByInstance(subContainer)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(_bindInfo); + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder ByInstanceGetter( + Func subContainerGetter) + { + SubFinalizer = new SubContainerBindingFinalizer( + _bindInfo, _subIdentifier, _resolveAll, + (_) => new SubContainerCreatorByInstanceGetter(subContainerGetter)); + + return new ScopeConcreteIdArgConditionCopyNonLazyBinder(_bindInfo); + } + + public +#if NOT_UNITY3D + WithKernelScopeConcreteIdArgConditionCopyNonLazyBinder +#else + WithKernelDefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder +#endif + ByInstaller() + where TInstaller : InstallerBase + { + return ByInstaller(typeof(TInstaller)); + } + + public +#if NOT_UNITY3D + WithKernelScopeConcreteIdArgConditionCopyNonLazyBinder +#else + WithKernelDefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder +#endif + ByInstaller(Type installerType) + { + Assert.That(installerType.DerivesFrom(), + "Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType); + + var subContainerBindInfo = new SubContainerCreatorBindInfo(); + + SubFinalizer = new SubContainerBindingFinalizer( + _bindInfo, _subIdentifier, _resolveAll, + (container) => new SubContainerCreatorByInstaller(container, subContainerBindInfo, installerType)); + + return new +#if NOT_UNITY3D + WithKernelScopeConcreteIdArgConditionCopyNonLazyBinder +#else + WithKernelDefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder +#endif + (subContainerBindInfo, _bindInfo); + } + + public +#if NOT_UNITY3D + WithKernelScopeConcreteIdArgConditionCopyNonLazyBinder +#else + WithKernelDefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder +#endif + ByMethod(Action installerMethod) + { + var subContainerBindInfo = new SubContainerCreatorBindInfo(); + + SubFinalizer = new SubContainerBindingFinalizer( + _bindInfo, _subIdentifier, _resolveAll, + (container) => new SubContainerCreatorByMethod(container, subContainerBindInfo, installerMethod)); + + return new +#if NOT_UNITY3D + WithKernelScopeConcreteIdArgConditionCopyNonLazyBinder +#else + WithKernelDefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder +#endif + (subContainerBindInfo, _bindInfo); + } + +#if !NOT_UNITY3D + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewGameObjectMethod( + Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + SubFinalizer = new SubContainerPrefabBindingFinalizer( + _bindInfo, _subIdentifier, _resolveAll, + (container) => new SubContainerCreatorByNewGameObjectMethod( + container, gameObjectInfo, installerMethod)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(_bindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + Func prefabGetter, Action installerMethod) + { + var gameObjectInfo = new GameObjectCreationParameters(); + + SubFinalizer = new SubContainerPrefabBindingFinalizer( + _bindInfo, _subIdentifier, _resolveAll, + (container) => new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderCustom(prefabGetter), + gameObjectInfo, installerMethod)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(_bindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabMethod( + UnityEngine.Object prefab, Action installerMethod) + { + BindingUtil.AssertIsValidPrefab(prefab); + + var gameObjectInfo = new GameObjectCreationParameters(); + + SubFinalizer = new SubContainerPrefabBindingFinalizer( + _bindInfo, _subIdentifier, _resolveAll, + (container) => new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProvider(prefab), + gameObjectInfo, installerMethod)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(_bindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewGameObjectInstaller() + where TInstaller : InstallerBase + { + return ByNewGameObjectInstaller(typeof(TInstaller)); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewGameObjectInstaller(Type installerType) + { + Assert.That(installerType.DerivesFrom(), + "Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType); + + var gameObjectInfo = new GameObjectCreationParameters(); + + SubFinalizer = new SubContainerPrefabBindingFinalizer( + _bindInfo, _subIdentifier, _resolveAll, + (container) => new SubContainerCreatorByNewGameObjectInstaller( + container, gameObjectInfo, installerType, _bindInfo.Arguments)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(_bindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabInstaller( + Func prefabGetter) + where TInstaller : InstallerBase + { + return ByNewPrefabInstaller(prefabGetter, typeof(TInstaller)); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabInstaller( + Func prefabGetter, Type installerType) + { + Assert.That(installerType.DerivesFrom(), + "Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType); + + var gameObjectInfo = new GameObjectCreationParameters(); + + SubFinalizer = new SubContainerPrefabBindingFinalizer( + _bindInfo, _subIdentifier, _resolveAll, + (container) => new SubContainerCreatorByNewPrefabInstaller( + container, + new PrefabProviderCustom(prefabGetter), + gameObjectInfo, installerType, _bindInfo.Arguments)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(_bindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabInstaller( + UnityEngine.Object prefab) + where TInstaller : InstallerBase + { + return ByNewPrefabInstaller(prefab, typeof(TInstaller)); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabInstaller( + UnityEngine.Object prefab, Type installerType) + { + Assert.That(installerType.DerivesFrom(), + "Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType); + + var gameObjectInfo = new GameObjectCreationParameters(); + + SubFinalizer = new SubContainerPrefabBindingFinalizer( + _bindInfo, _subIdentifier, _resolveAll, + (container) => new SubContainerCreatorByNewPrefabInstaller( + container, + new PrefabProvider(prefab), + gameObjectInfo, installerType, _bindInfo.Arguments)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(_bindInfo, gameObjectInfo); + } + + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResourceMethod( + string resourcePath, Action installerMethod) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + + var gameObjectInfo = new GameObjectCreationParameters(); + + SubFinalizer = new SubContainerPrefabBindingFinalizer( + _bindInfo, _subIdentifier, _resolveAll, + (container) => new SubContainerCreatorByNewPrefabMethod( + container, + new PrefabProviderResource(resourcePath), + gameObjectInfo, installerMethod)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(_bindInfo, gameObjectInfo); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResourceInstaller( + string resourcePath) + where TInstaller : InstallerBase + { + return ByNewPrefabResourceInstaller(resourcePath, typeof(TInstaller)); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResourceInstaller( + string resourcePath, Type installerType) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + Assert.That(installerType.DerivesFrom(), + "Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType); + + var gameObjectInfo = new GameObjectCreationParameters(); + + SubFinalizer = new SubContainerPrefabBindingFinalizer( + _bindInfo, _subIdentifier, _resolveAll, + (container) => new SubContainerCreatorByNewPrefabInstaller( + container, + new PrefabProviderResource(resourcePath), + gameObjectInfo, installerType, _bindInfo.Arguments)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(_bindInfo, gameObjectInfo); + } + + [System.Obsolete("ByNewPrefab has been renamed to ByNewContextPrefab to avoid confusion with ByNewPrefabInstaller and ByNewPrefabMethod")] + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefab(UnityEngine.Object prefab) + { + return ByNewContextPrefab(prefab); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewContextPrefab(UnityEngine.Object prefab) + { + BindingUtil.AssertIsValidPrefab(prefab); + + var gameObjectInfo = new GameObjectCreationParameters(); + + SubFinalizer = new SubContainerPrefabBindingFinalizer( + _bindInfo, _subIdentifier, _resolveAll, + (container) => new SubContainerCreatorByNewPrefab( + container, new PrefabProvider(prefab), gameObjectInfo)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(_bindInfo, gameObjectInfo); + } + + [System.Obsolete("ByNewPrefabResource has been renamed to ByNewContextPrefabResource to avoid confusion with ByNewPrefabResourceInstaller and ByNewPrefabResourceMethod")] + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewPrefabResource(string resourcePath) + { + return ByNewContextPrefabResource(resourcePath); + } + + public NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder ByNewContextPrefabResource(string resourcePath) + { + BindingUtil.AssertIsValidResourcePath(resourcePath); + + var gameObjectInfo = new GameObjectCreationParameters(); + + SubFinalizer = new SubContainerPrefabBindingFinalizer( + _bindInfo, _subIdentifier, _resolveAll, + (container) => new SubContainerCreatorByNewPrefab( + container, new PrefabProviderResource(resourcePath), gameObjectInfo)); + + return new NameTransformScopeConcreteIdArgConditionCopyNonLazyBinder(_bindInfo, gameObjectInfo); + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/SubContainerBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/SubContainerBinder.cs.meta new file mode 100644 index 0000000..8b4728b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/SubContainerBinder.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4d1fcd1593b05194a82073206057613e +timeCreated: 1461708050 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/WithKernelDefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/WithKernelDefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder.cs new file mode 100644 index 0000000..3d1912e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/WithKernelDefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder.cs @@ -0,0 +1,28 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class WithKernelDefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder : DefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder + { + public WithKernelDefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder( + SubContainerCreatorBindInfo subContainerBindInfo, BindInfo bindInfo) + : base(subContainerBindInfo, bindInfo) + { + } + + public DefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder WithKernel() + { + SubContainerCreatorBindInfo.CreateKernel = true; + return this; + } + + // This would be used in cases where you want to control the execution order for the + // subcontainer + public DefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder WithKernel() + where TKernel : Kernel + { + SubContainerCreatorBindInfo.CreateKernel = true; + SubContainerCreatorBindInfo.KernelType = typeof(TKernel); + return this; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/WithKernelDefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/WithKernelDefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta new file mode 100644 index 0000000..31f4e37 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/WithKernelDefaultParentScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 4690c1b02bdf3d34998b8a505c85b1b2 +timeCreated: 1535254659 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/WithKernelScopeConcreteIdArgConditionCopyNonLazyBinder.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/WithKernelScopeConcreteIdArgConditionCopyNonLazyBinder.cs new file mode 100644 index 0000000..72b1b91 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/WithKernelScopeConcreteIdArgConditionCopyNonLazyBinder.cs @@ -0,0 +1,31 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class WithKernelScopeConcreteIdArgConditionCopyNonLazyBinder : ScopeConcreteIdArgConditionCopyNonLazyBinder + { + SubContainerCreatorBindInfo _subContainerBindInfo; + + public WithKernelScopeConcreteIdArgConditionCopyNonLazyBinder( + SubContainerCreatorBindInfo subContainerBindInfo, BindInfo bindInfo) + : base(bindInfo) + { + _subContainerBindInfo = subContainerBindInfo; + } + + public ScopeConcreteIdArgConditionCopyNonLazyBinder WithKernel() + { + _subContainerBindInfo.CreateKernel = true; + return this; + } + + // This would be used in cases where you want to control the execution order for the + // subcontainer + public ScopeConcreteIdArgConditionCopyNonLazyBinder WithKernel() + where TKernel : Kernel + { + _subContainerBindInfo.CreateKernel = true; + _subContainerBindInfo.KernelType = typeof(TKernel); + return this; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/WithKernelScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/WithKernelScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta new file mode 100644 index 0000000..b99385d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Binders/WithKernelScopeConcreteIdArgConditionCopyNonLazyBinder.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 6447473513963f742b7ab3c02ec633a8 +timeCreated: 1535254659 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindingUtil.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindingUtil.cs new file mode 100644 index 0000000..bfea1d7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindingUtil.cs @@ -0,0 +1,380 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using ModestTree; +using Zenject.Internal; +using System.Linq; +using TypeExtensions = ModestTree.TypeExtensions; + +#if !NOT_UNITY3D +using UnityEngine; + +#if UNITY_EDITOR +using UnityEditor; +#endif + +#endif + +namespace Zenject +{ + internal static class BindingUtil + { +#if !NOT_UNITY3D + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsValidPrefab(UnityEngine.Object prefab) + { + Assert.That(!ZenUtilInternal.IsNull(prefab), "Received null prefab during bind command"); + +#if UNITY_EDITOR + // Unfortunately we can't do this check because asset bundles return PrefabType.None here + // as discussed here: https://github.com/svermeulen/Zenject/issues/269#issuecomment-323419408 + //Assert.That(PrefabUtility.GetPrefabType(prefab) == PrefabType.Prefab, + //"Expected prefab but found game object with name '{0}' during bind command", prefab.name); +#endif + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsValidGameObject(GameObject gameObject) + { + Assert.That(!ZenUtilInternal.IsNull(gameObject), "Received null game object during bind command"); + +#if UNITY_EDITOR + // Unfortunately we can't do this check because asset bundles return PrefabType.None here + // as discussed here: https://github.com/svermeulen/Zenject/issues/269#issuecomment-323419408 + //Assert.That(PrefabUtility.GetPrefabType(gameObject) != PrefabType.Prefab, + //"Expected game object but found prefab instead with name '{0}' during bind command", gameObject.name); +#endif + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsNotComponent(IEnumerable types) + { + foreach (var type in types) + { + AssertIsNotComponent(type); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsNotComponent() + { + AssertIsNotComponent(typeof(T)); + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsNotComponent(Type type) + { + Assert.That(!type.DerivesFrom(typeof(Component)), + "Invalid type given during bind command. Expected type '{0}' to NOT derive from UnityEngine.Component", type); + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertDerivesFromUnityObject(IEnumerable types) + { + foreach (var type in types) + { + AssertDerivesFromUnityObject(type); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertDerivesFromUnityObject() + { + AssertDerivesFromUnityObject(typeof(T)); + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertDerivesFromUnityObject(Type type) + { + Assert.That(type.DerivesFrom(), + "Invalid type given during bind command. Expected type '{0}' to derive from UnityEngine.Object", type); + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertTypesAreNotComponents(IEnumerable types) + { + foreach (var type in types) + { + AssertIsNotComponent(type); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsValidResourcePath(string resourcePath) + { + Assert.That(!string.IsNullOrEmpty(resourcePath), "Null or empty resource path provided"); + + // We'd like to validate the path here but unfortunately there doesn't appear to be + // a way to do this besides loading it + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsInterfaceOrScriptableObject(IEnumerable types) + { + foreach (var type in types) + { + AssertIsInterfaceOrScriptableObject(type); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsInterfaceOrScriptableObject() + { + AssertIsInterfaceOrScriptableObject(typeof(T)); + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsInterfaceOrScriptableObject(Type type) + { + Assert.That(type.DerivesFrom(typeof(ScriptableObject)) || type.IsInterface(), + "Invalid type given during bind command. Expected type '{0}' to either derive from UnityEngine.ScriptableObject or be an interface", type); + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsInterfaceOrComponent(IEnumerable types) + { + foreach (var type in types) + { + AssertIsInterfaceOrComponent(type); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsInterfaceOrComponent() + { + AssertIsInterfaceOrComponent(typeof(T)); + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsInterfaceOrComponent(Type type) + { + Assert.That(type.DerivesFrom(typeof(Component)) || type.IsInterface(), + "Invalid type given during bind command. Expected type '{0}' to either derive from UnityEngine.Component or be an interface", type); + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsComponent(IEnumerable types) + { + foreach (var type in types) + { + AssertIsComponent(type); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsComponent() + { + AssertIsComponent(typeof(T)); + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsComponent(Type type) + { + Assert.That(type.DerivesFrom(typeof(Component)), + "Invalid type given during bind command. Expected type '{0}' to derive from UnityEngine.Component", type); + } +#else + public static void AssertTypesAreNotComponents(IEnumerable types) + { + } + + public static void AssertIsNotComponent(Type type) + { + } + + public static void AssertIsNotComponent() + { + } + + public static void AssertIsNotComponent(IEnumerable types) + { + } +#endif + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertTypesAreNotAbstract(IEnumerable types) + { + foreach (var type in types) + { + AssertIsNotAbstract(type); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsNotAbstract(IEnumerable types) + { + foreach (var type in types) + { + AssertIsNotAbstract(type); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsNotAbstract() + { + AssertIsNotAbstract(typeof(T)); + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsNotAbstract(Type type) + { + Assert.That(!type.IsAbstract(), + "Invalid type given during bind command. Expected type '{0}' to not be abstract.", type); + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsDerivedFromType(Type concreteType, Type parentType) + { +#if !(UNITY_WSA && ENABLE_DOTNET) + // TODO: Is it possible to do this on WSA? + + Assert.That(parentType.IsOpenGenericType() == concreteType.IsOpenGenericType(), + "Invalid type given during bind command. Expected type '{0}' and type '{1}' to both either be open generic types or not open generic types", parentType, concreteType); + + if (parentType.IsOpenGenericType()) + { + Assert.That(concreteType.IsOpenGenericType()); + Assert.That(TypeExtensions.IsAssignableToGenericType(concreteType, parentType), + "Invalid type given during bind command. Expected open generic type '{0}' to derive from open generic type '{1}'", concreteType, parentType); + } + else +#endif + { + Assert.That(concreteType.DerivesFromOrEqual(parentType), + "Invalid type given during bind command. Expected type '{0}' to derive from type '{1}'", concreteType, parentType); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertConcreteTypeListIsNotEmpty(IEnumerable concreteTypes) + { + Assert.That(concreteTypes.Count() >= 1, + "Must supply at least one concrete type to the current binding"); + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsDerivedFromTypes( + IEnumerable concreteTypes, IEnumerable parentTypes, InvalidBindResponses invalidBindResponse) + { + if (invalidBindResponse == InvalidBindResponses.Assert) + { + AssertIsDerivedFromTypes(concreteTypes, parentTypes); + } + else + { + Assert.IsEqual(invalidBindResponse, InvalidBindResponses.Skip); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsDerivedFromTypes(IEnumerable concreteTypes, IEnumerable parentTypes) + { + foreach (var concreteType in concreteTypes) + { + AssertIsDerivedFromTypes(concreteType, parentTypes); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertIsDerivedFromTypes(Type concreteType, IEnumerable parentTypes) + { + foreach (var parentType in parentTypes) + { + AssertIsDerivedFromType(concreteType, parentType); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertInstanceDerivesFromOrEqual(object instance, IEnumerable parentTypes) + { + if (!ZenUtilInternal.IsNull(instance)) + { + foreach (var baseType in parentTypes) + { + AssertInstanceDerivesFromOrEqual(instance, baseType); + } + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void AssertInstanceDerivesFromOrEqual(object instance, Type baseType) + { + if (!ZenUtilInternal.IsNull(instance)) + { + Assert.That(instance.GetType().DerivesFromOrEqual(baseType), + "Invalid type given during bind command. Expected type '{0}' to derive from type '{1}'", instance.GetType(), baseType); + } + } + + public static IProvider CreateCachedProvider(IProvider creator) + { + if (creator.TypeVariesBasedOnMemberType) + { + return new CachedOpenTypeProvider(creator); + } + + return new CachedProvider(creator); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindingUtil.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindingUtil.cs.meta new file mode 100644 index 0000000..9f60ff9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/BindingUtil.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3d9014e328d4ff04682edfaaa5bdad36 +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers.meta new file mode 100644 index 0000000..80e1567 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 95ed99f2cba5359419d007822a4c0c31 +folderAsset: yes +timeCreated: 1461708046 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/IBindingFinalizer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/IBindingFinalizer.cs new file mode 100644 index 0000000..ca6901a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/IBindingFinalizer.cs @@ -0,0 +1,12 @@ +namespace Zenject +{ + public interface IBindingFinalizer + { + BindingInheritanceMethods BindingInheritanceMethod + { + get; + } + + void FinalizeBinding(DiContainer container); + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/IBindingFinalizer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/IBindingFinalizer.cs.meta new file mode 100644 index 0000000..5d54509 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/IBindingFinalizer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d0c24b30b6678884db62f15947ec943c +timeCreated: 1461708053 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/NullBindingFinalizer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/NullBindingFinalizer.cs new file mode 100644 index 0000000..f7d913b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/NullBindingFinalizer.cs @@ -0,0 +1,17 @@ +namespace Zenject +{ + [NoReflectionBaking] + public class NullBindingFinalizer : IBindingFinalizer + { + public BindingInheritanceMethods BindingInheritanceMethod + { + get { return BindingInheritanceMethods.None; } + } + + public void FinalizeBinding(DiContainer container) + { + // Do nothing + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/NullBindingFinalizer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/NullBindingFinalizer.cs.meta new file mode 100644 index 0000000..ab2cd8c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/NullBindingFinalizer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6b41a20eb0faa1041bf6aa0bfcc76064 +timeCreated: 1480010956 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/PrefabBindingFinalizer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/PrefabBindingFinalizer.cs new file mode 100644 index 0000000..a689399 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/PrefabBindingFinalizer.cs @@ -0,0 +1,158 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using ModestTree; +using UnityEngine; + +namespace Zenject +{ + [NoReflectionBaking] + public class PrefabBindingFinalizer : ProviderBindingFinalizer + { + readonly GameObjectCreationParameters _gameObjectBindInfo; + readonly UnityEngine.Object _prefab; + readonly Func _providerFactory; + + public PrefabBindingFinalizer( + BindInfo bindInfo, + GameObjectCreationParameters gameObjectBindInfo, + UnityEngine.Object prefab, Func providerFactory) + : base(bindInfo) + { + _gameObjectBindInfo = gameObjectBindInfo; + _prefab = prefab; + _providerFactory = providerFactory; + } + + protected override void OnFinalizeBinding(DiContainer container) + { + if (BindInfo.ToChoice == ToChoices.Self) + { + Assert.IsEmpty(BindInfo.ToTypes); + FinalizeBindingSelf(container); + } + else + { + FinalizeBindingConcrete(container, BindInfo.ToTypes); + } + } + + void FinalizeBindingConcrete(DiContainer container, List concreteTypes) + { + var scope = GetScope(); + + switch (scope) + { + case ScopeTypes.Transient: + { + RegisterProvidersForAllContractsPerConcreteType( + container, + concreteTypes, + (_, concreteType) => + _providerFactory( + concreteType, + new PrefabInstantiator( + container, + _gameObjectBindInfo, + concreteType, + concreteTypes, + BindInfo.Arguments, + new PrefabProvider(_prefab), + BindInfo.InstantiatedCallback))); + break; + } + case ScopeTypes.Singleton: + { + var argumentTarget = concreteTypes.OnlyOrDefault(); + + if (argumentTarget == null) + { + Assert.That(BindInfo.Arguments.IsEmpty(), + "Cannot provide arguments to prefab instantiator when using more than one concrete type"); + } + + var prefabCreator = new PrefabInstantiatorCached( + new PrefabInstantiator( + container, + _gameObjectBindInfo, + argumentTarget, + concreteTypes, + BindInfo.Arguments, + new PrefabProvider(_prefab), + BindInfo.InstantiatedCallback)); + + RegisterProvidersForAllContractsPerConcreteType( + container, + concreteTypes, + (_, concreteType) => BindingUtil.CreateCachedProvider( + _providerFactory(concreteType, prefabCreator))); + break; + } + default: + { + throw Assert.CreateException(); + } + } + } + + void FinalizeBindingSelf(DiContainer container) + { + var scope = GetScope(); + + switch (scope) + { + case ScopeTypes.Transient: + { + RegisterProviderPerContract( + container, + (_, contractType) => + _providerFactory( + contractType, + new PrefabInstantiator( + container, + _gameObjectBindInfo, + contractType, + BindInfo.ContractTypes, + BindInfo.Arguments, + new PrefabProvider(_prefab), + BindInfo.InstantiatedCallback))); + break; + } + case ScopeTypes.Singleton: + { + var argumentTarget = BindInfo.ContractTypes.OnlyOrDefault(); + + if (argumentTarget == null) + { + Assert.That(BindInfo.Arguments.IsEmpty(), + "Cannot provide arguments to prefab instantiator when using more than one concrete type"); + } + + var prefabCreator = new PrefabInstantiatorCached( + new PrefabInstantiator( + container, + _gameObjectBindInfo, + argumentTarget, + BindInfo.ContractTypes, + BindInfo.Arguments, + new PrefabProvider(_prefab), + BindInfo.InstantiatedCallback)); + + RegisterProviderPerContract( + container, + (_, contractType) => + BindingUtil.CreateCachedProvider( + _providerFactory(contractType, prefabCreator))); + break; + } + default: + { + throw Assert.CreateException(); + } + } + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/PrefabBindingFinalizer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/PrefabBindingFinalizer.cs.meta new file mode 100644 index 0000000..88f6849 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/PrefabBindingFinalizer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 10487121a4674d74884ee65e70762e35 +timeCreated: 1461708048 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/PrefabResourceBindingFinalizer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/PrefabResourceBindingFinalizer.cs new file mode 100644 index 0000000..92b8a5c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/PrefabResourceBindingFinalizer.cs @@ -0,0 +1,157 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class PrefabResourceBindingFinalizer : ProviderBindingFinalizer + { + readonly GameObjectCreationParameters _gameObjectBindInfo; + readonly string _resourcePath; + readonly Func _providerFactory; + + public PrefabResourceBindingFinalizer( + BindInfo bindInfo, + GameObjectCreationParameters gameObjectBindInfo, + string resourcePath, Func providerFactory) + : base(bindInfo) + { + _gameObjectBindInfo = gameObjectBindInfo; + _resourcePath = resourcePath; + _providerFactory = providerFactory; + } + + protected override void OnFinalizeBinding(DiContainer container) + { + if (BindInfo.ToChoice == ToChoices.Self) + { + Assert.IsEmpty(BindInfo.ToTypes); + FinalizeBindingSelf(container); + } + else + { + FinalizeBindingConcrete(container, BindInfo.ToTypes); + } + } + + void FinalizeBindingConcrete(DiContainer container, List concreteTypes) + { + var scope = GetScope(); + + switch (scope) + { + case ScopeTypes.Transient: + { + RegisterProvidersForAllContractsPerConcreteType( + container, + concreteTypes, + (_, concreteType) => + _providerFactory( + concreteType, + new PrefabInstantiator( + container, + _gameObjectBindInfo, + concreteType, + concreteTypes, + BindInfo.Arguments, + new PrefabProviderResource(_resourcePath), + BindInfo.InstantiatedCallback))); + break; + } + case ScopeTypes.Singleton: + { + var argumentTarget = concreteTypes.OnlyOrDefault(); + + if (argumentTarget == null) + { + Assert.That(BindInfo.Arguments.IsEmpty(), + "Cannot provide arguments to prefab instantiator when using more than one concrete type"); + } + + var prefabCreator = new PrefabInstantiatorCached( + new PrefabInstantiator( + container, + _gameObjectBindInfo, + argumentTarget, + concreteTypes, + BindInfo.Arguments, + new PrefabProviderResource(_resourcePath), + BindInfo.InstantiatedCallback)); + + RegisterProvidersForAllContractsPerConcreteType( + container, + concreteTypes, + (_, concreteType) => BindingUtil.CreateCachedProvider( + _providerFactory(concreteType, prefabCreator))); + break; + } + default: + { + throw Assert.CreateException(); + } + } + } + + void FinalizeBindingSelf(DiContainer container) + { + var scope = GetScope(); + + switch (scope) + { + case ScopeTypes.Transient: + { + RegisterProviderPerContract( + container, + (_, contractType) => + _providerFactory( + contractType, + new PrefabInstantiator( + container, + _gameObjectBindInfo, + contractType, + BindInfo.ContractTypes, + BindInfo.Arguments, + new PrefabProviderResource(_resourcePath), + BindInfo.InstantiatedCallback))); + break; + } + case ScopeTypes.Singleton: + { + var argumentTarget = BindInfo.ContractTypes.OnlyOrDefault(); + + if (argumentTarget == null) + { + Assert.That(BindInfo.Arguments.IsEmpty(), + "Cannot provide arguments to prefab instantiator when using more than one concrete type"); + } + + var prefabCreator = new PrefabInstantiatorCached( + new PrefabInstantiator( + container, + _gameObjectBindInfo, + argumentTarget, + BindInfo.ContractTypes, + BindInfo.Arguments, + new PrefabProviderResource(_resourcePath), + BindInfo.InstantiatedCallback)); + + RegisterProviderPerContract( + container, + (_, contractType) => + BindingUtil.CreateCachedProvider( + _providerFactory(contractType, prefabCreator))); + break; + } + default: + { + throw Assert.CreateException(); + } + } + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/PrefabResourceBindingFinalizer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/PrefabResourceBindingFinalizer.cs.meta new file mode 100644 index 0000000..58cfbc5 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/PrefabResourceBindingFinalizer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b851ccfb909f66c4587d694f6e37b279 +timeCreated: 1461708053 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/ProviderBindingFinalizer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/ProviderBindingFinalizer.cs new file mode 100644 index 0000000..074b5c2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/ProviderBindingFinalizer.cs @@ -0,0 +1,248 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using Zenject.Internal; + +namespace Zenject +{ + [NoReflectionBaking] + public abstract class ProviderBindingFinalizer : IBindingFinalizer + { + public ProviderBindingFinalizer(BindInfo bindInfo) + { + BindInfo = bindInfo; + } + + public BindingInheritanceMethods BindingInheritanceMethod + { + get { return BindInfo.BindingInheritanceMethod; } + } + + protected BindInfo BindInfo + { + get; + private set; + } + + protected ScopeTypes GetScope() + { + if (BindInfo.Scope == ScopeTypes.Unset) + { + // If condition is set then it's probably fine to allow the default of transient + Assert.That(!BindInfo.RequireExplicitScope || BindInfo.Condition != null, + "Scope must be set for the previous binding! Please either specify AsTransient, AsCached, or AsSingle. Last binding: Contract: {0}, Identifier: {1} {2}", + BindInfo.ContractTypes.Select(x => x.PrettyName()).Join(", "), BindInfo.Identifier, + BindInfo.ContextInfo != null ? "Context: '{0}'".Fmt(BindInfo.ContextInfo) : ""); + return ScopeTypes.Transient; + } + + return BindInfo.Scope; + } + + public void FinalizeBinding(DiContainer container) + { + if (BindInfo.ContractTypes.Count == 0) + { + // We could assert her instead but it is nice when used with things like + // BindInterfaces() (and there aren't any interfaces) to allow + // interfaces to be added later + return; + } + + try + { + OnFinalizeBinding(container); + } + catch (Exception e) + { + throw Assert.CreateException( + e, "Error while finalizing previous binding! Contract: {0}, Identifier: {1} {2}", + BindInfo.ContractTypes.Select(x => x.PrettyName()).Join(", "), BindInfo.Identifier, + BindInfo.ContextInfo != null ? "Context: '{0}'".Fmt(BindInfo.ContextInfo) : ""); + } + } + + protected abstract void OnFinalizeBinding(DiContainer container); + + protected void RegisterProvider( + DiContainer container, IProvider provider) + { + RegisterProvider(container, typeof(TContract), provider); + } + + protected void RegisterProvider( + DiContainer container, Type contractType, IProvider provider) + { + if (BindInfo.OnlyBindIfNotBound && container.HasBindingId(contractType, BindInfo.Identifier)) + { + return; + } + + container.RegisterProvider( + new BindingId(contractType, BindInfo.Identifier), + BindInfo.Condition, + provider, BindInfo.NonLazy); + + if (contractType.IsValueType() && !(contractType.IsGenericType() && contractType.GetGenericTypeDefinition() == typeof(Nullable<>))) + { + var nullableType = typeof(Nullable<>).MakeGenericType(contractType); + + // Also bind to nullable primitives + // this is useful so that we can have optional primitive dependencies + container.RegisterProvider( + new BindingId(nullableType, BindInfo.Identifier), + BindInfo.Condition, + provider, BindInfo.NonLazy); + } + } + + protected void RegisterProviderPerContract( + DiContainer container, Func providerFunc) + { + foreach (var contractType in BindInfo.ContractTypes) + { + var provider = providerFunc(container, contractType); + + if (BindInfo.MarkAsUniqueSingleton) + { + container.SingletonMarkRegistry.MarkSingleton(contractType); + } + else if (BindInfo.MarkAsCreationBinding) + { + container.SingletonMarkRegistry.MarkNonSingleton(contractType); + } + + RegisterProvider(container, contractType, provider); + } + } + + protected void RegisterProviderForAllContracts( + DiContainer container, IProvider provider) + { + foreach (var contractType in BindInfo.ContractTypes) + { + if (BindInfo.MarkAsUniqueSingleton) + { + container.SingletonMarkRegistry.MarkSingleton(contractType); + } + else if (BindInfo.MarkAsCreationBinding) + { + container.SingletonMarkRegistry.MarkNonSingleton(contractType); + } + + RegisterProvider(container, contractType, provider); + } + } + + protected void RegisterProvidersPerContractAndConcreteType( + DiContainer container, + List concreteTypes, + Func providerFunc) + { + Assert.That(!BindInfo.ContractTypes.IsEmpty()); + Assert.That(!concreteTypes.IsEmpty()); + + foreach (var contractType in BindInfo.ContractTypes) + { + foreach (var concreteType in concreteTypes) + { + if (ValidateBindTypes(concreteType, contractType)) + { + RegisterProvider(container, contractType, providerFunc(contractType, concreteType)); + } + } + } + } + + // Returns true if the bind should continue, false to skip + bool ValidateBindTypes(Type concreteType, Type contractType) + { + bool isConcreteOpenGenericType = concreteType.IsOpenGenericType(); + bool isContractOpenGenericType = contractType.IsOpenGenericType(); + if (isConcreteOpenGenericType != isContractOpenGenericType) + { + return false; + } + +#if !(UNITY_WSA && ENABLE_DOTNET) + // TODO: Is it possible to do this on WSA? + + if (isContractOpenGenericType) + { + Assert.That(isConcreteOpenGenericType); + + if (TypeExtensions.IsAssignableToGenericType(concreteType, contractType)) + { + return true; + } + } + else if (concreteType.DerivesFromOrEqual(contractType)) + { + return true; + } +#else + if (concreteType.DerivesFromOrEqual(contractType)) + { + return true; + } +#endif + + if (BindInfo.InvalidBindResponse == InvalidBindResponses.Assert) + { + throw Assert.CreateException( + "Expected type '{0}' to derive from or be equal to '{1}'", concreteType, contractType); + } + + Assert.IsEqual(BindInfo.InvalidBindResponse, InvalidBindResponses.Skip); + return false; + } + + // Note that if multiple contract types are provided per concrete type, + // it will re-use the same provider for each contract type + // (each concrete type will have its own provider though) + protected void RegisterProvidersForAllContractsPerConcreteType( + DiContainer container, + List concreteTypes, + Func providerFunc) + { + Assert.That(!BindInfo.ContractTypes.IsEmpty()); + Assert.That(!concreteTypes.IsEmpty()); + + var providerMap = ZenPools.SpawnDictionary(); + try + { + foreach (var concreteType in concreteTypes) + { + var provider = providerFunc(container, concreteType); + + providerMap[concreteType] = provider; + + if (BindInfo.MarkAsUniqueSingleton) + { + container.SingletonMarkRegistry.MarkSingleton(concreteType); + } + else if (BindInfo.MarkAsCreationBinding) + { + container.SingletonMarkRegistry.MarkNonSingleton(concreteType); + } + } + + foreach (var contractType in BindInfo.ContractTypes) + { + foreach (var concreteType in concreteTypes) + { + if (ValidateBindTypes(concreteType, contractType)) + { + RegisterProvider(container, contractType, providerMap[concreteType]); + } + } + } + } + finally + { + ZenPools.DespawnDictionary(providerMap); + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/ProviderBindingFinalizer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/ProviderBindingFinalizer.cs.meta new file mode 100644 index 0000000..fbbad31 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/ProviderBindingFinalizer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ee5cb643a9ee24c4fa00e62afc9ef599 +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/ScopableBindingFinalizer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/ScopableBindingFinalizer.cs new file mode 100644 index 0000000..e88c15a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/ScopableBindingFinalizer.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class ScopableBindingFinalizer : ProviderBindingFinalizer + { + readonly Func _providerFactory; + + public ScopableBindingFinalizer( + BindInfo bindInfo, Func providerFactory) + : base(bindInfo) + { + _providerFactory = providerFactory; + } + + protected override void OnFinalizeBinding(DiContainer container) + { + if (BindInfo.ToChoice == ToChoices.Self) + { + Assert.IsEmpty(BindInfo.ToTypes); + FinalizeBindingSelf(container); + } + else + { + FinalizeBindingConcrete(container, BindInfo.ToTypes); + } + } + + void FinalizeBindingConcrete(DiContainer container, List concreteTypes) + { + if (concreteTypes.Count == 0) + { + // This can be common when using convention based bindings + return; + } + + var scope = GetScope(); + switch (scope) + { + case ScopeTypes.Transient: + { + RegisterProvidersForAllContractsPerConcreteType( + container, concreteTypes, _providerFactory); + break; + } + case ScopeTypes.Singleton: + { + RegisterProvidersForAllContractsPerConcreteType( + container, + concreteTypes, + (_, concreteType) => + BindingUtil.CreateCachedProvider( + _providerFactory(container, concreteType))); + break; + } + default: + { + throw Assert.CreateException(); + } + } + } + + void FinalizeBindingSelf(DiContainer container) + { + var scope = GetScope(); + + switch (scope) + { + case ScopeTypes.Transient: + { + RegisterProviderPerContract(container, _providerFactory); + break; + } + case ScopeTypes.Singleton: + { + RegisterProviderPerContract( + container, + (_, contractType) => + BindingUtil.CreateCachedProvider( + _providerFactory(container, contractType))); + break; + } + default: + { + throw Assert.CreateException(); + } + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/ScopableBindingFinalizer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/ScopableBindingFinalizer.cs.meta new file mode 100644 index 0000000..89d2ebb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/ScopableBindingFinalizer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d2392181aaeca434cb15e2719d7567d6 +timeCreated: 1461708053 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SingleProviderBindingFinalizer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SingleProviderBindingFinalizer.cs new file mode 100644 index 0000000..3bb2453 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SingleProviderBindingFinalizer.cs @@ -0,0 +1,37 @@ +using System; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class SingleProviderBindingFinalizer : ProviderBindingFinalizer + { + readonly Func _providerFactory; + + public SingleProviderBindingFinalizer( + BindInfo bindInfo, Func providerFactory) + : base(bindInfo) + { + _providerFactory = providerFactory; + } + + protected override void OnFinalizeBinding(DiContainer container) + { + if (BindInfo.ToChoice == ToChoices.Self) + { + Assert.IsEmpty(BindInfo.ToTypes); + + RegisterProviderPerContract(container, _providerFactory); + } + else + { + // Empty sometimes when using convention based bindings + if (!BindInfo.ToTypes.IsEmpty()) + { + RegisterProvidersForAllContractsPerConcreteType( + container, BindInfo.ToTypes, _providerFactory); + } + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SingleProviderBindingFinalizer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SingleProviderBindingFinalizer.cs.meta new file mode 100644 index 0000000..d4317e8 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SingleProviderBindingFinalizer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: deaa9a3ee9e42a8448bba948495b9225 +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SubContainerBindingFinalizer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SubContainerBindingFinalizer.cs new file mode 100644 index 0000000..236757d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SubContainerBindingFinalizer.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class SubContainerBindingFinalizer : ProviderBindingFinalizer + { + readonly object _subIdentifier; + readonly bool _resolveAll; + readonly Func _creatorFactory; + + public SubContainerBindingFinalizer( + BindInfo bindInfo, object subIdentifier, + bool resolveAll, Func creatorFactory) + : base(bindInfo) + { + _subIdentifier = subIdentifier; + _resolveAll = resolveAll; + _creatorFactory = creatorFactory; + } + + protected override void OnFinalizeBinding(DiContainer container) + { + if (BindInfo.ToChoice == ToChoices.Self) + { + Assert.IsEmpty(BindInfo.ToTypes); + FinalizeBindingSelf(container); + } + else + { + FinalizeBindingConcrete(container, BindInfo.ToTypes); + } + } + + void FinalizeBindingConcrete(DiContainer container, List concreteTypes) + { + var scope = GetScope(); + + switch (scope) + { + case ScopeTypes.Transient: + { + RegisterProvidersForAllContractsPerConcreteType( + container, + concreteTypes, + (_, concreteType) => + new SubContainerDependencyProvider( + concreteType, _subIdentifier, _creatorFactory(container), _resolveAll)); + break; + } + case ScopeTypes.Singleton: + { + var containerCreator = new SubContainerCreatorCached(_creatorFactory(container)); + + RegisterProvidersForAllContractsPerConcreteType( + container, + concreteTypes, + (_, concreteType) => + new SubContainerDependencyProvider( + concreteType, _subIdentifier, containerCreator, _resolveAll)); + break; + } + default: + { + throw Assert.CreateException(); + } + } + } + + void FinalizeBindingSelf(DiContainer container) + { + var scope = GetScope(); + + switch (scope) + { + case ScopeTypes.Transient: + { + RegisterProviderPerContract( + container, + (_, contractType) => new SubContainerDependencyProvider( + contractType, _subIdentifier, _creatorFactory(container), _resolveAll)); + break; + } + case ScopeTypes.Singleton: + { + var containerCreator = new SubContainerCreatorCached(_creatorFactory(container)); + + RegisterProviderPerContract( + container, + (_, contractType) => + new SubContainerDependencyProvider( + contractType, _subIdentifier, containerCreator, _resolveAll)); + break; + } + default: + { + throw Assert.CreateException(); + } + } + } + } +} + + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SubContainerBindingFinalizer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SubContainerBindingFinalizer.cs.meta new file mode 100644 index 0000000..b21bf23 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SubContainerBindingFinalizer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b263fb784fd4b8140b850ff4d68c7aad +timeCreated: 1535189470 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SubContainerPrefabBindingFinalizer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SubContainerPrefabBindingFinalizer.cs new file mode 100644 index 0000000..05790a2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SubContainerPrefabBindingFinalizer.cs @@ -0,0 +1,112 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class SubContainerPrefabBindingFinalizer : ProviderBindingFinalizer + { + readonly object _subIdentifier; + readonly bool _resolveAll; + readonly Func _subContainerCreatorFactory; + + public SubContainerPrefabBindingFinalizer( + BindInfo bindInfo, + object subIdentifier, bool resolveAll, + Func subContainerCreatorFactory) + : base(bindInfo) + { + _subIdentifier = subIdentifier; + _resolveAll = resolveAll; + _subContainerCreatorFactory = subContainerCreatorFactory; + } + + protected override void OnFinalizeBinding(DiContainer container) + { + if (BindInfo.ToChoice == ToChoices.Self) + { + Assert.IsEmpty(BindInfo.ToTypes); + FinalizeBindingSelf(container); + } + else + { + FinalizeBindingConcrete(container, BindInfo.ToTypes); + } + } + + void FinalizeBindingConcrete(DiContainer container, List concreteTypes) + { + var scope = GetScope(); + + switch (scope) + { + case ScopeTypes.Transient: + { + RegisterProvidersForAllContractsPerConcreteType( + container, + concreteTypes, + (_, concreteType) => new SubContainerDependencyProvider( + concreteType, _subIdentifier, + _subContainerCreatorFactory(container), _resolveAll)); + break; + } + case ScopeTypes.Singleton: + { + var containerCreator = new SubContainerCreatorCached( + _subContainerCreatorFactory(container)); + + RegisterProvidersForAllContractsPerConcreteType( + container, + concreteTypes, + (_, concreteType) => + new SubContainerDependencyProvider( + concreteType, _subIdentifier, containerCreator, _resolveAll)); + break; + } + default: + { + throw Assert.CreateException(); + } + } + } + + void FinalizeBindingSelf(DiContainer container) + { + var scope = GetScope(); + + switch (scope) + { + case ScopeTypes.Transient: + { + RegisterProviderPerContract( + container, + (_, contractType) => new SubContainerDependencyProvider( + contractType, _subIdentifier, + _subContainerCreatorFactory(container), _resolveAll)); + break; + } + case ScopeTypes.Singleton: + { + var containerCreator = new SubContainerCreatorCached( + _subContainerCreatorFactory(container)); + + RegisterProviderPerContract( + container, + (_, contractType) => + new SubContainerDependencyProvider( + contractType, _subIdentifier, containerCreator, _resolveAll)); + break; + } + default: + { + throw Assert.CreateException(); + } + } + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SubContainerPrefabBindingFinalizer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SubContainerPrefabBindingFinalizer.cs.meta new file mode 100644 index 0000000..b0612e6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Binding/Finalizers/SubContainerPrefabBindingFinalizer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: da4cb0f689a9b074aa3d2f2da8b38015 +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor.meta new file mode 100644 index 0000000..8817817 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 70a96473817a0384580ace78f202a622 +folderAsset: yes +DefaultImporter: + userData: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorStaticInstaller.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorStaticInstaller.cs new file mode 100644 index 0000000..acb6d1f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorStaticInstaller.cs @@ -0,0 +1,30 @@ + +namespace Zenject +{ + // Derive from this class, add [InitializeOnLoad], and then call Install + // in a static constructor to add some editor time bindings + // For example: + // + // [InitializeOnLoad] + // public class FooInstaller : EditorStaticInstaller + // { + // static FooInstaller() + // { + // Install(); + // } + // + // public override void InstallBindings() + // { + // Container.BindInstance("hello world"); + // } + // } + // + public abstract class EditorStaticInstaller : InstallerBase + where T : EditorStaticInstaller + { + public static void Install() + { + StaticContext.Container.Instantiate().InstallBindings(); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorStaticInstaller.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorStaticInstaller.cs.meta new file mode 100644 index 0000000..fa35d7a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorStaticInstaller.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fcb2e11e0ed56de48b0ba9b5e3ae10c9 +timeCreated: 1486079412 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorWindow.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorWindow.meta new file mode 100644 index 0000000..cab3797 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorWindow.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: bd8d602c69b71714babee52a2d454aed +folderAsset: yes +timeCreated: 1461708046 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorWindow/ZenjectEditorWindow.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorWindow/ZenjectEditorWindow.cs new file mode 100644 index 0000000..99a31e2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorWindow/ZenjectEditorWindow.cs @@ -0,0 +1,160 @@ +using System; +using ModestTree; +using UnityEditor; +using UnityEngine; + +namespace Zenject +{ + public abstract class ZenjectEditorWindow : EditorWindow + { + [Inject] + [NonSerialized] + Kernel _kernel; + + [Inject] + [NonSerialized] + GuiRenderableManager _guiRenderableManager; + + [NonSerialized] + DiContainer _container; + + [NonSerialized] + Exception _fatalError; + + [NonSerialized] + GUIStyle _errorTextStyle; + + GUIStyle ErrorTextStyle + { + get + { + if (_errorTextStyle == null) + { + _errorTextStyle = new GUIStyle(GUI.skin.label); + _errorTextStyle.fontSize = 18; + _errorTextStyle.normal.textColor = Color.red; + _errorTextStyle.wordWrap = true; + _errorTextStyle.alignment = TextAnchor.MiddleCenter; + } + + return _errorTextStyle; + } + } + + protected DiContainer Container + { + get { return _container; } + } + + public virtual void OnEnable() + { + if (_fatalError != null) + { + return; + } + + Initialize(); + } + + protected virtual void Initialize() + { + Assert.IsNull(_container); + + _container = new DiContainer(new[] { StaticContext.Container }); + + // Make sure we don't create any game objects since editor windows don't have a scene + _container.AssertOnNewGameObjects = true; + + ZenjectManagersInstaller.Install(_container); + + _container.Bind().AsSingle(); + _container.Bind().AsSingle(); + _container.BindInstance(this); + + InstallBindings(); + + _container.QueueForInject(this); + _container.ResolveRoots(); + + _kernel.Initialize(); + } + + public virtual void OnDisable() + { + if (_fatalError != null) + { + return; + } + + _kernel.Dispose(); + } + + public virtual void Update() + { + if (_fatalError != null) + { + return; + } + + try + { + _kernel.Tick(); + } + catch (Exception e) + { + Log.ErrorException(e); + _fatalError = e; + } + + // We might also consider only calling Repaint when changes occur + Repaint(); + } + + public virtual void OnGUI() + { + if (_fatalError != null) + { + var labelWidth = 600; + var labelHeight = 200; + + GUI.Label(new Rect(Screen.width / 2 - labelWidth / 2, Screen.height / 3 - labelHeight / 2, labelWidth, labelHeight), "Unrecoverable error occurred! \nSee log for details.", ErrorTextStyle); + + var buttonWidth = 100; + var buttonHeight = 50; + var offset = new Vector2(0, 100); + + if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2 + offset.x, Screen.height / 3 - buttonHeight / 2 + offset.y, buttonWidth, buttonHeight), "Reload")) + { + ExecuteFullReload(); + } + } + else + { + try + { + if (_guiRenderableManager != null) + { + _guiRenderableManager.OnGui(); + } + } + catch (Exception e) + { + Log.ErrorException(e); + _fatalError = e; + } + } + } + + protected virtual void ExecuteFullReload() + { + _kernel = null; + _guiRenderableManager = null; + _container = null; + _fatalError = null; + + Initialize(); + } + + public abstract void InstallBindings(); + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorWindow/ZenjectEditorWindow.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorWindow/ZenjectEditorWindow.cs.meta new file mode 100644 index 0000000..c32c740 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/EditorWindow/ZenjectEditorWindow.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: bc25e694ccedbed4893d980ee61d1c8f +timeCreated: 1527961729 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors.meta new file mode 100644 index 0000000..fdb4f66 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: fbb1477b2e261944dad77cce5626aab0 +folderAsset: yes +timeCreated: 1461708046 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/ContextEditor.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/ContextEditor.cs new file mode 100644 index 0000000..f969c20 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/ContextEditor.cs @@ -0,0 +1,49 @@ +#if !ODIN_INSPECTOR + +namespace Zenject +{ + [NoReflectionBaking] + public class ContextEditor : UnityInspectorListEditor + { + protected override string[] PropertyNames + { + get + { + return new string[] + { + "_scriptableObjectInstallers", + "_monoInstallers", + "_installerPrefabs", + }; + } + } + + protected override string[] PropertyDisplayNames + { + get + { + return new string[] + { + "Scriptable Object Installers", + "Mono Installers", + "Prefab Installers", + }; + } + } + + protected override string[] PropertyDescriptions + { + get + { + return new string[] + { + "Drag any assets in your Project that implement ScriptableObjectInstaller here", + "Drag any MonoInstallers that you have added to your Scene Hierarchy here.", + "Drag any prefabs that contain a MonoInstaller on them here", + }; + } + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/ContextEditor.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/ContextEditor.cs.meta new file mode 100644 index 0000000..07dc4d2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/ContextEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 23155ecdf203bf24480fd49763b73677 +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/GameObjectContextEditor.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/GameObjectContextEditor.cs new file mode 100644 index 0000000..6f235c5 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/GameObjectContextEditor.cs @@ -0,0 +1,29 @@ +#if !ODIN_INSPECTOR + +using UnityEditor; + +namespace Zenject +{ + [CustomEditor(typeof(GameObjectContext))] + [NoReflectionBaking] + public class GameObjectContextEditor : RunnableContextEditor + { + SerializedProperty _kernel; + + public override void OnEnable() + { + base.OnEnable(); + + _kernel = serializedObject.FindProperty("_kernel"); + } + + protected override void OnGui() + { + base.OnGui(); + + EditorGUILayout.PropertyField(_kernel); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/GameObjectContextEditor.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/GameObjectContextEditor.cs.meta new file mode 100644 index 0000000..339cf8f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/GameObjectContextEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b0873c763efd1e94fb3a56ff80843cf1 +timeCreated: 1461708052 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/ProjectContextEditor.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/ProjectContextEditor.cs new file mode 100644 index 0000000..72de9d5 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/ProjectContextEditor.cs @@ -0,0 +1,38 @@ +#if !ODIN_INSPECTOR + +using UnityEditor; + +namespace Zenject +{ + [CustomEditor(typeof(ProjectContext))] + [NoReflectionBaking] + public class ProjectContextEditor : ContextEditor + { + SerializedProperty _settingsProperty; + SerializedProperty _editorReflectionBakingCoverageModeProperty; + SerializedProperty _buildsReflectionBakingCoverageModeProperty; + SerializedProperty _parentNewObjectsUnderContextProperty; + + public override void OnEnable() + { + base.OnEnable(); + + _settingsProperty = serializedObject.FindProperty("_settings"); + _editorReflectionBakingCoverageModeProperty = serializedObject.FindProperty("_editorReflectionBakingCoverageMode"); + _buildsReflectionBakingCoverageModeProperty = serializedObject.FindProperty("_buildsReflectionBakingCoverageMode"); + _parentNewObjectsUnderContextProperty = serializedObject.FindProperty("_parentNewObjectsUnderContext"); + } + + protected override void OnGui() + { + base.OnGui(); + + EditorGUILayout.PropertyField(_settingsProperty, true); + EditorGUILayout.PropertyField(_editorReflectionBakingCoverageModeProperty, true); + EditorGUILayout.PropertyField(_buildsReflectionBakingCoverageModeProperty, true); + EditorGUILayout.PropertyField(_parentNewObjectsUnderContextProperty); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/ProjectContextEditor.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/ProjectContextEditor.cs.meta new file mode 100644 index 0000000..a17643e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/ProjectContextEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b5ad40b612e67574aad508d053e6965b +timeCreated: 1461708053 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/RunnableContextEditor.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/RunnableContextEditor.cs new file mode 100644 index 0000000..deddebe --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/RunnableContextEditor.cs @@ -0,0 +1,29 @@ +#if !ODIN_INSPECTOR + +using UnityEditor; + +namespace Zenject +{ + [NoReflectionBaking] + public class RunnableContextEditor : ContextEditor + { + SerializedProperty _autoRun; + + public override void OnEnable() + { + base.OnEnable(); + + _autoRun = serializedObject.FindProperty("_autoRun"); + } + + protected override void OnGui() + { + base.OnGui(); + + EditorGUILayout.PropertyField(_autoRun); + } + } +} + + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/RunnableContextEditor.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/RunnableContextEditor.cs.meta new file mode 100644 index 0000000..2e085fd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/RunnableContextEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 02bed9738f9c4323ac05524465473dee +timeCreated: 1494728675 \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/SceneContextEditor.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/SceneContextEditor.cs new file mode 100644 index 0000000..fb2f7ae --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/SceneContextEditor.cs @@ -0,0 +1,37 @@ +#if !ODIN_INSPECTOR + +using UnityEditor; + +namespace Zenject +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(SceneContext))] + [NoReflectionBaking] + public class SceneContextEditor : RunnableContextEditor + { + SerializedProperty _contractNameProperty; + SerializedProperty _parentNamesProperty; + SerializedProperty _parentNewObjectsUnderSceneContextProperty; + + public override void OnEnable() + { + base.OnEnable(); + + _contractNameProperty = serializedObject.FindProperty("_contractNames"); + _parentNamesProperty = serializedObject.FindProperty("_parentContractNames"); + _parentNewObjectsUnderSceneContextProperty = serializedObject.FindProperty("_parentNewObjectsUnderSceneContext"); + } + + protected override void OnGui() + { + base.OnGui(); + + EditorGUILayout.PropertyField(_contractNameProperty, true); + EditorGUILayout.PropertyField(_parentNamesProperty, true); + EditorGUILayout.PropertyField(_parentNewObjectsUnderSceneContextProperty); + } + } +} + + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/SceneContextEditor.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/SceneContextEditor.cs.meta new file mode 100644 index 0000000..f2a862b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/SceneContextEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c04ae1d59f53f514f96e284ba43122f7 +timeCreated: 1461708053 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/SceneDecoratorContextEditor.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/SceneDecoratorContextEditor.cs new file mode 100644 index 0000000..07ab1c6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/SceneDecoratorContextEditor.cs @@ -0,0 +1,79 @@ +#if !ODIN_INSPECTOR + +using System.Collections.Generic; +using System.IO; +using System.Linq; +using UnityEditor.SceneManagement; +using UnityEngine.SceneManagement; +using UnityEditor; +using UnityEditorInternal; +using UnityEngine; +using ModestTree; + +namespace Zenject +{ + [CustomEditor(typeof(SceneDecoratorContext))] + [NoReflectionBaking] + public class SceneDecoratorContextEditor : ContextEditor + { + SerializedProperty _decoratedContractNameProperty; + + protected override string[] PropertyNames + { + get + { + return base.PropertyNames.Concat(new string[] + { + "_lateInstallers", + "_lateInstallerPrefabs", + "_lateScriptableObjectInstallers" + }) + .ToArray(); + } + } + + protected override string[] PropertyDisplayNames + { + get + { + return base.PropertyDisplayNames.Concat(new string[] + { + "Late Installers", + "Late Prefab Installers", + "Late Scriptable Object Installers" + }) + .ToArray(); + } + } + + protected override string[] PropertyDescriptions + { + get + { + return base.PropertyDescriptions.Concat(new string[] + { + "Drag any MonoInstallers that you have added to your Scene Hierarchy here. They'll be installed after the target installs its bindings", + "Drag any prefabs that contain a MonoInstaller on them here. They'll be installed after the target installs its bindings", + "Drag any assets in your Project that implement ScriptableObjectInstaller here. They'll be installed after the target installs its bindings" + }) + .ToArray(); + } + } + + public override void OnEnable() + { + base.OnEnable(); + + _decoratedContractNameProperty = serializedObject.FindProperty("_decoratedContractName"); + } + + protected override void OnGui() + { + base.OnGui(); + + EditorGUILayout.PropertyField(_decoratedContractNameProperty); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/SceneDecoratorContextEditor.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/SceneDecoratorContextEditor.cs.meta new file mode 100644 index 0000000..09003f0 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Editors/SceneDecoratorContextEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d2b9289e80031104295e10acf518d75a +timeCreated: 1461708053 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ObjectGraphVisualizer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ObjectGraphVisualizer.cs new file mode 100644 index 0000000..5eadfbd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ObjectGraphVisualizer.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using ModestTree; + +namespace Zenject +{ + // Responsibilities: + // - Output a file specifying the full object graph for a given root dependency + // - This file uses the DOT language with can be fed into GraphViz to generate an image + // - http://www.graphviz.org/ + public static class ObjectGraphVisualizer + { + public static void OutputObjectGraphToFile( + DiContainer container, string outputPath, + IEnumerable externalIgnoreTypes, IEnumerable contractTypes) + { + // Output the entire object graph to file + var graph = CalculateObjectGraph(container, contractTypes); + + var ignoreTypes = new List + { + typeof(DiContainer), + typeof(InitializableManager) + }; + + ignoreTypes.AddRange(externalIgnoreTypes); + + var resultStr = "digraph { \n"; + + resultStr += "rankdir=LR;\n"; + + foreach (var entry in graph) + { + if (ShouldIgnoreType(entry.Key, ignoreTypes)) + { + continue; + } + + foreach (var dependencyType in entry.Value) + { + if (ShouldIgnoreType(dependencyType, ignoreTypes)) + { + continue; + } + + resultStr += GetFormattedTypeName(entry.Key) + " -> " + GetFormattedTypeName(dependencyType) + "; \n"; + } + } + + resultStr += " }"; + + File.WriteAllText(outputPath, resultStr); + } + + static bool ShouldIgnoreType(Type type, List ignoreTypes) + { + return ignoreTypes.Contains(type); + } + + static Dictionary> CalculateObjectGraph( + DiContainer container, IEnumerable contracts) + { + var map = new Dictionary>(); + + foreach (var contractType in contracts) + { + var depends = GetDependencies(container, contractType); + + if (depends.Any()) + { + map.Add(contractType, depends); + } + } + + return map; + } + + static List GetDependencies( + DiContainer container, Type type) + { + var dependencies = new List(); + + foreach (var contractType in container.GetDependencyContracts(type)) + { + List dependTypes; + + if (contractType.FullName.StartsWith("System.Collections.Generic.List")) + { + var subTypes = contractType.GenericArguments(); + Assert.IsEqual(subTypes.Length, 1); + + var subType = subTypes[0]; + dependTypes = container.ResolveTypeAll(subType); + } + else + { + dependTypes = container.ResolveTypeAll(contractType); + Assert.That(dependTypes.Count <= 1); + } + + foreach (var dependType in dependTypes) + { + dependencies.Add(dependType); + } + } + + return dependencies; + } + + static string GetFormattedTypeName(Type type) + { + var str = type.PrettyName(); + + // GraphViz does not read names with <, >, or . characters so replace them + str = str.Replace(">", "_"); + str = str.Replace("<", "_"); + str = str.Replace(".", "_"); + + return str; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ObjectGraphVisualizer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ObjectGraphVisualizer.cs.meta new file mode 100644 index 0000000..14cbc9c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ObjectGraphVisualizer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 29f47f2a06418244e8fcbe27db1a0eea +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading.meta new file mode 100644 index 0000000..3d57785 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 8b93c2560e2014a4893f387eb7690dbd +folderAsset: yes +timeCreated: 1520777708 +licenseType: Store +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading/DefaultSceneContractConfig.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading/DefaultSceneContractConfig.cs new file mode 100644 index 0000000..14246bb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading/DefaultSceneContractConfig.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +namespace Zenject.Internal +{ + public class DefaultSceneContractConfig : ScriptableObject + { + public const string ResourcePath = "ZenjectDefaultSceneContractConfig"; + + public List DefaultContracts; + + [Serializable] + public class ContractInfo + { + public string ContractName; + public SceneAsset Scene; + } + } + +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading/DefaultSceneContractConfig.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading/DefaultSceneContractConfig.cs.meta new file mode 100644 index 0000000..3e5dfd5 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading/DefaultSceneContractConfig.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 8620c058a9173b84a97d72ed5e94dbd7 +timeCreated: 1520778887 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading/SceneParentAutomaticLoader.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading/SceneParentAutomaticLoader.cs new file mode 100644 index 0000000..c0f17a8 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading/SceneParentAutomaticLoader.cs @@ -0,0 +1,326 @@ +using System; +using System.Collections.Generic; +using ModestTree; +using UnityEditor; +using UnityEditor.SceneManagement; +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace Zenject.Internal +{ + [InitializeOnLoad] + public static class SceneParentAutomaticLoader + { + static SceneParentAutomaticLoader() + { + EditorApplication.playModeStateChanged += OnPlayModeStateChanged; + } + + static void OnPlayModeStateChanged(PlayModeStateChange state) + { + if (state == PlayModeStateChange.ExitingEditMode) + { + try + { + ValidateMultiSceneSetupAndLoadDefaultSceneParents(); + } + catch (Exception e) + { + EditorApplication.isPlaying = false; + throw new ZenjectException( + "Failure occurred when attempting to load default scene parent contracts!", e); + } + } + else if (state == PlayModeStateChange.EnteredEditMode) + { + // It would be cool to restore the initial scene set up here but in order to do this + // we would have to make sure that the user saves the scene before running which + // would be too annoying, so just leave any changes we've made alone + } + } + + public static void ValidateMultiSceneSetupAndLoadDefaultSceneParents() + { + var defaultContractsMap = LoadDefaultContractsMap(); + + // NOTE: Even if configs is empty we still want to do the below logic to validate the + // multi scene setup + + var sceneInfos = GetLoadedZenjectSceneInfos(); + var contractMap = GetCurrentSceneContractsMap(sceneInfos); + + foreach (var sceneInfo in sceneInfos) + { + ProcessScene(sceneInfo, contractMap, defaultContractsMap); + } + } + + static Dictionary GetCurrentSceneContractsMap( + List sceneInfos) + { + var contractMap = new Dictionary(); + + foreach (var info in sceneInfos) + { + AddToContractMap(contractMap, info); + } + + return contractMap; + } + + static void ProcessScene( + LoadedSceneInfo sceneInfo, + Dictionary contractMap, + Dictionary defaultContractsMap) + { + if (sceneInfo.SceneContext != null) + { + Assert.IsNull(sceneInfo.DecoratorContext); + ProcessSceneParents(sceneInfo, contractMap, defaultContractsMap); + } + else + { + Assert.IsNotNull(sceneInfo.DecoratorContext); + ProcessSceneDecorators(sceneInfo, contractMap, defaultContractsMap); + } + } + + static void ProcessSceneDecorators( + LoadedSceneInfo sceneInfo, + Dictionary contractMap, + Dictionary defaultContractsMap) + { + var decoratedContractName = sceneInfo.DecoratorContext.DecoratedContractName; + + LoadedSceneInfo decoratedSceneInfo; + + if (contractMap.TryGetValue(decoratedContractName, out decoratedSceneInfo)) + { + ValidateDecoratedSceneMatch(sceneInfo, decoratedSceneInfo); + return; + } + + decoratedSceneInfo = LoadDefaultSceneForContract( + sceneInfo, decoratedContractName, defaultContractsMap); + + EditorSceneManager.MoveSceneAfter(decoratedSceneInfo.Scene, sceneInfo.Scene); + + ValidateDecoratedSceneMatch(sceneInfo, decoratedSceneInfo); + + ProcessScene(decoratedSceneInfo, contractMap, defaultContractsMap); + } + + static void ProcessSceneParents( + LoadedSceneInfo sceneInfo, + Dictionary contractMap, + Dictionary defaultContractsMap) + { + foreach (var parentContractName in sceneInfo.SceneContext.ParentContractNames) + { + LoadedSceneInfo parentInfo; + + if (contractMap.TryGetValue(parentContractName, out parentInfo)) + { + ValidateParentChildMatch(parentInfo, sceneInfo); + continue; + } + + parentInfo = LoadDefaultSceneForContract(sceneInfo, parentContractName, defaultContractsMap); + + AddToContractMap(contractMap, parentInfo); + + EditorSceneManager.MoveSceneBefore(parentInfo.Scene, sceneInfo.Scene); + + ValidateParentChildMatch(parentInfo, sceneInfo); + + ProcessScene(parentInfo, contractMap, defaultContractsMap); + } + } + + static LoadedSceneInfo LoadDefaultSceneForContract( + LoadedSceneInfo sceneInfo, string contractName, Dictionary defaultContractsMap) + { + string scenePath; + + if (!defaultContractsMap.TryGetValue(contractName, out scenePath)) + { + throw Assert.CreateException( + "Could not fill contract '{0}' for scene '{1}'. No scenes with that contract name are loaded, and could not find a match in any default scene contract configs to auto load one either." + .Fmt(contractName, sceneInfo.Scene.name)); + } + + Scene scene; + + try + { + scene = EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Additive); + } + catch (Exception e) + { + throw new ZenjectException( + "Error while attempting to load contracts for scene '{0}'".Fmt(sceneInfo.Scene.name), e); + } + + return CreateLoadedSceneInfo(scene); + } + + static void ValidateDecoratedSceneMatch( + LoadedSceneInfo decoratorInfo, LoadedSceneInfo decoratedInfo) + { + var decoratorIndex = GetSceneIndex(decoratorInfo.Scene); + var decoratedIndex = GetSceneIndex(decoratedInfo.Scene); + var activeIndex = GetSceneIndex(EditorSceneManager.GetActiveScene()); + + Assert.That(decoratorIndex < decoratedIndex, + "Decorator scene '{0}' must be loaded before decorated scene '{1}'. Please drag the decorator scene to be placed above the other scene in the scene hierarchy.", + decoratorInfo.Scene.name, decoratedInfo.Scene.name); + + if (activeIndex > decoratorIndex) + { + EditorSceneManager.SetActiveScene(decoratorInfo.Scene); + } + } + + static void ValidateParentChildMatch( + LoadedSceneInfo parentSceneInfo, LoadedSceneInfo sceneInfo) + { + var parentIndex = GetSceneIndex(parentSceneInfo.Scene); + var childIndex = GetSceneIndex(sceneInfo.Scene); + var activeIndex = GetSceneIndex(EditorSceneManager.GetActiveScene()); + + Assert.That(parentIndex < childIndex, + "Parent scene '{0}' must be loaded before child scene '{1}'. Please drag it to be placed above its child in the scene hierarchy.", parentSceneInfo.Scene.name, sceneInfo.Scene.name); + + if (activeIndex > parentIndex) + { + EditorSceneManager.SetActiveScene(parentSceneInfo.Scene); + } + } + + static int GetSceneIndex(Scene scene) + { + for (int i = 0; i < EditorSceneManager.sceneCount; i++) + { + if (EditorSceneManager.GetSceneAt(i) == scene) + { + return i; + } + } + + throw Assert.CreateException(); + } + + static Dictionary LoadDefaultContractsMap() + { + var configs = Resources.LoadAll(DefaultSceneContractConfig.ResourcePath); + + var map = new Dictionary(); + + foreach (var config in configs) + { + foreach (var info in config.DefaultContracts) + { + if (info.ContractName.Trim().IsEmpty()) + { + Log.Warn("Found empty contract name in default scene contract config at path '{0}'", AssetDatabase.GetAssetPath(config)); + continue; + } + + Assert.That(!map.ContainsKey(info.ContractName), + "Found duplicate contract '{0}' in default scene contract config at '{1}'! Default contract already specified", info.ContractName, AssetDatabase.GetAssetPath(config)); + + map.Add(info.ContractName, AssetDatabase.GetAssetPath(info.Scene)); + } + } + + return map; + } + + static LoadedSceneInfo CreateLoadedSceneInfo(Scene scene) + { + var info = TryCreateLoadedSceneInfo(scene); + Assert.IsNotNull(info, "Expected scene '{0}' to be a zenject scene", scene.name); + return info; + } + + static LoadedSceneInfo TryCreateLoadedSceneInfo(Scene scene) + { + var sceneContext = ZenUnityEditorUtil.TryGetSceneContextForScene(scene); + var decoratorContext = ZenUnityEditorUtil.TryGetDecoratorContextForScene(scene); + + if (sceneContext == null && decoratorContext == null) + { + return null; + } + + var info = new LoadedSceneInfo + { + Scene = scene + }; + + if (sceneContext != null) + { + Assert.IsNull(decoratorContext, + "Found both SceneContext and SceneDecoratorContext in scene '{0}'", scene.name); + + info.SceneContext = sceneContext; + } + else + { + Assert.IsNotNull(decoratorContext); + + info.DecoratorContext = decoratorContext; + } + + return info; + } + + static List GetLoadedZenjectSceneInfos() + { + var result = new List(); + + for (int i = 0; i < EditorSceneManager.sceneCount; i++) + { + var scene = EditorSceneManager.GetSceneAt(i); + var info = TryCreateLoadedSceneInfo(scene); + + if (info != null) + { + result.Add(info); + } + } + + return result; + } + + static void AddToContractMap( + Dictionary contractMap, LoadedSceneInfo info) + { + if (info.SceneContext == null) + { + return; + } + + foreach (var contractName in info.SceneContext.ContractNames) + { + LoadedSceneInfo currentInfo; + + if (contractMap.TryGetValue(contractName, out currentInfo)) + { + throw Assert.CreateException( + "Found multiple scene contracts with name '{0}'. Scene '{1}' and scene '{2}'", + contractName, currentInfo.Scene.name, info.Scene.name); + } + + contractMap.Add(contractName, info); + } + } + + public class LoadedSceneInfo + { + public SceneContext SceneContext; + public SceneDecoratorContext DecoratorContext; + public Scene Scene; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading/SceneParentAutomaticLoader.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading/SceneParentAutomaticLoader.cs.meta new file mode 100644 index 0000000..6229f5a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/SceneParentLoading/SceneParentAutomaticLoader.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c9f09e0752f64214ba3413d7fdc47736 +timeCreated: 1520771371 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/UnityInspectorListEditor.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/UnityInspectorListEditor.cs new file mode 100644 index 0000000..b50b777 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/UnityInspectorListEditor.cs @@ -0,0 +1,93 @@ +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using UnityEditor; +using UnityEditorInternal; +using UnityEngine; + +namespace Zenject +{ + public abstract class UnityInspectorListEditor : Editor + { + List _installersLists; + List _installersProperties; + + protected abstract string[] PropertyDisplayNames + { + get; + } + + protected abstract string[] PropertyNames + { + get; + } + + protected abstract string[] PropertyDescriptions + { + get; + } + + public virtual void OnEnable() + { + _installersProperties = new List(); + _installersLists = new List(); + + var descriptions = PropertyDescriptions; + var names = PropertyNames; + var displayNames = PropertyDisplayNames; + + Assert.IsEqual(descriptions.Length, names.Length); + + var infos = Enumerable.Range(0, names.Length).Select(i => new { Name = names[i], DisplayName = displayNames[i], Description = descriptions[i] }).ToList(); + + foreach (var info in infos) + { + var installersProperty = serializedObject.FindProperty(info.Name); + _installersProperties.Add(installersProperty); + + ReorderableList installersList = new ReorderableList(serializedObject, installersProperty, true, true, true, true); + _installersLists.Add(installersList); + + var closedName = info.DisplayName; + var closedDesc = info.Description; + + installersList.drawHeaderCallback += rect => + { + GUI.Label(rect, + new GUIContent(closedName, closedDesc)); + }; + installersList.drawElementCallback += (rect, index, active, focused) => + { + rect.width -= 40; + rect.x += 20; + EditorGUI.PropertyField(rect, installersProperty.GetArrayElementAtIndex(index), GUIContent.none, true); + }; + } + } + + public sealed override void OnInspectorGUI() + { + serializedObject.Update(); + + OnGui(); + + serializedObject.ApplyModifiedProperties(); + } + + protected virtual void OnGui() + { + if (Application.isPlaying) + { + GUI.enabled = false; + } + + foreach (var list in _installersLists) + { + list.DoLayoutList(); + } + + GUI.enabled = true; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/UnityInspectorListEditor.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/UnityInspectorListEditor.cs.meta new file mode 100644 index 0000000..ea28f72 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/UnityInspectorListEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 06d16f2f9107265428d41710db4cbb14 +timeCreated: 1461708048 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ZenMenuItems.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ZenMenuItems.cs new file mode 100644 index 0000000..233f889 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ZenMenuItems.cs @@ -0,0 +1,349 @@ +#if !NOT_UNITY3D + +using System.IO; +using ModestTree; +using UnityEditor; +using UnityEditor.SceneManagement; +using UnityEngine; + +namespace Zenject.Internal +{ + public static class ZenMenuItems + { + [MenuItem("Edit/Zenject/Validate Current Scenes #&v")] + public static void ValidateCurrentScene() + { + ValidateCurrentSceneInternal(); + } + + [MenuItem("Edit/Zenject/Validate Then Run #&r")] + public static void ValidateCurrentSceneThenRun() + { + if (ValidateCurrentSceneInternal()) + { + EditorApplication.isPlaying = true; + } + } + + [MenuItem("Edit/Zenject/Help...")] + public static void OpenDocumentation() + { + Application.OpenURL("https://github.com/svermeulen/zenject"); + } + + [MenuItem("GameObject/Zenject/Scene Context", false, 9)] + public static void CreateSceneContext(MenuCommand menuCommand) + { + var root = new GameObject("SceneContext").AddComponent(); + Selection.activeGameObject = root.gameObject; + + EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); + } + + [MenuItem("GameObject/Zenject/Decorator Context", false, 9)] + public static void CreateDecoratorContext(MenuCommand menuCommand) + { + var root = new GameObject("DecoratorContext").AddComponent(); + Selection.activeGameObject = root.gameObject; + + EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); + } + + [MenuItem("GameObject/Zenject/Game Object Context", false, 9)] + public static void CreateGameObjectContext(MenuCommand menuCommand) + { + var root = new GameObject("GameObjectContext").AddComponent(); + Selection.activeGameObject = root.gameObject; + + EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); + } + + [MenuItem("Edit/Zenject/Create Project Context")] + public static void CreateProjectContextInDefaultLocation() + { + var fullDirPath = Path.Combine(Application.dataPath, "Resources"); + + if (!Directory.Exists(fullDirPath)) + { + Directory.CreateDirectory(fullDirPath); + } + + CreateProjectContextInternal("Assets/Resources"); + } + + [MenuItem("Assets/Create/Zenject/Default Scene Contract Config", false, 80)] + public static void CreateDefaultSceneContractConfig() + { + var folderPath = ZenUnityEditorUtil.GetCurrentDirectoryAssetPathFromSelection(); + + if (!folderPath.EndsWith("/Resources")) + { + EditorUtility.DisplayDialog("Error", + "ZenjectDefaultSceneContractConfig objects must be placed directly underneath a folder named 'Resources'. Please try again.", "Ok"); + return; + } + + var config = ScriptableObject.CreateInstance(); + + ZenUnityEditorUtil.SaveScriptableObjectAsset( + Path.Combine(folderPath, DefaultSceneContractConfig.ResourcePath + ".asset"), config); + } + + [MenuItem("Assets/Create/Zenject/Scriptable Object Installer", false, 1)] + public static void CreateScriptableObjectInstaller() + { + AddCSharpClassTemplate("Scriptable Object Installer", "UntitledInstaller", + "using UnityEngine;" + + "\nusing Zenject;" + + "\n" + + "\n[CreateAssetMenu(fileName = \"CLASS_NAME\", menuName = \"Installers/CLASS_NAME\")]" + + "\npublic class CLASS_NAME : ScriptableObjectInstaller" + + "\n{" + + "\n public override void InstallBindings()" + + "\n {" + + "\n }" + + "\n}"); + } + + [MenuItem("Assets/Create/Zenject/Mono Installer", false, 1)] + public static void CreateMonoInstaller() + { + AddCSharpClassTemplate("Mono Installer", "UntitledInstaller", + "using UnityEngine;" + + "\nusing Zenject;" + + "\n" + + "\npublic class CLASS_NAME : MonoInstaller" + + "\n{" + + "\n public override void InstallBindings()" + + "\n {" + + "\n }" + + "\n}"); + } + + [MenuItem("Assets/Create/Zenject/Installer", false, 1)] + public static void CreateInstaller() + { + AddCSharpClassTemplate("Installer", "UntitledInstaller", + "using UnityEngine;" + + "\nusing Zenject;" + + "\n" + + "\npublic class CLASS_NAME : Installer" + + "\n{" + + "\n public override void InstallBindings()" + + "\n {" + + "\n }" + + "\n}"); + } + + [MenuItem("Assets/Create/Zenject/Editor Window", false, 20)] + public static void CreateEditorWindow() + { + AddCSharpClassTemplate("Editor Window", "UntitledEditorWindow", + "using UnityEngine;" + + "\nusing UnityEditor;" + + "\nusing Zenject;" + + "\n" + + "\npublic class CLASS_NAME : ZenjectEditorWindow" + + "\n{" + + "\n [MenuItem(\"Window/CLASS_NAME\")]" + + "\n public static CLASS_NAME GetOrCreateWindow()" + + "\n {" + + "\n var window = EditorWindow.GetWindow();" + + "\n window.titleContent = new GUIContent(\"CLASS_NAME\");" + + "\n return window;" + + "\n }" + + "\n" + + "\n public override void InstallBindings()" + + "\n {" + + "\n // TODO" + + "\n }" + + "\n}"); + } + + [MenuItem("Assets/Create/Zenject/Project Context", false, 40)] + public static void CreateProjectContext() + { + var absoluteDir = ZenUnityEditorUtil.TryGetSelectedFolderPathInProjectsTab(); + + if (absoluteDir == null) + { + EditorUtility.DisplayDialog("Error", + "Could not find directory to place the '{0}.prefab' asset. Please try again by right clicking in the desired folder within the projects pane." + .Fmt(ProjectContext.ProjectContextResourcePath), "Ok"); + return; + } + + var parentFolderName = Path.GetFileName(absoluteDir); + + if (parentFolderName != "Resources") + { + EditorUtility.DisplayDialog("Error", + "'{0}.prefab' must be placed inside a directory named 'Resources'. Please try again by right clicking within the Project pane in a valid Resources folder." + .Fmt(ProjectContext.ProjectContextResourcePath), "Ok"); + return; + } + + CreateProjectContextInternal(absoluteDir); + } + + static void CreateProjectContextInternal(string absoluteDir) + { + var assetPath = ZenUnityEditorUtil.ConvertFullAbsolutePathToAssetPath(absoluteDir); + var prefabPath = (Path.Combine(assetPath, ProjectContext.ProjectContextResourcePath) + ".prefab").Replace("\\", "/"); + + var gameObject = new GameObject(); + + try + { + gameObject.AddComponent(); + +#if UNITY_2018_3_OR_NEWER + var prefabObj = PrefabUtility.SaveAsPrefabAsset(gameObject, prefabPath); +#else + var prefabObj = PrefabUtility.ReplacePrefab(gameObject, PrefabUtility.CreateEmptyPrefab(prefabPath)); +#endif + + Selection.activeObject = prefabObj; + } + finally + { + GameObject.DestroyImmediate(gameObject); + } + + Debug.Log("Created new ProjectContext at '{0}'".Fmt(prefabPath)); + } + + public static string AddCSharpClassTemplate( + string friendlyName, string defaultFileName, string templateStr) + { + return AddCSharpClassTemplate( + friendlyName, defaultFileName, templateStr, ZenUnityEditorUtil.GetCurrentDirectoryAssetPathFromSelection()); + } + + public static string AddCSharpClassTemplate( + string friendlyName, string defaultFileName, + string templateStr, string folderPath) + { + var absolutePath = EditorUtility.SaveFilePanel( + "Choose name for " + friendlyName, + folderPath, + defaultFileName + ".cs", + "cs"); + + if (absolutePath == "") + { + // Dialog was cancelled + return null; + } + + if (!absolutePath.ToLower().EndsWith(".cs")) + { + absolutePath += ".cs"; + } + + var className = Path.GetFileNameWithoutExtension(absolutePath); + File.WriteAllText(absolutePath, templateStr.Replace("CLASS_NAME", className)); + + AssetDatabase.Refresh(); + + var assetPath = ZenUnityEditorUtil.ConvertFullAbsolutePathToAssetPath(absolutePath); + + EditorUtility.FocusProjectWindow(); + Selection.activeObject = AssetDatabase.LoadAssetAtPath(assetPath); + + return assetPath; + } + + [MenuItem("Edit/Zenject/Validate All Active Scenes")] + public static void ValidateAllActiveScenes() + { + ZenUnityEditorUtil.SaveThenRunPreserveSceneSetup(() => + { + var numValidated = ZenUnityEditorUtil.ValidateAllActiveScenes(); + Log.Info("Validated all '{0}' active scenes successfully", numValidated); + }); + } + + static bool ValidateCurrentSceneInternal() + { + return ZenUnityEditorUtil.SaveThenRunPreserveSceneSetup(() => + { + SceneParentAutomaticLoader.ValidateMultiSceneSetupAndLoadDefaultSceneParents(); + ZenUnityEditorUtil.ValidateCurrentSceneSetup(); + Log.Info("All scenes validated successfully"); + }); + } + + [MenuItem("Assets/Create/Zenject/Unit Test", false, 60)] + public static void CreateUnitTest() + { + AddCSharpClassTemplate("Unit Test", "UntitledUnitTest", + "using Zenject;" + + "\nusing NUnit.Framework;" + + "\n" + + "\n[TestFixture]" + + "\npublic class CLASS_NAME : ZenjectUnitTestFixture" + + "\n{" + + "\n [Test]" + + "\n public void RunTest1()" + + "\n {" + + "\n // TODO" + + "\n }" + + "\n}"); + } + + [MenuItem("Assets/Create/Zenject/Integration Test", false, 60)] + public static void CreateIntegrationTest() + { + AddCSharpClassTemplate("Integration Test", "UntitledIntegrationTest", + "using Zenject;" + + "\nusing System.Collections;" + + "\nusing UnityEngine.TestTools;" + + "\n" + + "\npublic class CLASS_NAME : ZenjectIntegrationTestFixture" + + "\n{" + + "\n [UnityTest]" + + "\n public IEnumerator RunTest1()" + + "\n {" + + "\n // Setup initial state by creating game objects from scratch, loading prefabs/scenes, etc" + + "\n" + + "\n PreInstall();" + + "\n" + + "\n // Call Container.Bind methods" + + "\n" + + "\n PostInstall();" + + "\n" + + "\n // Add test assertions for expected state" + + "\n // Using Container.Resolve or [Inject] fields" + + "\n yield break;" + + "\n }" + + "\n}"); + } + + [MenuItem("Assets/Create/Zenject/Scene Test", false, 60)] + public static void CreateSceneTest() + { + AddCSharpClassTemplate("Scene Test Fixture", "UntitledSceneTest", + "using Zenject;" + + "\nusing System.Collections;" + + "\nusing UnityEngine;" + + "\nusing UnityEngine.TestTools;" + + "\n" + + "\npublic class CLASS_NAME : SceneTestFixture" + + "\n{" + + "\n [UnityTest]" + + "\n public IEnumerator TestScene()" + + "\n {" + + "\n yield return LoadScene(\"InsertSceneNameHere\");" + + "\n" + + "\n // TODO: Add assertions here now that the scene has started" + + "\n // Or you can just uncomment to simply wait some time to make sure the scene plays without errors" + + "\n //yield return new WaitForSeconds(1.0f);" + + "\n" + + "\n // Note that you can use SceneContainer.Resolve to look up objects that you need for assertions" + + "\n }" + + "\n}"); + } + } +} +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ZenMenuItems.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ZenMenuItems.cs.meta new file mode 100644 index 0000000..ecb4c7c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ZenMenuItems.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d45338750ad0b4f4b90ed09091927b46 +timeCreated: 1461708053 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ZenUnityEditorUtil.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ZenUnityEditorUtil.cs new file mode 100644 index 0000000..a66f1a2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ZenUnityEditorUtil.cs @@ -0,0 +1,352 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using ModestTree; +using UnityEditor; +using UnityEditor.SceneManagement; +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace Zenject.Internal +{ + public static class ZenUnityEditorUtil + { + // Returns true if succeeds without errors + public static bool SaveThenRunPreserveSceneSetup(Action action) + { + if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) + { + var originalSceneSetup = EditorSceneManager.GetSceneManagerSetup(); + + try + { + action(); + return true; + } + catch (Exception e) + { + Log.ErrorException(e); + return false; + } + finally + { + EditorSceneManager.RestoreSceneManagerSetup(originalSceneSetup); + } + } + + return false; + } + + // Feel free to call this method from an editor script, or a unit test, etc. + // An exception will be thrown if any validation errors are encountered + public static void ValidateCurrentSceneSetup() + { + bool encounteredError = false; + + Application.LogCallback logCallback = (condition, stackTrace, type) => + { + if (type == LogType.Error || type == LogType.Assert + || type == LogType.Exception) + { + encounteredError = true; + } + }; + + Application.logMessageReceived += logCallback; + + try + { + Assert.That(!ProjectContext.HasInstance); + ProjectContext.ValidateOnNextRun = true; + + foreach (var sceneContext in GetAllSceneContexts()) + { + sceneContext.Validate(); + } + } + catch (Exception e) + { + Log.ErrorException(e); + encounteredError = true; + } + finally + { + Application.logMessageReceived -= logCallback; + } + + if (encounteredError) + { + throw new ZenjectException("Zenject Validation Failed! See errors below for details."); + } + } + + // NOTE: An exception will be thrown if any validation errors are encountered + // Returns the number of scenes that successfully validated + public static int ValidateAllActiveScenes() + { + var activeScenePaths = EditorBuildSettings.scenes.Where(x => x.enabled) + .Select(x => x.path).ToList(); + + foreach (var scenePath in activeScenePaths) + { + EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single); + ValidateCurrentSceneSetup(); + } + + return activeScenePaths.Count; + } + + // Don't use this + public static void RunCurrentSceneSetup() + { + Assert.That(!ProjectContext.HasInstance); + + foreach (var sceneContext in GetAllSceneContexts()) + { + try + { + sceneContext.Run(); + } + catch (Exception e) + { + // Add a bit more context + throw new ZenjectException( + "Scene '{0}' Failed To Start!".Fmt(sceneContext.gameObject.scene.name), e); + } + } + } + + public static SceneContext GetSceneContextForScene(Scene scene) + { + var sceneContext = TryGetSceneContextForScene(scene); + + Assert.IsNotNull(sceneContext, + "Could not find scene context for scene '{0}'", scene.name); + + return sceneContext; + } + + public static SceneContext TryGetSceneContextForScene(Scene scene) + { + if (!scene.isLoaded) + { + return null; + } + + var sceneContexts = scene.GetRootGameObjects() + .SelectMany(x => x.GetComponentsInChildren()).ToList(); + + if (sceneContexts.IsEmpty()) + { + return null; + } + + Assert.That(sceneContexts.Count == 1, + "Found multiple SceneContexts in scene '{0}'. Expected a maximum of one.", scene.name); + + return sceneContexts[0]; + } + + public static SceneDecoratorContext GetDecoratorContextForScene(Scene scene) + { + var decoratorContext = TryGetDecoratorContextForScene(scene); + + Assert.IsNotNull(decoratorContext, + "Could not find decorator context for scene '{0}'", scene.name); + + return decoratorContext; + } + + public static SceneDecoratorContext TryGetDecoratorContextForScene(Scene scene) + { + if (!scene.isLoaded) + { + return null; + } + + var decoratorContexts = scene.GetRootGameObjects() + .SelectMany(x => x.GetComponentsInChildren()).ToList(); + + if (decoratorContexts.IsEmpty()) + { + return null; + } + + Assert.That(decoratorContexts.Count == 1, + "Found multiple DecoratorContexts in scene '{0}'. Expected a maximum of one.", scene.name); + + return decoratorContexts[0]; + } + + static IEnumerable GetAllSceneContexts() + { + var decoratedSceneNames = new List(); + + for (int i = 0; i < EditorSceneManager.sceneCount; i++) + { + var scene = EditorSceneManager.GetSceneAt(i); + + var sceneContext = TryGetSceneContextForScene(scene); + var decoratorContext = TryGetDecoratorContextForScene(scene); + + if (sceneContext != null) + { + Assert.That(decoratorContext == null, + "Found both SceneDecoratorContext and SceneContext in the same scene '{0}'. This is not allowed", scene.name); + + decoratedSceneNames.RemoveAll(x => sceneContext.ContractNames.Contains(x)); + + yield return sceneContext; + } + else if (decoratorContext != null) + { + Assert.That(!string.IsNullOrEmpty(decoratorContext.DecoratedContractName), + "Missing Decorated Contract Name on SceneDecoratorContext in scene '{0}'", scene.name); + + decoratedSceneNames.Add(decoratorContext.DecoratedContractName); + } + } + + Assert.That(decoratedSceneNames.IsEmpty(), + "Found decorator scenes without a corresponding scene to decorator. Missing scene contracts: {0}", decoratedSceneNames.Join(", ")); + } + + public static string ConvertAssetPathToAbsolutePath(string assetPath) + { + return Path.Combine( + Path.Combine(Path.GetFullPath(Application.dataPath), ".."), assetPath); + } + + public static string ConvertFullAbsolutePathToAssetPath(string fullPath) + { + fullPath = Path.GetFullPath(fullPath); + + var assetFolderFullPath = Path.GetFullPath(Application.dataPath); + + if (fullPath.Length == assetFolderFullPath.Length) + { + Assert.IsEqual(fullPath, assetFolderFullPath); + return "Assets"; + } + + var assetPath = fullPath.Remove(0, assetFolderFullPath.Length + 1).Replace("\\", "/"); + return "Assets/" + assetPath; + } + + public static string GetCurrentDirectoryAssetPathFromSelection() + { + return ConvertFullAbsolutePathToAssetPath( + GetCurrentDirectoryAbsolutePathFromSelection()); + } + + public static string GetCurrentDirectoryAbsolutePathFromSelection() + { + var folderPath = TryGetSelectedFolderPathInProjectsTab(); + + if (folderPath != null) + { + return folderPath; + } + + var filePath = TryGetSelectedFilePathInProjectsTab(); + + if (filePath != null) + { + return Path.GetDirectoryName(filePath); + } + + return Application.dataPath; + } + + public static string TryGetSelectedFilePathInProjectsTab() + { + return GetSelectedFilePathsInProjectsTab().OnlyOrDefault(); + } + + public static List GetSelectedFilePathsInProjectsTab() + { + return GetSelectedPathsInProjectsTab() + .Where(x => File.Exists(x)).ToList(); + } + + public static List GetSelectedAssetPathsInProjectsTab() + { + var paths = new List(); + + UnityEngine.Object[] selectedAssets = Selection.GetFiltered( + typeof(UnityEngine.Object), SelectionMode.Assets); + + foreach (var item in selectedAssets) + { + var assetPath = AssetDatabase.GetAssetPath(item); + + if (!string.IsNullOrEmpty(assetPath)) + { + paths.Add(assetPath); + } + } + + return paths; + } + + public static List GetSelectedPathsInProjectsTab() + { + var paths = new List(); + + UnityEngine.Object[] selectedAssets = Selection.GetFiltered( + typeof(UnityEngine.Object), SelectionMode.Assets); + + foreach (var item in selectedAssets) + { + var relativePath = AssetDatabase.GetAssetPath(item); + + if (!string.IsNullOrEmpty(relativePath)) + { + var fullPath = Path.GetFullPath(Path.Combine( + Application.dataPath, Path.Combine("..", relativePath))); + + paths.Add(fullPath); + } + } + + return paths; + } + + // Taken from http://wiki.unity3d.com/index.php?title=CreateScriptableObjectAsset + public static void SaveScriptableObjectAsset( + string path, ScriptableObject asset) + { + Assert.That(path.EndsWith(".asset")); + + string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path); + + AssetDatabase.CreateAsset(asset, assetPathAndName); + + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + EditorUtility.FocusProjectWindow(); + Selection.activeObject = asset; + } + + // Note that the path is relative to the Assets folder + public static List GetSelectedFolderPathsInProjectsTab() + { + return GetSelectedPathsInProjectsTab() + .Where(x => Directory.Exists(x)).ToList(); + } + + // Returns the best guess directory in projects pane + // Useful when adding to Assets -> Create context menu + // Returns null if it can't find one + // Note that the path is relative to the Assets folder for use in AssetDatabase.GenerateUniqueAssetPath etc. + public static string TryGetSelectedFolderPathInProjectsTab() + { + return GetSelectedFolderPathsInProjectsTab().OnlyOrDefault(); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ZenUnityEditorUtil.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ZenUnityEditorUtil.cs.meta new file mode 100644 index 0000000..1d8cef7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/ZenUnityEditorUtil.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f798e3a2f0079b840804c0516d265f03 +timeCreated: 1461710838 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Zenject-Editor.asmdef b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Zenject-Editor.asmdef new file mode 100644 index 0000000..929b03c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Zenject-Editor.asmdef @@ -0,0 +1,10 @@ +{ + "name": "Zenject-Editor", + "references": [ + "Zenject" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [] +} \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Zenject-Editor.asmdef.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Zenject-Editor.asmdef.meta new file mode 100644 index 0000000..1bf0b4c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Editor/Zenject-Editor.asmdef.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d0acddb179989574c8355991596bd3e6 +timeCreated: 1531030222 +licenseType: Store +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories.meta new file mode 100644 index 0000000..4230331 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 2750a8b0a1173074e9387536c12de4f7 +folderAsset: yes +DefaultImporter: + userData: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/FactoryProviderWrapper.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/FactoryProviderWrapper.cs new file mode 100644 index 0000000..30a887f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/FactoryProviderWrapper.cs @@ -0,0 +1,36 @@ +using ModestTree; + +namespace Zenject +{ + public class FactoryProviderWrapper : IFactory + { + readonly IProvider _provider; + readonly InjectContext _injectContext; + + public FactoryProviderWrapper( + IProvider provider, InjectContext injectContext) + { + Assert.That(injectContext.MemberType.DerivesFromOrEqual()); + + _provider = provider; + _injectContext = injectContext; + } + + public TContract Create() + { + var instance = _provider.GetInstance(_injectContext); + + if (_injectContext.Container.IsValidating) + { + // During validation it is sufficient to just call the _provider.GetInstance + return default(TContract); + } + + Assert.That(instance == null + || instance.GetType().DerivesFromOrEqual(_injectContext.MemberType)); + + return (TContract)instance; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/FactoryProviderWrapper.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/FactoryProviderWrapper.cs.meta new file mode 100644 index 0000000..aaddbfb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/FactoryProviderWrapper.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f1157303ef95f2448a355067327cb83a +timeCreated: 1488133028 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/IFactory.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/IFactory.cs new file mode 100644 index 0000000..f62fe0d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/IFactory.cs @@ -0,0 +1,62 @@ +namespace Zenject +{ + public interface IFactory + { + } + + public interface IFactory : IFactory + { + TValue Create(); + } + + public interface IFactory : IFactory + { + TValue Create(TParam1 param); + } + + public interface IFactory : IFactory + { + TValue Create(TParam1 param1, TParam2 param2); + } + + public interface IFactory : IFactory + { + TValue Create(TParam1 param1, TParam2 param2, TParam3 param3); + } + + public interface IFactory : IFactory + { + TValue Create(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4); + } + + public interface IFactory : IFactory + { + TValue Create(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5); + } + + public interface IFactory : IFactory + { + TValue Create(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6); + } + + public interface IFactory : IFactory + { + TValue Create(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6, TParam7 param7); + } + + public interface IFactory : IFactory + { + TValue Create(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6, TParam7 param7, TParam8 param8); + } + + public interface IFactory : IFactory + { + TValue Create(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6, TParam7 param7, TParam8 param8, TParam9 param9); + } + + public interface IFactory : IFactory + { + TValue Create(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6, TParam7 param7, TParam8 param8, TParam9 param9, TParam10 param10); + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/IFactory.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/IFactory.cs.meta new file mode 100644 index 0000000..2df5a90 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/IFactory.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 62c651ad6c58c1140ac224dc6284fa5e +timeCreated: 1461708050 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/KeyedFactory.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/KeyedFactory.cs new file mode 100644 index 0000000..f8f6cac --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/KeyedFactory.cs @@ -0,0 +1,193 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using ModestTree.Util; + +namespace Zenject +{ + public abstract class KeyedFactoryBase : IValidatable + { + [Inject] + readonly DiContainer _container = null; + + [InjectOptional] + readonly List> _typePairs = null; + + Dictionary _typeMap = null; + + [InjectOptional] + readonly Type _fallbackType = null; + + protected DiContainer Container + { + get { return _container; } + } + + protected abstract IEnumerable ProvidedTypes + { + get; + } + + public ICollection Keys + { + get { return _typeMap.Keys; } + } + + protected Dictionary TypeMap + { + get { return _typeMap; } + } + + [Inject] + public void Initialize() + { + Assert.That(_fallbackType == null || _fallbackType.DerivesFromOrEqual(), + "Expected fallback type '{0}' to derive from '{1}'", _fallbackType, typeof(TBase)); + +#if UNITY_EDITOR + var duplicates = _typePairs.Select(x => x.First).GetDuplicates(); + + if (!duplicates.IsEmpty()) + { + throw Assert.CreateException( + "Found duplicate values in KeyedFactory: {0}", duplicates.Select(x => x.ToString()).Join(", ")); + } +#endif + + _typeMap = _typePairs.ToDictionary(x => x.First, x => x.Second); + _typePairs.Clear(); + } + + public bool HasKey(TKey key) + { + return _typeMap.ContainsKey(key); + } + + protected Type GetTypeForKey(TKey key) + { + Type keyedType; + + if (!_typeMap.TryGetValue(key, out keyedType)) + { + Assert.IsNotNull(_fallbackType, "Could not find instance for key '{0}'", key); + return _fallbackType; + } + + return keyedType; + } + + public virtual void Validate() + { + foreach (var constructType in _typeMap.Values) + { + Container.InstantiateExplicit( + constructType, ValidationUtil.CreateDefaultArgs(ProvidedTypes.ToArray())); + } + } + + protected static ConditionCopyNonLazyBinder AddBindingInternal(DiContainer container, TKey key) + where TDerived : TBase + { + return container.Bind>() + .FromInstance(ValuePair.New(key, typeof(TDerived))); + } + } + + // Zero parameters + public class KeyedFactory : KeyedFactoryBase + { + protected override IEnumerable ProvidedTypes + { + get { return new Type[0]; } + } + + public virtual TBase Create(TKey key) + { + var type = GetTypeForKey(key); + return (TBase)Container.Instantiate(type); + } + } + + // One parameter + public class KeyedFactory : KeyedFactoryBase + { + protected override IEnumerable ProvidedTypes + { + get { return new[] { typeof(TParam1) }; } + } + + public virtual TBase Create(TKey key, TParam1 param1) + { + return (TBase)Container.InstantiateExplicit( + GetTypeForKey(key), + new List + { + InjectUtil.CreateTypePair(param1) + }); + } + } + + // Two parameters + public class KeyedFactory : KeyedFactoryBase + { + protected override IEnumerable ProvidedTypes + { + get { return new[] { typeof(TParam1), typeof(TParam2) }; } + } + + public virtual TBase Create(TKey key, TParam1 param1, TParam2 param2) + { + return (TBase)Container.InstantiateExplicit( + GetTypeForKey(key), + new List + { + InjectUtil.CreateTypePair(param1), + InjectUtil.CreateTypePair(param2) + }); + } + } + + // Three parameters + public class KeyedFactory : KeyedFactoryBase + { + protected override IEnumerable ProvidedTypes + { + get { return new[] { typeof(TParam1), typeof(TParam2), typeof(TParam3) }; } + } + + public virtual TBase Create(TKey key, TParam1 param1, TParam2 param2, TParam3 param3) + { + return (TBase)Container.InstantiateExplicit( + GetTypeForKey(key), + new List + { + InjectUtil.CreateTypePair(param1), + InjectUtil.CreateTypePair(param2), + InjectUtil.CreateTypePair(param3) + }); + } + } + + // Four parameters + public class KeyedFactory : KeyedFactoryBase + { + protected override IEnumerable ProvidedTypes + { + get { return new[] { typeof(TParam1), typeof(TParam2), typeof(TParam3), typeof(TParam4) }; } + } + + public virtual TBase Create(TKey key, TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4) + { + return (TBase)Container.InstantiateExplicit( + GetTypeForKey(key), + new List + { + InjectUtil.CreateTypePair(param1), + InjectUtil.CreateTypePair(param2), + InjectUtil.CreateTypePair(param3), + InjectUtil.CreateTypePair(param4) + }); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/KeyedFactory.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/KeyedFactory.cs.meta new file mode 100644 index 0000000..4ae7065 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/KeyedFactory.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 73ed4b67b639aaf4c94f61339a6ff413 +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PlaceholderFactory.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PlaceholderFactory.cs new file mode 100644 index 0000000..1e3afe7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PlaceholderFactory.cs @@ -0,0 +1,302 @@ +using System; +using System.Collections.Generic; +#if !NOT_UNITY3D +using JetBrains.Annotations; +#endif + +namespace Zenject +{ + // Zero parameters + public class PlaceholderFactory : PlaceholderFactoryBase, IFactory + { + // Note: Most of the time you should not override this method and should instead + // use BindFactory<>.FromIFactory if you want to do some custom logic +#if !NOT_UNITY3D + [NotNull] +#endif + public virtual TValue Create() + { + return CreateInternal(new List()); + } + + protected sealed override IEnumerable ParamTypes + { + get { yield break; } + } + } + + [Obsolete("Zenject.Factory has been renamed to PlaceholderFactory. Zenject.Factory will be removed in future versions")] + public class Factory : PlaceholderFactory + { + } + + // One parameter + public class PlaceholderFactory + : PlaceholderFactoryBase, IFactory + { + // Note: Most of the time you should not override this method and should instead + // use BindFactory<>.FromIFactory if you want to do some custom logic +#if !NOT_UNITY3D + [NotNull] +#endif + public virtual TValue Create(TParam1 param) + { + return CreateInternal( + new List + { + InjectUtil.CreateTypePair(param) + }); + } + + protected sealed override IEnumerable ParamTypes + { + get { yield return typeof(TParam1); } + } + } + + [Obsolete("Zenject.Factory has been renamed to PlaceholderFactory. Zenject.Factory will be removed in future versions")] + public class Factory : PlaceholderFactory + { + } + + // Two parameters + public class PlaceholderFactory + : PlaceholderFactoryBase, IFactory + { + // Note: Most of the time you should not override this method and should instead + // use BindFactory<>.FromIFactory if you want to do some custom logic +#if !NOT_UNITY3D + [NotNull] +#endif + public virtual TValue Create(TParam1 param1, TParam2 param2) + { + return CreateInternal( + new List + { + InjectUtil.CreateTypePair(param1), + InjectUtil.CreateTypePair(param2) + }); + } + + protected sealed override IEnumerable ParamTypes + { + get + { + yield return typeof(TParam1); + yield return typeof(TParam2); + } + } + } + + [Obsolete("Zenject.Factory has been renamed to PlaceholderFactory. Zenject.Factory will be removed in future versions")] + public class Factory : PlaceholderFactory + { + } + + // Three parameters + public class PlaceholderFactory + : PlaceholderFactoryBase, IFactory + { + // Note: Most of the time you should not override this method and should instead + // use BindFactory<>.FromIFactory if you want to do some custom logic +#if !NOT_UNITY3D + [NotNull] +#endif + public virtual TValue Create(TParam1 param1, TParam2 param2, TParam3 param3) + { + return CreateInternal( + new List + { + InjectUtil.CreateTypePair(param1), + InjectUtil.CreateTypePair(param2), + InjectUtil.CreateTypePair(param3) + }); + } + + protected sealed override IEnumerable ParamTypes + { + get + { + yield return typeof(TParam1); + yield return typeof(TParam2); + yield return typeof(TParam3); + } + } + } + + [Obsolete("Zenject.Factory has been renamed to PlaceholderFactory. Zenject.Factory will be removed in future versions")] + public class Factory : PlaceholderFactory + { + } + + // Four parameters + public class PlaceholderFactory + : PlaceholderFactoryBase, IFactory + { + // Note: Most of the time you should not override this method and should instead + // use BindFactory<>.FromIFactory if you want to do some custom logic +#if !NOT_UNITY3D + [NotNull] +#endif + public virtual TValue Create(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4) + { + return CreateInternal( + new List + { + InjectUtil.CreateTypePair(param1), + InjectUtil.CreateTypePair(param2), + InjectUtil.CreateTypePair(param3), + InjectUtil.CreateTypePair(param4) + }); + } + + protected sealed override IEnumerable ParamTypes + { + get + { + yield return typeof(TParam1); + yield return typeof(TParam2); + yield return typeof(TParam3); + yield return typeof(TParam4); + } + } + } + + [Obsolete("Zenject.Factory has been renamed to PlaceholderFactory. Zenject.Factory will be removed in future versions")] + public class Factory + : PlaceholderFactory + { + } + + // Five parameters + public class PlaceholderFactory + : PlaceholderFactoryBase, IFactory + { + // Note: Most of the time you should not override this method and should instead + // use BindFactory<>.FromIFactory if you want to do some custom logic +#if !NOT_UNITY3D + [NotNull] +#endif + public virtual TValue Create(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5) + { + return CreateInternal( + new List + { + InjectUtil.CreateTypePair(param1), + InjectUtil.CreateTypePair(param2), + InjectUtil.CreateTypePair(param3), + InjectUtil.CreateTypePair(param4), + InjectUtil.CreateTypePair(param5) + }); + } + + protected sealed override IEnumerable ParamTypes + { + get + { + yield return typeof(TParam1); + yield return typeof(TParam2); + yield return typeof(TParam3); + yield return typeof(TParam4); + yield return typeof(TParam5); + } + } + } + + [Obsolete("Zenject.Factory has been renamed to PlaceholderFactory. Zenject.Factory will be removed in future versions")] + public class Factory + : PlaceholderFactory + { + } + + // Six parameters + public class PlaceholderFactory + : PlaceholderFactoryBase, IFactory + { + // Note: Most of the time you should not override this method and should instead + // use BindFactory<>.FromIFactory if you want to do some custom logic +#if !NOT_UNITY3D + [NotNull] +#endif + public virtual TValue Create(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6) + { + return CreateInternal( + new List + { + InjectUtil.CreateTypePair(param1), + InjectUtil.CreateTypePair(param2), + InjectUtil.CreateTypePair(param3), + InjectUtil.CreateTypePair(param4), + InjectUtil.CreateTypePair(param5), + InjectUtil.CreateTypePair(param6) + }); + } + + protected sealed override IEnumerable ParamTypes + { + get + { + yield return typeof(TParam1); + yield return typeof(TParam2); + yield return typeof(TParam3); + yield return typeof(TParam4); + yield return typeof(TParam5); + yield return typeof(TParam6); + } + } + } + + [Obsolete("Zenject.Factory has been renamed to PlaceholderFactory. Zenject.Factory will be removed in future versions")] + public class Factory + : PlaceholderFactory + { + } + + // Ten parameters + public class PlaceholderFactory + : PlaceholderFactoryBase, IFactory + { + // If you were hoping to override this method, use BindFactory<>.ToFactory instead + public virtual TValue Create(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6, TParam7 param7, TParam8 param8, TParam9 param9, TParam10 param10) + { + return CreateInternal( + new List + { + InjectUtil.CreateTypePair(param1), + InjectUtil.CreateTypePair(param2), + InjectUtil.CreateTypePair(param3), + InjectUtil.CreateTypePair(param4), + InjectUtil.CreateTypePair(param5), + InjectUtil.CreateTypePair(param6), + InjectUtil.CreateTypePair(param7), + InjectUtil.CreateTypePair(param8), + InjectUtil.CreateTypePair(param9), + InjectUtil.CreateTypePair(param10) + }); + } + + protected sealed override IEnumerable ParamTypes + { + get + { + yield return typeof(TParam1); + yield return typeof(TParam2); + yield return typeof(TParam3); + yield return typeof(TParam4); + yield return typeof(TParam5); + yield return typeof(TParam6); + yield return typeof(TParam7); + yield return typeof(TParam8); + yield return typeof(TParam9); + yield return typeof(TParam10); + } + } + } + + [Obsolete("Zenject.Factory has been renamed to PlaceholderFactory. Zenject.Factory will be removed in future versions")] + public class Factory + : PlaceholderFactory + { + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PlaceholderFactory.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PlaceholderFactory.cs.meta new file mode 100644 index 0000000..bd9ef23 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PlaceholderFactory.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 665a56f53857092408155478e576cfd0 +timeCreated: 1486691381 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PlaceholderFactoryBase.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PlaceholderFactoryBase.cs new file mode 100644 index 0000000..be43001 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PlaceholderFactoryBase.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; + +namespace Zenject +{ + public interface IPlaceholderFactory : IValidatable + { + } + + // Placeholder factories can be used to choose a creation method in an installer, using FactoryBinder + public abstract class PlaceholderFactoryBase : IPlaceholderFactory + { + IProvider _provider; + InjectContext _injectContext; + + [Inject] + void Construct(IProvider provider, InjectContext injectContext) + { + Assert.IsNotNull(provider); + Assert.IsNotNull(injectContext); + + _provider = provider; + _injectContext = injectContext; + } + + protected TValue CreateInternal(List extraArgs) + { + try + { + var result = _provider.GetInstance(_injectContext, extraArgs); + + if (_injectContext.Container.IsValidating && result is ValidationMarker) + { + return default(TValue); + } + + Assert.That(result == null || result.GetType().DerivesFromOrEqual()); + + return (TValue) result; + } + catch (Exception e) + { + throw new ZenjectException( + "Error during construction of type '{0}' via {1}.Create method!".Fmt(typeof(TValue), GetType()), e); + } + } + + public virtual void Validate() + { + _provider.GetInstance( + _injectContext, ValidationUtil.CreateDefaultArgs(ParamTypes.ToArray())); + } + + protected abstract IEnumerable ParamTypes + { + get; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PlaceholderFactoryBase.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PlaceholderFactoryBase.cs.meta new file mode 100644 index 0000000..c556dbb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PlaceholderFactoryBase.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2a15cf923ae4d72418e9951480e9f178 +timeCreated: 1527952932 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling.meta new file mode 100644 index 0000000..a485239 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0f3fb191ad2b6c74c97f488543a89c82 +folderAsset: yes +timeCreated: 1484511595 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/IMemoryPool.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/IMemoryPool.cs new file mode 100644 index 0000000..185e0fe --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/IMemoryPool.cs @@ -0,0 +1,90 @@ +using System; + +namespace Zenject +{ + public interface IMemoryPool + { + int NumTotal { get; } + int NumActive { get; } + int NumInactive { get; } + + Type ItemType + { + get; + } + + /// + /// Changes pool size by creating new elements or destroying existing elements + /// This bypasses the configured expansion method (OneAtATime or Doubling) + /// + void Resize(int desiredPoolSize); + + void Clear(); + + /// + /// Expands the pool by the additional size. + /// This bypasses the configured expansion method (OneAtATime or Doubling) + /// + /// The additional number of items to allocate in the pool + void ExpandBy(int numToAdd); + + /// + /// Shrinks the MemoryPool by removing a given number of elements + /// This bypasses the configured expansion method (OneAtATime or Doubling) + /// + /// The amount of items to remove from the pool + void ShrinkBy(int numToRemove); + + void Despawn(object obj); + } + + public interface IDespawnableMemoryPool : IMemoryPool + { + void Despawn(TValue item); + } + + public interface IMemoryPool : IDespawnableMemoryPool + { + TValue Spawn(); + } + + public interface IMemoryPool : IDespawnableMemoryPool + { + TValue Spawn(TParam1 param); + } + + public interface IMemoryPool : IDespawnableMemoryPool + { + TValue Spawn(TParam1 param1, TParam2 param2); + } + + public interface IMemoryPool : IDespawnableMemoryPool + { + TValue Spawn(TParam1 param1, TParam2 param2, TParam3 param3); + } + + public interface IMemoryPool : IDespawnableMemoryPool + { + TValue Spawn(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4); + } + + public interface IMemoryPool : IDespawnableMemoryPool + { + TValue Spawn(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5); + } + + public interface IMemoryPool : IDespawnableMemoryPool + { + TValue Spawn(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6); + } + + public interface IMemoryPool : IDespawnableMemoryPool + { + TValue Spawn(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6, TParam7 param7); + } + + public interface IMemoryPool : IDespawnableMemoryPool + { + TValue Spawn(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6, TParam7 param7, TParam8 param8); + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/IMemoryPool.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/IMemoryPool.cs.meta new file mode 100644 index 0000000..afd4b6d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/IMemoryPool.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 13b8377ec575a1a44a1028ee324ba17a +timeCreated: 1485699960 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MemoryPool.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MemoryPool.cs new file mode 100644 index 0000000..89356d9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MemoryPool.cs @@ -0,0 +1,316 @@ +namespace Zenject +{ + // Zero parameters + public class MemoryPool : MemoryPoolBase, IMemoryPool, IFactory + { + public TValue Spawn() + { + var item = GetInternal(); + + if (!Container.IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.Reinitialize", GetType())) +#endif + { + Reinitialize(item); + } + } + return item; + } + + protected virtual void Reinitialize(TValue item) + { + // Optional + } + + TValue IFactory.Create() + { + return Spawn(); + } + } + + // One parameter + public class MemoryPool + : MemoryPoolBase, IMemoryPool, IFactory + { + public TValue Spawn(TParam1 param) + { + var item = GetInternal(); + + if (!Container.IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.Reinitialize", GetType())) +#endif + { + Reinitialize(param, item); + } + } + + return item; + } + + protected virtual void Reinitialize(TParam1 p1, TValue item) + { + // Optional + } + + TValue IFactory.Create(TParam1 p1) + { + return Spawn(p1); + } + } + + // Two parameters + public class MemoryPool + : MemoryPoolBase, IMemoryPool, IFactory + { + public TValue Spawn(TParam1 param1, TParam2 param2) + { + var item = GetInternal(); + + if (!Container.IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.Reinitialize", GetType())) +#endif + { + Reinitialize(param1, param2, item); + } + } + + return item; + } + + protected virtual void Reinitialize(TParam1 p1, TParam2 p2, TValue item) + { + // Optional + } + + TValue IFactory.Create(TParam1 p1, TParam2 p2) + { + return Spawn(p1, p2); + } + } + + // Three parameters + public class MemoryPool + : MemoryPoolBase, IMemoryPool, IFactory + { + public TValue Spawn(TParam1 param1, TParam2 param2, TParam3 param3) + { + var item = GetInternal(); + + if (!Container.IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.Reinitialize", GetType())) +#endif + { + Reinitialize(param1, param2, param3, item); + } + } + return item; + } + + protected virtual void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TValue item) + { + // Optional + } + + TValue IFactory.Create(TParam1 p1, TParam2 p2, TParam3 p3) + { + return Spawn(p1, p2, p3); + } + } + + // Four parameters + public class MemoryPool + : MemoryPoolBase, IMemoryPool, IFactory + { + public TValue Spawn(TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4) + { + var item = GetInternal(); + + if (!Container.IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.Reinitialize", GetType())) +#endif + { + Reinitialize(param1, param2, param3, param4, item); + } + } + return item; + } + + protected virtual void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TValue item) + { + // Optional + } + + TValue IFactory.Create(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4) + { + return Spawn(p1, p2, p3, p4); + } + } + + // Five parameters + public class MemoryPool + : MemoryPoolBase, IMemoryPool, IFactory + { + public TValue Spawn( + TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5) + { + var item = GetInternal(); + if (!Container.IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.Reinitialize", GetType())) +#endif + { + Reinitialize(param1, param2, param3, param4, param5, item); + } + } + return item; + } + + protected virtual void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TValue item) + { + // Optional + } + + TValue IFactory.Create(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5) + { + return Spawn(p1, p2, p3, p4, p5); + } + } + + // Six parameters + public class MemoryPool + : MemoryPoolBase, IMemoryPool, + IFactory + { + public TValue Spawn( + TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6) + { + var item = GetInternal(); + + if (!Container.IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.Reinitialize", GetType())) +#endif + { + Reinitialize(param1, param2, param3, param4, param5, param6, item); + } + } + return item; + } + + protected virtual void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TValue item) + { + // Optional + } + + TValue IFactory.Create(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6) + { + return Spawn(p1, p2, p3, p4, p5, p6); + } + } + + // Seven parameters + public class MemoryPool + : MemoryPoolBase, IMemoryPool, + IFactory + { + public TValue Spawn( + TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6, TParam7 param7) + { + var item = GetInternal(); + + if (!Container.IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.Reinitialize", GetType())) +#endif + { + Reinitialize(param1, param2, param3, param4, param5, param6, param7, item); + } + } + return item; + } + + protected virtual void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TParam7 p7, TValue item) + { + // Optional + } + + TValue IFactory.Create(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TParam7 p7) + { + return Spawn(p1, p2, p3, p4, p5, p6, p7); + } + } + + // Eight parameters + public class MemoryPool + : MemoryPoolBase, IMemoryPool, + IFactory + { + public TValue Spawn( + TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6, TParam7 param7, TParam8 param8) + { + var item = GetInternal(); + + if (!Container.IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.Reinitialize", GetType())) +#endif + { + Reinitialize(param1, param2, param3, param4, param5, param6, param7, param8, item); + } + } + return item; + } + + protected virtual void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TParam7 p7, TParam8 p8, TValue item) + { + // Optional + } + + TValue IFactory.Create( + TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TParam7 p7, TParam8 p8) + { + return Spawn(p1, p2, p3, p4, p5, p6, p7, p8); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MemoryPool.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MemoryPool.cs.meta new file mode 100644 index 0000000..c9ea95f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MemoryPool.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 305d88c8b2af3f2479cb45ffb6f2923c +timeCreated: 1485699960 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MemoryPoolBase.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MemoryPoolBase.cs new file mode 100644 index 0000000..deab0be --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MemoryPoolBase.cs @@ -0,0 +1,290 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class PoolExceededFixedSizeException : Exception + { + public PoolExceededFixedSizeException(string errorMessage) + : base(errorMessage) + { + } + } + + [Serializable] + public class MemoryPoolSettings + { + public int InitialSize; + public int MaxSize; + public PoolExpandMethods ExpandMethod; + + public MemoryPoolSettings() + { + InitialSize = 0; + MaxSize = int.MaxValue; + ExpandMethod = PoolExpandMethods.OneAtATime; + } + + public MemoryPoolSettings(int initialSize, int maxSize, PoolExpandMethods expandMethod) + { + InitialSize = initialSize; + MaxSize = maxSize; + ExpandMethod = expandMethod; + } + + public static readonly MemoryPoolSettings Default = new MemoryPoolSettings(); + } + + [ZenjectAllowDuringValidation] + public class MemoryPoolBase : IValidatable, IMemoryPool, IDisposable + { + Stack _inactiveItems; + IFactory _factory; + MemoryPoolSettings _settings; + DiContainer _container; + + int _activeCount; + + [Inject] + void Construct( + IFactory factory, + DiContainer container, + [InjectOptional] + MemoryPoolSettings settings) + { + _settings = settings ?? MemoryPoolSettings.Default; + _factory = factory; + _container = container; + + _inactiveItems = new Stack(_settings.InitialSize); + + if (!container.IsValidating) + { + for (int i = 0; i < _settings.InitialSize; i++) + { + _inactiveItems.Push(AllocNew()); + } + } + +#if UNITY_EDITOR + StaticMemoryPoolRegistry.Add(this); +#endif + } + + protected DiContainer Container + { + get { return _container; } + } + + public IEnumerable InactiveItems + { + get { return _inactiveItems; } + } + + public int NumTotal + { + get { return NumInactive + NumActive; } + } + + public int NumInactive + { + get { return _inactiveItems.Count; } + } + + public int NumActive + { + get { return _activeCount; } + } + + public Type ItemType + { + get { return typeof(TContract); } + } + + public void Dispose() + { +#if UNITY_EDITOR + StaticMemoryPoolRegistry.Remove(this); +#endif + } + + void IMemoryPool.Despawn(object item) + { + Despawn((TContract)item); + } + + public void Despawn(TContract item) + { + Assert.That(!_inactiveItems.Contains(item), + "Tried to return an item to pool {0} twice", GetType()); + + _activeCount--; + + _inactiveItems.Push(item); + +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.OnDespawned", GetType())) +#endif + { + OnDespawned(item); + } + + if (_inactiveItems.Count > _settings.MaxSize) + { + Resize(_settings.MaxSize); + } + } + + TContract AllocNew() + { + try + { + var item = _factory.Create(); + + if (!_container.IsValidating) + { + Assert.IsNotNull(item, "Factory '{0}' returned null value when creating via {1}!", _factory.GetType(), GetType()); + OnCreated(item); + } + + return item; + } + catch (Exception e) + { + throw new ZenjectException( + "Error during construction of type '{0}' via {1}.Create method!".Fmt( + typeof(TContract), GetType()), e); + } + } + + void IValidatable.Validate() + { + try + { + _factory.Create(); + } + catch (Exception e) + { + throw new ZenjectException( + "Validation for factory '{0}' failed".Fmt(GetType()), e); + } + } + + public void Clear() + { + Resize(0); + } + + public void ShrinkBy(int numToRemove) + { + Resize(_inactiveItems.Count - numToRemove); + } + + public void ExpandBy(int numToAdd) + { + Resize(_inactiveItems.Count + numToAdd); + } + + protected TContract GetInternal() + { + if (_inactiveItems.Count == 0) + { + ExpandPool(); + Assert.That(!_inactiveItems.IsEmpty()); + } + + var item = _inactiveItems.Pop(); + _activeCount++; + OnSpawned(item); + return item; + } + + public void Resize(int desiredPoolSize) + { + if (_inactiveItems.Count == desiredPoolSize) + { + return; + } + + if (_settings.ExpandMethod == PoolExpandMethods.Disabled) + { + throw new PoolExceededFixedSizeException( + "Pool factory '{0}' attempted resize but pool set to fixed size of '{1}'!" + .Fmt(GetType(), _inactiveItems.Count)); + } + + Assert.That(desiredPoolSize >= 0, "Attempted to resize the pool to a negative amount"); + + while (_inactiveItems.Count > desiredPoolSize) + { + OnDestroyed(_inactiveItems.Pop()); + } + + while (desiredPoolSize > _inactiveItems.Count) + { + _inactiveItems.Push(AllocNew()); + } + + Assert.IsEqual(_inactiveItems.Count, desiredPoolSize); + } + + void ExpandPool() + { + switch (_settings.ExpandMethod) + { + case PoolExpandMethods.Disabled: + { + throw new PoolExceededFixedSizeException( + "Pool factory '{0}' exceeded its fixed size of '{1}'!" + .Fmt(GetType(), _inactiveItems.Count)); + } + case PoolExpandMethods.OneAtATime: + { + ExpandBy(1); + break; + } + case PoolExpandMethods.Double: + { + if (NumTotal == 0) + { + ExpandBy(1); + } + else + { + ExpandBy(NumTotal); + } + break; + } + default: + { + throw Assert.CreateException(); + } + } + } + + protected virtual void OnDespawned(TContract item) + { + // Optional + } + + protected virtual void OnSpawned(TContract item) + { + // Optional + } + + protected virtual void OnCreated(TContract item) + { + // Optional + } + + protected virtual void OnDestroyed(TContract item) + { + // Optional + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MemoryPoolBase.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MemoryPoolBase.cs.meta new file mode 100644 index 0000000..633217f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MemoryPoolBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ba9d727a5d866fb46a576ab76012b727 +timeCreated: 1485703991 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MonoMemoryPool.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MonoMemoryPool.cs new file mode 100644 index 0000000..9428957 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MonoMemoryPool.cs @@ -0,0 +1,254 @@ +using UnityEngine; + +namespace Zenject +{ + // Zero parameters + // NOTE: For this to work, the given component must be at the root game object of the thing + // you want to use in a pool + public class MonoMemoryPool : MemoryPool + where TValue : Component + { + Transform _originalParent; + + [Inject] + public MonoMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + // Record the original parent which will be set to whatever is used in the UnderTransform method + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnSpawned(TValue item) + { + item.gameObject.SetActive(true); + } + + protected override void OnDespawned(TValue item) + { + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + } + + // One parameter + // NOTE: For this to work, the given component must be at the root game object of the thing + // you want to use in a pool + public class MonoMemoryPool : MemoryPool + where TValue : Component + { + Transform _originalParent; + + [Inject] + public MonoMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + // Record the original parent which will be set to whatever is used in the UnderTransform method + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnSpawned(TValue item) + { + item.gameObject.SetActive(true); + } + + protected override void OnDespawned(TValue item) + { + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + } + + // Two parameters + // NOTE: For this to work, the given component must be at the root game object of the thing + // you want to use in a pool + public class MonoMemoryPool + : MemoryPool + where TValue : Component + { + Transform _originalParent; + + [Inject] + public MonoMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + // Record the original parent which will be set to whatever is used in the UnderTransform method + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnSpawned(TValue item) + { + item.gameObject.SetActive(true); + } + + protected override void OnDespawned(TValue item) + { + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + } + + // Three parameters + // NOTE: For this to work, the given component must be at the root game object of the thing + // you want to use in a pool + public class MonoMemoryPool + : MemoryPool + where TValue : Component + { + Transform _originalParent; + + [Inject] + public MonoMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + // Record the original parent which will be set to whatever is used in the UnderTransform method + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnSpawned(TValue item) + { + item.gameObject.SetActive(true); + } + + protected override void OnDespawned(TValue item) + { + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + } + + // Four parameters + // NOTE: For this to work, the given component must be at the root game object of the thing + // you want to use in a pool + public class MonoMemoryPool + : MemoryPool + where TValue : Component + { + Transform _originalParent; + + [Inject] + public MonoMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + // Record the original parent which will be set to whatever is used in the UnderTransform method + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnSpawned(TValue item) + { + item.gameObject.SetActive(true); + } + + protected override void OnDespawned(TValue item) + { + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + } + + // Five parameters + // NOTE: For this to work, the given component must be at the root game object of the thing + // you want to use in a pool + public class MonoMemoryPool + : MemoryPool + where TValue : Component + { + Transform _originalParent; + + [Inject] + public MonoMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + // Record the original parent which will be set to whatever is used in the UnderTransform method + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnSpawned(TValue item) + { + item.gameObject.SetActive(true); + } + + protected override void OnDespawned(TValue item) + { + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MonoMemoryPool.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MonoMemoryPool.cs.meta new file mode 100644 index 0000000..00a6179 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MonoMemoryPool.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1334aecb808e6c145a993cb441f43bdb +timeCreated: 1485703991 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MonoPoolableMemoryPool.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MonoPoolableMemoryPool.cs new file mode 100644 index 0000000..f9d1694 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MonoPoolableMemoryPool.cs @@ -0,0 +1,372 @@ +using UnityEngine; + +namespace Zenject +{ + // Zero parameters + public class MonoPoolableMemoryPool : MemoryPool + where TValue : Component, IPoolable + { + Transform _originalParent; + + [Inject] + public MonoPoolableMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + + protected override void Reinitialize(TValue item) + { + item.gameObject.SetActive(true); + item.OnSpawned(); + } + } + + // One parameters + public class MonoPoolableMemoryPool + : MemoryPool + where TValue : Component, IPoolable + { + Transform _originalParent; + + [Inject] + public MonoPoolableMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + + protected override void Reinitialize(TParam1 p1, TValue item) + { + item.gameObject.SetActive(true); + item.OnSpawned(p1); + } + } + + // Two parameters + public class MonoPoolableMemoryPool + : MemoryPool + where TValue : Component, IPoolable + { + Transform _originalParent; + + [Inject] + public MonoPoolableMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + + protected override void Reinitialize(TParam1 p1, TParam2 p2, TValue item) + { + item.gameObject.SetActive(true); + item.OnSpawned(p1, p2); + } + } + + // Three parameters + public class MonoPoolableMemoryPool + : MemoryPool + where TValue : Component, IPoolable + { + Transform _originalParent; + + [Inject] + public MonoPoolableMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + + protected override void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TValue item) + { + item.gameObject.SetActive(true); + item.OnSpawned(p1, p2, p3); + } + } + + // Four parameters + public class MonoPoolableMemoryPool + : MemoryPool + where TValue : Component, IPoolable + { + Transform _originalParent; + + [Inject] + public MonoPoolableMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + + protected override void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TValue item) + { + item.gameObject.SetActive(true); + item.OnSpawned(p1, p2, p3, p4); + } + } + + // Five parameters + public class MonoPoolableMemoryPool + : MemoryPool + where TValue : Component, IPoolable + { + Transform _originalParent; + + [Inject] + public MonoPoolableMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + + protected override void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TValue item) + { + item.gameObject.SetActive(true); + item.OnSpawned(p1, p2, p3, p4, p5); + } + } + + // Six parameters + public class MonoPoolableMemoryPool + : MemoryPool + where TValue : Component, IPoolable + { + Transform _originalParent; + + [Inject] + public MonoPoolableMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + + protected override void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TValue item) + { + item.gameObject.SetActive(true); + item.OnSpawned(p1, p2, p3, p4, p5, p6); + } + } + + // Seven parameters + public class MonoPoolableMemoryPool + : MemoryPool + where TValue : Component, IPoolable + { + Transform _originalParent; + + [Inject] + public MonoPoolableMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + + protected override void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TParam7 p7, TValue item) + { + item.gameObject.SetActive(true); + item.OnSpawned(p1, p2, p3, p4, p5, p6, p7); + } + } + + // Eight parameters + public class MonoPoolableMemoryPool + : MemoryPool + where TValue : Component, IPoolable + { + Transform _originalParent; + + [Inject] + public MonoPoolableMemoryPool() + { + } + + protected override void OnCreated(TValue item) + { + item.gameObject.SetActive(false); + _originalParent = item.transform.parent; + } + + protected override void OnDestroyed(TValue item) + { + GameObject.Destroy(item.gameObject); + } + + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + item.gameObject.SetActive(false); + + if (item.transform.parent != _originalParent) + { + item.transform.SetParent(_originalParent, false); + } + } + + protected override void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TParam7 p7, TParam8 p8, TValue item) + { + item.gameObject.SetActive(true); + item.OnSpawned(p1, p2, p3, p4, p5, p6, p7, p8); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MonoPoolableMemoryPool.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MonoPoolableMemoryPool.cs.meta new file mode 100644 index 0000000..2214fbb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/MonoPoolableMemoryPool.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 5475433f41ca61c4a9095affbf60b848 +timeCreated: 1528535898 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/PoolFactory.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/PoolFactory.cs new file mode 100644 index 0000000..541f293 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/PoolFactory.cs @@ -0,0 +1,38 @@ +using System; + +namespace Zenject +{ + // Here we assume that each spawned object does the work of returning itself to the pool + // in its own Dispose method + public class PoolWrapperFactory : IFactory + where T : IDisposable + { + readonly IMemoryPool _pool; + + public PoolWrapperFactory(IMemoryPool pool) + { + _pool = pool; + } + + public T Create() + { + return _pool.Spawn(); + } + } + + public class PoolWrapperFactory : IFactory + where TValue : IDisposable + { + readonly IMemoryPool _pool; + + public PoolWrapperFactory(IMemoryPool pool) + { + _pool = pool; + } + + public TValue Create(TParam1 arg) + { + return _pool.Spawn(arg); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/PoolFactory.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/PoolFactory.cs.meta new file mode 100644 index 0000000..340c1c2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/PoolFactory.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 125bde4ab63a4984484c450640ee1702 +timeCreated: 1518946218 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/PoolableMemoryPool.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/PoolableMemoryPool.cs new file mode 100644 index 0000000..febb762 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/PoolableMemoryPool.cs @@ -0,0 +1,147 @@ +namespace Zenject +{ + // Zero parameters + public class PoolableMemoryPool + : MemoryPool + where TValue : IPoolable + { + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + } + + protected override void Reinitialize(TValue item) + { + item.OnSpawned(); + } + } + + // One parameters + public class PoolableMemoryPool + : MemoryPool + where TValue : IPoolable + { + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + } + + protected override void Reinitialize(TParam1 p1, TValue item) + { + item.OnSpawned(p1); + } + } + + // Two parameters + public class PoolableMemoryPool + : MemoryPool + where TValue : IPoolable + { + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + } + + protected override void Reinitialize(TParam1 p1, TParam2 p2, TValue item) + { + item.OnSpawned(p1, p2); + } + } + + // Three parameters + public class PoolableMemoryPool + : MemoryPool + where TValue : IPoolable + { + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + } + + protected override void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TValue item) + { + item.OnSpawned(p1, p2, p3); + } + } + + // Four parameters + public class PoolableMemoryPool + : MemoryPool + where TValue : IPoolable + { + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + } + + protected override void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TValue item) + { + item.OnSpawned(p1, p2, p3, p4); + } + } + + // Five parameters + public class PoolableMemoryPool + : MemoryPool + where TValue : IPoolable + { + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + } + + protected override void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TValue item) + { + item.OnSpawned(p1, p2, p3, p4, p5); + } + } + + // Six parameters + public class PoolableMemoryPool + : MemoryPool + where TValue : IPoolable + { + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + } + + protected override void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TValue item) + { + item.OnSpawned(p1, p2, p3, p4, p5, p6); + } + } + + // Seven parameters + public class PoolableMemoryPool + : MemoryPool + where TValue : IPoolable + { + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + } + + protected override void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TParam7 p7, TValue item) + { + item.OnSpawned(p1, p2, p3, p4, p5, p6, p7); + } + } + + // Eight parameters + public class PoolableMemoryPool + : MemoryPool + where TValue : IPoolable + { + protected override void OnDespawned(TValue item) + { + item.OnDespawned(); + } + + protected override void Reinitialize(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TParam7 p7, TParam8 p8, TValue item) + { + item.OnSpawned(p1, p2, p3, p4, p5, p6, p7, p8); + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/PoolableMemoryPool.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/PoolableMemoryPool.cs.meta new file mode 100644 index 0000000..99b8f0a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/PoolableMemoryPool.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7fa0c435e1800a048ac5f7c53e03472d +timeCreated: 1517205083 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static.meta new file mode 100644 index 0000000..55b3ed4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 28d06bc0b4cdf374ca41d78b0ec5dc0a +folderAsset: yes +timeCreated: 1515014902 +licenseType: Store +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static/PoolableStaticMemoryPool.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static/PoolableStaticMemoryPool.cs new file mode 100644 index 0000000..3002390 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static/PoolableStaticMemoryPool.cs @@ -0,0 +1,154 @@ +namespace Zenject +{ + public class PoolableStaticMemoryPool : StaticMemoryPool + where TValue : class, IPoolable, new() + { + public PoolableStaticMemoryPool() + : base(OnSpawned, OnDespawned) + { + } + + static void OnSpawned(TValue value) + { + value.OnSpawned(); + } + + static void OnDespawned(TValue value) + { + value.OnDespawned(); + } + } + + public class PoolableStaticMemoryPool : StaticMemoryPool + where TValue : class, IPoolable, new() + { + public PoolableStaticMemoryPool() + : base(OnSpawned, OnDespawned) + { + } + + static void OnSpawned(TParam1 p1, TValue value) + { + value.OnSpawned(p1); + } + + static void OnDespawned(TValue value) + { + value.OnDespawned(); + } + } + + public class PoolableStaticMemoryPool : StaticMemoryPool + where TValue : class, IPoolable, new() + { + public PoolableStaticMemoryPool() + : base(OnSpawned, OnDespawned) + { + } + + static void OnSpawned(TParam1 p1, TParam2 p2, TValue value) + { + value.OnSpawned(p1, p2); + } + + static void OnDespawned(TValue value) + { + value.OnDespawned(); + } + } + + public class PoolableStaticMemoryPool : StaticMemoryPool + where TValue : class, IPoolable, new() + { + public PoolableStaticMemoryPool() + : base(OnSpawned, OnDespawned) + { + } + + static void OnSpawned(TParam1 p1, TParam2 p2, TParam3 p3, TValue value) + { + value.OnSpawned(p1, p2, p3); + } + + static void OnDespawned(TValue value) + { + value.OnDespawned(); + } + } + + public class PoolableStaticMemoryPool : StaticMemoryPool + where TValue : class, IPoolable, new() + { + public PoolableStaticMemoryPool() + : base(OnSpawned, OnDespawned) + { + } + + static void OnSpawned(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TValue value) + { + value.OnSpawned(p1, p2, p3, p4); + } + + static void OnDespawned(TValue value) + { + value.OnDespawned(); + } + } + + public class PoolableStaticMemoryPool : StaticMemoryPool + where TValue : class, IPoolable, new() + { + public PoolableStaticMemoryPool() + : base(OnSpawned, OnDespawned) + { + } + + static void OnSpawned(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TValue value) + { + value.OnSpawned(p1, p2, p3, p4, p5); + } + + static void OnDespawned(TValue value) + { + value.OnDespawned(); + } + } + + public class PoolableStaticMemoryPool : StaticMemoryPool + where TValue : class, IPoolable, new() + { + public PoolableStaticMemoryPool() + : base(OnSpawned, OnDespawned) + { + } + + static void OnSpawned(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TValue value) + { + value.OnSpawned(p1, p2, p3, p4, p5, p6); + } + + static void OnDespawned(TValue value) + { + value.OnDespawned(); + } + } + + public class PoolableStaticMemoryPool : StaticMemoryPool + where TValue : class, IPoolable, new() + { + public PoolableStaticMemoryPool() + : base(OnSpawned, OnDespawned) + { + } + + static void OnSpawned(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TParam7 p7, TValue value) + { + value.OnSpawned(p1, p2, p3, p4, p5, p6, p7); + } + + static void OnDespawned(TValue value) + { + value.OnDespawned(); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static/PoolableStaticMemoryPool.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static/PoolableStaticMemoryPool.cs.meta new file mode 100644 index 0000000..e5c2b5b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static/PoolableStaticMemoryPool.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 3bf78918a4d09d44695230ef305b6e1a +timeCreated: 1528618262 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static/StaticMemoryPool.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static/StaticMemoryPool.cs new file mode 100644 index 0000000..032809a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static/StaticMemoryPool.cs @@ -0,0 +1,557 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public abstract class StaticMemoryPoolBaseBase : IDespawnableMemoryPool, IDisposable + where TValue : class + { + // I also tried using ConcurrentBag instead of Stack + lock here but that performed much much worse + readonly Stack _stack = new Stack(); + + Action _onDespawnedMethod; + int _activeCount; + +#if ZEN_MULTITHREADING + protected readonly object _locker = new object(); +#endif + + public StaticMemoryPoolBaseBase(Action onDespawnedMethod) + { + _onDespawnedMethod = onDespawnedMethod; + +#if UNITY_EDITOR + StaticMemoryPoolRegistry.Add(this); +#endif + } + + public Action OnDespawnedMethod + { + set { _onDespawnedMethod = value; } + } + + public int NumTotal + { + get { return NumInactive + NumActive; } + } + + public int NumActive + { + get + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + return _activeCount; + } + } + } + + public int NumInactive + { + get + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + return _stack.Count; + } + } + } + + public Type ItemType + { + get { return typeof(TValue); } + } + + public void Resize(int desiredPoolSize) + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + ResizeInternal(desiredPoolSize); + } + } + + // We assume here that we're in a lock + void ResizeInternal(int desiredPoolSize) + { + Assert.That(desiredPoolSize >= 0, "Attempted to resize the pool to a negative amount"); + + while (_stack.Count > desiredPoolSize) + { + _stack.Pop(); + } + + while (desiredPoolSize > _stack.Count) + { + _stack.Push(Alloc()); + } + + Assert.IsEqual(_stack.Count, desiredPoolSize); + } + + public void Dispose() + { +#if UNITY_EDITOR + StaticMemoryPoolRegistry.Remove(this); +#endif + } + + public void ClearActiveCount() + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + _activeCount = 0; + } + } + + public void Clear() + { + Resize(0); + } + + public void ShrinkBy(int numToRemove) + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + ResizeInternal(_stack.Count - numToRemove); + } + } + + public void ExpandBy(int numToAdd) + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + ResizeInternal(_stack.Count + numToAdd); + } + } + + // We assume here that we're in a lock + protected TValue SpawnInternal() + { + TValue element; + + if (_stack.Count == 0) + { + element = Alloc(); + } + else + { + element = _stack.Pop(); + } + + _activeCount++; + return element; + } + + void IMemoryPool.Despawn(object item) + { + Despawn((TValue)item); + } + + public void Despawn(TValue element) + { + if (_onDespawnedMethod != null) + { + _onDespawnedMethod(element); + } + +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + Assert.That(!_stack.Contains(element), "Attempted to despawn element twice!"); + + _activeCount--; + _stack.Push(element); + } + } + + protected abstract TValue Alloc(); + } + + [NoReflectionBaking] + public abstract class StaticMemoryPoolBase : StaticMemoryPoolBaseBase + where TValue : class, new() + { + public StaticMemoryPoolBase(Action onDespawnedMethod) + : base(onDespawnedMethod) + { + } + + protected override TValue Alloc() + { + return new TValue(); + } + } + + // Zero parameters + + [NoReflectionBaking] + public class StaticMemoryPool : StaticMemoryPoolBase, IMemoryPool + where TValue : class, new() + { + Action _onSpawnMethod; + + public StaticMemoryPool( + Action onSpawnMethod = null, Action onDespawnedMethod = null) + : base(onDespawnedMethod) + { + _onSpawnMethod = onSpawnMethod; + } + + public Action OnSpawnMethod + { + set { _onSpawnMethod = value; } + } + + public TValue Spawn() + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + var item = SpawnInternal(); + + if (_onSpawnMethod != null) + { + _onSpawnMethod(item); + } + + return item; + } + } + } + + // One parameter + + [NoReflectionBaking] + public class StaticMemoryPool : StaticMemoryPoolBase, IMemoryPool + where TValue : class, new() + { + Action _onSpawnMethod; + + public StaticMemoryPool( + Action onSpawnMethod, Action onDespawnedMethod = null) + : base(onDespawnedMethod) + { + // What's the point of having a param otherwise? + Assert.IsNotNull(onSpawnMethod); + _onSpawnMethod = onSpawnMethod; + } + + public Action OnSpawnMethod + { + set { _onSpawnMethod = value; } + } + + public TValue Spawn(TParam1 param) + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + var item = SpawnInternal(); + + if (_onSpawnMethod != null) + { + _onSpawnMethod(param, item); + } + + return item; + } + } + } + + // Two parameter + + [NoReflectionBaking] + public class StaticMemoryPool : StaticMemoryPoolBase, IMemoryPool + where TValue : class, new() + { + Action _onSpawnMethod; + + public StaticMemoryPool( + Action onSpawnMethod, Action onDespawnedMethod = null) + : base(onDespawnedMethod) + { + // What's the point of having a param otherwise? + Assert.IsNotNull(onSpawnMethod); + _onSpawnMethod = onSpawnMethod; + } + + public Action OnSpawnMethod + { + set { _onSpawnMethod = value; } + } + + public TValue Spawn(TParam1 p1, TParam2 p2) + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + var item = SpawnInternal(); + + if (_onSpawnMethod != null) + { + _onSpawnMethod(p1, p2, item); + } + + return item; + } + } + } + + // Three parameters + + [NoReflectionBaking] + public class StaticMemoryPool : StaticMemoryPoolBase, IMemoryPool + where TValue : class, new() + { + Action _onSpawnMethod; + + public StaticMemoryPool( + Action onSpawnMethod, Action onDespawnedMethod = null) + : base(onDespawnedMethod) + { + // What's the point of having a param otherwise? + Assert.IsNotNull(onSpawnMethod); + _onSpawnMethod = onSpawnMethod; + } + + public Action OnSpawnMethod + { + set { _onSpawnMethod = value; } + } + + public TValue Spawn(TParam1 p1, TParam2 p2, TParam3 p3) + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + var item = SpawnInternal(); + + if (_onSpawnMethod != null) + { + _onSpawnMethod(p1, p2, p3, item); + } + + return item; + } + } + } + + // Four parameters + + [NoReflectionBaking] + public class StaticMemoryPool : StaticMemoryPoolBase, IMemoryPool + where TValue : class, new() + { +#if !NET_4_6 + ModestTree.Util. +#endif + Action _onSpawnMethod; + + public StaticMemoryPool( +#if !NET_4_6 + ModestTree.Util. +#endif + Action onSpawnMethod, Action onDespawnedMethod = null) + : base(onDespawnedMethod) + { + // What's the point of having a param otherwise? + Assert.IsNotNull(onSpawnMethod); + _onSpawnMethod = onSpawnMethod; + } + + public +#if !NET_4_6 + ModestTree.Util. +#endif + Action OnSpawnMethod + { + set { _onSpawnMethod = value; } + } + + public TValue Spawn(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4) + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + var item = SpawnInternal(); + + if (_onSpawnMethod != null) + { + _onSpawnMethod(p1, p2, p3, p4, item); + } + + return item; + } + } + } + + // Five parameters + + [NoReflectionBaking] + public class StaticMemoryPool : StaticMemoryPoolBase, IMemoryPool + where TValue : class, new() + { +#if !NET_4_6 + ModestTree.Util. +#endif + Action _onSpawnMethod; + + public StaticMemoryPool( +#if !NET_4_6 + ModestTree.Util. +#endif + Action onSpawnMethod, Action onDespawnedMethod = null) + : base(onDespawnedMethod) + { + // What's the point of having a param otherwise? + Assert.IsNotNull(onSpawnMethod); + _onSpawnMethod = onSpawnMethod; + } + + public +#if !NET_4_6 + ModestTree.Util. +#endif + Action OnSpawnMethod + { + set { _onSpawnMethod = value; } + } + + public TValue Spawn(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5) + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + var item = SpawnInternal(); + + if (_onSpawnMethod != null) + { + _onSpawnMethod(p1, p2, p3, p4, p5, item); + } + + return item; + } + } + } + + // Six parameters + + [NoReflectionBaking] + public class StaticMemoryPool : StaticMemoryPoolBase, IMemoryPool + where TValue : class, new() + { +#if !NET_4_6 + ModestTree.Util. +#endif + Action _onSpawnMethod; + + public StaticMemoryPool( +#if !NET_4_6 + ModestTree.Util. +#endif + Action onSpawnMethod, Action onDespawnedMethod = null) + : base(onDespawnedMethod) + { + // What's the point of having a param otherwise? + Assert.IsNotNull(onSpawnMethod); + _onSpawnMethod = onSpawnMethod; + } + + public +#if !NET_4_6 + ModestTree.Util. +#endif + Action OnSpawnMethod + { + set { _onSpawnMethod = value; } + } + + public TValue Spawn(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6) + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + var item = SpawnInternal(); + + if (_onSpawnMethod != null) + { + _onSpawnMethod(p1, p2, p3, p4, p5, p6, item); + } + + return item; + } + } + } + + // Seven parameters + + [NoReflectionBaking] + public class StaticMemoryPool : StaticMemoryPoolBase, IMemoryPool + where TValue : class, new() + { +#if !NET_4_6 + ModestTree.Util. +#endif + Action _onSpawnMethod; + + public StaticMemoryPool( +#if !NET_4_6 + ModestTree.Util. +#endif + Action onSpawnMethod, Action onDespawnedMethod = null) + : base(onDespawnedMethod) + { + // What's the point of having a param otherwise? + Assert.IsNotNull(onSpawnMethod); + _onSpawnMethod = onSpawnMethod; + } + + public +#if !NET_4_6 + ModestTree.Util. +#endif + Action OnSpawnMethod + { + set { _onSpawnMethod = value; } + } + + public TValue Spawn(TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TParam7 p7) + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + var item = SpawnInternal(); + + if (_onSpawnMethod != null) + { + _onSpawnMethod(p1, p2, p3, p4, p5, p6, p7, item); + } + + return item; + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static/StaticMemoryPool.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static/StaticMemoryPool.cs.meta new file mode 100644 index 0000000..6bdbf53 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Static/StaticMemoryPool.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 56b2eb81b3385fd47a0500abeac7b60e +timeCreated: 1528024394 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util.meta new file mode 100644 index 0000000..16e963a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 6214acccd2e0c2044921cc068fb3d0a6 +folderAsset: yes +timeCreated: 1520607639 +licenseType: Store +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/ArrayPool.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/ArrayPool.cs new file mode 100644 index 0000000..a5edb89 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/ArrayPool.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; + +namespace Zenject +{ + public class ArrayPool : StaticMemoryPoolBaseBase + { + readonly int _length; + + public ArrayPool(int length) + : base(OnDespawned) + { + _length = length; + } + + static void OnDespawned(T[] arr) + { + for (int i = 0; i < arr.Length; i++) + { + arr[i] = default(T); + } + } + + public T[] Spawn() + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + return SpawnInternal(); + } + } + + protected override T[] Alloc() + { + return new T[_length]; + } + + static readonly Dictionary> _pools = + new Dictionary>(); + + public static ArrayPool GetPool(int length) + { + ArrayPool pool; + + if (!_pools.TryGetValue(length, out pool)) + { + pool = new ArrayPool(length); + _pools.Add(length, pool); + } + + return pool; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/ArrayPool.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/ArrayPool.cs.meta new file mode 100644 index 0000000..023fea7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/ArrayPool.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 891d6e713fcfdfc4a95271fdee018e94 +timeCreated: 1537870146 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/DictionaryPool.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/DictionaryPool.cs new file mode 100644 index 0000000..8ec6d37 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/DictionaryPool.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + public class DictionaryPool : StaticMemoryPool> + { + static DictionaryPool _instance = new DictionaryPool(); + + public DictionaryPool() + { + OnSpawnMethod = OnSpawned; + OnDespawnedMethod = OnDespawned; + } + + public static DictionaryPool Instance + { + get { return _instance; } + } + + static void OnSpawned(Dictionary items) + { + Assert.That(items.IsEmpty()); + } + + static void OnDespawned(Dictionary items) + { + items.Clear(); + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/DictionaryPool.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/DictionaryPool.cs.meta new file mode 100644 index 0000000..cfad657 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/DictionaryPool.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 031a0490d1684424e9e33b22106cb178 +timeCreated: 1520670682 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/HashSetPool.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/HashSetPool.cs new file mode 100644 index 0000000..5fb2950 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/HashSetPool.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + public class HashSetPool : StaticMemoryPool> + { + static HashSetPool _instance = new HashSetPool(); + + public HashSetPool() + { + OnSpawnMethod = OnSpawned; + OnDespawnedMethod = OnDespawned; + } + + public static HashSetPool Instance + { + get { return _instance; } + } + + static void OnSpawned(HashSet items) + { + Assert.That(items.IsEmpty()); + } + + static void OnDespawned(HashSet items) + { + items.Clear(); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/HashSetPool.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/HashSetPool.cs.meta new file mode 100644 index 0000000..330ec55 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/HashSetPool.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 89c66035001289a4199cb04e17d0bc28 +timeCreated: 1520670682 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/ListPool.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/ListPool.cs new file mode 100644 index 0000000..70b5c74 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/ListPool.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; + +namespace Zenject +{ + public class ListPool : StaticMemoryPool> + { + static ListPool _instance = new ListPool(); + + public ListPool() + { + OnDespawnedMethod = OnDespawned; + } + + public static ListPool Instance + { + get { return _instance; } + } + + void OnDespawned(List list) + { + list.Clear(); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/ListPool.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/ListPool.cs.meta new file mode 100644 index 0000000..b7683fb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/ListPool.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f30364d1ac067164ea56051cd000b49f +timeCreated: 1520670682 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/PoolCleanupChecker.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/PoolCleanupChecker.cs new file mode 100644 index 0000000..df27969 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/PoolCleanupChecker.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; + +namespace Zenject +{ + // If you want to ensure that all items are always returned to the pool, include the following + // in an installer + // Container.BindInterfacesTo().AsSingle() + public class PoolCleanupChecker : ILateDisposable + { + readonly List _poolFactories; + readonly List _ignoredPools; + + public PoolCleanupChecker( + [Inject(Optional = true, Source = InjectSources.Local)] + List poolFactories, + [Inject(Source = InjectSources.Local)] + List ignoredPools) + { + _poolFactories = poolFactories; + _ignoredPools = ignoredPools; + + Assert.That(ignoredPools.All(x => x.DerivesFrom())); + } + + public void LateDispose() + { + foreach (var pool in _poolFactories) + { + if (!_ignoredPools.Contains(pool.GetType())) + { + Assert.IsEqual(pool.NumActive, 0, + "Found active objects in pool '{0}' during dispose. Did you forget to despawn an object of type '{1}'?".Fmt(pool.GetType(), pool.ItemType)); + } + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/PoolCleanupChecker.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/PoolCleanupChecker.cs.meta new file mode 100644 index 0000000..b8b3ac7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/PoolCleanupChecker.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 69aee89274cd16b48aa790ddd5a061d2 +timeCreated: 1520670682 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/StaticMemoryPoolRegistry.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/StaticMemoryPoolRegistry.cs new file mode 100644 index 0000000..d110001 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/StaticMemoryPoolRegistry.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ +#if UNITY_EDITOR + public static class StaticMemoryPoolRegistry + { + public static event Action PoolAdded = delegate {}; + public static event Action PoolRemoved = delegate {}; + + readonly static List _pools = new List(); + + public static IEnumerable Pools + { + get { return _pools; } + } + + public static void Add(IMemoryPool memoryPool) + { + _pools.Add(memoryPool); + PoolAdded(memoryPool); + } + + public static void Remove(IMemoryPool memoryPool) + { + _pools.RemoveWithConfirm(memoryPool); + PoolRemoved(memoryPool); + } + } +#endif +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/StaticMemoryPoolRegistry.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/StaticMemoryPoolRegistry.cs.meta new file mode 100644 index 0000000..dc99c3b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/Pooling/Util/StaticMemoryPoolRegistry.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: cccc66ed95242b544bd7f501f0ecb89b +timeCreated: 1521390236 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PrefabFactory.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PrefabFactory.cs new file mode 100644 index 0000000..e149b3c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PrefabFactory.cs @@ -0,0 +1,127 @@ +#if !NOT_UNITY3D + +using ModestTree; +using UnityEngine; + +namespace Zenject +{ + // This factory type can be useful if you want to control where the prefab comes from at runtime + // rather than from within the installers + + //No parameters + public class PrefabFactory : IFactory + //where T : Component + { + [Inject] + readonly DiContainer _container = null; + + public DiContainer Container + { + get { return _container; } + } + + public virtual T Create(UnityEngine.Object prefab) + { + Assert.That(prefab != null, + "Null prefab given to factory create method when instantiating object with type '{0}'.", typeof(T)); + + return _container.InstantiatePrefabForComponent(prefab); + } + + // Note: We can't really validate here without access to the prefab + // We could validate the class directly with the current container but that fails when the + // class is inside a GameObjectContext + } + + // One parameter + public class PrefabFactory : IFactory + //where T : Component + { + [Inject] + readonly DiContainer _container = null; + + public DiContainer Container + { + get { return _container; } + } + + public virtual T Create(UnityEngine.Object prefab, P1 param) + { + Assert.That(prefab != null, + "Null prefab given to factory create method when instantiating object with type '{0}'.", typeof(T)); + + return (T)_container.InstantiatePrefabForComponentExplicit( + typeof(T), prefab, InjectUtil.CreateArgListExplicit(param)); + } + } + + // Two parameters + public class PrefabFactory : IFactory + //where T : Component + { + [Inject] + readonly DiContainer _container = null; + + public DiContainer Container + { + get { return _container; } + } + + public virtual T Create(UnityEngine.Object prefab, P1 param, P2 param2) + { + Assert.That(prefab != null, + "Null prefab given to factory create method when instantiating object with type '{0}'.", typeof(T)); + + return (T)_container.InstantiatePrefabForComponentExplicit( + typeof(T), prefab, InjectUtil.CreateArgListExplicit(param, param2)); + } + } + + // Three parameters + public class PrefabFactory : IFactory + //where T : Component + { + [Inject] + readonly DiContainer _container = null; + + public DiContainer Container + { + get { return _container; } + } + + public virtual T Create(UnityEngine.Object prefab, P1 param, P2 param2, P3 param3) + { + Assert.That(prefab != null, + "Null prefab given to factory create method when instantiating object with type '{0}'.", typeof(T)); + + return (T)_container.InstantiatePrefabForComponentExplicit( + typeof(T), prefab, InjectUtil.CreateArgListExplicit(param, param2, param3)); + } + } + + // Four parameters + public class PrefabFactory : IFactory + //where T : Component + { + [Inject] + readonly DiContainer _container = null; + + public DiContainer Container + { + get { return _container; } + } + + public virtual T Create(UnityEngine.Object prefab, P1 param, P2 param2, P3 param3, P4 param4) + { + Assert.That(prefab != null, + "Null prefab given to factory create method when instantiating object with type '{0}'.", typeof(T)); + + return (T)_container.InstantiatePrefabForComponentExplicit( + typeof(T), prefab, InjectUtil.CreateArgListExplicit(param, param2, param3, param4)); + } + } +} + +#endif + + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PrefabFactory.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PrefabFactory.cs.meta new file mode 100644 index 0000000..ece95e6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PrefabFactory.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 39782cb4430018d459f5707002dff73c +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PrefabResourceFactory.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PrefabResourceFactory.cs new file mode 100644 index 0000000..8967e23 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PrefabResourceFactory.cs @@ -0,0 +1,136 @@ +#if !NOT_UNITY3D + +using ModestTree; +using UnityEngine; + +namespace Zenject +{ + // This factory type can be useful if you want to control where the prefab comes from at runtime + // rather than from within the installers + + //No parameters + public class PrefabResourceFactory : IFactory + //where T : Component + { + [Inject] + readonly DiContainer _container = null; + + public DiContainer Container + { + get { return _container; } + } + + public virtual T Create(string prefabResourceName) + { + Assert.That(!string.IsNullOrEmpty(prefabResourceName), + "Null or empty prefab resource name given to factory create method when instantiating object with type '{0}'.", typeof(T)); + + var prefab = (GameObject)Resources.Load(prefabResourceName); + return _container.InstantiatePrefabForComponent(prefab); + } + + // Note: We can't really validate here without access to the prefab + // We could validate the class directly with the current container but that fails when the + // class is inside a GameObjectContext + } + + // One parameter + public class PrefabResourceFactory : IFactory + //where T : Component + { + [Inject] + readonly DiContainer _container = null; + + public DiContainer Container + { + get { return _container; } + } + + public virtual T Create(string prefabResourceName, P1 param) + { + Assert.That(!string.IsNullOrEmpty(prefabResourceName), + "Null or empty prefab resource name given to factory create method when instantiating object with type '{0}'.", typeof(T)); + + var prefab = (GameObject)Resources.Load(prefabResourceName); + return (T)_container.InstantiatePrefabForComponentExplicit( + typeof(T), prefab, InjectUtil.CreateArgListExplicit(param)); + } + } + + // Two parameters + public class PrefabResourceFactory : IFactory + //where T : Component + { + [Inject] + readonly DiContainer _container = null; + + public DiContainer Container + { + get { return _container; } + } + + public virtual T Create(string prefabResourceName, P1 param, P2 param2) + { + Assert.That(!string.IsNullOrEmpty(prefabResourceName), + "Null or empty prefab resource name given to factory create method when instantiating object with type '{0}'.", typeof(T)); + + var prefab = (GameObject)Resources.Load(prefabResourceName); + + return (T)_container.InstantiatePrefabForComponentExplicit( + typeof(T), prefab, InjectUtil.CreateArgListExplicit(param, param2)); + } + } + + // Three parameters + public class PrefabResourceFactory : IFactory + //where T : Component + { + [Inject] + readonly DiContainer _container = null; + + public DiContainer Container + { + get { return _container; } + } + + public virtual T Create(string prefabResourceName, P1 param, P2 param2, P3 param3) + { + Assert.That(!string.IsNullOrEmpty(prefabResourceName), + "Null or empty prefab resource name given to factory create method when instantiating object with type '{0}'.", typeof(T)); + + var prefab = (GameObject)Resources.Load(prefabResourceName); + + return (T)_container.InstantiatePrefabForComponentExplicit( + typeof(T), prefab, InjectUtil.CreateArgListExplicit(param, param2, param3)); + } + } + + // Four parameters + public class PrefabResourceFactory : IFactory + //where T : Component + { + [Inject] + readonly DiContainer _container = null; + + public DiContainer Container + { + get { return _container; } + } + + public virtual T Create(string prefabResourceName, P1 param, P2 param2, P3 param3, P4 param4) + { + Assert.That(!string.IsNullOrEmpty(prefabResourceName), + "Null or empty prefab resource name given to factory create method when instantiating object with type '{0}'.", typeof(T)); + + var prefab = (GameObject)Resources.Load(prefabResourceName); + + return (T)_container.InstantiatePrefabForComponentExplicit( + typeof(T), prefab, InjectUtil.CreateArgListExplicit(param, param2, param3, param4)); + } + } +} + +#endif + + + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PrefabResourceFactory.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PrefabResourceFactory.cs.meta new file mode 100644 index 0000000..ef61259 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Factories/PrefabResourceFactory.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 5fd50037209abd647b7ae7391717f015 +timeCreated: 1534319565 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection.meta new file mode 100644 index 0000000..a927c30 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: e36c66e30e287cf48b9bb264d4924562 +folderAsset: yes +DefaultImporter: + userData: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/InjectContext.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/InjectContext.cs new file mode 100644 index 0000000..86d13be --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/InjectContext.cs @@ -0,0 +1,274 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ModestTree; +using Zenject.Internal; + +namespace Zenject +{ + [NoReflectionBaking] + public class InjectContext : IDisposable + { + BindingId _bindingId; + Type _objectType; + InjectContext _parentContext; + object _objectInstance; + string _memberName; + bool _optional; + InjectSources _sourceType; + object _fallBackValue; + object _concreteIdentifier; + DiContainer _container; + + public InjectContext() + { + _bindingId = new BindingId(); + Reset(); + } + + public InjectContext(DiContainer container, Type memberType) + : this() + { + Container = container; + MemberType = memberType; + } + + public InjectContext(DiContainer container, Type memberType, object identifier) + : this(container, memberType) + { + Identifier = identifier; + } + + public InjectContext(DiContainer container, Type memberType, object identifier, bool optional) + : this(container, memberType, identifier) + { + Optional = optional; + } + + public void Dispose() + { + ZenPools.DespawnInjectContext(this); + } + + public void Reset() + { + _objectType = null; + _parentContext = null; + _objectInstance = null; + _memberName = ""; + _optional = false; + _sourceType = InjectSources.Any; + _fallBackValue = null; + _container = null; + _bindingId.Type = null; + _bindingId.Identifier = null; + } + + public BindingId BindingId + { + get { return _bindingId; } + } + + // The type of the object which is having its members injected + // NOTE: This is null for root calls to Resolve<> or Instantiate<> + public Type ObjectType + { + get { return _objectType; } + set { _objectType = value; } + } + + // Parent context that triggered the creation of ObjectType + // This can be used for very complex conditions using parent info such as identifiers, types, etc. + // Note that ParentContext.MemberType is not necessarily the same as ObjectType, + // since the ObjectType could be a derived type from ParentContext.MemberType + public InjectContext ParentContext + { + get { return _parentContext; } + set { _parentContext = value; } + } + + // The instance which is having its members injected + // Note that this is null when injecting into the constructor + public object ObjectInstance + { + get { return _objectInstance; } + set { _objectInstance = value; } + } + + // Identifier - most of the time this is null + // It will match 'foo' in this example: + // ... In an installer somewhere: + // Container.Bind("foo").AsSingle(); + // ... + // ... In a constructor: + // public Foo([Inject(Id = "foo") Foo foo) + public object Identifier + { + get { return _bindingId.Identifier; } + set { _bindingId.Identifier = value; } + } + + // The constructor parameter name, or field name, or property name + public string MemberName + { + get { return _memberName; } + set { _memberName = value; } + } + + // The type of the constructor parameter, field or property + public Type MemberType + { + get { return _bindingId.Type; } + set { _bindingId.Type = value; } + } + + // When optional, null is a valid value to be returned + public bool Optional + { + get { return _optional; } + set { _optional = value; } + } + + // When set to true, this will only look up dependencies in the local container and will not + // search in parent containers + public InjectSources SourceType + { + get { return _sourceType; } + set { _sourceType = value; } + } + + public object ConcreteIdentifier + { + get { return _concreteIdentifier; } + set { _concreteIdentifier = value; } + } + + // When optional, this is used to provide the value + public object FallBackValue + { + get { return _fallBackValue; } + set { _fallBackValue = value; } + } + + // The container used for this injection + public DiContainer Container + { + get { return _container; } + set { _container = value; } + } + + public IEnumerable ParentContexts + { + get + { + if (ParentContext == null) + { + yield break; + } + + yield return ParentContext; + + foreach (var context in ParentContext.ParentContexts) + { + yield return context; + } + } + } + + public IEnumerable ParentContextsAndSelf + { + get + { + yield return this; + + foreach (var context in ParentContexts) + { + yield return context; + } + } + } + + // This will return the types of all the objects that are being injected + // So if you have class Foo which has constructor parameter of type IBar, + // and IBar resolves to Bar, this will be equal to (Bar, Foo) + public IEnumerable AllObjectTypes + { + get + { + foreach (var context in ParentContextsAndSelf) + { + if (context.ObjectType != null) + { + yield return context.ObjectType; + } + } + } + } + + public InjectContext CreateSubContext(Type memberType) + { + return CreateSubContext(memberType, null); + } + + public InjectContext CreateSubContext(Type memberType, object identifier) + { + var subContext = new InjectContext(); + + subContext.ParentContext = this; + subContext.Identifier = identifier; + subContext.MemberType = memberType; + + // Clear these + subContext.ConcreteIdentifier = null; + subContext.MemberName = ""; + subContext.FallBackValue = null; + + // Inherit these ones by default + subContext.ObjectType = ObjectType; + subContext.ObjectInstance = ObjectInstance; + subContext.Optional = Optional; + subContext.SourceType = SourceType; + subContext.Container = Container; + + return subContext; + } + + public InjectContext Clone() + { + var clone = new InjectContext(); + + clone.ObjectType = ObjectType; + clone.ParentContext = ParentContext; + clone.ConcreteIdentifier = ConcreteIdentifier; + clone.ObjectInstance = ObjectInstance; + clone.Identifier = Identifier; + clone.MemberType = MemberType; + clone.MemberName = MemberName; + clone.Optional = Optional; + clone.SourceType = SourceType; + clone.FallBackValue = FallBackValue; + clone.Container = Container; + + return clone; + } + + // This is very useful to print out for debugging purposes + public string GetObjectGraphString() + { + var result = new StringBuilder(); + + foreach (var context in ParentContextsAndSelf.Reverse()) + { + if (context.ObjectType == null) + { + continue; + } + + result.AppendLine(context.ObjectType.PrettyName()); + } + + return result.ToString(); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/InjectContext.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/InjectContext.cs.meta new file mode 100644 index 0000000..9e8c7bd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/InjectContext.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2005ce29739317b48bcc3c06695da848 +timeCreated: 1461708048 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/InjectUtil.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/InjectUtil.cs new file mode 100644 index 0000000..430df54 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/InjectUtil.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using ModestTree; + +namespace Zenject +{ + [DebuggerStepThrough] + public struct TypeValuePair + { + public Type Type; + public object Value; + + public TypeValuePair(Type type, object value) + { + Type = type; + Value = value; + } + } + + [DebuggerStepThrough] + public static class InjectUtil + { + public static List CreateArgList(IEnumerable args) + { + Assert.That(!args.ContainsItem(null), + "Cannot include null values when creating a zenject argument list because zenject has no way of deducing the type from a null value. If you want to allow null, use the Explicit form."); + return args.Select(x => new TypeValuePair(x.GetType(), x)).ToList(); + } + + public static TypeValuePair CreateTypePair(T param) + { + // Use the most derived type that we can find here + return new TypeValuePair( + param == null ? typeof(T) : param.GetType(), param); + } + + public static List CreateArgListExplicit(T param) + { + return new List + { + CreateTypePair(param) + }; + } + + public static List CreateArgListExplicit(TParam1 param1, TParam2 param2) + { + return new List + { + CreateTypePair(param1), + CreateTypePair(param2) + }; + } + + public static List CreateArgListExplicit( + TParam1 param1, TParam2 param2, TParam3 param3) + { + return new List + { + CreateTypePair(param1), + CreateTypePair(param2), + CreateTypePair(param3) + }; + } + + public static List CreateArgListExplicit( + TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4) + { + return new List + { + CreateTypePair(param1), + CreateTypePair(param2), + CreateTypePair(param3), + CreateTypePair(param4) + }; + } + + public static List CreateArgListExplicit( + TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5) + { + return new List + { + CreateTypePair(param1), + CreateTypePair(param2), + CreateTypePair(param3), + CreateTypePair(param4), + CreateTypePair(param5) + }; + } + + public static List CreateArgListExplicit( + TParam1 param1, TParam2 param2, TParam3 param3, TParam4 param4, TParam5 param5, TParam6 param6) + { + return new List + { + CreateTypePair(param1), + CreateTypePair(param2), + CreateTypePair(param3), + CreateTypePair(param4), + CreateTypePair(param5), + CreateTypePair(param6) + }; + } + + // Find the first match with the given type and remove it from the list + // Return true if it was removed + public static bool PopValueWithType( + List extraArgMap, Type injectedFieldType, out object value) + { + for (int i = 0; i < extraArgMap.Count; i++) + { + var arg = extraArgMap[i]; + + if (arg.Type.DerivesFromOrEqual(injectedFieldType)) + { + value = arg.Value; + extraArgMap.RemoveAt(i); + return true; + } + } + + value = injectedFieldType.GetDefaultValue(); + return false; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/InjectUtil.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/InjectUtil.cs.meta new file mode 100644 index 0000000..20a4e46 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/InjectUtil.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0ebfddbd9452a9c4cb6c9dfe7a25ea53 +timeCreated: 1461708048 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/LazyInject.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/LazyInject.cs new file mode 100644 index 0000000..9dd2cf5 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/LazyInject.cs @@ -0,0 +1,42 @@ +using ModestTree; + +namespace Zenject +{ + [ZenjectAllowDuringValidation] + [NoReflectionBaking] + public class LazyInject : IValidatable + { + readonly DiContainer _container; + readonly InjectContext _context; + + bool _hasValue; + T _value; + + public LazyInject(DiContainer container, InjectContext context) + { + Assert.DerivesFromOrEqual(context.MemberType); + + _container = container; + _context = context; + } + + void IValidatable.Validate() + { + _container.Resolve(_context); + } + + public T Value + { + get + { + if (!_hasValue) + { + _value = (T)_container.Resolve(_context); + _hasValue = true; + } + + return _value; + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/LazyInject.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/LazyInject.cs.meta new file mode 100644 index 0000000..7fcd77b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Injection/LazyInject.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 54883063c774a244c898edbc91b859a0 +timeCreated: 1529237555 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install.meta new file mode 100644 index 0000000..922e252 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6a15b3ef3a9656b4f85216520ae9b180 +folderAsset: yes +timeCreated: 1459463884 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts.meta new file mode 100644 index 0000000..a3cb192 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: fc41c06067fc1d4479c3b85aa2707cfb +folderAsset: yes +timeCreated: 1461708046 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/Context.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/Context.cs new file mode 100644 index 0000000..4c54192 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/Context.cs @@ -0,0 +1,334 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using UnityEngine; +using UnityEngine.Serialization; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace Zenject +{ + public abstract class Context : MonoBehaviour + { + [SerializeField] + List _scriptableObjectInstallers = new List(); + + [FormerlySerializedAs("Installers")] + [FormerlySerializedAs("_installers")] + [SerializeField] + List _monoInstallers = new List(); + + [SerializeField] + List _installerPrefabs = new List(); + + List _normalInstallers = new List(); + List _normalInstallerTypes = new List(); + + public IEnumerable Installers + { + get { return _monoInstallers; } + set + { + _monoInstallers.Clear(); + _monoInstallers.AddRange(value); + } + } + + public IEnumerable InstallerPrefabs + { + get { return _installerPrefabs; } + set + { + _installerPrefabs.Clear(); + _installerPrefabs.AddRange(value); + } + } + + public IEnumerable ScriptableObjectInstallers + { + get { return _scriptableObjectInstallers; } + set + { + _scriptableObjectInstallers.Clear(); + _scriptableObjectInstallers.AddRange(value); + } + } + + // Unlike other installer types this has to be set through code + public IEnumerable NormalInstallerTypes + { + get { return _normalInstallerTypes; } + set + { + Assert.That(value.All(x => x != null && x.DerivesFrom())); + + _normalInstallerTypes.Clear(); + _normalInstallerTypes.AddRange(value); + } + } + + // Unlike other installer types this has to be set through code + public IEnumerable NormalInstallers + { + get { return _normalInstallers; } + set + { + _normalInstallers.Clear(); + _normalInstallers.AddRange(value); + } + } + + public abstract DiContainer Container + { + get; + } + public abstract IEnumerable GetRootGameObjects(); + + + public void AddNormalInstallerType(Type installerType) + { + Assert.IsNotNull(installerType); + Assert.That(installerType.DerivesFrom()); + + _normalInstallerTypes.Add(installerType); + } + + public void AddNormalInstaller(InstallerBase installer) + { + _normalInstallers.Add(installer); + } + + void CheckInstallerPrefabTypes(List installers, List installerPrefabs) + { + foreach (var installer in installers) + { + Assert.IsNotNull(installer, "Found null installer in Context '{0}'", name); + +#if UNITY_EDITOR +#if UNITY_2018_3_OR_NEWER + Assert.That(!PrefabUtility.IsPartOfPrefabAsset(installer.gameObject), +#else + Assert.That(PrefabUtility.GetPrefabType(installer.gameObject) != PrefabType.Prefab, +#endif + "Found prefab with name '{0}' in the Installer property of Context '{1}'. You should use the property 'InstallerPrefabs' for this instead.", installer.name, name); +#endif + } + + foreach (var installerPrefab in installerPrefabs) + { + Assert.IsNotNull(installerPrefab, "Found null prefab in Context"); + + // We'd like to do this but this is actually a valid case sometimes + // (eg. loading an asset bundle with a scene containing a scene context when inside unity editor) +//#if UNITY_EDITOR + //Assert.That(PrefabUtility.GetPrefabType(installerPrefab.gameObject) == PrefabType.Prefab, + //"Found non-prefab with name '{0}' in the InstallerPrefabs property of Context '{1}'. You should use the property 'Installer' for this instead", + //installerPrefab.name, this.name); +//#endif + Assert.That(installerPrefab.GetComponent() != null, + "Expected to find component with type 'MonoInstaller' on given installer prefab '{0}'", installerPrefab.name); + } + } + + protected void InstallInstallers() + { + InstallInstallers( + _normalInstallers, _normalInstallerTypes, _scriptableObjectInstallers, _monoInstallers, _installerPrefabs); + } + + protected void InstallInstallers( + List normalInstallers, + List normalInstallerTypes, + List scriptableObjectInstallers, + List installers, + List installerPrefabs) + { + CheckInstallerPrefabTypes(installers, installerPrefabs); + + // Ideally we would just have one flat list of all the installers + // since that way the user has complete control over the order, but + // that's not possible since Unity does not allow serializing lists of interfaces + // (and it has to be an inteface since the scriptable object installers only share + // the interface) + // + // So the best we can do is have a hard-coded order in terms of the installer type + // + // The order is: + // - Normal installers given directly via code + // - ScriptableObject installers + // - MonoInstallers in the scene + // - Prefab Installers + // + // We put ScriptableObject installers before the MonoInstallers because + // ScriptableObjectInstallers are often used for settings (including settings + // that are injected into other installers like MonoInstallers) + + var allInstallers = normalInstallers.Cast() + .Concat(scriptableObjectInstallers.Cast()) + .Concat(installers.Cast()).ToList(); + + foreach (var installerPrefab in installerPrefabs) + { + Assert.IsNotNull(installerPrefab, "Found null installer prefab in '{0}'", GetType()); + + GameObject installerGameObject; + +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("GameObject.Instantiate")) +#endif + { + installerGameObject = GameObject.Instantiate(installerPrefab.gameObject); + } + + installerGameObject.transform.SetParent(transform, false); + var installer = installerGameObject.GetComponent(); + + Assert.IsNotNull(installer, "Could not find installer component on prefab '{0}'", installerPrefab.name); + + allInstallers.Add(installer); + } + + foreach (var installerType in normalInstallerTypes) + { + var installer = (InstallerBase)Container.Instantiate(installerType); + +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif + { + installer.InstallBindings(); + } + } + + foreach (var installer in allInstallers) + { + Assert.IsNotNull(installer, + "Found null installer in '{0}'", GetType()); + + Container.Inject(installer); + +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif + { + installer.InstallBindings(); + } + } + } + + protected void InstallSceneBindings(List injectableMonoBehaviours) + { + foreach (var binding in injectableMonoBehaviours.OfType()) + { + if (binding == null) + { + continue; + } + + if (binding.Context == null || (binding.UseSceneContext && this is SceneContext)) + { + binding.Context = this; + } + } + + // We'd prefer to use GameObject.FindObjectsOfType() here + // instead but that doesn't find inactive gameobjects + // TODO: Consider changing this + // Maybe ZenjectBinding could add itself to a registry class on Awake/OnEnable + // then we could avoid calling the slow Resources.FindObjectsOfTypeAll here + foreach (var binding in Resources.FindObjectsOfTypeAll()) + { + if (binding == null) + { + continue; + } + + // This is necessary for cases where the ZenjectBinding is inside a GameObjectContext + // since it won't be caught in the other loop above + if (this is SceneContext) + { + if (binding.Context == null && binding.UseSceneContext + && binding.gameObject.scene == gameObject.scene) + { + binding.Context = this; + } + } + + if (binding.Context == this) + { + InstallZenjectBinding(binding); + } + } + } + + void InstallZenjectBinding(ZenjectBinding binding) + { + if (!binding.enabled) + { + return; + } + + if (binding.Components == null || binding.Components.IsEmpty()) + { + Log.Warn("Found empty list of components on ZenjectBinding on object '{0}'", binding.name); + return; + } + + string identifier = null; + + if (binding.Identifier.Trim().Length > 0) + { + identifier = binding.Identifier; + } + + foreach (var component in binding.Components) + { + var bindType = binding.BindType; + + if (component == null) + { + Log.Warn("Found null component in ZenjectBinding on object '{0}'", binding.name); + continue; + } + + var componentType = component.GetType(); + + switch (bindType) + { + case ZenjectBinding.BindTypes.Self: + { + Container.Bind(componentType).WithId(identifier).FromInstance(component); + break; + } + case ZenjectBinding.BindTypes.BaseType: + { + Container.Bind(componentType.BaseType()).WithId(identifier).FromInstance(component); + break; + } + case ZenjectBinding.BindTypes.AllInterfaces: + { + Container.Bind(componentType.Interfaces()).WithId(identifier).FromInstance(component); + break; + } + case ZenjectBinding.BindTypes.AllInterfacesAndSelf: + { + Container.Bind(componentType.Interfaces().Concat(new[] { componentType }).ToArray()).WithId(identifier).FromInstance(component); + break; + } + default: + { + throw Assert.CreateException(); + } + } + } + } + + protected abstract void GetInjectableMonoBehaviours(List components); + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/Context.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/Context.cs.meta new file mode 100644 index 0000000..7b574e7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/Context.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: be0cf56827265f44bbdeba09329d66ab +timeCreated: 1461708053 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/GameObjectContext.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/GameObjectContext.cs new file mode 100644 index 0000000..80e1897 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/GameObjectContext.cs @@ -0,0 +1,205 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using ModestTree; +using UnityEngine; +using UnityEngine.Serialization; +using Zenject.Internal; + +#pragma warning disable 649 + +namespace Zenject +{ + public class GameObjectContext : RunnableContext + { + public event Action PreInstall; + public event Action PostInstall; + public event Action PreResolve; + public event Action PostResolve; + + [SerializeField] + [Tooltip("Note that this field is optional and can be ignored in most cases. This is really only needed if you want to control the 'Script Execution Order' of your subcontainer. In this case, define a new class that derives from MonoKernel, add it to this game object, then drag it into this field. Then you can set a value for 'Script Execution Order' for this new class and this will control when all ITickable/IInitializable classes bound within this subcontainer get called.")] + [FormerlySerializedAs("_facade")] + MonoKernel _kernel; + + DiContainer _container; + + // Need to cache this when auto run is false + DiContainer _parentContainer; + + bool _hasInstalled; + + public override DiContainer Container + { + get { return _container; } + } + + public override IEnumerable GetRootGameObjects() + { + return new[] { gameObject }; + } + + [Inject] + public void Construct( + DiContainer parentContainer) + { + Assert.IsNull(_parentContainer); + _parentContainer = parentContainer; + + Initialize(); + } + + protected override void RunInternal() + { + Install(_parentContainer); + ResolveAndStart(); + } + + public void Install(DiContainer parentContainer) + { + Assert.That(_parentContainer == null || _parentContainer == parentContainer); + + // We allow calling this explicitly instead of relying on the [Inject] event above + // so that we can follow the two-pass construction-injection pattern in the providers + if (_hasInstalled) + { + return; + } + + _hasInstalled = true; + + Assert.IsNull(_container); + _container = parentContainer.CreateSubContainer(); + + // Do this after creating DiContainer in case it's needed by the pre install logic + if (PreInstall != null) + { + PreInstall(); + } + + var injectableMonoBehaviours = new List(); + + GetInjectableMonoBehaviours(injectableMonoBehaviours); + + foreach (var instance in injectableMonoBehaviours) + { + if (instance is MonoKernel) + { + Assert.That(ReferenceEquals(instance, _kernel), + "Found MonoKernel derived class that is not hooked up to GameObjectContext. If you use MonoKernel, you must indicate this to GameObjectContext by dragging and dropping it to the Kernel field in the inspector"); + } + + _container.QueueForInject(instance); + } + + _container.IsInstalling = true; + + try + { + InstallBindings(injectableMonoBehaviours); + } + finally + { + _container.IsInstalling = false; + } + + if (PostInstall != null) + { + PostInstall(); + } + } + + void ResolveAndStart() + { + if (PreResolve != null) + { + PreResolve(); + } + + _container.ResolveRoots(); + + if (PostResolve != null) + { + PostResolve(); + } + + // Normally, the IInitializable.Initialize method would be called during MonoKernel.Start + // However, this behaviour is undesirable for dynamically created objects, since Unity + // has the strange behaviour of waiting until the end of the frame to call Start() on + // dynamically created objects, which means that any GameObjectContext that is created + // dynamically via a factory cannot be used immediately after calling Create(), since + // it will not have been initialized + // So we have chosen to diverge from Unity behaviour here and trigger IInitializable.Initialize + // immediately - but only when the GameObjectContext is created dynamically. For any + // GameObjectContext's that are placed in the scene, we still want to execute + // IInitializable.Initialize during Start() + if (gameObject.scene.isLoaded && !_container.IsValidating) + { + _kernel = _container.Resolve(); + _kernel.Initialize(); + } + } + + protected override void GetInjectableMonoBehaviours(List monoBehaviours) + { + ZenUtilInternal.AddStateMachineBehaviourAutoInjectersUnderGameObject(gameObject); + + // We inject on all components on the root except ourself + foreach (var monoBehaviour in GetComponents()) + { + if (monoBehaviour == null) + { + // Missing script + continue; + } + + if (!ZenUtilInternal.IsInjectableMonoBehaviourType(monoBehaviour.GetType())) + { + continue; + } + + if (monoBehaviour == this) + { + continue; + } + + monoBehaviours.Add(monoBehaviour); + } + + for (int i = 0; i < transform.childCount; i++) + { + var child = transform.GetChild(i); + + if (child != null) + { + ZenUtilInternal.GetInjectableMonoBehavioursUnderGameObject( + child.gameObject, monoBehaviours); + } + } + } + + void InstallBindings(List injectableMonoBehaviours) + { + _container.DefaultParent = transform; + + _container.Bind().FromInstance(this); + _container.Bind().FromInstance(this); + + if (_kernel == null) + { + _container.Bind() + .To().FromNewComponentOn(gameObject).AsSingle().NonLazy(); + } + else + { + _container.Bind().FromInstance(_kernel).AsSingle().NonLazy(); + } + + InstallSceneBindings(injectableMonoBehaviours); + InstallInstallers(); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/GameObjectContext.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/GameObjectContext.cs.meta new file mode 100644 index 0000000..6d59454 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/GameObjectContext.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 08eca9f7688a0a24685b89133b020c8e +timeCreated: 1456086415 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/ProjectContext.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/ProjectContext.cs new file mode 100644 index 0000000..924dcb3 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/ProjectContext.cs @@ -0,0 +1,298 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using System.Threading; +using ModestTree; +using UnityEngine; +using Zenject.Internal; + +namespace Zenject +{ + public class ProjectContext : Context + { + public static event Action PreInstall; + public static event Action PostInstall; + public static event Action PreResolve; + public static event Action PostResolve; + + public const string ProjectContextResourcePath = "ProjectContext"; + public const string ProjectContextResourcePathOld = "ProjectCompositionRoot"; + + static ProjectContext _instance; + + // TODO: Set this to false the next time major version is incremented + [Tooltip("When true, objects that are created at runtime will be parented to the ProjectContext")] + [SerializeField] + bool _parentNewObjectsUnderContext = true; + + [SerializeField] + ReflectionBakingCoverageModes _editorReflectionBakingCoverageMode = ReflectionBakingCoverageModes.FallbackToDirectReflection; + + [SerializeField] + ReflectionBakingCoverageModes _buildsReflectionBakingCoverageMode = ReflectionBakingCoverageModes.FallbackToDirectReflection; + + [SerializeField] + ZenjectSettings _settings = null; + + DiContainer _container; + + public override DiContainer Container + { + get { return _container; } + } + + public static bool HasInstance + { + get { return _instance != null; } + } + + public static ProjectContext Instance + { + get + { + if (_instance == null) + { + InstantiateAndInitialize(); + Assert.IsNotNull(_instance); + } + + return _instance; + } + } + + public static bool ValidateOnNextRun + { + get; + set; + } + + public override IEnumerable GetRootGameObjects() + { + return new[] { gameObject }; + } + + public static GameObject TryGetPrefab() + { + var prefabs = Resources.LoadAll(ProjectContextResourcePath, typeof(GameObject)); + + if (prefabs.Length > 0) + { + Assert.That(prefabs.Length == 1, + "Found multiple project context prefabs at resource path '{0}'", ProjectContextResourcePath); + return (GameObject)prefabs[0]; + } + + prefabs = Resources.LoadAll(ProjectContextResourcePathOld, typeof(GameObject)); + + if (prefabs.Length > 0) + { + Assert.That(prefabs.Length == 1, + "Found multiple project context prefabs at resource path '{0}'", ProjectContextResourcePathOld); + return (GameObject)prefabs[0]; + } + + return null; + } + + static void InstantiateAndInitialize() + { +#if UNITY_EDITOR + ProfileBlock.UnityMainThread = Thread.CurrentThread; +#endif + + Assert.That(FindObjectsOfType().IsEmpty(), + "Tried to create multiple instances of ProjectContext!"); + + var prefab = TryGetPrefab(); + + var prefabWasActive = false; + +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("GameObject.Instantiate")) +#endif + { + if (prefab == null) + { + _instance = new GameObject("ProjectContext") + .AddComponent(); + } + else + { + prefabWasActive = prefab.activeSelf; + + GameObject gameObjectInstance; +#if UNITY_EDITOR + if(prefabWasActive) + { + // This ensures the prefab's Awake() methods don't fire (and, if in the editor, that the prefab file doesn't get modified) + gameObjectInstance = GameObject.Instantiate(prefab, ZenUtilInternal.GetOrCreateInactivePrefabParent()); + gameObjectInstance.SetActive(false); + gameObjectInstance.transform.SetParent(null, false); + } + else + { + gameObjectInstance = GameObject.Instantiate(prefab); + } +#else + if(prefabWasActive) + { + prefab.SetActive(false); + gameObjectInstance = GameObject.Instantiate(prefab); + prefab.SetActive(true); + } + else + { + gameObjectInstance = GameObject.Instantiate(prefab); + } +#endif + + _instance = gameObjectInstance.GetComponent(); + + Assert.IsNotNull(_instance, + "Could not find ProjectContext component on prefab 'Resources/{0}.prefab'", ProjectContextResourcePath); + } + } + + // Note: We use Initialize instead of awake here in case someone calls + // ProjectContext.Instance while ProjectContext is initializing + _instance.Initialize(); + + if (prefabWasActive) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif + { + // We always instantiate it as disabled so that Awake and Start events are triggered after inject + _instance.gameObject.SetActive(true); + } + } + } + + public bool ParentNewObjectsUnderContext + { + get { return _parentNewObjectsUnderContext; } + set { _parentNewObjectsUnderContext = value; } + } + + public void EnsureIsInitialized() + { + // Do nothing - Initialize occurs in Instance property + } + + public void Awake() + { + if (Application.isPlaying) + // DontDestroyOnLoad can only be called when in play mode and otherwise produces errors + // ProjectContext is created during design time (in an empty scene) when running validation + // and also when running unit tests + // In these cases we don't need DontDestroyOnLoad so just skip it + { + DontDestroyOnLoad(gameObject); + } + } + + void Initialize() + { + Assert.IsNull(_container); + + if (Application.isEditor) + { + TypeAnalyzer.ReflectionBakingCoverageMode = _editorReflectionBakingCoverageMode; + } + else + { + TypeAnalyzer.ReflectionBakingCoverageMode = _buildsReflectionBakingCoverageMode; + } + + var isValidating = ValidateOnNextRun; + + // Reset immediately to ensure it doesn't get used in another run + ValidateOnNextRun = false; + + _container = new DiContainer( + new[] { StaticContext.Container }, isValidating); + + // Do this after creating DiContainer in case it's needed by the pre install logic + if (PreInstall != null) + { + PreInstall(); + } + + var injectableMonoBehaviours = new List(); + GetInjectableMonoBehaviours(injectableMonoBehaviours); + + foreach (var instance in injectableMonoBehaviours) + { + _container.QueueForInject(instance); + } + + _container.IsInstalling = true; + + try + { + InstallBindings(injectableMonoBehaviours); + } + finally + { + _container.IsInstalling = false; + } + + if (PostInstall != null) + { + PostInstall(); + } + + if (PreResolve != null) + { + PreResolve(); + } + + _container.ResolveRoots(); + + if (PostResolve != null) + { + PostResolve(); + } + } + + protected override void GetInjectableMonoBehaviours(List monoBehaviours) + { + ZenUtilInternal.AddStateMachineBehaviourAutoInjectersUnderGameObject(gameObject); + ZenUtilInternal.GetInjectableMonoBehavioursUnderGameObject(gameObject, monoBehaviours); + } + + void InstallBindings(List injectableMonoBehaviours) + { + if (_parentNewObjectsUnderContext) + { + _container.DefaultParent = transform; + } + else + { + _container.DefaultParent = null; + } + + _container.Settings = _settings ?? ZenjectSettings.Default; + + _container.Bind().AsSingle(); + + ZenjectManagersInstaller.Install(_container); + + _container.Bind().FromInstance(this); + + _container.Bind(typeof(ProjectKernel), typeof(MonoKernel)) + .To().FromNewComponentOn(gameObject).AsSingle().NonLazy(); + + _container.Bind().AsSingle(); + + InstallSceneBindings(injectableMonoBehaviours); + + InstallInstallers(); + + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/ProjectContext.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/ProjectContext.cs.meta new file mode 100644 index 0000000..4da7107 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/ProjectContext.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a4e6589720da476459dc6dd71624b071 +timeCreated: 1487808999 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/RunnableContext.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/RunnableContext.cs new file mode 100644 index 0000000..ab32a48 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/RunnableContext.cs @@ -0,0 +1,54 @@ +using ModestTree; +using UnityEngine; + +#if !NOT_UNITY3D + +namespace Zenject +{ + public abstract class RunnableContext : Context + { + [Tooltip("When false, wait until run method is explicitly called. Otherwise run on initialize")] + [SerializeField] + bool _autoRun = true; + + static bool _staticAutoRun = true; + + public bool Initialized { get; private set; } + + protected void Initialize() + { + if (_staticAutoRun && _autoRun) + { + Run(); + } + else + { + // True should always be default + _staticAutoRun = true; + } + } + + public void Run() + { + Assert.That(!Initialized, + "The context already has been initialized!"); + + RunInternal(); + + Initialized = true; + } + + protected abstract void RunInternal(); + + public static T CreateComponent(GameObject gameObject) where T : RunnableContext + { + _staticAutoRun = false; + + var result = gameObject.AddComponent(); + Assert.That(_staticAutoRun); // Should be reset + return result; + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/RunnableContext.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/RunnableContext.cs.meta new file mode 100644 index 0000000..bbd17a0 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/RunnableContext.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 13e9b26d23f6422cb282cc27631fc9e2 +timeCreated: 1494725784 \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/SceneContext.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/SceneContext.cs new file mode 100644 index 0000000..ceba027 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/SceneContext.cs @@ -0,0 +1,381 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using ModestTree.Util; +using UnityEngine; +using UnityEngine.Serialization; +using Zenject.Internal; +using UnityEngine.Events; + +namespace Zenject +{ + public class SceneContext : RunnableContext + { + public event Action PreInstall; + public event Action PostInstall; + public event Action PreResolve; + public event Action PostResolve; + + public UnityEvent OnPreInstall; + public UnityEvent OnPostInstall; + public UnityEvent OnPreResolve; + public UnityEvent OnPostResolve; + + public static Action ExtraBindingsInstallMethod; + public static Action ExtraBindingsLateInstallMethod; + + public static IEnumerable ParentContainers; + + [FormerlySerializedAs("ParentNewObjectsUnderRoot")] + [FormerlySerializedAs("_parentNewObjectsUnderRoot")] + [Tooltip("When true, objects that are created at runtime will be parented to the SceneContext")] + [SerializeField] + bool _parentNewObjectsUnderSceneContext; + + [Tooltip("Optional contract names for this SceneContext, allowing contexts in subsequently loaded scenes to depend on it and be parented to it, and also for previously loaded decorators to be included")] + [SerializeField] + List _contractNames = new List(); + + [Tooltip("Optional contract names of SceneContexts in previously loaded scenes that this context depends on and to which it should be parented")] + [SerializeField] + List _parentContractNames = new List(); + + DiContainer _container; + + readonly List _decoratorContexts = new List(); + + bool _hasInstalled; + bool _hasResolved; + + public override DiContainer Container + { + get { return _container; } + } + + public bool HasResolved + { + get { return _hasResolved; } + } + + public bool HasInstalled + { + get { return _hasInstalled; } + } + + public bool IsValidating + { + get + { + return ProjectContext.Instance.Container.IsValidating; + } + } + + public IEnumerable ContractNames + { + get { return _contractNames; } + set + { + _contractNames.Clear(); + _contractNames.AddRange(value); + } + } + + public IEnumerable ParentContractNames + { + get + { + var result = new List(); + result.AddRange(_parentContractNames); + return result; + } + set + { + _parentContractNames = value.ToList(); + } + } + + public bool ParentNewObjectsUnderSceneContext + { + get { return _parentNewObjectsUnderSceneContext; } + set { _parentNewObjectsUnderSceneContext = value; } + } + + public void Awake() + { +#if ZEN_INTERNAL_PROFILING + ProfileTimers.ResetAll(); + using (ProfileTimers.CreateTimedBlock("Other")) +#endif + { + Initialize(); + } + } + + public void Validate() + { + Assert.That(IsValidating); + + Install(); + Resolve(); + } + + protected override void RunInternal() + { + // We always want to initialize ProjectContext as early as possible + ProjectContext.Instance.EnsureIsInitialized(); + +#if UNITY_EDITOR + using (ProfileBlock.Start("Zenject.SceneContext.Install")) +#endif + { + Install(); + } + +#if UNITY_EDITOR + using (ProfileBlock.Start("Zenject.SceneContext.Resolve")) +#endif + { + Resolve(); + } + } + + public override IEnumerable GetRootGameObjects() + { + return ZenUtilInternal.GetRootGameObjects(gameObject.scene); + } + + IEnumerable GetParentContainers() + { + var parentContractNames = ParentContractNames; + + if (parentContractNames.IsEmpty()) + { + if (ParentContainers != null) + { + var tempParentContainer = ParentContainers; + + // Always reset after using it - it is only used to pass the reference + // between scenes via ZenjectSceneLoader + ParentContainers = null; + + return tempParentContainer; + } + + return new[] { ProjectContext.Instance.Container }; + } + + Assert.IsNull(ParentContainers, + "Scene cannot have both a parent scene context name set and also an explicit parent container given"); + + var parentContainers = UnityUtil.AllLoadedScenes + .Except(gameObject.scene) + .SelectMany(scene => scene.GetRootGameObjects()) + .SelectMany(root => root.GetComponentsInChildren()) + .Where(sceneContext => sceneContext.ContractNames.Where(x => parentContractNames.Contains(x)).Any()) + .Select(x => x.Container) + .ToList(); + + if (!parentContainers.Any()) + { + throw Assert.CreateException( + "SceneContext on object {0} of scene {1} requires at least one of contracts '{2}', but none of the loaded SceneContexts implements that contract.", + gameObject.name, + gameObject.scene.name, + parentContractNames.Join(", ")); + } + + return parentContainers; + } + + List LookupDecoratorContexts() + { + if (_contractNames.IsEmpty()) + { + return new List(); + } + + return UnityUtil.AllLoadedScenes + .Except(gameObject.scene) + .SelectMany(scene => scene.GetRootGameObjects()) + .SelectMany(root => root.GetComponentsInChildren()) + .Where(decoratorContext => _contractNames.Contains(decoratorContext.DecoratedContractName)) + .ToList(); + } + + public void Install() + { + Assert.That(!_hasInstalled); + _hasInstalled = true; + + Assert.IsNull(_container); + + var parents = GetParentContainers(); + Assert.That(!parents.IsEmpty()); + Assert.That(parents.All(x => x.IsValidating == parents.First().IsValidating)); + + _container = new DiContainer(parents, parents.First().IsValidating); + + // Do this after creating DiContainer in case it's needed by the pre install logic + if (PreInstall != null) + { + PreInstall(); + } + + if (OnPreInstall != null) + { + OnPreInstall.Invoke(); + } + + Assert.That(_decoratorContexts.IsEmpty()); + _decoratorContexts.AddRange(LookupDecoratorContexts()); + + if (_parentNewObjectsUnderSceneContext) + { + _container.DefaultParent = transform; + } + else + { + _container.DefaultParent = null; + } + + // Record all the injectable components in the scene BEFORE installing the installers + // This is nice for cases where the user calls InstantiatePrefab<>, etc. in their installer + // so that it doesn't inject on the game object twice + // InitialComponentsInjecter will also guarantee that any component that is injected into + // another component has itself been injected + var injectableMonoBehaviours = new List(); + GetInjectableMonoBehaviours(injectableMonoBehaviours); + foreach (var instance in injectableMonoBehaviours) + { + _container.QueueForInject(instance); + } + + foreach (var decoratorContext in _decoratorContexts) + { + decoratorContext.Initialize(_container); + } + + _container.IsInstalling = true; + + try + { + InstallBindings(injectableMonoBehaviours); + } + finally + { + _container.IsInstalling = false; + } + + if (PostInstall != null) + { + PostInstall(); + } + + if (OnPostInstall != null) + { + OnPostInstall.Invoke(); + } + } + + public void Resolve() + { + if (PreResolve != null) + { + PreResolve(); + } + + if (OnPreResolve != null) + { + OnPreResolve.Invoke(); + } + + Assert.That(_hasInstalled); + Assert.That(!_hasResolved); + _hasResolved = true; + + _container.ResolveRoots(); + + if (PostResolve != null) + { + PostResolve(); + } + + if (OnPostResolve != null) + { + OnPostResolve.Invoke(); + } + } + + void InstallBindings(List injectableMonoBehaviours) + { + _container.Bind(typeof(Context), typeof(SceneContext)).To().FromInstance(this); + _container.BindInterfacesTo().AsSingle(); + + // Add to registry first and remove from registry last + _container.BindExecutionOrder(-1); + + foreach (var decoratorContext in _decoratorContexts) + { + decoratorContext.InstallDecoratorSceneBindings(); + } + + InstallSceneBindings(injectableMonoBehaviours); + + _container.Bind(typeof(SceneKernel), typeof(MonoKernel)) + .To().FromNewComponentOn(gameObject).AsSingle().NonLazy(); + + _container.Bind().AsSingle(); + + if (ExtraBindingsInstallMethod != null) + { + ExtraBindingsInstallMethod(_container); + // Reset extra bindings for next time we change scenes + ExtraBindingsInstallMethod = null; + } + + // Always install the installers last so they can be injected with + // everything above + foreach (var decoratorContext in _decoratorContexts) + { + decoratorContext.InstallDecoratorInstallers(); + } + + InstallInstallers(); + + foreach (var decoratorContext in _decoratorContexts) + { + decoratorContext.InstallLateDecoratorInstallers(); + } + + if (ExtraBindingsLateInstallMethod != null) + { + ExtraBindingsLateInstallMethod(_container); + // Reset extra bindings for next time we change scenes + ExtraBindingsLateInstallMethod = null; + } + } + + protected override void GetInjectableMonoBehaviours(List monoBehaviours) + { + var scene = gameObject.scene; + + ZenUtilInternal.AddStateMachineBehaviourAutoInjectersInScene(scene); + ZenUtilInternal.GetInjectableMonoBehavioursInScene(scene, monoBehaviours); + } + + // These methods can be used for cases where you need to create the SceneContext entirely in code + // Note that if you use these methods that you have to call Run() yourself + // This is useful because it allows you to create a SceneContext and configure it how you want + // and add what installers you want before kicking off the Install/Resolve + public static SceneContext Create() + { + return CreateComponent( + new GameObject("SceneContext")); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/SceneContext.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/SceneContext.cs.meta new file mode 100644 index 0000000..5ca4028 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/SceneContext.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 89715ad69b973a14899afa2c6730b30b +timeCreated: 1435941958 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: -9999 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/SceneDecoratorContext.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/SceneDecoratorContext.cs new file mode 100644 index 0000000..587bda2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/SceneDecoratorContext.cs @@ -0,0 +1,122 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using ModestTree; +using UnityEngine; +using UnityEngine.Serialization; +using Zenject.Internal; + +namespace Zenject +{ + public class SceneDecoratorContext : Context + { + [SerializeField] + List _lateInstallers = new List(); + + [SerializeField] + List _lateInstallerPrefabs = new List(); + + [SerializeField] + List _lateScriptableObjectInstallers = new List(); + + public IEnumerable LateInstallers + { + get { return _lateInstallers; } + set + { + _lateInstallers.Clear(); + _lateInstallers.AddRange(value); + } + } + + public IEnumerable LateInstallerPrefabs + { + get { return _lateInstallerPrefabs; } + set + { + _lateInstallerPrefabs.Clear(); + _lateInstallerPrefabs.AddRange(value); + } + } + + public IEnumerable LateScriptableObjectInstallers + { + get { return _lateScriptableObjectInstallers; } + set + { + _lateScriptableObjectInstallers.Clear(); + _lateScriptableObjectInstallers.AddRange(value); + } + } + + [FormerlySerializedAs("SceneName")] + [SerializeField] + string _decoratedContractName = null; + + DiContainer _container; + readonly List _injectableMonoBehaviours = new List(); + + public string DecoratedContractName + { + get { return _decoratedContractName; } + } + + public override DiContainer Container + { + get + { + Assert.IsNotNull(_container); + return _container; + } + } + + public override IEnumerable GetRootGameObjects() + { + // This method should never be called because SceneDecoratorContext's are not bound + // to the container + throw Assert.CreateException(); + } + + public void Initialize(DiContainer container) + { + Assert.IsNull(_container); + Assert.That(_injectableMonoBehaviours.IsEmpty()); + + _container = container; + + GetInjectableMonoBehaviours(_injectableMonoBehaviours); + + foreach (var instance in _injectableMonoBehaviours) + { + container.QueueForInject(instance); + } + } + + public void InstallDecoratorSceneBindings() + { + _container.Bind().FromInstance(this); + InstallSceneBindings(_injectableMonoBehaviours); + } + + public void InstallDecoratorInstallers() + { + InstallInstallers(); + } + + protected override void GetInjectableMonoBehaviours(List monoBehaviours) + { + var scene = gameObject.scene; + + ZenUtilInternal.AddStateMachineBehaviourAutoInjectersInScene(scene); + ZenUtilInternal.GetInjectableMonoBehavioursInScene(scene, monoBehaviours); + } + + public void InstallLateDecoratorInstallers() + { + InstallInstallers(new List(), new List(), _lateScriptableObjectInstallers, _lateInstallers, _lateInstallerPrefabs); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/SceneDecoratorContext.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/SceneDecoratorContext.cs.meta new file mode 100644 index 0000000..6ac58ec --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/SceneDecoratorContext.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ed7323e8fdd8c26438c6485f2060dad0 +timeCreated: 1487808999 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/StaticContext.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/StaticContext.cs new file mode 100644 index 0000000..c4933d4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/StaticContext.cs @@ -0,0 +1,40 @@ +#if !NOT_UNITY3D + +namespace Zenject +{ + // For some platforms, it's desirable to be able to add dependencies to Zenject before + // Unity even starts up (eg. WSA as described here https://github.com/svermeulen/Zenject/issues/118) + // In those cases you can call StaticContext.Container.BindX to add dependencies + // Anything you add there will then be injected everywhere, since all other contexts + // should be children of StaticContext + public static class StaticContext + { + static DiContainer _container; + + // Useful sometimes to call from play mode tests + public static void Clear() + { + _container = null; + } + + public static bool HasContainer + { + get { return _container != null; } + } + + public static DiContainer Container + { + get + { + if (_container == null) + { + _container = new DiContainer(); + } + + return _container; + } + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/StaticContext.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/StaticContext.cs.meta new file mode 100644 index 0000000..f0dd2e1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Contexts/StaticContext.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 668a9feb769954340b35901a0c829397 +timeCreated: 1462834162 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/IInstaller.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/IInstaller.cs new file mode 100644 index 0000000..c74a4ba --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/IInstaller.cs @@ -0,0 +1,14 @@ +namespace Zenject +{ + // We extract the interface so that monobehaviours can be installers + public interface IInstaller + { + void InstallBindings(); + + bool IsEnabled + { + get; + } + } + +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/IInstaller.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/IInstaller.cs.meta new file mode 100644 index 0000000..8b86483 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/IInstaller.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 65a9d43edcbe33640989f12f980de5d1 +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Installer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Installer.cs new file mode 100644 index 0000000..75e6fea --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Installer.cs @@ -0,0 +1,77 @@ +namespace Zenject +{ + // + // I'd recommmend using Installer<> instead, and then always use the approach + // of calling `MyInstaller.Install(Container)` + // This way, if you want to add strongly typed parameters later you can do this + // by deriving from a different Installer<> base class + // + public abstract class Installer : InstallerBase + { + } + + // + // Derive from this class then install like this: + // FooInstaller.Install(Container); + // + public abstract class Installer : InstallerBase + where TDerived : Installer + { + public static void Install(DiContainer container) + { + container.Instantiate().InstallBindings(); + } + } + + // Use these versions to pass parameters to your installer + + public abstract class Installer : InstallerBase + where TDerived : Installer + { + public static void Install(DiContainer container, TParam1 p1) + { + container.InstantiateExplicit( + InjectUtil.CreateArgListExplicit(p1)).InstallBindings(); + } + } + + public abstract class Installer : InstallerBase + where TDerived : Installer + { + public static void Install(DiContainer container, TParam1 p1, TParam2 p2) + { + container.InstantiateExplicit( + InjectUtil.CreateArgListExplicit(p1, p2)).InstallBindings(); + } + } + + public abstract class Installer : InstallerBase + where TDerived : Installer + { + public static void Install(DiContainer container, TParam1 p1, TParam2 p2, TParam3 p3) + { + container.InstantiateExplicit( + InjectUtil.CreateArgListExplicit(p1, p2, p3)).InstallBindings(); + } + } + + public abstract class Installer : InstallerBase + where TDerived : Installer + { + public static void Install(DiContainer container, TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4) + { + container.InstantiateExplicit( + InjectUtil.CreateArgListExplicit(p1, p2, p3, p4)).InstallBindings(); + } + } + + public abstract class Installer : InstallerBase + where TDerived : Installer + { + public static void Install(DiContainer container, TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5) + { + container.InstantiateExplicit( + InjectUtil.CreateArgListExplicit(p1, p2, p3, p4, p5)).InstallBindings(); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Installer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Installer.cs.meta new file mode 100644 index 0000000..0aac821 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/Installer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 743eef94d86c79e4189b311a7c7528ce +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/InstallerBase.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/InstallerBase.cs new file mode 100644 index 0000000..5dc96f0 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/InstallerBase.cs @@ -0,0 +1,21 @@ +namespace Zenject +{ + public abstract class InstallerBase : IInstaller + { + [Inject] + DiContainer _container = null; + + protected DiContainer Container + { + get { return _container; } + } + + public virtual bool IsEnabled + { + get { return true; } + } + + public abstract void InstallBindings(); + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/InstallerBase.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/InstallerBase.cs.meta new file mode 100644 index 0000000..dca2d90 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/InstallerBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d908209e11d07744483c5fea3b406f33 +timeCreated: 1465520282 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/MonoInstaller.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/MonoInstaller.cs new file mode 100644 index 0000000..ce38296 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/MonoInstaller.cs @@ -0,0 +1,171 @@ +#if !NOT_UNITY3D + +using ModestTree; + +namespace Zenject +{ + // We'd prefer to make this abstract but Unity 5.3.5 has a bug where references + // can get lost during compile errors for classes that are abstract + public class MonoInstaller : MonoInstallerBase + { + } + + // + // Derive from this class instead to install like this: + // FooInstaller.InstallFromResource(Container); + // Or + // FooInstaller.InstallFromResource("My/Path/ToPrefab", Container); + // + // (Instead of needing to add the MonoInstaller via inspector) + // + // This approach is needed if you want to pass in strongly parameters to it from + // another installer + public class MonoInstaller : MonoInstaller + where TDerived : MonoInstaller + { + public static TDerived InstallFromResource(DiContainer container) + { + return InstallFromResource(MonoInstallerUtil.GetDefaultResourcePath(), container); + } + + public static TDerived InstallFromResource(string resourcePath, DiContainer container) + { + return InstallFromResource(resourcePath, container, new object[0]); + } + + public static TDerived InstallFromResource(DiContainer container, object[] extraArgs) + { + return InstallFromResource(MonoInstallerUtil.GetDefaultResourcePath(), container, extraArgs); + } + + public static TDerived InstallFromResource(string resourcePath, DiContainer container, object[] extraArgs) + { + var installer = MonoInstallerUtil.CreateInstaller(resourcePath, container); + container.Inject(installer, extraArgs); + installer.InstallBindings(); + return installer; + } + } + + public class MonoInstaller : MonoInstallerBase + where TDerived : MonoInstaller + { + public static TDerived InstallFromResource(DiContainer container, TParam1 p1) + { + return InstallFromResource(MonoInstallerUtil.GetDefaultResourcePath(), container, p1); + } + + public static TDerived InstallFromResource(string resourcePath, DiContainer container, TParam1 p1) + { + var installer = MonoInstallerUtil.CreateInstaller(resourcePath, container); + container.InjectExplicit(installer, InjectUtil.CreateArgListExplicit(p1)); + installer.InstallBindings(); + return installer; + } + } + + public class MonoInstaller : MonoInstallerBase + where TDerived : MonoInstaller + { + public static TDerived InstallFromResource(DiContainer container, TParam1 p1, TParam2 p2) + { + return InstallFromResource(MonoInstallerUtil.GetDefaultResourcePath(), container, p1, p2); + } + + public static TDerived InstallFromResource(string resourcePath, DiContainer container, TParam1 p1, TParam2 p2) + { + var installer = MonoInstallerUtil.CreateInstaller(resourcePath, container); + container.InjectExplicit(installer, InjectUtil.CreateArgListExplicit(p1, p2)); + installer.InstallBindings(); + return installer; + } + } + + public class MonoInstaller : MonoInstallerBase + where TDerived : MonoInstaller + { + public static TDerived InstallFromResource(DiContainer container, TParam1 p1, TParam2 p2, TParam3 p3) + { + return InstallFromResource(MonoInstallerUtil.GetDefaultResourcePath(), container, p1, p2, p3); + } + + public static TDerived InstallFromResource(string resourcePath, DiContainer container, TParam1 p1, TParam2 p2, TParam3 p3) + { + var installer = MonoInstallerUtil.CreateInstaller(resourcePath, container); + container.InjectExplicit(installer, InjectUtil.CreateArgListExplicit(p1, p2, p3)); + installer.InstallBindings(); + return installer; + } + } + + public class MonoInstaller : MonoInstallerBase + where TDerived : MonoInstaller + { + public static TDerived InstallFromResource(DiContainer container, TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4) + { + return InstallFromResource(MonoInstallerUtil.GetDefaultResourcePath(), container, p1, p2, p3, p4); + } + + public static TDerived InstallFromResource(string resourcePath, DiContainer container, TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4) + { + var installer = MonoInstallerUtil.CreateInstaller(resourcePath, container); + container.InjectExplicit(installer, InjectUtil.CreateArgListExplicit(p1, p2, p3, p4)); + installer.InstallBindings(); + return installer; + } + } + + public class MonoInstaller : MonoInstallerBase + where TDerived : MonoInstaller + { + public static TDerived InstallFromResource(DiContainer container, TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5) + { + return InstallFromResource(MonoInstallerUtil.GetDefaultResourcePath(), container, p1, p2, p3, p4, p5); + } + + public static TDerived InstallFromResource(string resourcePath, DiContainer container, TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5) + { + var installer = MonoInstallerUtil.CreateInstaller(resourcePath, container); + container.InjectExplicit(installer, InjectUtil.CreateArgListExplicit(p1, p2, p3, p4, p5)); + installer.InstallBindings(); + return installer; + } + } + + public static class MonoInstallerUtil + { + public static string GetDefaultResourcePath() + where TInstaller : MonoInstallerBase + { + return "Installers/" + typeof(TInstaller).PrettyName(); + } + + public static TInstaller CreateInstaller( + string resourcePath, DiContainer container) + where TInstaller : MonoInstallerBase + { + bool shouldMakeActive; + var gameObj = container.CreateAndParentPrefabResource( + resourcePath, GameObjectCreationParameters.Default, null, out shouldMakeActive); + + if (shouldMakeActive && !container.IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif + { + gameObj.SetActive(true); + } + } + + var installers = gameObj.GetComponentsInChildren(); + + Assert.That(installers.Length == 1, + "Could not find unique MonoInstaller with type '{0}' on prefab '{1}'", typeof(TInstaller), gameObj.name); + + return installers[0]; + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/MonoInstaller.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/MonoInstaller.cs.meta new file mode 100644 index 0000000..9ac8124 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/MonoInstaller.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 724ff9f6c80e0b044b7db58730dc6075 +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/MonoInstallerBase.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/MonoInstallerBase.cs new file mode 100644 index 0000000..a2da881 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/MonoInstallerBase.cs @@ -0,0 +1,38 @@ +#if !NOT_UNITY3D + +using System; +using System.Diagnostics; +using UnityEngine; + +namespace Zenject +{ + // We'd prefer to make this abstract but Unity 5.3.5 has a bug where references + // can get lost during compile errors for classes that are abstract + [DebuggerStepThrough] + public class MonoInstallerBase : MonoBehaviour, IInstaller + { + [Inject] + protected DiContainer Container + { + get; set; + } + + public virtual bool IsEnabled + { + get { return enabled; } + } + + public virtual void Start() + { + // Define this method so we expose the enabled check box + } + + public virtual void InstallBindings() + { + throw new NotImplementedException(); + } + } +} + +#endif + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/MonoInstallerBase.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/MonoInstallerBase.cs.meta new file mode 100644 index 0000000..292961f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/MonoInstallerBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 93d53e91e1ef3484a99feb7aa58f2b63 +timeCreated: 1465520769 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ScriptableObjectInstaller.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ScriptableObjectInstaller.cs new file mode 100644 index 0000000..d45c562 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ScriptableObjectInstaller.cs @@ -0,0 +1,141 @@ +#if !NOT_UNITY3D + +using ModestTree; +using UnityEngine; + +namespace Zenject +{ + // We'd prefer to make this abstract but Unity 5.3.5 has a bug where references + // can get lost during compile errors for classes that are abstract + public class ScriptableObjectInstaller : ScriptableObjectInstallerBase + { + } + + // + // Derive from this class instead to install like this: + // FooInstaller.InstallFromResource(Container); + // Or + // FooInstaller.InstallFromResource("My/Path/ToScriptableObjectInstance", Container); + // + // (Instead of needing to add the ScriptableObjectInstaller directly via inspector) + // + // This approach is needed if you want to pass in strongly typed runtime parameters too it + // + public class ScriptableObjectInstaller : ScriptableObjectInstaller + where TDerived : ScriptableObjectInstaller + { + public static TDerived InstallFromResource(DiContainer container) + { + return InstallFromResource( + ScriptableObjectInstallerUtil.GetDefaultResourcePath(), container); + } + + public static TDerived InstallFromResource(string resourcePath, DiContainer container) + { + var installer = ScriptableObjectInstallerUtil.CreateInstaller(resourcePath, container); + container.Inject(installer); + installer.InstallBindings(); + return installer; + } + } + + public class ScriptableObjectInstaller : ScriptableObjectInstallerBase + where TDerived : ScriptableObjectInstaller + { + public static TDerived InstallFromResource(DiContainer container, TParam1 p1) + { + return InstallFromResource( + ScriptableObjectInstallerUtil.GetDefaultResourcePath(), container, p1); + } + + public static TDerived InstallFromResource(string resourcePath, DiContainer container, TParam1 p1) + { + var installer = ScriptableObjectInstallerUtil.CreateInstaller(resourcePath, container); + container.InjectExplicit(installer, InjectUtil.CreateArgListExplicit(p1)); + installer.InstallBindings(); + return installer; + } + } + + public class ScriptableObjectInstaller : ScriptableObjectInstallerBase + where TDerived : ScriptableObjectInstaller + { + public static TDerived InstallFromResource(DiContainer container, TParam1 p1, TParam2 p2) + { + return InstallFromResource( + ScriptableObjectInstallerUtil.GetDefaultResourcePath(), container, p1, p2); + } + + public static TDerived InstallFromResource(string resourcePath, DiContainer container, TParam1 p1, TParam2 p2) + { + var installer = ScriptableObjectInstallerUtil.CreateInstaller(resourcePath, container); + container.InjectExplicit(installer, InjectUtil.CreateArgListExplicit(p1, p2)); + installer.InstallBindings(); + return installer; + } + } + + public class ScriptableObjectInstaller : ScriptableObjectInstallerBase + where TDerived : ScriptableObjectInstaller + { + public static TDerived InstallFromResource(DiContainer container, TParam1 p1, TParam2 p2, TParam3 p3) + { + return InstallFromResource( + ScriptableObjectInstallerUtil.GetDefaultResourcePath(), container, p1, p2, p3); + } + + public static TDerived InstallFromResource(string resourcePath, DiContainer container, TParam1 p1, TParam2 p2, TParam3 p3) + { + var installer = ScriptableObjectInstallerUtil.CreateInstaller(resourcePath, container); + container.InjectExplicit(installer, InjectUtil.CreateArgListExplicit(p1, p2, p3)); + installer.InstallBindings(); + return installer; + } + } + + public class ScriptableObjectInstaller : ScriptableObjectInstallerBase + where TDerived : ScriptableObjectInstaller + { + public static TDerived InstallFromResource(DiContainer container, TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4) + { + return InstallFromResource( + ScriptableObjectInstallerUtil.GetDefaultResourcePath(), container, p1, p2, p3, p4); + } + + public static TDerived InstallFromResource(string resourcePath, DiContainer container, TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4) + { + var installer = ScriptableObjectInstallerUtil.CreateInstaller(resourcePath, container); + container.InjectExplicit(installer, InjectUtil.CreateArgListExplicit(p1, p2, p3, p4)); + installer.InstallBindings(); + return installer; + } + } + + public static class ScriptableObjectInstallerUtil + { + public static string GetDefaultResourcePath() + where TInstaller : ScriptableObjectInstallerBase + { + return "Installers/" + typeof(TInstaller).PrettyName(); + } + + public static TInstaller CreateInstaller( + string resourcePath, DiContainer container) + where TInstaller : ScriptableObjectInstallerBase + { + var installers = Resources.LoadAll(resourcePath); + + Assert.That(installers.Length == 1, + "Could not find unique ScriptableObjectInstaller with type '{0}' at resource path '{1}'", typeof(TInstaller), resourcePath); + + var installer = installers[0]; + + Assert.That(installer is TInstaller, + "Expected to find installer with type '{0}' at resource path '{1}'", typeof(TInstaller), resourcePath); + + return (TInstaller)installer; + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ScriptableObjectInstaller.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ScriptableObjectInstaller.cs.meta new file mode 100644 index 0000000..702cc4f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ScriptableObjectInstaller.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 00b9d7602aaf02748aa93779bbf29799 +timeCreated: 1461708048 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ScriptableObjectInstallerBase.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ScriptableObjectInstallerBase.cs new file mode 100644 index 0000000..a38501f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ScriptableObjectInstallerBase.cs @@ -0,0 +1,33 @@ +#if !NOT_UNITY3D + +using System; +using UnityEngine; + +namespace Zenject +{ + // We'd prefer to make this abstract but Unity 5.3.5 has a bug where references + // can get lost during compile errors for classes that are abstract + public class ScriptableObjectInstallerBase : ScriptableObject, IInstaller + { + [Inject] + DiContainer _container = null; + + protected DiContainer Container + { + get { return _container; } + } + + bool IInstaller.IsEnabled + { + get { return true; } + } + + public virtual void InstallBindings() + { + throw new NotImplementedException(); + } + } +} + +#endif + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ScriptableObjectInstallerBase.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ScriptableObjectInstallerBase.cs.meta new file mode 100644 index 0000000..5111156 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ScriptableObjectInstallerBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 97c39aeade32bd54c8754bc9d6da25ab +timeCreated: 1465523215 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ZenjectBinding.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ZenjectBinding.cs new file mode 100644 index 0000000..fcdb386 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ZenjectBinding.cs @@ -0,0 +1,72 @@ +#if !NOT_UNITY3D + +using UnityEngine; +using UnityEngine.Serialization; + +namespace Zenject +{ + public class ZenjectBinding : MonoBehaviour + { + [Tooltip("The component to add to the Zenject container")] + [SerializeField] + Component[] _components = null; + + [Tooltip("Note: This value is optional and can be ignored in most cases. This can be useful to differentiate multiple bindings of the same type. For example, if you have multiple cameras in your scene, you can 'name' them by giving each one a different identifier. For your main camera you might call it 'Main' then any class can refer to it by using an attribute like [Inject(Id = 'Main')]")] + [SerializeField] + string _identifier = string.Empty; + + [Tooltip("When set, this will bind the given components to the SceneContext. It can be used as a shortcut to explicitly dragging the SceneContext into the Context field. This is useful when using ZenjectBinding inside GameObjectContext. If your ZenjectBinding is for a component that is not underneath GameObjectContext then it is not necessary to check this")] + [SerializeField] + bool _useSceneContext = false; + + [Tooltip("Note: This value is optional and can be ignored in most cases. This value will determine what container the component gets added to. If unset, the component will be bound on the most 'local' context. In most cases this will be the SceneContext, unless this component is underneath a GameObjectContext, or ProjectContext, in which case it will bind to that instead by default. You can also override this default by providing the Context directly. This can be useful if you want to bind something that is inside a GameObjectContext to the SceneContext container.")] + [SerializeField] + [FormerlySerializedAs("_compositionRoot")] + Context _context = null; + + [Tooltip("This value is used to determine how to bind this component. When set to 'Self' is equivalent to calling Container.FromInstance inside an installer. When set to 'AllInterfaces' this is equivalent to calling 'Container.BindInterfaces().ToInstance', and similarly for InterfacesAndSelf")] + [SerializeField] + BindTypes _bindType = BindTypes.Self; + + public bool UseSceneContext + { + get { return _useSceneContext; } + } + + public Context Context + { + get { return _context; } + set { _context = value; } + } + + public Component[] Components + { + get { return _components; } + } + + public string Identifier + { + get { return _identifier; } + } + + public BindTypes BindType + { + get { return _bindType; } + } + + public void Start() + { + // Define this method so we expose the enabled check box + } + + public enum BindTypes + { + Self, + AllInterfaces, + AllInterfacesAndSelf, + BaseType + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ZenjectBinding.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ZenjectBinding.cs.meta new file mode 100644 index 0000000..ed3c9bd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ZenjectBinding.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0166d8ff8d905b048b2448179e1f5d11 +timeCreated: 1454288321 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ZenjectManagersInstaller.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ZenjectManagersInstaller.cs new file mode 100644 index 0000000..b5329d7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ZenjectManagersInstaller.cs @@ -0,0 +1,21 @@ + +namespace Zenject +{ + // This is installed by default in ProjectContext, however, if you are using Zenject outside + // of Unity then you might want to call this + // + // In this case though, you will have to manually call InitializableManager.Initialize, + // DisposableManager.Dispose, TickableManager.Tick, etc. when appropriate for the environment + // you are working in + // + // You might also want to use this installer in a ZenjectUnitTestFixture + public class ZenjectManagersInstaller : Installer + { + public override void InstallBindings() + { + Container.Bind(typeof(TickableManager), typeof(InitializableManager), typeof(DisposableManager)) + .ToSelf().AsSingle().CopyIntoAllSubContainers(); + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ZenjectManagersInstaller.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ZenjectManagersInstaller.cs.meta new file mode 100644 index 0000000..1caba5a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Install/ZenjectManagersInstaller.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b05e95f8fed82b244b78a5e2df541713 +timeCreated: 1529046908 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal.meta new file mode 100644 index 0000000..a4415bb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: dd4fbc001f8bada428bbe3af6b6b21e8 +folderAsset: yes +timeCreated: 1452188408 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Assert.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Assert.cs new file mode 100644 index 0000000..77d1f0e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Assert.cs @@ -0,0 +1,433 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using Zenject; + +namespace ModestTree +{ + public static class Assert + { +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void That(bool condition) + { + if (!condition) + { + throw CreateException("Assert hit!"); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsNotEmpty(string str) + { + if (String.IsNullOrEmpty(str)) + { + throw CreateException("Unexpected null or empty string"); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + // This is better because IsEmpty with IEnumerable causes a memory alloc + public static void IsEmpty(IList list) + { + if (list.Count != 0) + { + throw CreateException( + "Expected collection to be empty but instead found '{0}' elements", list.Count); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsEmpty(IEnumerable sequence) + { + if (!sequence.IsEmpty()) + { + throw CreateException("Expected collection to be empty but instead found '{0}' elements", + sequence.Count()); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsType(object obj) + { + IsType(obj, ""); + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsType(object obj, string message) + { + if (!(obj is T)) + { + throw CreateException("Assert Hit! {0}\nWrong type found. Expected '{1}' (left) but found '{2}' (right). ", message, typeof(T).PrettyName(), obj.GetType().PrettyName()); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void DerivesFrom(Type type) + { + if (!type.DerivesFrom()) + { + throw CreateException("Expected type '{0}' to derive from '{1}'", type.Name, typeof(T).Name); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void DerivesFromOrEqual(Type type) + { + if (!type.DerivesFromOrEqual()) + { + throw CreateException("Expected type '{0}' to derive from or be equal to '{1}'", type.Name, typeof(T).Name); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void DerivesFrom(Type childType, Type parentType) + { + if (!childType.DerivesFrom(parentType)) + { + throw CreateException("Expected type '{0}' to derive from '{1}'", childType.Name, parentType.Name); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void DerivesFromOrEqual(Type childType, Type parentType) + { + if (!childType.DerivesFromOrEqual(parentType)) + { + throw CreateException("Expected type '{0}' to derive from or be equal to '{1}'", childType.Name, parentType.Name); + } + } + + // Use AssertEquals to get better error output (with values) +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsEqual(object left, object right) + { + IsEqual(left, right, ""); + } + + // Use AssertEquals to get better error output (with values) +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsEqual(object left, object right, Func messageGenerator) + { + if (!object.Equals(left, right)) + { + left = left ?? ""; + right = right ?? ""; + throw CreateException("Assert Hit! {0}. Expected '{1}' (left) but found '{2}' (right). ", messageGenerator(), left, right); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsApproximately(float left, float right, float epsilon = 0.00001f) + { + bool isEqual = Math.Abs(left - right) < epsilon; + + if (!isEqual) + { + throw CreateException("Assert Hit! Expected '{0}' (left) but found '{1}' (right). ", left, right); + } + } + + // Use AssertEquals to get better error output (with values) +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsEqual(object left, object right, string message) + { + if (!object.Equals(left, right)) + { + left = left ?? ""; + right = right ?? ""; + throw CreateException("Assert Hit! {0}\nExpected '{1}' (left) but found '{2}' (right). ", message, left, right); + } + } + + // Use Assert.IsNotEqual to get better error output (with values) +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsNotEqual(object left, object right) + { + IsNotEqual(left, right, ""); + } + + // Use Assert.IsNotEqual to get better error output (with values) +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsNotEqual(object left, object right, Func messageGenerator) + { + if(object.Equals(left, right)) + { + left = left ?? ""; + right = right ?? ""; + throw CreateException("Assert Hit! {0}. Expected '{1}' (left) to differ from '{2}' (right). ", messageGenerator(), left, right); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsNull(object val) + { + if (val != null) + { + throw CreateException( + "Assert Hit! Expected null pointer but instead found '{0}'", val); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsNull(object val, string message) + { + if (val != null) + { + throw CreateException( + "Assert Hit! {0}", message); + } + } + + // We don't use params here to avoid the memory alloc +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsNull(object val, string message, object p1) + { + if (val != null) + { + throw CreateException( + "Assert Hit! {0}", message.Fmt(p1)); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsNotNull(object val) + { + if (val == null) + { + throw CreateException("Assert Hit! Found null pointer when value was expected"); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsNotNull(object val, string message) + { + if (val == null) + { + throw CreateException("Assert Hit! {0}", message); + } + } + + // We don't use params here to avoid the memory alloc +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsNotNull(object val, string message, object p1) + { + if (val == null) + { + throw CreateException("Assert Hit! {0}", message.Fmt(p1)); + } + } + + // We don't use params here to avoid the memory alloc +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsNotNull(object val, string message, object p1, object p2) + { + if (val == null) + { + throw CreateException("Assert Hit! {0}", message.Fmt(p1, p2)); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsNotEmpty(IEnumerable val, string message = "") + { + if (!val.Any()) + { + throw CreateException("Assert Hit! Expected empty collection but found {0} values. {1}", val.Count(), message); + } + } + + // Use Assert.IsNotEqual to get better error output (with values) +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void IsNotEqual(object left, object right, string message) + { + if (object.Equals(left, right)) + { + left = left ?? ""; + right = right ?? ""; + throw CreateException("Assert Hit! {0}. Unexpected value found '{1}'. ", message, left); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void Warn(bool condition) + { + if (!condition) + { + ModestTree.Log.Warn("Warning! See call stack"); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void Warn(bool condition, Func messageGenerator) + { + if (!condition) + { + ModestTree.Log.Warn("Warning Assert hit! " + messageGenerator()); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void That( + bool condition, string message) + { + if (!condition) + { + throw CreateException("Assert hit! " + message); + } + } + + // We don't use params here to avoid the memory alloc +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void That( + bool condition, string message, object p1) + { + if (!condition) + { + throw CreateException("Assert hit! " + message.Fmt(p1)); + } + } + + // We don't use params here to avoid the memory alloc +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void That( + bool condition, string message, object p1, object p2) + { + if (!condition) + { + throw CreateException("Assert hit! " + message.Fmt(p1, p2)); + } + } + + // We don't use params here to avoid the memory alloc +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void That( + bool condition, string message, object p1, object p2, object p3) + { + if (!condition) + { + throw CreateException("Assert hit! " + message.Fmt(p1, p2, p3)); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void Warn(bool condition, string message) + { + if (!condition) + { + ModestTree.Log.Warn("Warning Assert hit! " + message); + } + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void Throws(Action action) + { + Throws(action); + } + +#if ZEN_STRIP_ASSERTS_IN_BUILDS + [Conditional("UNITY_EDITOR")] +#endif + public static void Throws(Action action) + where TException : Exception + { + try + { + action(); + } + catch (TException) + { + return; + } + + throw CreateException( + "Expected to receive exception of type '{0}' but nothing was thrown", typeof(TException).Name); + } + + public static ZenjectException CreateException() + { + return new ZenjectException("Assert hit!"); + } + + public static ZenjectException CreateException(string message) + { + return new ZenjectException(message); + } + + public static ZenjectException CreateException(string message, params object[] parameters) + { + return new ZenjectException(message.Fmt(parameters)); + } + + public static ZenjectException CreateException(Exception innerException, string message, params object[] parameters) + { + return new ZenjectException(message.Fmt(parameters), innerException); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Assert.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Assert.cs.meta new file mode 100644 index 0000000..ef6719c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Assert.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2968c9f42475ea146aec3ced9cbd99ad +timeCreated: 1427464253 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Func.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Func.cs new file mode 100644 index 0000000..2e3e6f6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Func.cs @@ -0,0 +1,24 @@ +#if !NET_4_6 + +namespace ModestTree.Util +{ + // C# 3.5 only defines Func and Action to a maximum of 4 generic parameters + // Note that if you are using .NET framework > 3.5 you will have to comment these out to avoid ambiguous errors + public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5); + public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6); + public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7); + public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8); + public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9); + public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10); + public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11); + + public delegate void Action(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5); + public delegate void Action(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6); + public delegate void Action(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7); + public delegate void Action(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8); + public delegate void Action(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9); + public delegate void Action(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10); + public delegate void Action(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11); +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Func.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Func.cs.meta new file mode 100644 index 0000000..e26539a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Func.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cf53ad544fd972d4eb4716fb02fb5e9e +timeCreated: 1491195389 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/LinqExtensions.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/LinqExtensions.cs new file mode 100644 index 0000000..c783095 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/LinqExtensions.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Collections; +using ModestTree.Util; + +namespace ModestTree +{ + public static class LinqExtensions + { + public static IEnumerable Yield(this T item) + { + yield return item; + } + + // Return the first item when the list is of length one and otherwise returns default + public static TSource OnlyOrDefault(this IEnumerable source) + { + Assert.IsNotNull(source); + + if (source.Count() > 1) + { + return default(TSource); + } + + return source.FirstOrDefault(); + } + + // These are more efficient than Count() in cases where the size of the collection is not known + public static bool HasAtLeast(this IEnumerable enumerable, int amount) + { + return enumerable.Take(amount).Count() == amount; + } + + public static bool HasMoreThan(this IEnumerable enumerable, int amount) + { + return enumerable.HasAtLeast(amount+1); + } + + public static bool HasLessThan(this IEnumerable enumerable, int amount) + { + return enumerable.HasAtMost(amount-1); + } + + public static bool HasAtMost(this IEnumerable enumerable, int amount) + { + return enumerable.Take(amount + 1).Count() <= amount; + } + + public static bool IsEmpty(this IEnumerable enumerable) + { + return !enumerable.Any(); + } + + public static IEnumerable GetDuplicates(this IEnumerable list) + { + return list.GroupBy(x => x).Where(x => x.Skip(1).Any()).Select(x => x.Key); + } + + public static IEnumerable Except(this IEnumerable list, T item) + { + return list.Except(item.Yield()); + } + + // LINQ already has a method called "Contains" that does the same thing as this + // BUT it fails to work with Mono 3.5 in some cases. + // For example the following prints False, True in Mono 3.5 instead of True, True like it should: + // + // IEnumerable args = new string[] + // { + // "", + // null, + // }; + + // Log.Info(args.ContainsItem(null)); + // Log.Info(args.Where(x => x == null).Any()); + public static bool ContainsItem(this IEnumerable list, T value) + { + // Use object.Equals to support null values + return list.Where(x => object.Equals(x, value)).Any(); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/LinqExtensions.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/LinqExtensions.cs.meta new file mode 100644 index 0000000..dbbb738 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/LinqExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 68fac2f8aa1edec4b9ef45794638a59c +timeCreated: 1427464292 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Log.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Log.cs new file mode 100644 index 0000000..a3d57f4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Log.cs @@ -0,0 +1,84 @@ +using System; +using System.Diagnostics; + +namespace ModestTree +{ + // Simple wrapper around unity's logging system + public static class Log + { + // Strip out debug logs outside of unity + [Conditional("UNITY_EDITOR")] + public static void Debug(string message, params object[] args) + { +#if NOT_UNITY3D + //Console.WriteLine(message.Fmt(args)); +#else + //UnityEngine.Debug.Log(message.Fmt(args)); +#endif + } + + ///////////// + + public static void Info(string message, params object[] args) + { +#if NOT_UNITY3D + Console.WriteLine(message.Fmt(args)); +#else + UnityEngine.Debug.Log(message.Fmt(args)); +#endif + } + + ///////////// + + public static void Warn(string message, params object[] args) + { +#if NOT_UNITY3D + Console.WriteLine(message.Fmt(args)); +#else + UnityEngine.Debug.LogWarning(message.Fmt(args)); +#endif + } + + ///////////// + + public static void Trace(string message, params object[] args) + { +#if NOT_UNITY3D + Console.WriteLine(message.Fmt(args)); +#else + UnityEngine.Debug.Log(message.Fmt(args)); +#endif + } + + ///////////// + + public static void ErrorException(Exception e) + { +#if NOT_UNITY3D + Console.WriteLine(e.ToString()); +#else + UnityEngine.Debug.LogException(e); +#endif + } + + public static void ErrorException(string message, Exception e) + { +#if NOT_UNITY3D + Console.WriteLine(message); +#else + UnityEngine.Debug.LogError(message); + UnityEngine.Debug.LogException(e); +#endif + } + + public static void Error(string message, params object[] args) + { +#if NOT_UNITY3D + Console.WriteLine(message.Fmt(args)); +#else + UnityEngine.Debug.LogError(message.Fmt(args)); +#endif + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Log.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Log.cs.meta new file mode 100644 index 0000000..dfbf565 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/Log.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 622a24d4c6769414495ea1786bfee872 +timeCreated: 1427464253 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/MiscExtensions.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/MiscExtensions.cs new file mode 100644 index 0000000..52f4b84 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/MiscExtensions.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace ModestTree +{ + public static class MiscExtensions + { + // We'd prefer to use the name Format here but that conflicts with + // the existing string.Format method + public static string Fmt(this string s, params object[] args) + { + // Do in-place change to avoid the memory alloc + // This should be fine because the params is always used instead of directly + // passing an array + for (int i = 0; i < args.Length; i++) + { + var arg = args[i]; + + if (arg == null) + { + // This is much more understandable than just the empty string + args[i] = "NULL"; + } + else if (arg is Type) + { + // This often reads much better sometimes + args[i] = ((Type)arg).PrettyName(); + } + } + + return String.Format(s, args); + } + + public static int IndexOf(this IList list, T item) + { + for (int i = 0; i < list.Count; i++) + { + if (object.Equals(list[i], item)) + { + return i; + } + } + + return -1; + } + + public static string Join(this IEnumerable values, string separator) + { + return string.Join(separator, values.ToArray()); + } + + // When using C# 4.6, for some reason the normal AddRange causes some allocations + // https://issuetracker.unity3d.com/issues/dot-net-4-dot-6-unexpected-gc-allocations-in-list-dot-addrange + public static void AllocFreeAddRange(this IList list, IList items) + { + for (int i = 0; i < items.Count; i++) + { + list.Add(items[i]); + } + } + + // Most of the time when you call remove you always intend on removing something + // so assert in that case + public static void RemoveWithConfirm(this IList list, T item) + { + bool removed = list.Remove(item); + Assert.That(removed); + } + + public static void RemoveWithConfirm(this LinkedList list, T item) + { + bool removed = list.Remove(item); + Assert.That(removed); + } + + public static void RemoveWithConfirm(this IDictionary dictionary, TKey key) + { + bool removed = dictionary.Remove(key); + Assert.That(removed); + } + + public static void RemoveWithConfirm(this HashSet set, T item) + { + bool removed = set.Remove(item); + Assert.That(removed); + } + + public static TVal GetValueAndRemove(this IDictionary dictionary, TKey key) + { + TVal val = dictionary[key]; + dictionary.RemoveWithConfirm(key); + return val; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/MiscExtensions.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/MiscExtensions.cs.meta new file mode 100644 index 0000000..ffce9db --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/MiscExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: da4e9bf39c1ac464d84d2f743a25f8d1 +timeCreated: 1427464359 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/PreserveAttribute.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/PreserveAttribute.cs new file mode 100644 index 0000000..f1bc8bc --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/PreserveAttribute.cs @@ -0,0 +1,9 @@ +using System; + +namespace ModestTree.Util +{ + [AttributeUsage(AttributeTargets.All, AllowMultiple = false)] + public class PreserveAttribute : Attribute + { + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/PreserveAttribute.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/PreserveAttribute.cs.meta new file mode 100644 index 0000000..95d2aa1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/PreserveAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: de17d24691e2bfd458a9d10cb1d49098 +timeCreated: 1453682156 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/TypeExtensions.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/TypeExtensions.cs new file mode 100644 index 0000000..ca0ac00 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/TypeExtensions.cs @@ -0,0 +1,391 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace ModestTree +{ + public static class TypeExtensions + { + static readonly Dictionary _isClosedGenericType = new Dictionary(); + static readonly Dictionary _isOpenGenericType = new Dictionary(); + static readonly Dictionary _isValueType = new Dictionary(); + static readonly Dictionary _interfaces = new Dictionary(); + + public static bool DerivesFrom(this Type a) + { + return DerivesFrom(a, typeof(T)); + } + + // This seems easier to think about than IsAssignableFrom + public static bool DerivesFrom(this Type a, Type b) + { + return b != a && a.DerivesFromOrEqual(b); + } + + public static bool DerivesFromOrEqual(this Type a) + { + return DerivesFromOrEqual(a, typeof(T)); + } + + public static bool DerivesFromOrEqual(this Type a, Type b) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return b == a || b.GetTypeInfo().IsAssignableFrom(a.GetTypeInfo()); +#else + return b == a || b.IsAssignableFrom(a); +#endif + } + +#if !(UNITY_WSA && ENABLE_DOTNET) + // TODO: Is it possible to do this on WSA? + public static bool IsAssignableToGenericType(Type givenType, Type genericType) + { + var interfaceTypes = givenType.Interfaces(); + + foreach (var it in interfaceTypes) + { + if (it.IsGenericType && it.GetGenericTypeDefinition() == genericType) + { + return true; + } + } + + if (givenType.IsGenericType && givenType.GetGenericTypeDefinition() == genericType) + { + return true; + } + + Type baseType = givenType.BaseType; + + if (baseType == null) + { + return false; + } + + return IsAssignableToGenericType(baseType, genericType); + } +#endif + + public static bool IsEnum(this Type type) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return type.GetTypeInfo().IsEnum; +#else + return type.IsEnum; +#endif + } + + public static bool IsValueType(this Type type) + { + bool result; + if (!_isValueType.TryGetValue(type, out result)) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + result = type.GetTypeInfo().IsValueType; +#else + result = type.IsValueType; +#endif + _isValueType[type] = result; + } + return result; + } + + public static MethodInfo[] DeclaredInstanceMethods(this Type type) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return type.GetRuntimeMethods() + .Where(x => x.DeclaringType == type).ToArray(); +#else + return type.GetMethods( + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly); +#endif + } + + public static PropertyInfo[] DeclaredInstanceProperties(this Type type) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + // There doesn't appear to be an IsStatic member on PropertyInfo + return type.GetRuntimeProperties() + .Where(x => x.DeclaringType == type).ToArray(); +#else + return type.GetProperties( + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly); +#endif + } + + public static FieldInfo[] DeclaredInstanceFields(this Type type) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return type.GetRuntimeFields() + .Where(x => x.DeclaringType == type && !x.IsStatic).ToArray(); +#else + return type.GetFields( + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly); +#endif + } + +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + public static bool IsAssignableFrom(this Type a, Type b) + { + return a.GetTypeInfo().IsAssignableFrom(b.GetTypeInfo()); + } +#endif + + public static Type BaseType(this Type type) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return type.GetTypeInfo().BaseType; +#else + return type.BaseType; +#endif + } + + public static bool IsGenericType(this Type type) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return type.GetTypeInfo().IsGenericType; +#else + return type.IsGenericType; +#endif + } + public static bool IsGenericTypeDefinition(this Type type) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return type.GetTypeInfo().IsGenericTypeDefinition; +#else + return type.IsGenericTypeDefinition; +#endif + } + + public static bool IsPrimitive(this Type type) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return type.GetTypeInfo().IsPrimitive; +#else + return type.IsPrimitive; +#endif + } + + public static bool IsInterface(this Type type) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return type.GetTypeInfo().IsInterface; +#else + return type.IsInterface; +#endif + } + + public static bool ContainsGenericParameters(this Type type) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return type.GetTypeInfo().ContainsGenericParameters; +#else + return type.ContainsGenericParameters; +#endif + } + + public static bool IsAbstract(this Type type) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return type.GetTypeInfo().IsAbstract; +#else + return type.IsAbstract; +#endif + } + + public static bool IsSealed(this Type type) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return type.GetTypeInfo().IsSealed; +#else + return type.IsSealed; +#endif + } + + public static MethodInfo Method(this Delegate del) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return del.GetMethodInfo(); +#else + return del.Method; +#endif + } + + public static Type[] GenericArguments(this Type type) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return type.GetTypeInfo().GenericTypeArguments; +#else + return type.GetGenericArguments(); +#endif + } + + public static Type[] Interfaces(this Type type) + { + Type[] result; + if (!_interfaces.TryGetValue(type, out result)) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + result = type.GetTypeInfo().ImplementedInterfaces.ToArray(); +#else + result = type.GetInterfaces(); +#endif + _interfaces.Add(type, result); + } + return result; + } + + public static ConstructorInfo[] Constructors(this Type type) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return type.GetTypeInfo().DeclaredConstructors.ToArray(); +#else + return type.GetConstructors( + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); +#endif + } + + public static object GetDefaultValue(this Type type) + { +#if ENABLE_IL2CPP + // Workaround for IL2CPP returning default(T) for Activator.CreateInstance(typeof(T?)) + if (type.IsGenericType() && type.GetGenericTypeDefinition() == typeof(Nullable<>)) + { + return null; + } +#endif + + if (type.IsValueType()) + { + return Activator.CreateInstance(type); + } + + return null; + } + + public static bool IsClosedGenericType(this Type type) + { + bool result; + if (!_isClosedGenericType.TryGetValue(type, out result)) + { + result = type.IsGenericType() && type != type.GetGenericTypeDefinition(); + _isClosedGenericType[type] = result; + } + return result; + } + + public static IEnumerable GetParentTypes(this Type type) + { + if (type == null || type.BaseType() == null || type == typeof(object) || type.BaseType() == typeof(object)) + { + yield break; + } + + yield return type.BaseType(); + + foreach (var ancestor in type.BaseType().GetParentTypes()) + { + yield return ancestor; + } + } + + public static bool IsOpenGenericType(this Type type) + { + bool result; + if (!_isOpenGenericType.TryGetValue(type, out result)) + { + result = type.IsGenericType() && type == type.GetGenericTypeDefinition(); + _isOpenGenericType[type] = result; + } + return result; + } + + public static T GetAttribute(this MemberInfo provider) + where T : Attribute + { + return provider.AllAttributes().Single(); + } + + public static T TryGetAttribute(this MemberInfo provider) + where T : Attribute + { + return provider.AllAttributes().OnlyOrDefault(); + } + + public static bool HasAttribute( + this MemberInfo provider, params Type[] attributeTypes) + { + return provider.AllAttributes(attributeTypes).Any(); + } + + public static bool HasAttribute(this MemberInfo provider) + where T : Attribute + { + return provider.AllAttributes(typeof(T)).Any(); + } + + public static IEnumerable AllAttributes( + this MemberInfo provider) + where T : Attribute + { + return provider.AllAttributes(typeof(T)).Cast(); + } + + public static IEnumerable AllAttributes( + this MemberInfo provider, params Type[] attributeTypes) + { + Attribute[] allAttributes; +#if NETFX_CORE + allAttributes = provider.GetCustomAttributes(true).ToArray(); +#else + allAttributes = System.Attribute.GetCustomAttributes(provider, typeof(Attribute), true); +#endif + if (attributeTypes.Length == 0) + { + return allAttributes; + } + + return allAttributes.Where(a => attributeTypes.Any(x => a.GetType().DerivesFromOrEqual(x))); + } + + // We could avoid this duplication here by using ICustomAttributeProvider but this class + // does not exist on the WP8 platform + public static bool HasAttribute( + this ParameterInfo provider, params Type[] attributeTypes) + { + return provider.AllAttributes(attributeTypes).Any(); + } + + public static bool HasAttribute(this ParameterInfo provider) + where T : Attribute + { + return provider.AllAttributes(typeof(T)).Any(); + } + + public static IEnumerable AllAttributes( + this ParameterInfo provider) + where T : Attribute + { + return provider.AllAttributes(typeof(T)).Cast(); + } + + public static IEnumerable AllAttributes( + this ParameterInfo provider, params Type[] attributeTypes) + { + Attribute[] allAttributes; +#if NETFX_CORE + allAttributes = provider.GetCustomAttributes(true).ToArray(); +#else + allAttributes = System.Attribute.GetCustomAttributes(provider, typeof(Attribute), true); +#endif + if (attributeTypes.Length == 0) + { + return allAttributes; + } + + return allAttributes.Where(a => attributeTypes.Any(x => a.GetType().DerivesFromOrEqual(x))); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/TypeExtensions.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/TypeExtensions.cs.meta new file mode 100644 index 0000000..9bb8510 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/TypeExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2697c251f47f2bc40b32922c5a796f65 +timeCreated: 1427464253 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/TypeStringFormatter.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/TypeStringFormatter.cs new file mode 100644 index 0000000..56af29a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/TypeStringFormatter.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace ModestTree +{ + public static class TypeStringFormatter + { + static readonly Dictionary _prettyNameCache = new Dictionary(); + + public static string PrettyName(this Type type) + { + string prettyName; + + if (!_prettyNameCache.TryGetValue(type, out prettyName)) + { + prettyName = PrettyNameInternal(type); + _prettyNameCache.Add(type, prettyName); + } + + return prettyName; + } + + static string PrettyNameInternal(Type type) + { + var sb = new StringBuilder(); + + if (type.IsNested) + { + sb.Append(type.DeclaringType.PrettyName()); + sb.Append("."); + } + + if (type.IsArray) + { + sb.Append(type.GetElementType().PrettyName()); + sb.Append("[]"); + } + else + { + var name = GetCSharpTypeName(type.Name); + + if (type.IsGenericType()) + { + var quoteIndex = name.IndexOf('`'); + + if (quoteIndex != -1) + { + sb.Append(name.Substring(0, name.IndexOf('`'))); + } + else + { + sb.Append(name); + } + + sb.Append("<"); + + if (type.IsGenericTypeDefinition()) + { + var numArgs = type.GenericArguments().Count(); + + if (numArgs > 0) + { + sb.Append(new String(',', numArgs - 1)); + } + } + else + { + sb.Append(string.Join(", ", type.GenericArguments().Select(t => t.PrettyName()).ToArray())); + } + + sb.Append(">"); + } + else + { + sb.Append(name); + } + } + + return sb.ToString(); + } + + static string GetCSharpTypeName(string typeName) + { + switch (typeName) + { + case "String": + case "Object": + case "Void": + case "Byte": + case "Double": + case "Decimal": + return typeName.ToLower(); + case "Int16": + return "short"; + case "Int32": + return "int"; + case "Int64": + return "long"; + case "Single": + return "float"; + case "Boolean": + return "bool"; + default: + return typeName; + } + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/TypeStringFormatter.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/TypeStringFormatter.cs.meta new file mode 100644 index 0000000..d0262a1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/TypeStringFormatter.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 94a0a9a58e17e3d438c169678c9795f7 +timeCreated: 1538018650 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/ValuePair.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/ValuePair.cs new file mode 100644 index 0000000..78e386e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/ValuePair.cs @@ -0,0 +1,190 @@ +using System; +using System.Collections.Generic; + +namespace ModestTree.Util +{ + public class ValuePair + { + public readonly T1 First; + public readonly T2 Second; + + public ValuePair() + { + First = default(T1); + Second = default(T2); + } + + public ValuePair(T1 first, T2 second) + { + First = first; + Second = second; + } + + public override bool Equals(Object obj) + { + var that = obj as ValuePair; + + if (that == null) + { + return false; + } + + return Equals(that); + } + + public bool Equals(ValuePair that) + { + if (that == null) + { + return false; + } + + return object.Equals(First, that.First) && object.Equals(Second, that.Second); + } + + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hash = 17; + hash = hash * 29 + (First == null ? 0 : First.GetHashCode()); + hash = hash * 29 + (Second == null ? 0 : Second.GetHashCode()); + return hash; + } + } + } + + public class ValuePair + { + public readonly T1 First; + public readonly T2 Second; + public readonly T3 Third; + + public ValuePair() + { + First = default(T1); + Second = default(T2); + Third = default(T3); + } + + public ValuePair(T1 first, T2 second, T3 third) + { + First = first; + Second = second; + Third = third; + } + + public override bool Equals(Object obj) + { + var that = obj as ValuePair; + + if (that == null) + { + return false; + } + + return Equals(that); + } + + public bool Equals(ValuePair that) + { + if (that == null) + { + return false; + } + + return object.Equals(First, that.First) && object.Equals(Second, that.Second) && object.Equals(Third, that.Third); + } + + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hash = 17; + hash = hash * 29 + (First == null ? 0 : First.GetHashCode()); + hash = hash * 29 + (Second == null ? 0 : Second.GetHashCode()); + hash = hash * 29 + (Third == null ? 0 : Third.GetHashCode()); + return hash; + } + } + } + + public class ValuePair + { + public readonly T1 First; + public readonly T2 Second; + public readonly T3 Third; + public readonly T4 Fourth; + + public ValuePair() + { + First = default(T1); + Second = default(T2); + Third = default(T3); + Fourth = default(T4); + } + + public ValuePair(T1 first, T2 second, T3 third, T4 fourth) + { + First = first; + Second = second; + Third = third; + Fourth = fourth; + } + + public override bool Equals(Object obj) + { + var that = obj as ValuePair; + + if (that == null) + { + return false; + } + + return Equals(that); + } + + public bool Equals(ValuePair that) + { + if (that == null) + { + return false; + } + + return object.Equals(First, that.First) && object.Equals(Second, that.Second) + && object.Equals(Third, that.Third) && object.Equals(Fourth, that.Fourth); + } + + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hash = 17; + hash = hash * 29 + (First == null ? 0 : First.GetHashCode()); + hash = hash * 29 + (Second == null ? 0 : Second.GetHashCode()); + hash = hash * 29 + (Third == null ? 0 : Third.GetHashCode()); + hash = hash * 29 + (Fourth == null ? 0 : Fourth.GetHashCode()); + return hash; + } + } + } + + public static class ValuePair + { + public static ValuePair New(T1 first, T2 second) + { + return new ValuePair(first, second); + } + + public static ValuePair New(T1 first, T2 second, T3 third) + { + return new ValuePair(first, second, third); + } + + public static ValuePair New(T1 first, T2 second, T3 third, T4 fourth) + { + return new ValuePair(first, second, third, fourth); + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/ValuePair.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/ValuePair.cs.meta new file mode 100644 index 0000000..5796689 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Internal/ValuePair.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a3c968adce0a9a24e949dc4eedb496e8 +timeCreated: 1478449513 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main.meta new file mode 100644 index 0000000..5bdc609 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: b5f870edd43b85f4dae7b77cc0d75b46 +folderAsset: yes +DefaultImporter: + userData: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/BindingId.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/BindingId.cs new file mode 100644 index 0000000..2c21605 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/BindingId.cs @@ -0,0 +1,78 @@ +using System; +using System.Diagnostics; +using ModestTree; + +namespace Zenject +{ + [DebuggerStepThrough] + public struct BindingId : IEquatable + { + Type _type; + object _identifier; + + public BindingId(Type type, object identifier) + { + _type = type; + _identifier = identifier; + } + + public Type Type + { + get { return _type; } + set { _type = value; } + } + + public object Identifier + { + get { return _identifier; } + set { _identifier = value; } + } + + public override string ToString() + { + if (_identifier == null) + { + return _type.PrettyName(); + } + + return "{0} (ID: {1})".Fmt(_type, _identifier); + } + + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hash = 17; + hash = hash * 29 + _type.GetHashCode(); + hash = hash * 29 + (_identifier == null ? 0 : _identifier.GetHashCode()); + return hash; + } + } + + public override bool Equals(object other) + { + if (other is BindingId) + { + BindingId otherId = (BindingId)other; + return otherId == this; + } + + return false; + } + + public bool Equals(BindingId that) + { + return this == that; + } + + public static bool operator ==(BindingId left, BindingId right) + { + return left.Type == right.Type && Equals(left.Identifier, right.Identifier); + } + + public static bool operator !=(BindingId left, BindingId right) + { + return !left.Equals(right); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/BindingId.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/BindingId.cs.meta new file mode 100644 index 0000000..9d59a20 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/BindingId.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 05e8238358230bf4e9cbb692280d28f1 +timeCreated: 1461708048 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/DiContainer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/DiContainer.cs new file mode 100644 index 0000000..571099a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/DiContainer.cs @@ -0,0 +1,3579 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using ModestTree.Util; +using Zenject.Internal; +#if !NOT_UNITY3D +using UnityEngine; +#endif + +namespace Zenject +{ + public delegate bool BindingCondition(InjectContext c); + + // Responsibilities: + // - Expose methods to configure object graph via BindX() methods + // - Look up bound values via Resolve() method + // - Instantiate new values via InstantiateX() methods + [NoReflectionBaking] + public class DiContainer : IInstantiator + { + readonly Dictionary _decorators = new Dictionary(); + readonly Dictionary> _providers = new Dictionary>(); + + readonly DiContainer[][] _containerLookups = new DiContainer[4][]; + + readonly HashSet _resolvesInProgress = new HashSet(); + readonly HashSet _resolvesTwiceInProgress = new HashSet(); + + readonly LazyInstanceInjector _lazyInjector; + + readonly SingletonMarkRegistry _singletonMarkRegistry = new SingletonMarkRegistry(); + readonly Queue _currentBindings = new Queue(); + readonly List _childBindings = new List(); + + readonly HashSet _validatedTypes = new HashSet(); + readonly List _validationQueue = new List(); + +#if !NOT_UNITY3D + Transform _contextTransform; + bool _hasLookedUpContextTransform; + Transform _inheritedDefaultParent; + Transform _explicitDefaultParent; + bool _hasExplicitDefaultParent; +#endif + + ZenjectSettings _settings; + + bool _hasResolvedRoots; + bool _isFinalizingBinding; + bool _isValidating; + bool _isInstalling; +#if DEBUG || UNITY_EDITOR + bool _hasDisplayedInstallWarning; +#endif + + public DiContainer( + IEnumerable parentContainersEnumerable, bool isValidating) + { + _isValidating = isValidating; + + _lazyInjector = new LazyInstanceInjector(this); + + InstallDefaultBindings(); + FlushBindings(); + Assert.That(_currentBindings.Count == 0); + + _settings = ZenjectSettings.Default; + + var selfLookup = new[] { this }; + _containerLookups[(int)InjectSources.Local] = selfLookup; + + var parentContainers = parentContainersEnumerable.ToArray(); + _containerLookups[(int)InjectSources.Parent] = parentContainers; + + var ancestorContainers = FlattenInheritanceChain().ToArray(); + + _containerLookups[(int)InjectSources.AnyParent] = ancestorContainers; + _containerLookups[(int)InjectSources.Any] = selfLookup.Concat(ancestorContainers).ToArray(); + + if (!parentContainers.IsEmpty()) + { + for (int i = 0; i < parentContainers.Length; i++) + { + parentContainers[i].FlushBindings(); + } + +#if !NOT_UNITY3D + _inheritedDefaultParent = parentContainers.First().DefaultParent; +#endif + + // Make sure to avoid duplicates which could happen if a parent container + // appears multiple times in the inheritance chain + foreach (var ancestorContainer in ancestorContainers.Distinct()) + { + foreach (var binding in ancestorContainer._childBindings) + { + if (ShouldInheritBinding(binding, ancestorContainer)) + { + FinalizeBinding(binding); + } + } + } + + Assert.That(_currentBindings.Count == 0); + Assert.That(_childBindings.Count == 0); + } + + // Assumed to be configured in a parent container + var settings = TryResolve(); + + if (settings != null) + { + _settings = settings; + } + } + + public DiContainer(bool isValidating) + : this(Enumerable.Empty(), isValidating) + { + } + + public DiContainer() + : this(Enumerable.Empty(), false) + { + } + + public DiContainer(DiContainer parentContainer, bool isValidating) + : this(new [] { parentContainer }, isValidating) + { + } + + public DiContainer(DiContainer parentContainer) + : this(new [] { parentContainer }, false) + { + } + + public DiContainer(IEnumerable parentContainers) + : this(parentContainers, false) + { + } + + // By default the settings will be inherited from parent containers, but can be + // set explicitly here as well which is useful in particular in unit tests + // Note however that if you want child containers to use this same value you have + // to bind it as well + public ZenjectSettings Settings + { + get { return _settings; } + set + { + _settings = value; + Rebind().FromInstance(value); + } + } + + internal SingletonMarkRegistry SingletonMarkRegistry + { + get { return _singletonMarkRegistry; } + } + + public IEnumerable AllProviders + { + // Distinct is necessary since the same providers can be used with multiple contracts + get { return _providers.Values.SelectMany(x => x).Select(x => x.Provider).Distinct(); } + } + + void InstallDefaultBindings() + { + Bind(typeof(DiContainer), typeof(IInstantiator)).FromInstance(this); + Bind(typeof(LazyInject<>)).FromMethodUntyped(CreateLazyBinding).Lazy(); + } + + object CreateLazyBinding(InjectContext context) + { + // By cloning it this also means that Ids, optional, etc. are forwarded properly + var newContext = context.Clone(); + newContext.MemberType = context.MemberType.GenericArguments().Single(); + + var result = Activator.CreateInstance( + typeof(LazyInject<>) + .MakeGenericType(newContext.MemberType), this, newContext); + + if (_isValidating) + { + QueueForValidate((IValidatable)result); + } + + return result; + } + + public void QueueForValidate(IValidatable validatable) + { + // Don't bother adding to queue if the initial resolve is already completed + if (!_hasResolvedRoots) + { + var concreteType = validatable.GetType(); + + if (!_validatedTypes.Contains(concreteType)) + { + _validatedTypes.Add(concreteType); + _validationQueue.Add(validatable); + } + } + } + + bool ShouldInheritBinding(BindStatement binding, DiContainer ancestorContainer) + { + if (binding.BindingInheritanceMethod == BindingInheritanceMethods.CopyIntoAll + || binding.BindingInheritanceMethod == BindingInheritanceMethods.MoveIntoAll) + { + return true; + } + + if ((binding.BindingInheritanceMethod == BindingInheritanceMethods.CopyDirectOnly + || binding.BindingInheritanceMethod == BindingInheritanceMethods.MoveDirectOnly) + && ParentContainers.Contains(ancestorContainer)) + { + return true; + } + + return false; + } + +#if !NOT_UNITY3D + // This might be null in some rare cases like when used in ZenjectUnitTestFixture + Transform ContextTransform + { + get + { + if (!_hasLookedUpContextTransform) + { + _hasLookedUpContextTransform = true; + + var context = TryResolve(); + + if (context != null) + { + _contextTransform = context.transform; + } + } + + return _contextTransform; + } + } +#endif + + // When true, this will throw exceptions whenever we create new game objects + // This is helpful when used in places like EditorWindowKernel where we can't + // assume that there is a "scene" to place objects + public bool AssertOnNewGameObjects + { + get; + set; + } + +#if !NOT_UNITY3D + + public Transform InheritedDefaultParent + { + get { return _inheritedDefaultParent; } + } + + public Transform DefaultParent + { + get { return _explicitDefaultParent; } + set + { + _explicitDefaultParent = value; + // Need to use a flag because null is a valid explicit default parent + _hasExplicitDefaultParent = true; + } + } +#endif + + public DiContainer[] ParentContainers + { + get { return _containerLookups[(int)InjectSources.Parent]; } + } + + public DiContainer[] AncestorContainers + { + get { return _containerLookups[(int)InjectSources.AnyParent]; } + } + + public bool ChecksForCircularDependencies + { + get + { +#if ZEN_MULTITHREADING + // When multithreading is supported we can't use a static field to track the lookup + // TODO: We could look at the inject context though + return false; +#else + return true; +#endif + } + } + + public bool IsValidating + { + get { return _isValidating; } + } + + // When this is true, it will log warnings when Resolve or Instantiate + // methods are called + // Used to ensure that Resolve and Instantiate methods are not called + // during bind phase. This is important since Resolve and Instantiate + // make use of the bindings, so if the bindings are not complete then + // unexpected behaviour can occur + public bool IsInstalling + { + get { return _isInstalling; } + set { _isInstalling = value; } + } + + public IEnumerable AllContracts + { + get + { + FlushBindings(); + return _providers.Keys; + } + } + + public void ResolveRoots() + { + Assert.That(!_hasResolvedRoots); + + FlushBindings(); + + ResolveDependencyRoots(); +#if DEBUG + if (IsValidating && _settings.ValidationRootResolveMethod == RootResolveMethods.All) + { + ValidateFullResolve(); + } +#endif + + _lazyInjector.LazyInjectAll(); + + if (IsValidating) + { + FlushValidationQueue(); + } + + Assert.That(!_hasResolvedRoots); + _hasResolvedRoots = true; + } + + void ResolveDependencyRoots() + { + var rootBindings = new List(); + var rootProviders = new List(); + + foreach (var bindingPair in _providers) + { + foreach (var provider in bindingPair.Value) + { + if (provider.NonLazy) + { + // Save them to a list instead of resolving for them here to account + // for the rare case where one of the resolves does another binding + // and therefore changes _providers, causing an exception. + rootBindings.Add(bindingPair.Key); + rootProviders.Add(provider); + } + } + } + + Assert.IsEqual(rootProviders.Count, rootBindings.Count); + + var instances = ZenPools.SpawnList(); + + try + { + for (int i = 0; i < rootProviders.Count; i++) + { + var bindId = rootBindings[i]; + var providerInfo = rootProviders[i]; + + using (var context = ZenPools.SpawnInjectContext(this, bindId.Type)) + { + context.Identifier = bindId.Identifier; + context.SourceType = InjectSources.Local; + + // Should this be true? Are there cases where you are ok that NonLazy matches + // zero providers? + // Probably better to be false to catch mistakes + context.Optional = false; + + instances.Clear(); + +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("DiContainer.Resolve")) +#endif + { + SafeGetInstances(providerInfo, context, instances); + } + + // Zero matches might actually be valid in some cases + //Assert.That(matches.Any()); + } + } + } + finally + { + ZenPools.DespawnList(instances); + } + } + + void ValidateFullResolve() + { + Assert.That(!_hasResolvedRoots); + Assert.That(IsValidating); + + foreach (var bindingId in _providers.Keys.ToList()) + { + if (!bindingId.Type.IsOpenGenericType()) + { + using (var context = ZenPools.SpawnInjectContext(this, bindingId.Type)) + { + context.Identifier = bindingId.Identifier; + context.SourceType = InjectSources.Local; + context.Optional = true; + + ResolveAll(context); + } + } + } + } + + void FlushValidationQueue() + { + Assert.That(!_hasResolvedRoots); + Assert.That(IsValidating); + + var validatables = new List(); + + // Repeatedly flush the validation queue until it's empty, to account for + // cases where calls to Validate() add more objects to the queue + while (_validationQueue.Any()) + { + validatables.Clear(); + validatables.AllocFreeAddRange(_validationQueue); + _validationQueue.Clear(); + + for (int i = 0; i < validatables.Count; i++) + { + validatables[i].Validate(); + } + } + } + + public DiContainer CreateSubContainer() + { + return CreateSubContainer(_isValidating); + } + + public void QueueForInject(object instance) + { + _lazyInjector.AddInstance(instance); + } + + // Note: this only does anything useful during the injection phase + // It will inject on the given instance if it hasn't already been injected, but only + // if the given instance has been queued for inject already by calling QueueForInject + // In some rare cases this can be useful - for example if you want to add a binding in a + // a higher level container to a resolve inside a lower level game object context container + // since in this case you need the game object context to be injected so you can access its + // Container property + public T LazyInject(T instance) + { + _lazyInjector.LazyInject(instance); + return instance; + } + + DiContainer CreateSubContainer(bool isValidating) + { + return new DiContainer(new[] { this }, isValidating); + } + + public void RegisterProvider( + BindingId bindingId, BindingCondition condition, IProvider provider, bool nonLazy) + { + var info = new ProviderInfo(provider, condition, nonLazy, this); + + List providerInfos; + + if (!_providers.TryGetValue(bindingId, out providerInfos)) + { + providerInfos = new List(); + _providers.Add(bindingId, providerInfos); + } + + providerInfos.Add(info); + } + + void GetProviderMatches( + InjectContext context, List buffer) + { + Assert.IsNotNull(context); + Assert.That(buffer.Count == 0); + + var allMatches = ZenPools.SpawnList(); + + try + { + GetProvidersForContract( + context.BindingId, context.SourceType, allMatches); + + for (int i = 0; i < allMatches.Count; i++) + { + var match = allMatches[i]; + + if (match.Condition == null || match.Condition(context)) + { + buffer.Add(match); + } + } + } + finally + { + ZenPools.DespawnList(allMatches); + } + } + + ProviderInfo TryGetUniqueProvider(InjectContext context) + { + Assert.IsNotNull(context); + + var bindingId = context.BindingId; + var sourceType = context.SourceType; + + var containerLookups = _containerLookups[(int)sourceType]; + + for (int i = 0; i < containerLookups.Length; i++) + { + containerLookups[i].FlushBindings(); + } + + var localProviders = ZenPools.SpawnList(); + + try + { + ProviderInfo selected = null; + int selectedDistance = Int32.MaxValue; + bool selectedHasCondition = false; + bool ambiguousSelection = false; + + for (int i = 0; i < containerLookups.Length; i++) + { + var container = containerLookups[i]; + + int curDistance = GetContainerHeirarchyDistance(container); + + if (curDistance > selectedDistance) + { + // If matching provider was already found lower in the hierarchy => don't search for a new one, + // because there can't be a better or equal provider in this container. + continue; + } + + localProviders.Clear(); + container.GetLocalProviders(bindingId, localProviders); + + for (int k = 0; k < localProviders.Count; k++) + { + var provider = localProviders[k]; + + bool curHasCondition = provider.Condition != null; + + if (curHasCondition && !provider.Condition(context)) + { + // The condition is not satisfied. + continue; + } + + // The distance can't decrease becuase we are iterating over the containers with increasing distance. + // The distance can't increase because we skip the container if the distance is greater than selected. + // So the distances are equal and only the condition can help resolving the amiguity. + Assert.That(selected == null || selectedDistance == curDistance); + + if (curHasCondition) + { + if (selectedHasCondition) + { + // Both providers have condition and are on equal depth. + ambiguousSelection = true; + } + else + { + // Ambiguity is resolved because a provider with condition was found. + ambiguousSelection = false; + } + } + else + { + if (selectedHasCondition) + { + // Selected provider is better because it has condition. + continue; + } + if (selected != null) + { + // Both providers don't have a condition and are on equal depth. + ambiguousSelection = true; + } + } + + if (ambiguousSelection) + { + continue; + } + + selectedDistance = curDistance; + selectedHasCondition = curHasCondition; + selected = provider; + } + } + + if (ambiguousSelection) + { + throw Assert.CreateException( + "Found multiple matches when only one was expected for type '{0}'{1}. Object graph:\n {2}", + context.MemberType, + (context.ObjectType == null + ? "" + : " while building object with type '{0}'".Fmt(context.ObjectType)), + context.GetObjectGraphString()); + } + + return selected; + } + finally + { + ZenPools.DespawnList(localProviders); + } + } + + // Get the full list of ancestor Di Containers, making sure to avoid + // duplicates and also order them in a breadth-first way + List FlattenInheritanceChain() + { + var processed = new List(); + + var containerQueue = new Queue(); + containerQueue.Enqueue(this); + + while (containerQueue.Count > 0) + { + var current = containerQueue.Dequeue(); + + foreach (var parent in current.ParentContainers) + { + if (!processed.Contains(parent)) + { + processed.Add(parent); + containerQueue.Enqueue(parent); + } + } + } + + return processed; + } + + void GetLocalProviders(BindingId bindingId, List buffer) + { + List localProviders; + + if (_providers.TryGetValue(bindingId, out localProviders)) + { + buffer.AllocFreeAddRange(localProviders); + return; + } + + // If we are asking for a List, we should also match for any localProviders that are bound to the open generic type List<> + // Currently it only matches one and not the other - not totally sure if this is better than returning both + if (bindingId.Type.IsGenericType() && _providers.TryGetValue(new BindingId(bindingId.Type.GetGenericTypeDefinition(), bindingId.Identifier), out localProviders)) + { + buffer.AllocFreeAddRange(localProviders); + } + + // None found + } + + void GetProvidersForContract( + BindingId bindingId, InjectSources sourceType, List buffer) + { + var containerLookups = _containerLookups[(int)sourceType]; + + for (int i = 0; i < containerLookups.Length; i++) + { + containerLookups[i].FlushBindings(); + } + + for (int i = 0; i < containerLookups.Length; i++) + { + containerLookups[i].GetLocalProviders(bindingId, buffer); + } + } + + public void Install() + where TInstaller : Installer + { + Instantiate().InstallBindings(); + } + + // Note: You might want to use Installer<> as your base class instead to allow + // for strongly typed parameters + public void Install(object[] extraArgs) + where TInstaller : Installer + { + Instantiate(extraArgs).InstallBindings(); + } + + public IList ResolveAll(InjectContext context) + { + var buffer = ZenPools.SpawnList(); + + try + { + ResolveAll(context, buffer); + return ReflectionUtil.CreateGenericList(context.MemberType, buffer); + } + finally + { + ZenPools.DespawnList(buffer); + } + } + + public void ResolveAll(InjectContext context, List buffer) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("DiContainer.Resolve")) +#endif + { + Assert.IsNotNull(context); + // Note that different types can map to the same provider (eg. a base type to a concrete class and a concrete class to itself) + + FlushBindings(); + CheckForInstallWarning(context); + + var matches = ZenPools.SpawnList(); + + try + { + GetProviderMatches(context, matches); + + if (matches.Count == 0) + { + if (!context.Optional) + { + throw Assert.CreateException( + "Could not find required dependency with type '{0}' Object graph:\n {1}", context.MemberType, context.GetObjectGraphString()); + } + + return; + } + + var instances = ZenPools.SpawnList(); + var allInstances = ZenPools.SpawnList(); + + try + { + for (int i = 0; i < matches.Count; i++) + { + var match = matches[i]; + + instances.Clear(); + SafeGetInstances(match, context, instances); + + for (int k = 0; k < instances.Count; k++) + { + allInstances.Add(instances[k]); + } + } + + if (allInstances.Count == 0 && !context.Optional) + { + throw Assert.CreateException( + "Could not find required dependency with type '{0}'. Found providers but they returned zero results!", context.MemberType); + } + + if (IsValidating) + { + for (int i = 0; i < allInstances.Count; i++) + { + var instance = allInstances[i]; + + if (instance is ValidationMarker) + { + allInstances[i] = context.MemberType.GetDefaultValue(); + } + } + } + + buffer.AllocFreeAddRange(allInstances); + } + finally + { + ZenPools.DespawnList(instances); + ZenPools.DespawnList(allInstances); + } + } + finally + { + ZenPools.DespawnList(matches); + } + } + } + + void CheckForInstallWarning(InjectContext context) + { + if (!_settings.DisplayWarningWhenResolvingDuringInstall) + { + return; + } + + Assert.IsNotNull(context); + +#if DEBUG || UNITY_EDITOR + if (!_isInstalling) + { + return; + } + + if (_hasDisplayedInstallWarning) + { + return; + } + + if (context == null) + { + // No way to tell whether this is ok or not so just assume ok + return; + } + +#if UNITY_EDITOR + if (context.MemberType.DerivesFrom()) + { + // This happens when getting default transform parent so ok + return; + } +#endif + if (IsValidating && TypeAnalyzer.ShouldAllowDuringValidation(context.MemberType)) + { + return; + } + + var rootContext = context.ParentContextsAndSelf.Last(); + + if (rootContext.MemberType.DerivesFrom()) + { + // Resolving/instantiating/injecting installers is valid during install phase + return; + } + + _hasDisplayedInstallWarning = true; + + // Feel free to comment this out if you are comfortable with this practice + Log.Warn("Zenject Warning: It is bad practice to call Inject/Resolve/Instantiate before all the Installers have completed! This is important to ensure that all bindings have properly been installed in case they are needed when injecting/instantiating/resolving. Detected when operating on type '{0}'. If you don't care about this, you can disable this warning by setting flag 'ZenjectSettings.DisplayWarningWhenResolvingDuringInstall' to false (see docs for details on ZenjectSettings).", rootContext.MemberType); +#endif + } + + // Returns the concrete type that would be returned with Resolve + // without actually instantiating it + // This is safe to use within installers + public Type ResolveType() + { + return ResolveType(typeof(T)); + } + + // Returns the concrete type that would be returned with Resolve(type) + // without actually instantiating it + // This is safe to use within installers + public Type ResolveType(Type type) + { + using (var context = ZenPools.SpawnInjectContext(this, type)) + { + return ResolveType(context); + } + } + + // Returns the concrete type that would be returned with Resolve(context) + // without actually instantiating it + // This is safe to use within installers + public Type ResolveType(InjectContext context) + { + Assert.IsNotNull(context); + + FlushBindings(); + + var providerInfo = TryGetUniqueProvider(context); + + if (providerInfo == null) + { + throw Assert.CreateException( + "Unable to resolve {0}{1}. Object graph:\n{2}", context.BindingId, + (context.ObjectType == null ? "" : " while building object with type '{0}'".Fmt(context.ObjectType)), + context.GetObjectGraphString()); + } + + return providerInfo.Provider.GetInstanceType(context); + } + + public List ResolveTypeAll(Type type) + { + return ResolveTypeAll(type, null); + } + + public List ResolveTypeAll(Type type, object identifier) + { + using (var context = ZenPools.SpawnInjectContext(this, type)) + { + context.Identifier = identifier; + return ResolveTypeAll(context); + } + } + + // Returns all the types that would be returned if ResolveAll was called with the given values + public List ResolveTypeAll(InjectContext context) + { + Assert.IsNotNull(context); + + FlushBindings(); + + var matches = ZenPools.SpawnList(); + + try + { + GetProviderMatches(context, matches); + + if (matches.Count > 0 ) + { + return matches.Select( + x => x.Provider.GetInstanceType(context)) + .Where(x => x != null).ToList(); + } + + return new List(); + } + finally + { + ZenPools.DespawnList(matches); + } + } + + public object Resolve(BindingId id) + { + using (var context = ZenPools.SpawnInjectContext(this, id.Type)) + { + context.Identifier = id.Identifier; + return Resolve(context); + } + } + + public object Resolve(InjectContext context) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("DiContainer.Resolve")) +#endif + { + // Note: context.Container is not necessarily equal to this, since + // you can have some lookups recurse to parent containers + Assert.IsNotNull(context); + + var memberType = context.MemberType; + + FlushBindings(); + CheckForInstallWarning(context); + + var lookupContext = context; + + // The context used for lookups is always the same as the given context EXCEPT for LazyInject<> + // In CreateLazyBinding above, we forward the context to a new instance of LazyInject<> + // The problem is, we want the binding for Bind(typeof(LazyInject<>)) to always match even + // for members that are marked for a specific ID, so we need to discard the identifier + // for this one particular case + if (memberType.IsGenericType() && memberType.GetGenericTypeDefinition() == typeof(LazyInject<>)) + { + lookupContext = context.Clone(); + lookupContext.Identifier = null; + lookupContext.SourceType = InjectSources.Local; + lookupContext.Optional = false; + } + + var providerInfo = TryGetUniqueProvider(lookupContext); + + if (providerInfo == null) + { + // If it's an array try matching to multiple values using its array type + if (memberType.IsArray && memberType.GetArrayRank() == 1) + { + var subType = memberType.GetElementType(); + + var subContext = context.Clone(); + subContext.MemberType = subType; + // By making this optional this means that all injected fields of type T[] + // will pass validation, which could be error prone, but I think this is better + // than always requiring that they explicitly mark their array types as optional + subContext.Optional = true; + + var results = ZenPools.SpawnList(); + + try + { + ResolveAll(subContext, results); + return ReflectionUtil.CreateArray(subContext.MemberType, results); + } + finally + { + ZenPools.DespawnList(results); + } + } + + // If it's a generic list then try matching multiple instances to its generic type + if (memberType.IsGenericType() + && (memberType.GetGenericTypeDefinition() == typeof(List<>) + || memberType.GetGenericTypeDefinition() == typeof(IList<>) +#if NET_4_6 + || memberType.GetGenericTypeDefinition() == typeof(IReadOnlyList<>) +#endif + || memberType.GetGenericTypeDefinition() == typeof(IEnumerable<>))) + { + var subType = memberType.GenericArguments().Single(); + + var subContext = context.Clone(); + subContext.MemberType = subType; + // By making this optional this means that all injected fields of type List<> + // will pass validation, which could be error prone, but I think this is better + // than always requiring that they explicitly mark their list types as optional + subContext.Optional = true; + + return ResolveAll(subContext); + } + + if (context.Optional) + { + return context.FallBackValue; + } + + throw Assert.CreateException("Unable to resolve '{0}'{1}. Object graph:\n{2}", context.BindingId, + (context.ObjectType == null ? "" : " while building object with type '{0}'".Fmt(context.ObjectType)), + context.GetObjectGraphString()); + } + + var instances = ZenPools.SpawnList(); + + try + { + SafeGetInstances(providerInfo, context, instances); + + if (instances.Count == 0) + { + if (context.Optional) + { + return context.FallBackValue; + } + + throw Assert.CreateException( + "Unable to resolve '{0}'{1}. Object graph:\n{2}", context.BindingId, + (context.ObjectType == null + ? "" + : " while building object with type '{0}'".Fmt(context.ObjectType)), + context.GetObjectGraphString()); + } + + if (instances.Count() > 1) + { + throw Assert.CreateException( + "Provider returned multiple instances when only one was expected! While resolving '{0}'{1}. Object graph:\n{2}", context.BindingId, + (context.ObjectType == null + ? "" + : " while building object with type '{0}'".Fmt(context.ObjectType)), + context.GetObjectGraphString()); + } + + return instances.First(); + } + finally + { + ZenPools.DespawnList(instances); + } + } + } + + void SafeGetInstances(ProviderInfo providerInfo, InjectContext context, List instances) + { + Assert.IsNotNull(context); + + var provider = providerInfo.Provider; + + if (ChecksForCircularDependencies) + { + var lookupId = ZenPools.SpawnLookupId(provider, context.BindingId); + + try + { + // Use the container associated with the provider to address some rare cases + // which would otherwise result in an infinite loop. Like this: + // Container.Bind().FromComponentInNewPrefab(Prefab).AsTransient() + // With the prefab being a GameObjectContext containing a script that has a + // ICharacter dependency. In this case, we would otherwise use the _resolvesInProgress + // associated with the GameObjectContext container, which will allow the recursive + // lookup, which will trigger another GameObjectContext and container (since it is + // transient) and the process continues indefinitely + var providerContainer = providerInfo.Container; + + if (providerContainer._resolvesTwiceInProgress.Contains(lookupId)) + { + // Allow one before giving up so that you can do circular dependencies via postinject or fields + throw Assert.CreateException( + "Circular dependency detected! Object graph:\n {0}", context.GetObjectGraphString()); + } + + bool twice = false; + if (!providerContainer._resolvesInProgress.Add(lookupId)) + { + bool added = providerContainer._resolvesTwiceInProgress.Add(lookupId); + Assert.That(added); + twice = true; + } + + try + { + GetDecoratedInstances(provider, context, instances); + } + finally + { + if (twice) + { + bool removed = providerContainer._resolvesTwiceInProgress.Remove(lookupId); + Assert.That(removed); + } + else + { + bool removed = providerContainer._resolvesInProgress.Remove(lookupId); + Assert.That(removed); + } + } + } + finally + { + ZenPools.DespawnLookupId(lookupId); + } + } + else + { + GetDecoratedInstances(provider, context, instances); + } + } + + public DecoratorToChoiceFromBinder Decorate() + { + var bindStatement = StartBinding(); + var bindInfo = bindStatement.SpawnBindInfo(); + + bindInfo.ContractTypes.Add(typeof(IFactory)); + + var factoryBindInfo = new FactoryBindInfo( + typeof(PlaceholderFactory)); + + bindStatement.SetFinalizer( + new PlaceholderFactoryBindingFinalizer( + bindInfo, factoryBindInfo)); + + var bindId = Guid.NewGuid(); + + bindInfo.Identifier = bindId; + + IDecoratorProvider decoratorProvider; + + if (!_decorators.TryGetValue(typeof(TContract), out decoratorProvider)) + { + decoratorProvider = new DecoratorProvider(this); + _decorators.Add(typeof(TContract), decoratorProvider); + } + + ((DecoratorProvider)decoratorProvider).AddFactoryId(bindId); + + return new DecoratorToChoiceFromBinder( + this, bindInfo, factoryBindInfo); + } + + void GetDecoratedInstances( + IProvider provider, InjectContext context, List buffer) + { + // TODO: This is flawed since it doesn't allow binding new decorators in subcontainers + var decoratorProvider = TryGetDecoratorProvider(context.BindingId.Type); + + if (decoratorProvider != null) + { + decoratorProvider.GetAllInstances(provider, context, buffer); + return; + } + + provider.GetAllInstances(context, buffer); + } + + IDecoratorProvider TryGetDecoratorProvider(Type contractType) + { + IDecoratorProvider decoratorProvider; + + if (_decorators.TryGetValue(contractType, out decoratorProvider)) + { + return decoratorProvider; + } + + var ancestorContainers = AncestorContainers; + + for (int i = 0; i < ancestorContainers.Length; i++) + { + if (ancestorContainers[i]._decorators.TryGetValue(contractType, out decoratorProvider)) + { + return decoratorProvider; + } + } + + return null; + } + + int GetContainerHeirarchyDistance(DiContainer container) + { + return GetContainerHeirarchyDistance(container, 0).Value; + } + + int? GetContainerHeirarchyDistance(DiContainer container, int depth) + { + if (container == this) + { + return depth; + } + + int? result = null; + + var parentContainers = ParentContainers; + + for (int i = 0; i < parentContainers.Length; i++) + { + var parent = parentContainers[i]; + + var distance = parent.GetContainerHeirarchyDistance(container, depth + 1); + + if (distance.HasValue && (!result.HasValue || distance.Value < result.Value)) + { + result = distance; + } + } + + return result; + } + + public IEnumerable GetDependencyContracts() + { + return GetDependencyContracts(typeof(TContract)); + } + + public IEnumerable GetDependencyContracts(Type contract) + { + FlushBindings(); + + var info = TypeAnalyzer.TryGetInfo(contract); + + if (info != null) + { + foreach (var injectMember in info.AllInjectables) + { + yield return injectMember.MemberType; + } + } + } + + object InstantiateInternal( + Type concreteType, bool autoInject, List extraArgs, InjectContext context, object concreteIdentifier) + { +#if !NOT_UNITY3D + Assert.That(!concreteType.DerivesFrom(), + "Error occurred while instantiating object of type '{0}'. Instantiator should not be used to create new mono behaviours. Must use InstantiatePrefabForComponent, InstantiatePrefab, or InstantiateComponent.", concreteType); +#endif + + Assert.That(!concreteType.IsAbstract(), "Expected type '{0}' to be non-abstract", concreteType); + + FlushBindings(); + CheckForInstallWarning(context); + + var typeInfo = TypeAnalyzer.TryGetInfo(concreteType); + + Assert.IsNotNull(typeInfo, "Tried to create type '{0}' but could not find type information", concreteType); + + bool allowDuringValidation = IsValidating && TypeAnalyzer.ShouldAllowDuringValidation(concreteType); + + object newObj; + +#if !NOT_UNITY3D + if (concreteType.DerivesFrom()) + { + Assert.That(typeInfo.InjectConstructor.Parameters.Length == 0, + "Found constructor parameters on ScriptableObject type '{0}'. This is not allowed. Use an [Inject] method or fields instead."); + + if (!IsValidating || allowDuringValidation) + { + newObj = ScriptableObject.CreateInstance(concreteType); + } + else + { + newObj = new ValidationMarker(concreteType); + } + } + else +#endif + { + Assert.IsNotNull(typeInfo.InjectConstructor.Factory, + "More than one (or zero) constructors found for type '{0}' when creating dependencies. Use one [Inject] attribute to specify which to use.", concreteType); + + // Make a copy since we remove from it below + var paramValues = ZenPools.SpawnArray(typeInfo.InjectConstructor.Parameters.Length); + + try + { + for (int i = 0; i < typeInfo.InjectConstructor.Parameters.Length; i++) + { + var injectInfo = typeInfo.InjectConstructor.Parameters[i]; + + object value; + + if (!InjectUtil.PopValueWithType( + extraArgs, injectInfo.MemberType, out value)) + { + using (var subContext = ZenPools.SpawnInjectContext( + this, injectInfo, context, null, concreteType, concreteIdentifier)) + { + value = Resolve(subContext); + } + } + + if (value == null || value is ValidationMarker) + { + paramValues[i] = injectInfo.MemberType.GetDefaultValue(); + } + else + { + paramValues[i] = value; + } + } + + if (!IsValidating || allowDuringValidation) + { + //ModestTree.Log.Debug("Zenject: Instantiating type '{0}'", concreteType); + try + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.{1}()", concreteType, concreteType.Name)) +#endif + { + newObj = typeInfo.InjectConstructor.Factory(paramValues); + } + } + catch (Exception e) + { + throw Assert.CreateException( + e, "Error occurred while instantiating object with type '{0}'", concreteType); + } + } + else + { + newObj = new ValidationMarker(concreteType); + } + } + finally + { + ZenPools.DespawnArray(paramValues); + } + } + + if (autoInject) + { + InjectExplicit(newObj, concreteType, extraArgs, context, concreteIdentifier); + + if (extraArgs.Count > 0 && !(newObj is ValidationMarker)) + { + throw Assert.CreateException( + "Passed unnecessary parameters when injecting into type '{0}'. \nExtra Parameters: {1}\nObject graph:\n{2}", + newObj.GetType(), String.Join(",", extraArgs.Select(x => x.Type.PrettyName()).ToArray()), context.GetObjectGraphString()); + } + } + +#if DEBUG + if (IsValidating && newObj is IValidatable) + { + QueueForValidate((IValidatable)newObj); + } +#endif + + return newObj; + } + + // InjectExplicit is only necessary when you want to inject null values into your object + // otherwise you can just use Inject() + // Note: Any arguments that are used will be removed from extraArgMap + public void InjectExplicit(object injectable, List extraArgs) + { + Type injectableType; + + if (injectable is ValidationMarker) + { + injectableType = ((ValidationMarker)injectable).MarkedType; + } + else + { + injectableType = injectable.GetType(); + } + + InjectExplicit( + injectable, + injectableType, + extraArgs, + new InjectContext(this, injectableType, null), + null); + } + + public void InjectExplicit( + object injectable, Type injectableType, + List extraArgs, InjectContext context, object concreteIdentifier) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("DiContainer.Inject")) +#endif + { + if (IsValidating) + { + var marker = injectable as ValidationMarker; + + if (marker != null && marker.InstantiateFailed) + { + // Do nothing in this case because it already failed and so there + // could be many knock-on errors that aren't related to the user + return; + } + + if (_settings.ValidationErrorResponse == ValidationErrorResponses.Throw) + { + InjectExplicitInternal( + injectable, injectableType, extraArgs, context, concreteIdentifier); + } + else + { + // In this case, just log it and continue to print out multiple validation errors + // at once + try + { + InjectExplicitInternal(injectable, injectableType, extraArgs, context, concreteIdentifier); + } + catch (Exception e) + { + Log.ErrorException(e); + } + } + } + else + { + InjectExplicitInternal(injectable, injectableType, extraArgs, context, concreteIdentifier); + } + } + } + + void CallInjectMethodsTopDown( + object injectable, Type injectableType, + InjectTypeInfo typeInfo, List extraArgs, + InjectContext context, object concreteIdentifier, bool isDryRun) + { + if (typeInfo.BaseTypeInfo != null) + { + CallInjectMethodsTopDown( + injectable, injectableType, typeInfo.BaseTypeInfo, extraArgs, + context, concreteIdentifier, isDryRun); + } + + for (int i = 0; i < typeInfo.InjectMethods.Length; i++) + { + var method = typeInfo.InjectMethods[i]; + var paramValues = ZenPools.SpawnArray(method.Parameters.Length); + + try + { + for (int k = 0; k < method.Parameters.Length; k++) + { + var injectInfo = method.Parameters[k]; + + object value; + + if (!InjectUtil.PopValueWithType(extraArgs, injectInfo.MemberType, out value)) + { + using (var subContext = ZenPools.SpawnInjectContext( + this, injectInfo, context, injectable, injectableType, concreteIdentifier)) + { + value = Resolve(subContext); + } + } + + if (value is ValidationMarker) + { + Assert.That(IsValidating); + + paramValues[k] = injectInfo.MemberType.GetDefaultValue(); + } + else + { + paramValues[k] = value; + } + } + + if (!isDryRun) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.{1}()", typeInfo.Type, method.Name)) +#endif + { + method.Action(injectable, paramValues); + } + } + } + finally + { + ZenPools.DespawnArray(paramValues); + } + } + } + + void InjectMembersTopDown( + object injectable, Type injectableType, + InjectTypeInfo typeInfo, List extraArgs, + InjectContext context, object concreteIdentifier, bool isDryRun) + { + if (typeInfo.BaseTypeInfo != null) + { + InjectMembersTopDown( + injectable, injectableType, typeInfo.BaseTypeInfo, extraArgs, + context, concreteIdentifier, isDryRun); + } + + for (int i = 0; i < typeInfo.InjectMembers.Length; i++) + { + var injectInfo = typeInfo.InjectMembers[i].Info; + var setterMethod = typeInfo.InjectMembers[i].Setter; + + object value; + + if (InjectUtil.PopValueWithType(extraArgs, injectInfo.MemberType, out value)) + { + if (!isDryRun) + { + if (value is ValidationMarker) + { + Assert.That(IsValidating); + } + else + { + setterMethod(injectable, value); + } + } + } + else + { + using (var subContext = ZenPools.SpawnInjectContext( + this, injectInfo, context, injectable, injectableType, concreteIdentifier)) + { + value = Resolve(subContext); + } + + if (injectInfo.Optional && value == null) + { + // Do not override in this case so it retains the hard-coded value + } + else + { + if (!isDryRun) + { + if (value is ValidationMarker) + { + Assert.That(IsValidating); + } + else + { + setterMethod(injectable, value); + } + } + } + } + } + } + + void InjectExplicitInternal( + object injectable, Type injectableType, List extraArgs, + InjectContext context, object concreteIdentifier) + { + Assert.That(injectable != null); + + var typeInfo = TypeAnalyzer.TryGetInfo(injectableType); + + if (typeInfo == null) + { + Assert.That(extraArgs.IsEmpty()); + return; + } + + var allowDuringValidation = IsValidating && TypeAnalyzer.ShouldAllowDuringValidation(injectableType); + + // Installers are the only things that we instantiate/inject on during validation + var isDryRun = IsValidating && !allowDuringValidation; + + if (!isDryRun) + { + Assert.IsEqual(injectable.GetType(), injectableType); + } + +#if !NOT_UNITY3D + if (injectableType == typeof(GameObject)) + { + Assert.CreateException( + "Use InjectGameObject to Inject game objects instead of Inject method. Object graph: {0}", context.GetObjectGraphString()); + } +#endif + + FlushBindings(); + CheckForInstallWarning(context); + + InjectMembersTopDown( + injectable, injectableType, typeInfo, extraArgs, context, concreteIdentifier, isDryRun); + + CallInjectMethodsTopDown( + injectable, injectableType, typeInfo, extraArgs, context, concreteIdentifier, isDryRun); + + if (extraArgs.Count > 0) + { + throw Assert.CreateException( + "Passed unnecessary parameters when injecting into type '{0}'. \nExtra Parameters: {1}\nObject graph:\n{2}", + injectableType, String.Join(",", extraArgs.Select(x => x.Type.PrettyName()).ToArray()), context.GetObjectGraphString()); + } + } + +#if !NOT_UNITY3D + + // Don't use this unless you know what you're doing + // You probably want to use InstantiatePrefab instead + // This one will only create the prefab and will not inject into it + // Also, this will always return the new game object as disabled, so that injection can occur before Awake / OnEnable / Start + internal GameObject CreateAndParentPrefabResource( + string resourcePath, GameObjectCreationParameters gameObjectBindInfo, InjectContext context, out bool shouldMakeActive) + { + var prefab = (GameObject)Resources.Load(resourcePath); + + Assert.IsNotNull(prefab, + "Could not find prefab at resource location '{0}'".Fmt(resourcePath)); + + return CreateAndParentPrefab(prefab, gameObjectBindInfo, context, out shouldMakeActive); + } + + GameObject GetPrefabAsGameObject(UnityEngine.Object prefab) + { + if (prefab is GameObject) + { + return (GameObject)prefab; + } + + Assert.That(prefab is Component, "Invalid type given for prefab. Given object name: '{0}'", prefab.name); + return ((Component)prefab).gameObject; + } + + // Don't use this unless you know what you're doing + // You probably want to use InstantiatePrefab instead + // This one will only create the prefab and will not inject into it + internal GameObject CreateAndParentPrefab( + UnityEngine.Object prefab, GameObjectCreationParameters gameObjectBindInfo, + InjectContext context, out bool shouldMakeActive) + { + Assert.That(prefab != null, "Null prefab found when instantiating game object"); + + Assert.That(!AssertOnNewGameObjects, + "Given DiContainer does not support creating new game objects"); + + FlushBindings(); + + var prefabAsGameObject = GetPrefabAsGameObject(prefab); + + var prefabWasActive = prefabAsGameObject.activeSelf; + + shouldMakeActive = prefabWasActive; + + var parent = GetTransformGroup(gameObjectBindInfo, context); + + Transform initialParent; +#if !UNITY_EDITOR + if (prefabWasActive) + { + prefabAsGameObject.SetActive(false); + } +#else + if (prefabWasActive) + { + initialParent = ZenUtilInternal.GetOrCreateInactivePrefabParent(); + } + else +#endif + { + if (parent != null) + { + initialParent = parent; + } + else + { + // This ensures it gets added to the right scene instead of just the active scene + initialParent = ContextTransform; + } + } + + bool positionAndRotationWereSet; + GameObject gameObj; + +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("GameObject.Instantiate")) +#endif + { + if (gameObjectBindInfo.Position.HasValue && gameObjectBindInfo.Rotation.HasValue) + { + gameObj = GameObject.Instantiate( + prefabAsGameObject, gameObjectBindInfo.Position.Value, gameObjectBindInfo.Rotation.Value, initialParent); + positionAndRotationWereSet = true; + } + else if (gameObjectBindInfo.Position.HasValue) + { + gameObj = GameObject.Instantiate( + prefabAsGameObject, gameObjectBindInfo.Position.Value, prefabAsGameObject.transform.rotation, initialParent); + positionAndRotationWereSet = true; + } + else if (gameObjectBindInfo.Rotation.HasValue) + { + gameObj = GameObject.Instantiate( + prefabAsGameObject, prefabAsGameObject.transform.position, gameObjectBindInfo.Rotation.Value, initialParent); + positionAndRotationWereSet = true; + } + else + { + gameObj = GameObject.Instantiate(prefabAsGameObject, initialParent); + positionAndRotationWereSet = false; + } + } + +#if !UNITY_EDITOR + if (prefabWasActive) + { + prefabAsGameObject.SetActive(true); + } +#else + if (prefabWasActive) + { + gameObj.SetActive(false); + + if (parent == null) + { + gameObj.transform.SetParent(ContextTransform, positionAndRotationWereSet); + } + } +#endif + + if (gameObj.transform.parent != parent) + { + gameObj.transform.SetParent(parent, positionAndRotationWereSet); + } + + if (gameObjectBindInfo.Name != null) + { + gameObj.name = gameObjectBindInfo.Name; + } + + return gameObj; + } + + public GameObject CreateEmptyGameObject(string name) + { + return CreateEmptyGameObject(new GameObjectCreationParameters { Name = name }, null); + } + + public GameObject CreateEmptyGameObject( + GameObjectCreationParameters gameObjectBindInfo, InjectContext context) + { + Assert.That(!AssertOnNewGameObjects, + "Given DiContainer does not support creating new game objects"); + + FlushBindings(); + + var gameObj = new GameObject(gameObjectBindInfo.Name ?? "GameObject"); + var parent = GetTransformGroup(gameObjectBindInfo, context); + + if (parent == null) + { + // This ensures it gets added to the right scene instead of just the active scene + gameObj.transform.SetParent(ContextTransform, false); + gameObj.transform.SetParent(null, false); + } + else + { + gameObj.transform.SetParent(parent, false); + } + + return gameObj; + } + + Transform GetTransformGroup( + GameObjectCreationParameters gameObjectBindInfo, InjectContext context) + { + Assert.That(!AssertOnNewGameObjects, + "Given DiContainer does not support creating new game objects"); + + if (gameObjectBindInfo.ParentTransform != null) + { + Assert.IsNull(gameObjectBindInfo.GroupName); + Assert.IsNull(gameObjectBindInfo.ParentTransformGetter); + + return gameObjectBindInfo.ParentTransform; + } + + // Don't execute the ParentTransformGetter method during validation + // since it might do a resolve etc. + if (gameObjectBindInfo.ParentTransformGetter != null && !IsValidating) + { + Assert.IsNull(gameObjectBindInfo.GroupName); + + if (context == null) + { + context = new InjectContext + { + // This is the only information we can supply in this case + Container = this + }; + } + + // NOTE: Null is fine here, will just be a root game object in that case + return gameObjectBindInfo.ParentTransformGetter(context); + } + + var groupName = gameObjectBindInfo.GroupName; + + // Only use the inherited parent if is not set locally + var defaultParent = _hasExplicitDefaultParent ? _explicitDefaultParent : _inheritedDefaultParent; + + if (defaultParent == null) + { + if (groupName == null) + { + return null; + } + + return (GameObject.Find("/" + groupName) ?? CreateTransformGroup(groupName)).transform; + } + + if (groupName == null) + { + return defaultParent; + } + + foreach (Transform child in defaultParent) + { + if (child.name == groupName) + { + return child; + } + } + + var group = new GameObject(groupName).transform; + group.SetParent(defaultParent, false); + return group; + } + + GameObject CreateTransformGroup(string groupName) + { + var gameObj = new GameObject(groupName); + gameObj.transform.SetParent(ContextTransform, false); + gameObj.transform.SetParent(null, false); + return gameObj; + } + +#endif + + // Use this method to create any non-monobehaviour + // Any fields marked [Inject] will be set using the bindings on the container + // Any methods marked with a [Inject] will be called + // Any constructor parameters will be filled in with values from the container + public T Instantiate() + { + return Instantiate(new object[0]); + } + + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public T Instantiate(IEnumerable extraArgs) + { + var result = Instantiate(typeof(T), extraArgs); + + if (IsValidating && !(result is T)) + { + Assert.That(result is ValidationMarker); + return default(T); + } + + return (T)result; + } + + public object Instantiate(Type concreteType) + { + return Instantiate(concreteType, new object[0]); + } + + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public object Instantiate( + Type concreteType, IEnumerable extraArgs) + { + Assert.That(!extraArgs.ContainsItem(null), + "Null value given to factory constructor arguments when instantiating object with type '{0}'. In order to use null use InstantiateExplicit", concreteType); + + return InstantiateExplicit( + concreteType, InjectUtil.CreateArgList(extraArgs)); + } + +#if !NOT_UNITY3D + // Add new component to existing game object and fill in its dependencies + // This is the same as AddComponent except the [Inject] fields will be filled in + // NOTE: Gameobject here is not a prefab prototype, it is an instance + public TContract InstantiateComponent(GameObject gameObject) + where TContract : Component + { + return InstantiateComponent(gameObject, new object[0]); + } + + // Add new component to existing game object and fill in its dependencies + // This is the same as AddComponent except the [Inject] fields will be filled in + // NOTE: Gameobject here is not a prefab prototype, it is an instance + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public TContract InstantiateComponent( + GameObject gameObject, IEnumerable extraArgs) + where TContract : Component + { + return (TContract)InstantiateComponent(typeof(TContract), gameObject, extraArgs); + } + + // Add new component to existing game object and fill in its dependencies + // This is the same as AddComponent except the [Inject] fields will be filled in + // NOTE: Gameobject here is not a prefab prototype, it is an instance + public Component InstantiateComponent( + Type componentType, GameObject gameObject) + { + return InstantiateComponent(componentType, gameObject, new object[0]); + } + + // Add new component to existing game object and fill in its dependencies + // This is the same as AddComponent except the [Inject] fields will be filled in + // NOTE: Gameobject here is not a prefab prototype, it is an instance + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public Component InstantiateComponent( + Type componentType, GameObject gameObject, IEnumerable extraArgs) + { + return InstantiateComponentExplicit( + componentType, gameObject, InjectUtil.CreateArgList(extraArgs)); + } + + public T InstantiateComponentOnNewGameObject() + where T : Component + { + return InstantiateComponentOnNewGameObject(typeof(T).Name); + } + + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public T InstantiateComponentOnNewGameObject(IEnumerable extraArgs) + where T : Component + { + return InstantiateComponentOnNewGameObject(typeof(T).Name, extraArgs); + } + + public T InstantiateComponentOnNewGameObject(string gameObjectName) + where T : Component + { + return InstantiateComponentOnNewGameObject(gameObjectName, new object[0]); + } + + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public T InstantiateComponentOnNewGameObject( + string gameObjectName, IEnumerable extraArgs) + where T : Component + { + return InstantiateComponent( + CreateEmptyGameObject(gameObjectName), + extraArgs); + } + + // Create a new game object from a prefab and fill in dependencies for all children + public GameObject InstantiatePrefab(UnityEngine.Object prefab) + { + return InstantiatePrefab( + prefab, GameObjectCreationParameters.Default); + } + + // Create a new game object from a prefab and fill in dependencies for all children + public GameObject InstantiatePrefab(UnityEngine.Object prefab, Transform parentTransform) + { + return InstantiatePrefab( + prefab, new GameObjectCreationParameters { ParentTransform = parentTransform }); + } + + // Create a new game object from a prefab and fill in dependencies for all children + public GameObject InstantiatePrefab( + UnityEngine.Object prefab, Vector3 position, Quaternion rotation, Transform parentTransform) + { + return InstantiatePrefab( + prefab, new GameObjectCreationParameters + { + ParentTransform = parentTransform, + Position = position, + Rotation = rotation + }); + } + + // Create a new game object from a prefab and fill in dependencies for all children + public GameObject InstantiatePrefab( + UnityEngine.Object prefab, GameObjectCreationParameters gameObjectBindInfo) + { + FlushBindings(); + + bool shouldMakeActive; + var gameObj = CreateAndParentPrefab( + prefab, gameObjectBindInfo, null, out shouldMakeActive); + + InjectGameObject(gameObj); + + if (shouldMakeActive && !IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif + { + gameObj.SetActive(true); + } + } + + return gameObj; + } + + // Create a new game object from a resource path and fill in dependencies for all children + public GameObject InstantiatePrefabResource(string resourcePath) + { + return InstantiatePrefabResource(resourcePath, GameObjectCreationParameters.Default); + } + + // Create a new game object from a resource path and fill in dependencies for all children + public GameObject InstantiatePrefabResource(string resourcePath, Transform parentTransform) + { + return InstantiatePrefabResource(resourcePath, new GameObjectCreationParameters { ParentTransform = parentTransform }); + } + + public GameObject InstantiatePrefabResource( + string resourcePath, Vector3 position, Quaternion rotation, Transform parentTransform) + { + return InstantiatePrefabResource( + resourcePath, new GameObjectCreationParameters + { + ParentTransform = parentTransform, + Position = position, + Rotation = rotation + }); + } + + // Create a new game object from a resource path and fill in dependencies for all children + public GameObject InstantiatePrefabResource( + string resourcePath, GameObjectCreationParameters creationInfo) + { + var prefab = (GameObject)Resources.Load(resourcePath); + + Assert.IsNotNull(prefab, + "Could not find prefab at resource location '{0}'".Fmt(resourcePath)); + + return InstantiatePrefab(prefab, creationInfo); + } + + // Same as InstantiatePrefab but returns a component after it's initialized + // and optionally allows extra arguments for the given component type + public T InstantiatePrefabForComponent(UnityEngine.Object prefab) + { + return (T)InstantiatePrefabForComponent( + typeof(T), prefab, null, new object[0]); + } + + // Same as InstantiatePrefab but returns a component after it's initialized + // and optionally allows extra arguments for the given component type + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public T InstantiatePrefabForComponent( + UnityEngine.Object prefab, IEnumerable extraArgs) + { + return (T)InstantiatePrefabForComponent( + typeof(T), prefab, null, extraArgs); + } + + public T InstantiatePrefabForComponent( + UnityEngine.Object prefab, Transform parentTransform) + { + return (T)InstantiatePrefabForComponent( + typeof(T), prefab, parentTransform, new object[0]); + } + + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public T InstantiatePrefabForComponent( + UnityEngine.Object prefab, Transform parentTransform, IEnumerable extraArgs) + { + return (T)InstantiatePrefabForComponent( + typeof(T), prefab, parentTransform, extraArgs); + } + + public T InstantiatePrefabForComponent( + UnityEngine.Object prefab, Vector3 position, Quaternion rotation, Transform parentTransform) + { + return (T)InstantiatePrefabForComponent( + typeof(T), prefab, new object[0], new GameObjectCreationParameters + { + ParentTransform = parentTransform, + Position = position, + Rotation = rotation + }); + } + + public T InstantiatePrefabForComponent( + UnityEngine.Object prefab, Vector3 position, Quaternion rotation, Transform parentTransform, IEnumerable extraArgs) + { + return (T)InstantiatePrefabForComponent( + typeof(T), prefab, extraArgs, new GameObjectCreationParameters + { + ParentTransform = parentTransform, + Position = position, + Rotation = rotation + }); + } + + // Same as InstantiatePrefab but returns a component after it's initialized + // and optionally allows extra arguments for the given component type + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public object InstantiatePrefabForComponent( + Type concreteType, UnityEngine.Object prefab, + Transform parentTransform, IEnumerable extraArgs) + { + return InstantiatePrefabForComponent( + concreteType, prefab, extraArgs, + new GameObjectCreationParameters { ParentTransform = parentTransform }); + } + + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public object InstantiatePrefabForComponent( + Type concreteType, UnityEngine.Object prefab, + IEnumerable extraArgs, GameObjectCreationParameters creationInfo) + { + return InstantiatePrefabForComponentExplicit( + concreteType, prefab, + InjectUtil.CreateArgList(extraArgs), creationInfo); + } + + // Same as InstantiatePrefabResource but returns a component after it's initialized + // and optionally allows extra arguments for the given component type + public T InstantiatePrefabResourceForComponent(string resourcePath) + { + return (T)InstantiatePrefabResourceForComponent( + typeof(T), resourcePath, null, new object[0]); + } + + // Same as InstantiatePrefabResource but returns a component after it's initialized + // and optionally allows extra arguments for the given component type + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public T InstantiatePrefabResourceForComponent( + string resourcePath, IEnumerable extraArgs) + { + return (T)InstantiatePrefabResourceForComponent( + typeof(T), resourcePath, null, extraArgs); + } + + public T InstantiatePrefabResourceForComponent( + string resourcePath, Transform parentTransform) + { + return (T)InstantiatePrefabResourceForComponent( + typeof(T), resourcePath, parentTransform, new object[0]); + } + + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public T InstantiatePrefabResourceForComponent( + string resourcePath, Transform parentTransform, IEnumerable extraArgs) + { + return (T)InstantiatePrefabResourceForComponent( + typeof(T), resourcePath, parentTransform, extraArgs); + } + + public T InstantiatePrefabResourceForComponent( + string resourcePath, Vector3 position, Quaternion rotation, Transform parentTransform) + { + return InstantiatePrefabResourceForComponent(resourcePath, position, rotation, parentTransform, new object[0]); + } + + public T InstantiatePrefabResourceForComponent( + string resourcePath, Vector3 position, Quaternion rotation, Transform parentTransform, IEnumerable extraArgs) + { + var argsList = InjectUtil.CreateArgList(extraArgs); + var creationParameters = new GameObjectCreationParameters + { + ParentTransform = parentTransform, + Position = position, + Rotation = rotation + }; + return (T)InstantiatePrefabResourceForComponentExplicit( + typeof(T), resourcePath, argsList, creationParameters); + } + + // Same as InstantiatePrefabResource but returns a component after it's initialized + // and optionally allows extra arguments for the given component type + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public object InstantiatePrefabResourceForComponent( + Type concreteType, string resourcePath, Transform parentTransform, + IEnumerable extraArgs) + { + Assert.That(!extraArgs.ContainsItem(null), + "Null value given to factory constructor arguments when instantiating object with type '{0}'. In order to use null use InstantiatePrefabForComponentExplicit", concreteType); + + return InstantiatePrefabResourceForComponentExplicit( + concreteType, resourcePath, + InjectUtil.CreateArgList(extraArgs), + new GameObjectCreationParameters { ParentTransform = parentTransform }); + } + + public T InstantiateScriptableObjectResource(string resourcePath) + where T : ScriptableObject + { + return InstantiateScriptableObjectResource(resourcePath, new object[0]); + } + + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public T InstantiateScriptableObjectResource( + string resourcePath, IEnumerable extraArgs) + where T : ScriptableObject + { + return (T)InstantiateScriptableObjectResource( + typeof(T), resourcePath, extraArgs); + } + + public object InstantiateScriptableObjectResource( + Type scriptableObjectType, string resourcePath) + { + return InstantiateScriptableObjectResource( + scriptableObjectType, resourcePath, new object[0]); + } + + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public object InstantiateScriptableObjectResource( + Type scriptableObjectType, string resourcePath, IEnumerable extraArgs) + { + Assert.DerivesFromOrEqual(scriptableObjectType); + return InstantiateScriptableObjectResourceExplicit( + scriptableObjectType, resourcePath, InjectUtil.CreateArgList(extraArgs)); + } + + // Inject dependencies into any and all child components on the given game object + public void InjectGameObject(GameObject gameObject) + { + FlushBindings(); + + ZenUtilInternal.AddStateMachineBehaviourAutoInjectersUnderGameObject(gameObject); + + var monoBehaviours = ZenPools.SpawnList(); + try + { + ZenUtilInternal.GetInjectableMonoBehavioursUnderGameObject(gameObject, monoBehaviours); + + for (int i = 0; i < monoBehaviours.Count; i++) + { + Inject(monoBehaviours[i]); + } + } + finally + { + ZenPools.DespawnList(monoBehaviours); + } + } + + // Same as InjectGameObject except it will also search the game object for the + // given component, and also optionally allow passing extra inject arguments into the + // given component + public T InjectGameObjectForComponent(GameObject gameObject) + where T : Component + { + return InjectGameObjectForComponent(gameObject, new object[0]); + } + + // Same as InjectGameObject except it will also search the game object for the + // given component, and also optionally allow passing extra inject arguments into the + // given component + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public T InjectGameObjectForComponent( + GameObject gameObject, IEnumerable extraArgs) + where T : Component + { + return (T)InjectGameObjectForComponent(gameObject, typeof(T), extraArgs); + } + + // Same as InjectGameObject except it will also search the game object for the + // given component, and also optionally allow passing extra inject arguments into the + // given component + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public object InjectGameObjectForComponent( + GameObject gameObject, Type componentType, IEnumerable extraArgs) + { + return InjectGameObjectForComponentExplicit( + gameObject, componentType, InjectUtil.CreateArgList(extraArgs), new InjectContext(this, componentType, null), null); + } + + // Same as InjectGameObjectForComponent except allows null values + // to be included in the argument list. Also see InjectUtil.CreateArgList + public Component InjectGameObjectForComponentExplicit( + GameObject gameObject, Type componentType, List extraArgs, InjectContext context, object concreteIdentifier) + { + if (!componentType.DerivesFrom() && extraArgs.Count > 0) + { + throw Assert.CreateException( + "Cannot inject into non-monobehaviours! Argument list must be zero length"); + } + + ZenUtilInternal.AddStateMachineBehaviourAutoInjectersUnderGameObject(gameObject); + + var injectableMonoBehaviours = ZenPools.SpawnList(); + try + { + + ZenUtilInternal.GetInjectableMonoBehavioursUnderGameObject(gameObject, injectableMonoBehaviours); + + for (int i = 0; i < injectableMonoBehaviours.Count; i++) + { + var monoBehaviour = injectableMonoBehaviours[i]; + if (monoBehaviour.GetType().DerivesFromOrEqual(componentType)) + { + InjectExplicit(monoBehaviour, monoBehaviour.GetType(), extraArgs, context, concreteIdentifier); + } + else + { + Inject(monoBehaviour); + } + } + } + finally + { + ZenPools.DespawnList(injectableMonoBehaviours); + } + + var matches = gameObject.GetComponentsInChildren(componentType, true); + + Assert.That(matches.Length > 0, + "Expected to find component with type '{0}' when injecting into game object '{1}'", componentType, gameObject.name); + + Assert.That(matches.Length == 1, + "Found multiple component with type '{0}' when injecting into game object '{1}'", componentType, gameObject.name); + + return matches[0]; + } +#endif + + // When you call any of these Inject methods + // Any fields marked [Inject] will be set using the bindings on the container + // Any methods marked with a [Inject] will be called + // Any constructor parameters will be filled in with values from the container + public void Inject(object injectable) + { + Inject(injectable, new object[0]); + } + + // Same as Inject(injectable) except allows adding extra values to be injected + // Note: For IL2CPP platforms make sure to use new object[] instead of new [] when creating + // the argument list to avoid errors converting to IEnumerable + public void Inject(object injectable, IEnumerable extraArgs) + { + InjectExplicit( + injectable, InjectUtil.CreateArgList(extraArgs)); + } + + // Resolve<> - Lookup a value in the container. + // + // Note that this may result in a new object being created (for transient bindings) or it + // may return an already created object (for FromInstance or ToSingle, etc. bindings) + // + // If a single unique value for the given type cannot be found, an exception is thrown. + // + public TContract Resolve() + { + return (TContract)Resolve(typeof(TContract)); + } + + public object Resolve(Type contractType) + { + return ResolveId(contractType, null); + } + + public TContract ResolveId(object identifier) + { + return (TContract)ResolveId(typeof(TContract), identifier); + } + + public object ResolveId(Type contractType, object identifier) + { + using (var context = ZenPools.SpawnInjectContext(this, contractType)) + { + context.Identifier = identifier; + return Resolve(context); + } + } + + // Same as Resolve<> except it will return null if a value for the given type cannot + // be found. + public TContract TryResolve() + where TContract : class + { + return (TContract)TryResolve(typeof(TContract)); + } + + public object TryResolve(Type contractType) + { + return TryResolveId(contractType, null); + } + + public TContract TryResolveId(object identifier) + where TContract : class + { + return (TContract)TryResolveId( + typeof(TContract), identifier); + } + + public object TryResolveId(Type contractType, object identifier) + { + using (var context = ZenPools.SpawnInjectContext(this, contractType)) + { + context.Identifier = identifier; + context.Optional = true; + return Resolve(context); + } + } + + // Same as Resolve<> except it will return all bindings that are associated with the given type + public List ResolveAll() + { + return (List)ResolveAll(typeof(TContract)); + } + + public IList ResolveAll(Type contractType) + { + return ResolveIdAll(contractType, null); + } + + public List ResolveIdAll(object identifier) + { + return (List)ResolveIdAll(typeof(TContract), identifier); + } + + public IList ResolveIdAll(Type contractType, object identifier) + { + using (var context = ZenPools.SpawnInjectContext(this, contractType)) + { + context.Identifier = identifier; + context.Optional = true; + return ResolveAll(context); + } + } + + // Removes all bindings + public void UnbindAll() + { + FlushBindings(); + _providers.Clear(); + } + + // Remove all bindings bound to the given contract type + public bool Unbind() + { + return Unbind(typeof(TContract)); + } + + public bool Unbind(Type contractType) + { + return UnbindId(contractType, null); + } + + public bool UnbindId(object identifier) + { + return UnbindId(typeof(TContract), identifier); + } + + public bool UnbindId(Type contractType, object identifier) + { + FlushBindings(); + + var bindingId = new BindingId(contractType, identifier); + + return _providers.Remove(bindingId); + } + + public void UnbindInterfacesTo() + { + UnbindInterfacesTo(typeof(TConcrete)); + } + + public void UnbindInterfacesTo(Type concreteType) + { + foreach (var i in concreteType.Interfaces()) + { + Unbind(i, concreteType); + } + } + + public bool Unbind() + { + return Unbind(typeof(TContract), typeof(TConcrete)); + } + + public bool Unbind(Type contractType, Type concreteType) + { + return UnbindId(contractType, concreteType, null); + } + + public bool UnbindId(object identifier) + { + return UnbindId(typeof(TContract), typeof(TConcrete), identifier); + } + + public bool UnbindId(Type contractType, Type concreteType, object identifier) + { + FlushBindings(); + + var bindingId = new BindingId(contractType, identifier); + + List providers; + + if (!_providers.TryGetValue(bindingId, out providers)) + { + return false; + } + + var matches = providers.Where(x => x.Provider.GetInstanceType(new InjectContext(this, contractType, identifier)).DerivesFromOrEqual(concreteType)).ToList(); + + if (matches.Count == 0) + { + return false; + } + + foreach (var info in matches) + { + bool success = providers.Remove(info); + Assert.That(success); + } + + return true; + } + + // Returns true if the given type is bound to something in the container + public bool HasBinding() + { + return HasBinding(typeof(TContract)); + } + + public bool HasBinding(Type contractType) + { + return HasBindingId(contractType, null); + } + + public bool HasBindingId(object identifier) + { + return HasBindingId(typeof(TContract), identifier); + } + + public bool HasBindingId(Type contractType, object identifier) + { + return HasBindingId(contractType, identifier, InjectSources.Any); + } + + public bool HasBindingId(Type contractType, object identifier, InjectSources sourceType) + { + using (var ctx = ZenPools.SpawnInjectContext(this, contractType)) + { + ctx.Identifier = identifier; + ctx.SourceType = sourceType; + return HasBinding(ctx); + } + } + + // You shouldn't need to use this + public bool HasBinding(InjectContext context) + { + Assert.IsNotNull(context); + + FlushBindings(); + + var matches = ZenPools.SpawnList(); + + try + { + GetProviderMatches(context, matches); + return matches.Count > 0; + } + finally + { + ZenPools.DespawnList(matches); + } + } + + // You shouldn't need to use this + public void FlushBindings() + { + while (_currentBindings.Count > 0) + { + var binding = _currentBindings.Dequeue(); + + if (binding.BindingInheritanceMethod != BindingInheritanceMethods.MoveDirectOnly + && binding.BindingInheritanceMethod != BindingInheritanceMethods.MoveIntoAll) + { + FinalizeBinding(binding); + } + + if (binding.BindingInheritanceMethod != BindingInheritanceMethods.None) + { + _childBindings.Add(binding); + } + else + { + binding.Dispose(); + } + } + } + + void FinalizeBinding(BindStatement binding) + { + _isFinalizingBinding = true; + + try + { + binding.FinalizeBinding(this); + } + finally + { + _isFinalizingBinding = false; + } + } + + // Don't use this method + public BindStatement StartBinding(bool flush = true) + { + Assert.That(!_isFinalizingBinding, + "Attempted to start a binding during a binding finalizer. This is not allowed, since binding finalizers should directly use AddProvider instead, to allow for bindings to be inherited properly without duplicates"); + + if (flush) + { + FlushBindings(); + } + + var bindStatement = ZenPools.SpawnStatement(); + _currentBindings.Enqueue(bindStatement); + return bindStatement; + } + + public ConcreteBinderGeneric Rebind() + { + return RebindId(null); + } + + public ConcreteBinderGeneric RebindId(object identifier) + { + UnbindId(identifier); + return Bind().WithId(identifier); + } + + public ConcreteBinderNonGeneric Rebind(Type contractType) + { + return RebindId(contractType, null); + } + + public ConcreteBinderNonGeneric RebindId(Type contractType, object identifier) + { + UnbindId(contractType, identifier); + return Bind(contractType).WithId(identifier); + } + + // Map the given type to a way of obtaining it + // Note that this can include open generic types as well such as List<> + public ConcreteIdBinderGeneric Bind() + { + return Bind(StartBinding()); + } + + // This is only useful for complex cases where you want to add multiple bindings + // at the same time and can be ignored by 99% of users + public ConcreteIdBinderGeneric BindNoFlush() + { + return Bind(StartBinding(false)); + } + + ConcreteIdBinderGeneric Bind( + BindStatement bindStatement) + { + var bindInfo = bindStatement.SpawnBindInfo(); + + Assert.That(!typeof(TContract).DerivesFrom(), + "You should not use Container.Bind for factory classes. Use Container.BindFactory instead."); + + Assert.That(!bindInfo.ContractTypes.Contains(typeof(TContract))); + bindInfo.ContractTypes.Add(typeof(TContract)); + + return new ConcreteIdBinderGeneric( + this, bindInfo, bindStatement); + } + + // Non-generic version of Bind<> for cases where you only have the runtime type + // Note that this can include open generic types as well such as List<> + public ConcreteIdBinderNonGeneric Bind(params Type[] contractTypes) + { + var statement = StartBinding(); + var bindInfo = statement.SpawnBindInfo(); + bindInfo.ContractTypes.AllocFreeAddRange(contractTypes); + return BindInternal(bindInfo, statement); + } + + public ConcreteIdBinderNonGeneric Bind(IEnumerable contractTypes) + { + var statement = StartBinding(); + var bindInfo = statement.SpawnBindInfo(); + bindInfo.ContractTypes.AddRange(contractTypes); + return BindInternal(bindInfo, statement); + } + + ConcreteIdBinderNonGeneric BindInternal( + BindInfo bindInfo, BindStatement bindingFinalizer) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("DiContainer.Bind")) +#endif + { + Assert.That(bindInfo.ContractTypes.All(x => !x.DerivesFrom()), + "You should not use Container.Bind for factory classes. Use Container.BindFactory instead."); + + return new ConcreteIdBinderNonGeneric(this, bindInfo, bindingFinalizer); + } + } + +#if !(UNITY_WSA && ENABLE_DOTNET) + public ConcreteIdBinderNonGeneric Bind( + Action generator) + { + var conventionBindInfo = new ConventionBindInfo(); + generator(new ConventionSelectTypesBinder(conventionBindInfo)); + + var contractTypesList = conventionBindInfo.ResolveTypes(); + + Assert.That(contractTypesList.All(x => !x.DerivesFrom()), + "You should not use Container.Bind for factory classes. Use Container.BindFactory instead."); + + var statement = StartBinding(); + var bindInfo = statement.SpawnBindInfo(); + bindInfo.ContractTypes.AllocFreeAddRange(contractTypesList); + + // This is nice because it allows us to do things like Bind(all interfaces).To() + // (though of course it would be more efficient to use BindInterfacesTo in this case) + bindInfo.InvalidBindResponse = InvalidBindResponses.Skip; + + return new ConcreteIdBinderNonGeneric(this, bindInfo, statement); + } +#endif + + // Bind all the interfaces for the given type to the same thing. + // + // Example: + // + // public class Foo : ITickable, IInitializable + // { + // } + // + // Container.BindInterfacesTo().AsSingle(); + // + // This line above is equivalent to the following: + // + // Container.Bind().ToSingle(); + // Container.Bind().ToSingle(); + // + // Note here that we do not bind Foo to itself. For that, use BindInterfacesAndSelfTo + public FromBinderNonGeneric BindInterfacesTo() + { + return BindInterfacesTo(typeof(T)); + } + + public FromBinderNonGeneric BindInterfacesTo(Type type) + { + var statement = StartBinding(); + var bindInfo = statement.SpawnBindInfo(); + + var interfaces = type.Interfaces(); + + if (interfaces.Length == 0) + { + Log.Warn("Called BindInterfacesTo for type {0} but no interfaces were found", type); + } + + bindInfo.ContractTypes.AllocFreeAddRange(interfaces); + bindInfo.SetContextInfo("BindInterfacesTo({0})".Fmt(type)); + + // Almost always, you don't want to use the default AsTransient so make them type it + bindInfo.RequireExplicitScope = true; + return BindInternal(bindInfo, statement).To(type); + } + + // Same as BindInterfaces except also binds to self + public FromBinderNonGeneric BindInterfacesAndSelfTo() + { + return BindInterfacesAndSelfTo(typeof(T)); + } + + public FromBinderNonGeneric BindInterfacesAndSelfTo(Type type) + { + var statement = StartBinding(); + var bindInfo = statement.SpawnBindInfo(); + + bindInfo.ContractTypes.AllocFreeAddRange(type.Interfaces()); + bindInfo.ContractTypes.Add(type); + + bindInfo.SetContextInfo("BindInterfacesAndSelfTo({0})".Fmt(type)); + + // Almost always, you don't want to use the default AsTransient so make them type it + bindInfo.RequireExplicitScope = true; + return BindInternal(bindInfo, statement).To(type); + } + + // This is simply a shortcut to using the FromInstance method. + // + // Example: + // Container.BindInstance(new Foo()); + // + // This line above is equivalent to the following: + // + // Container.Bind().FromInstance(new Foo()); + // + public IdScopeConcreteIdArgConditionCopyNonLazyBinder BindInstance(TContract instance) + { + var statement = StartBinding(); + var bindInfo = statement.SpawnBindInfo(); + bindInfo.ContractTypes.Add(typeof(TContract)); + + statement.SetFinalizer( + new ScopableBindingFinalizer( + bindInfo, + (container, type) => new InstanceProvider(type, instance, container, bindInfo.InstantiatedCallback))); + + return new IdScopeConcreteIdArgConditionCopyNonLazyBinder(bindInfo); + } + + // Unfortunately we can't support setting scope / condition / etc. here since all the + // bindings are finalized one at a time + public void BindInstances(params object[] instances) + { + for (int i = 0; i < instances.Length; i++) + { + var instance = instances[i]; + + Assert.That(!ZenUtilInternal.IsNull(instance), + "Found null instance provided to BindInstances method"); + + Bind(instance.GetType()).FromInstance(instance); + } + } + + FactoryToChoiceIdBinder BindFactoryInternal() + where TFactoryConcrete : TFactoryContract, IFactory + where TFactoryContract : IFactory + { + var statement = StartBinding(); + var bindInfo = statement.SpawnBindInfo(); + bindInfo.ContractTypes.Add(typeof(TFactoryContract)); + + var factoryBindInfo = new FactoryBindInfo(typeof(TFactoryConcrete)); + + statement.SetFinalizer( + new PlaceholderFactoryBindingFinalizer( + bindInfo, factoryBindInfo)); + + return new FactoryToChoiceIdBinder( + this, bindInfo, factoryBindInfo); + } + + public FactoryToChoiceIdBinder BindIFactory() + { + return BindFactoryInternal, PlaceholderFactory>(); + } + + public FactoryToChoiceIdBinder BindFactory() + where TFactory : PlaceholderFactory + { + return BindFactoryInternal(); + } + + public FactoryToChoiceIdBinder BindFactoryCustomInterface() + where TFactoryConcrete : PlaceholderFactory, TFactoryContract + where TFactoryContract : IFactory + { + return BindFactoryInternal(); + } + + public MemoryPoolIdInitialSizeMaxSizeBinder BindMemoryPool() + { + return BindMemoryPool>(); + } + + public MemoryPoolIdInitialSizeMaxSizeBinder BindMemoryPool() + where TPool : IMemoryPool + { + return BindMemoryPoolCustomInterface(); + } + + public MemoryPoolIdInitialSizeMaxSizeBinder BindMemoryPoolCustomInterface(bool includeConcreteType = false) + where TPoolConcrete : TPoolContract, IMemoryPool + where TPoolContract : IMemoryPool + { + return BindMemoryPoolCustomInterfaceInternal(includeConcreteType, StartBinding()); + } + + internal MemoryPoolIdInitialSizeMaxSizeBinder BindMemoryPoolCustomInterfaceNoFlush(bool includeConcreteType = false) + where TPoolConcrete : TPoolContract, IMemoryPool + where TPoolContract : IMemoryPool + { + return BindMemoryPoolCustomInterfaceInternal(includeConcreteType, StartBinding(false)); + } + + MemoryPoolIdInitialSizeMaxSizeBinder BindMemoryPoolCustomInterfaceInternal( + bool includeConcreteType, BindStatement statement) + where TPoolConcrete : TPoolContract, IMemoryPool + where TPoolContract : IMemoryPool + { + var contractTypes = new List { typeof(IDisposable), typeof(TPoolContract) }; + + if (includeConcreteType) + { + contractTypes.Add(typeof(TPoolConcrete)); + } + + var bindInfo = statement.SpawnBindInfo(); + + bindInfo.ContractTypes.AllocFreeAddRange(contractTypes); + + // This interface is used in the optional class PoolCleanupChecker + // And also allow people to manually call DespawnAll() for all IMemoryPool + // if they want + bindInfo.ContractTypes.Add(typeof(IMemoryPool)); + + var factoryBindInfo = new FactoryBindInfo(typeof(TPoolConcrete)); + var poolBindInfo = new MemoryPoolBindInfo(); + + statement.SetFinalizer( + new MemoryPoolBindingFinalizer( + bindInfo, factoryBindInfo, poolBindInfo)); + + return new MemoryPoolIdInitialSizeMaxSizeBinder( + this, bindInfo, factoryBindInfo, poolBindInfo); + } + + FactoryToChoiceIdBinder BindFactoryInternal() + where TFactoryConcrete : TFactoryContract, IFactory + where TFactoryContract : IFactory + { + var statement = StartBinding(); + var bindInfo = statement.SpawnBindInfo(); + + bindInfo.ContractTypes.Add(typeof(TFactoryContract)); + + var factoryBindInfo = new FactoryBindInfo(typeof(TFactoryConcrete)); + + statement.SetFinalizer( + new PlaceholderFactoryBindingFinalizer( + bindInfo, factoryBindInfo)); + + return new FactoryToChoiceIdBinder( + this, bindInfo, factoryBindInfo); + } + + public FactoryToChoiceIdBinder BindIFactory() + { + return BindFactoryInternal< + TParam1, TContract, IFactory, PlaceholderFactory>(); + } + + public FactoryToChoiceIdBinder BindFactory() + where TFactory : PlaceholderFactory + { + return BindFactoryInternal< + TParam1, TContract, TFactory, TFactory>(); + } + + public FactoryToChoiceIdBinder BindFactoryCustomInterface() + where TFactoryConcrete : PlaceholderFactory, TFactoryContract + where TFactoryContract : IFactory + { + return BindFactoryInternal(); + } + + FactoryToChoiceIdBinder BindFactoryInternal() + where TFactoryConcrete : TFactoryContract, IFactory + where TFactoryContract : IFactory + { + var statement = StartBinding(); + var bindInfo = statement.SpawnBindInfo(); + + bindInfo.ContractTypes.Add(typeof(TFactoryContract)); + + var factoryBindInfo = new FactoryBindInfo(typeof(TFactoryConcrete)); + + statement.SetFinalizer( + new PlaceholderFactoryBindingFinalizer( + bindInfo, factoryBindInfo)); + + return new FactoryToChoiceIdBinder( + this, bindInfo, factoryBindInfo); + } + + public FactoryToChoiceIdBinder BindIFactory() + { + return BindFactoryInternal< + TParam1, TParam2, TContract, IFactory, PlaceholderFactory>(); + } + + public FactoryToChoiceIdBinder BindFactory() + where TFactory : PlaceholderFactory + { + return BindFactoryInternal< + TParam1, TParam2, TContract, TFactory, TFactory>(); + } + + public FactoryToChoiceIdBinder BindFactoryCustomInterface() + where TFactoryConcrete : PlaceholderFactory, TFactoryContract + where TFactoryContract : IFactory + { + return BindFactoryInternal(); + } + + FactoryToChoiceIdBinder BindFactoryInternal() + where TFactoryConcrete : TFactoryContract, IFactory + where TFactoryContract : IFactory + { + var statement = StartBinding(); + var bindInfo = statement.SpawnBindInfo(); + + bindInfo.ContractTypes.Add(typeof(TFactoryContract)); + + var factoryBindInfo = new FactoryBindInfo(typeof(TFactoryConcrete)); + + statement.SetFinalizer( + new PlaceholderFactoryBindingFinalizer( + bindInfo, factoryBindInfo)); + + return new FactoryToChoiceIdBinder( + this, bindInfo, factoryBindInfo); + } + + public FactoryToChoiceIdBinder BindIFactory() + { + return BindFactoryInternal< + TParam1, TParam2, TParam3, TContract, IFactory, PlaceholderFactory>(); + } + + public FactoryToChoiceIdBinder BindFactory() + where TFactory : PlaceholderFactory + { + return BindFactoryInternal< + TParam1, TParam2, TParam3, TContract, TFactory, TFactory>(); + } + + public FactoryToChoiceIdBinder BindFactoryCustomInterface() + where TFactoryConcrete : PlaceholderFactory, TFactoryContract + where TFactoryContract : IFactory + { + return BindFactoryInternal(); + } + + FactoryToChoiceIdBinder BindFactoryInternal() + where TFactoryConcrete : TFactoryContract, IFactory + where TFactoryContract : IFactory + { + var statement = StartBinding(); + var bindInfo = statement.SpawnBindInfo(); + + bindInfo.ContractTypes.Add(typeof(TFactoryContract)); + + var factoryBindInfo = new FactoryBindInfo(typeof(TFactoryConcrete)); + + statement.SetFinalizer( + new PlaceholderFactoryBindingFinalizer( + bindInfo, factoryBindInfo)); + + return new FactoryToChoiceIdBinder( + this, bindInfo, factoryBindInfo); + } + + public FactoryToChoiceIdBinder BindIFactory() + { + return BindFactoryInternal< + TParam1, TParam2, TParam3, TParam4, TContract, IFactory, PlaceholderFactory>(); + } + + public FactoryToChoiceIdBinder BindFactory() + where TFactory : PlaceholderFactory + { + return BindFactoryInternal< + TParam1, TParam2, TParam3, TParam4, TContract, TFactory, TFactory>(); + } + + public FactoryToChoiceIdBinder BindFactoryCustomInterface() + where TFactoryConcrete : PlaceholderFactory, TFactoryContract + where TFactoryContract : IFactory + { + return BindFactoryInternal(); + } + + FactoryToChoiceIdBinder BindFactoryInternal() + where TFactoryConcrete : TFactoryContract, IFactory + where TFactoryContract : IFactory + { + var statement = StartBinding(); + var bindInfo = statement.SpawnBindInfo(); + + bindInfo.ContractTypes.Add(typeof(TFactoryContract)); + + var factoryBindInfo = new FactoryBindInfo(typeof(TFactoryConcrete)); + + statement.SetFinalizer( + new PlaceholderFactoryBindingFinalizer( + bindInfo, factoryBindInfo)); + + return new FactoryToChoiceIdBinder( + this, bindInfo, factoryBindInfo); + } + + public FactoryToChoiceIdBinder BindIFactory() + { + return BindFactoryInternal< + TParam1, TParam2, TParam3, TParam4, TParam5, TContract, IFactory, PlaceholderFactory>(); + } + + public FactoryToChoiceIdBinder BindFactory() + where TFactory : PlaceholderFactory + { + return BindFactoryInternal< + TParam1, TParam2, TParam3, TParam4, TParam5, TContract, TFactory, TFactory>(); + } + + public FactoryToChoiceIdBinder BindFactoryCustomInterface() + where TFactoryConcrete : PlaceholderFactory, TFactoryContract + where TFactoryContract : IFactory + { + return BindFactoryInternal(); + } + + FactoryToChoiceIdBinder BindFactoryInternal() + where TFactoryConcrete : TFactoryContract, IFactory + where TFactoryContract : IFactory + { + var statement = StartBinding(); + var bindInfo = statement.SpawnBindInfo(); + + bindInfo.ContractTypes.Add(typeof(TFactoryContract)); + + var factoryBindInfo = new FactoryBindInfo(typeof(TFactoryConcrete)); + + statement.SetFinalizer( + new PlaceholderFactoryBindingFinalizer( + bindInfo, factoryBindInfo)); + + return new FactoryToChoiceIdBinder( + this, bindInfo, factoryBindInfo); + } + + public FactoryToChoiceIdBinder BindIFactory() + { + return BindFactoryInternal< + TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TContract, IFactory, PlaceholderFactory>(); + } + + public FactoryToChoiceIdBinder BindFactory() + where TFactory : PlaceholderFactory + { + return BindFactoryInternal< + TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TContract, TFactory, TFactory>(); + } + + public FactoryToChoiceIdBinder BindFactoryCustomInterface() + where TFactoryConcrete : PlaceholderFactory, TFactoryContract + where TFactoryContract : IFactory + { + return BindFactoryInternal(); + } + + FactoryToChoiceIdBinder BindFactoryInternal() + where TFactoryConcrete : TFactoryContract, IFactory + where TFactoryContract : IFactory + { + var statement = StartBinding(); + var bindInfo = statement.SpawnBindInfo(); + + bindInfo.ContractTypes.Add(typeof(TFactoryContract)); + + var factoryBindInfo = new FactoryBindInfo(typeof(TFactoryConcrete)); + + statement.SetFinalizer( + new PlaceholderFactoryBindingFinalizer( + bindInfo, factoryBindInfo)); + + return new FactoryToChoiceIdBinder( + this, bindInfo, factoryBindInfo); + } + + public FactoryToChoiceIdBinder BindIFactory() + { + return BindFactoryInternal< + TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10, TContract, IFactory, PlaceholderFactory>(); + } + + public FactoryToChoiceIdBinder BindFactory() + where TFactory : PlaceholderFactory + { + return BindFactoryInternal< + TParam1, TParam2, TParam3, TParam4, TParam5, TParam6, TParam7, TParam8, TParam9, TParam10, TContract, TFactory, TFactory>(); + } + + public FactoryToChoiceIdBinder BindFactoryCustomInterface() + where TFactoryConcrete : PlaceholderFactory, TFactoryContract + where TFactoryContract : IFactory + { + return BindFactoryInternal(); + } + + public T InstantiateExplicit(List extraArgs) + { + return (T)InstantiateExplicit(typeof(T), extraArgs); + } + + public object InstantiateExplicit(Type concreteType, List extraArgs) + { + bool autoInject = true; + + return InstantiateExplicit( + concreteType, + autoInject, + extraArgs, + new InjectContext(this, concreteType, null), + null); + } + + public object InstantiateExplicit(Type concreteType, bool autoInject, List extraArgs, InjectContext context, object concreteIdentifier) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("DiContainer.Instantiate")) +#endif + { + if (IsValidating) + { + if (_settings.ValidationErrorResponse == ValidationErrorResponses.Throw) + { + return InstantiateInternal(concreteType, autoInject, extraArgs, context, concreteIdentifier); + } + + // In this case, just log it and continue to print out multiple validation errors + // at once + try + { + return InstantiateInternal(concreteType, autoInject, extraArgs, context, concreteIdentifier); + } + catch (Exception e) + { + Log.ErrorException(e); + return new ValidationMarker(concreteType, true); + } + } + + return InstantiateInternal(concreteType, autoInject, extraArgs, context, concreteIdentifier); + } + } + +#if !NOT_UNITY3D + public Component InstantiateComponentExplicit( + Type componentType, GameObject gameObject, List extraArgs) + { + Assert.That(componentType.DerivesFrom()); + + FlushBindings(); + + var monoBehaviour = gameObject.AddComponent(componentType); + InjectExplicit(monoBehaviour, extraArgs); + return monoBehaviour; + } + + public object InstantiateScriptableObjectResourceExplicit( + Type scriptableObjectType, string resourcePath, List extraArgs) + { + var objects = Resources.LoadAll(resourcePath, scriptableObjectType); + + Assert.That(objects.Length > 0, + "Could not find resource at path '{0}' with type '{1}'", resourcePath, scriptableObjectType); + + Assert.That(objects.Length == 1, + "Found multiple scriptable objects at path '{0}' when only 1 was expected with type '{1}'", resourcePath, scriptableObjectType); + + var newObj = ScriptableObject.Instantiate(objects.Single()); + + InjectExplicit(newObj, extraArgs); + + return newObj; + } + + // Same as InstantiatePrefabResourceForComponent except allows null values + // to be included in the argument list. Also see InjectUtil.CreateArgList + public object InstantiatePrefabResourceForComponentExplicit( + Type componentType, string resourcePath, List extraArgs, + GameObjectCreationParameters creationInfo) + { + return InstantiatePrefabResourceForComponentExplicit( + componentType, resourcePath, extraArgs, new InjectContext(this, componentType, null), null, creationInfo); + } + + public object InstantiatePrefabResourceForComponentExplicit( + Type componentType, string resourcePath, List extraArgs, InjectContext context, object concreteIdentifier, + GameObjectCreationParameters creationInfo) + { + var prefab = (GameObject)Resources.Load(resourcePath); + Assert.IsNotNull(prefab, + "Could not find prefab at resource location '{0}'".Fmt(resourcePath)); + return InstantiatePrefabForComponentExplicit( + componentType, prefab, extraArgs, context, concreteIdentifier, creationInfo); + } + + public object InstantiatePrefabForComponentExplicit( + Type componentType, UnityEngine.Object prefab, + List extraArgs) + { + return InstantiatePrefabForComponentExplicit( + componentType, prefab, extraArgs, GameObjectCreationParameters.Default); + } + + public object InstantiatePrefabForComponentExplicit( + Type componentType, UnityEngine.Object prefab, + List extraArgs, GameObjectCreationParameters gameObjectBindInfo) + { + return InstantiatePrefabForComponentExplicit( + componentType, prefab, extraArgs, new InjectContext(this, componentType, null), null, gameObjectBindInfo); + } + + // Same as InstantiatePrefabForComponent except allows null values + // to be included in the argument list. Also see InjectUtil.CreateArgList + public object InstantiatePrefabForComponentExplicit( + Type componentType, UnityEngine.Object prefab, + List extraArgs, InjectContext context, object concreteIdentifier, GameObjectCreationParameters gameObjectBindInfo) + { + Assert.That(!AssertOnNewGameObjects, + "Given DiContainer does not support creating new game objects"); + + FlushBindings(); + + Assert.That(componentType.IsInterface() || componentType.DerivesFrom(), + "Expected type '{0}' to derive from UnityEngine.Component", componentType); + + bool shouldMakeActive; + var gameObj = CreateAndParentPrefab(prefab, gameObjectBindInfo, context, out shouldMakeActive); + + var component = InjectGameObjectForComponentExplicit( + gameObj, componentType, extraArgs, context, concreteIdentifier); + + if (shouldMakeActive && !IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif + { + gameObj.SetActive(true); + } + } + + return component; + } +#endif + + ////////////// Execution order //////////////// + + public void BindExecutionOrder(int order) + { + BindExecutionOrder(typeof(T), order); + } + + public void BindExecutionOrder(Type type, int order) + { + Assert.That(type.DerivesFrom() || type.DerivesFrom() || type.DerivesFrom() || type.DerivesFrom() || type.DerivesFrom() || type.DerivesFrom() || type.DerivesFrom(), + "Expected type '{0}' to derive from one or more of the following interfaces: ITickable, IInitializable, ILateTickable, IFixedTickable, IDisposable, ILateDisposable", type); + + if (type.DerivesFrom()) + { + BindTickableExecutionOrder(type, order); + } + + if (type.DerivesFrom()) + { + BindInitializableExecutionOrder(type, order); + } + + if (type.DerivesFrom()) + { + BindDisposableExecutionOrder(type, order); + } + + if (type.DerivesFrom()) + { + BindLateDisposableExecutionOrder(type, order); + } + + if (type.DerivesFrom()) + { + BindFixedTickableExecutionOrder(type, order); + } + + if (type.DerivesFrom()) + { + BindLateTickableExecutionOrder(type, order); + } + + if (type.DerivesFrom()) + { + BindPoolableExecutionOrder(type, order); + } + } + + public CopyNonLazyBinder BindTickableExecutionOrder(int order) + where T : ITickable + { + return BindTickableExecutionOrder(typeof(T), order); + } + + public CopyNonLazyBinder BindTickableExecutionOrder(Type type, int order) + { + Assert.That(type.DerivesFrom(), + "Expected type '{0}' to derive from ITickable", type); + + return BindInstance( + ValuePair.New(type, order)).WhenInjectedInto(); + } + + public CopyNonLazyBinder BindInitializableExecutionOrder(int order) + where T : IInitializable + { + return BindInitializableExecutionOrder(typeof(T), order); + } + + public CopyNonLazyBinder BindInitializableExecutionOrder(Type type, int order) + { + Assert.That(type.DerivesFrom(), + "Expected type '{0}' to derive from IInitializable", type); + + return BindInstance( + ValuePair.New(type, order)).WhenInjectedInto(); + } + + public CopyNonLazyBinder BindDisposableExecutionOrder(int order) + where T : IDisposable + { + return BindDisposableExecutionOrder(typeof(T), order); + } + + public CopyNonLazyBinder BindLateDisposableExecutionOrder(int order) + where T : ILateDisposable + { + return BindLateDisposableExecutionOrder(typeof(T), order); + } + + public CopyNonLazyBinder BindDisposableExecutionOrder(Type type, int order) + { + Assert.That(type.DerivesFrom(), + "Expected type '{0}' to derive from IDisposable", type); + + return BindInstance( + ValuePair.New(type, order)).WhenInjectedInto(); + } + + public CopyNonLazyBinder BindLateDisposableExecutionOrder(Type type, int order) + { + Assert.That(type.DerivesFrom(), + "Expected type '{0}' to derive from ILateDisposable", type); + + return BindInstance( + ValuePair.New(type, order)).WithId("Late").WhenInjectedInto(); + } + + public CopyNonLazyBinder BindFixedTickableExecutionOrder(int order) + where T : IFixedTickable + { + return BindFixedTickableExecutionOrder(typeof(T), order); + } + + public CopyNonLazyBinder BindFixedTickableExecutionOrder(Type type, int order) + { + Assert.That(type.DerivesFrom(), + "Expected type '{0}' to derive from IFixedTickable", type); + + return Bind>().WithId("Fixed") + .FromInstance(ValuePair.New(type, order)).WhenInjectedInto(); + } + + public CopyNonLazyBinder BindLateTickableExecutionOrder(int order) + where T : ILateTickable + { + return BindLateTickableExecutionOrder(typeof(T), order); + } + + public CopyNonLazyBinder BindLateTickableExecutionOrder(Type type, int order) + { + Assert.That(type.DerivesFrom(), + "Expected type '{0}' to derive from ILateTickable", type); + + return Bind>().WithId("Late") + .FromInstance(ValuePair.New(type, order)).WhenInjectedInto(); + } + + public CopyNonLazyBinder BindPoolableExecutionOrder(int order) + where T : IPoolable + { + return BindPoolableExecutionOrder(typeof(T), order); + } + + public CopyNonLazyBinder BindPoolableExecutionOrder(Type type, int order) + { + Assert.That(type.DerivesFrom(), + "Expected type '{0}' to derive from IPoolable", type); + + return Bind>() + .FromInstance(ValuePair.New(type, order)).WhenInjectedInto(); + } + + class ProviderInfo + { + public ProviderInfo( + IProvider provider, BindingCondition condition, bool nonLazy, DiContainer container) + { + Provider = provider; + Condition = condition; + NonLazy = nonLazy; + Container = container; + } + + public readonly DiContainer Container; + public readonly bool NonLazy; + public readonly IProvider Provider; + public readonly BindingCondition Condition; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/DiContainer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/DiContainer.cs.meta new file mode 100644 index 0000000..810c1cb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/DiContainer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: de4283f91e0232a4897afd2a0af141bc +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/IInstantiator.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/IInstantiator.cs new file mode 100644 index 0000000..ba58b56 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/IInstantiator.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; + +#if !NOT_UNITY3D +using UnityEngine; +#endif + +namespace Zenject +{ + // You can optionally inject this interface into your classes/factories + // rather than using DiContainer which contains many methods you might not need + public interface IInstantiator + { + // Use this method to create any non-monobehaviour + // Any fields marked [Inject] will be set using the bindings on the container + // Any methods marked with a [Inject] will be called + // Any constructor parameters will be filled in with values from the container + T Instantiate(); + T Instantiate(IEnumerable extraArgs); + + object Instantiate(Type concreteType); + object Instantiate(Type concreteType, IEnumerable extraArgs); + +#if !NOT_UNITY3D + + // Add new component to existing game object and fill in its dependencies + // NOTE: Gameobject here is not a prefab prototype, it is an instance + TContract InstantiateComponent(GameObject gameObject) + where TContract : Component; + TContract InstantiateComponent( + GameObject gameObject, IEnumerable extraArgs) + where TContract : Component; + Component InstantiateComponent( + Type componentType, GameObject gameObject); + Component InstantiateComponent( + Type componentType, GameObject gameObject, IEnumerable extraArgs); + + T InstantiateComponentOnNewGameObject() + where T : Component; + T InstantiateComponentOnNewGameObject(string gameObjectName) + where T : Component; + T InstantiateComponentOnNewGameObject(IEnumerable extraArgs) + where T : Component; + T InstantiateComponentOnNewGameObject(string gameObjectName, IEnumerable extraArgs) + where T : Component; + + // Create a new game object from a prefab and fill in dependencies for all children + GameObject InstantiatePrefab(UnityEngine.Object prefab); + GameObject InstantiatePrefab( + UnityEngine.Object prefab, Transform parentTransform); + GameObject InstantiatePrefab( + UnityEngine.Object prefab, Vector3 position, Quaternion rotation, Transform parentTransform); + + // Create a new game object from a resource path and fill in dependencies for all children + GameObject InstantiatePrefabResource(string resourcePath); + GameObject InstantiatePrefabResource( + string resourcePath, Transform parentTransform); + GameObject InstantiatePrefabResource( + string resourcePath, Vector3 position, Quaternion rotation, Transform parentTransform); + + // Same as InstantiatePrefab but returns a component after it's initialized + // and optionally allows extra arguments for the given component type + T InstantiatePrefabForComponent(UnityEngine.Object prefab); + T InstantiatePrefabForComponent( + UnityEngine.Object prefab, IEnumerable extraArgs); + T InstantiatePrefabForComponent( + UnityEngine.Object prefab, Transform parentTransform); + T InstantiatePrefabForComponent( + UnityEngine.Object prefab, Transform parentTransform, IEnumerable extraArgs); + T InstantiatePrefabForComponent( + UnityEngine.Object prefab, Vector3 position, Quaternion rotation, Transform parentTransform); + T InstantiatePrefabForComponent( + UnityEngine.Object prefab, Vector3 position, Quaternion rotation, Transform parentTransform, IEnumerable extraArgs); + object InstantiatePrefabForComponent( + Type concreteType, UnityEngine.Object prefab, Transform parentTransform, IEnumerable extraArgs); + + // Same as InstantiatePrefabResource but returns a component after it's initialized + // and optionally allows extra arguments for the given component type + T InstantiatePrefabResourceForComponent(string resourcePath); + T InstantiatePrefabResourceForComponent( + string resourcePath, IEnumerable extraArgs); + T InstantiatePrefabResourceForComponent( + string resourcePath, Transform parentTransform); + T InstantiatePrefabResourceForComponent( + string resourcePath, Transform parentTransform, IEnumerable extraArgs); + T InstantiatePrefabResourceForComponent( + string resourcePath, Vector3 position, Quaternion rotation, Transform parentTransform); + T InstantiatePrefabResourceForComponent( + string resourcePath, Vector3 position, Quaternion rotation, Transform parentTransform, IEnumerable extraArgs); + object InstantiatePrefabResourceForComponent( + Type concreteType, string resourcePath, Transform parentTransform, IEnumerable extraArgs); + + T InstantiateScriptableObjectResource(string resourcePath) + where T : ScriptableObject; + T InstantiateScriptableObjectResource( + string resourcePath, IEnumerable extraArgs) + where T : ScriptableObject; + object InstantiateScriptableObjectResource( + Type scriptableObjectType, string resourcePath); + object InstantiateScriptableObjectResource( + Type scriptableObjectType, string resourcePath, IEnumerable extraArgs); + + GameObject CreateEmptyGameObject(string name); +#endif + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/IInstantiator.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/IInstantiator.cs.meta new file mode 100644 index 0000000..92177fd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/IInstantiator.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 27acc83df7708be4185afec9bd506165 +timeCreated: 1523188912 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/LazyInstanceInjector.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/LazyInstanceInjector.cs new file mode 100644 index 0000000..6d061bb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/LazyInstanceInjector.cs @@ -0,0 +1,76 @@ + +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + // When the app starts up, typically there is a list of instances that need to be injected + // The question is, what is the order that they should be injected? Originally we would + // just iterate over the list and inject in whatever order they were in + // What is better than that though, is to inject based on their dependency order + // So if A depends on B then it would be nice if B was always injected before A + // That way, in [Inject] methods for A, A can access members on B knowing that it's + // already been initialized. + // So in order to do this, we add the initial pool of instances to this class then + // notify this class whenever an instance is resolved via a FromInstance binding + // That way we can lazily call inject on-demand whenever the instance is requested + [NoReflectionBaking] + public class LazyInstanceInjector + { + readonly DiContainer _container; + readonly HashSet _instancesToInject = new HashSet(); + + public LazyInstanceInjector(DiContainer container) + { + _container = container; + } + + public IEnumerable Instances + { + get { return _instancesToInject; } + } + + public void AddInstance(object instance) + { + _instancesToInject.Add(instance); + } + + public void AddInstances(IEnumerable instances) + { + _instancesToInject.UnionWith(instances); + } + + public void LazyInject(object instance) + { + if (_instancesToInject.Remove(instance)) + { + _container.Inject(instance); + } + } + + public void LazyInjectAll() + { +#if UNITY_EDITOR + using (ProfileBlock.Start("Zenject.LazyInstanceInjector.LazyInjectAll")) +#endif + { + var tempList = new List(); + + while (!_instancesToInject.IsEmpty()) + { + tempList.Clear(); + tempList.AddRange(_instancesToInject); + + foreach (var instance in tempList) + { + // We use LazyInject instead of calling _container.inject directly + // Because it might have already been lazily injected + // as a result of a previous call to inject + LazyInject(instance); + } + } + } + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/LazyInstanceInjector.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/LazyInstanceInjector.cs.meta new file mode 100644 index 0000000..00f6fd3 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/LazyInstanceInjector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c7bd2a03033e83a4c9dab4d27166b412 +timeCreated: 1476651829 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/LookupId.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/LookupId.cs new file mode 100644 index 0000000..77c340d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/LookupId.cs @@ -0,0 +1,39 @@ +using ModestTree; + +namespace Zenject.Internal +{ + [NoReflectionBaking] + public class LookupId + { + public IProvider Provider; + public BindingId BindingId; + + public LookupId() + { + } + + public LookupId(IProvider provider, BindingId bindingId) + { + Assert.IsNotNull(provider); + Assert.IsNotNull(bindingId); + + Provider = provider; + BindingId = bindingId; + } + + public override int GetHashCode() + { + int hash = 17; + hash = hash * 23 + Provider.GetHashCode(); + hash = hash * 23 + BindingId.GetHashCode(); + return hash; + } + + public void Reset() + { + Provider = null; + BindingId.Type = null; + BindingId.Identifier = null; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/LookupId.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/LookupId.cs.meta new file mode 100644 index 0000000..223164a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/LookupId.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 75d6ff51a82574249bd77fb5fd40d948 +timeCreated: 1535860932 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/SingletonMarkRegistry.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/SingletonMarkRegistry.cs new file mode 100644 index 0000000..ac627f4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/SingletonMarkRegistry.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject.Internal +{ + [NoReflectionBaking] + public class SingletonMarkRegistry + { + readonly HashSet _boundSingletons = new HashSet(); + readonly HashSet _boundNonSingletons = new HashSet(); + + public void MarkNonSingleton(Type type) + { + Assert.That(!_boundSingletons.Contains(type), + "Found multiple creation bindings for type '{0}' in addition to AsSingle. The AsSingle binding must be the definitive creation binding. If this is intentional, use AsCached instead of AsSingle.", type); + _boundNonSingletons.Add(type); + } + + public void MarkSingleton(Type type) + { + bool added = _boundSingletons.Add(type); + Assert.That(added, "Attempted to use AsSingle multiple times for type '{0}'. As of Zenject 6+, AsSingle as can no longer be used for the same type across different bindings. See the upgrade guide for details.", type); + + Assert.That(!_boundNonSingletons.Contains(type), + "Found multiple creation bindings for type '{0}' in addition to AsSingle. The AsSingle binding must be the definitive creation binding. If this is intentional, use AsCached instead of AsSingle.", type); + } + + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/SingletonMarkRegistry.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/SingletonMarkRegistry.cs.meta new file mode 100644 index 0000000..70cfb70 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/SingletonMarkRegistry.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 3844511961cf2ee40948fbe1569a2f31 +timeCreated: 1520759760 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/ZenjectSettings.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/ZenjectSettings.cs new file mode 100644 index 0000000..d7fd4c7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/ZenjectSettings.cs @@ -0,0 +1,190 @@ +using System; +#if !NOT_UNITY3D +using UnityEngine; +#endif + +namespace Zenject +{ + public enum ValidationErrorResponses + { + Log, + Throw + } + + public enum RootResolveMethods + { + NonLazyOnly, + All + } + + public enum SignalDefaultSyncModes + { + Synchronous, + Asynchronous + } + + public enum SignalMissingHandlerResponses + { + Ignore, + Throw, + Warn + } + + [Serializable] + [ZenjectAllowDuringValidation] + [NoReflectionBaking] + public class ZenjectSettings + { + public static ZenjectSettings Default = new ZenjectSettings(); + +#if !NOT_UNITY3D + [SerializeField] +#endif + bool _ensureDeterministicDestructionOrderOnApplicationQuit; + +#if !NOT_UNITY3D + [SerializeField] +#endif + bool _displayWarningWhenResolvingDuringInstall; + +#if !NOT_UNITY3D + [SerializeField] +#endif + RootResolveMethods _validationRootResolveMethod; + +#if !NOT_UNITY3D + [SerializeField] +#endif + ValidationErrorResponses _validationErrorResponse; + +#if !NOT_UNITY3D + [SerializeField] +#endif + SignalSettings _signalSettings; + + public ZenjectSettings( + ValidationErrorResponses validationErrorResponse, + RootResolveMethods validationRootResolveMethod = RootResolveMethods.NonLazyOnly, + bool displayWarningWhenResolvingDuringInstall = true, + bool ensureDeterministicDestructionOrderOnApplicationQuit = false, + SignalSettings signalSettings = null) + { + _validationErrorResponse = validationErrorResponse; + _validationRootResolveMethod = validationRootResolveMethod; + _displayWarningWhenResolvingDuringInstall = displayWarningWhenResolvingDuringInstall; + _ensureDeterministicDestructionOrderOnApplicationQuit =ensureDeterministicDestructionOrderOnApplicationQuit; + _signalSettings = signalSettings ?? SignalSettings.Default; + } + + // Need to define an emtpy constructor since this is created by unity serialization + // even if the above constructor has defaults for all + public ZenjectSettings() + : this(ValidationErrorResponses.Log) + { + } + + public SignalSettings Signals + { + get { return _signalSettings; } + } + + // Setting this to Log can be more useful because it will print out + // multiple validation errors at once so you can fix multiple problems before + // attempting validation again + public ValidationErrorResponses ValidationErrorResponse + { + get { return _validationErrorResponse; } + } + + // Settings this to true will ensure that every binding in the container can be + // instantiated with all its dependencies, and not just those bindings that will be + // constructed as part of the object graph generated from the nonlazy bindings + public RootResolveMethods ValidationRootResolveMethod + { + get { return _validationRootResolveMethod; } + } + + public bool DisplayWarningWhenResolvingDuringInstall + { + get { return _displayWarningWhenResolvingDuringInstall; } + } + + // When this is set to true and the application is exitted, all the scenes will be + // destroyed in the reverse order in which they were loaded, and then the project context + // will be destroyed last + // When this is set to false (the default) the order that this occurs in is not predictable + // It is set to false by default because manually destroying objects during OnApplicationQuit + // event can cause crashes on android (see github issue #468) + public bool EnsureDeterministicDestructionOrderOnApplicationQuit + { + get { return _ensureDeterministicDestructionOrderOnApplicationQuit; } + } + + [Serializable] + public class SignalSettings + { + public static SignalSettings Default = new SignalSettings(); + +#if !NOT_UNITY3D + [SerializeField] +#endif + SignalDefaultSyncModes _defaultSyncMode; + +#if !NOT_UNITY3D + [SerializeField] +#endif + SignalMissingHandlerResponses _missingHandlerDefaultResponse; + +#if !NOT_UNITY3D + [SerializeField] +#endif + bool _requireStrictUnsubscribe; + +#if !NOT_UNITY3D + [SerializeField] +#endif + int _defaultAsyncTickPriority; + + public SignalSettings( + SignalDefaultSyncModes defaultSyncMode, + SignalMissingHandlerResponses missingHandlerDefaultResponse = SignalMissingHandlerResponses.Warn, + bool requireStrictUnsubscribe = false, + // Run right after all the unspecified tick priorities so that the effects of the + // signal are handled during the same frame when they are triggered + int defaultAsyncTickPriority = 1) + { + _defaultSyncMode = defaultSyncMode; + _missingHandlerDefaultResponse = missingHandlerDefaultResponse; + _requireStrictUnsubscribe = requireStrictUnsubscribe; + _defaultAsyncTickPriority = defaultAsyncTickPriority; + } + + // Need to define an emtpy constructor since this is created by unity serialization + // even if the above constructor has defaults for all + public SignalSettings() + : this(SignalDefaultSyncModes.Synchronous) + { + } + + public int DefaultAsyncTickPriority + { + get { return _defaultAsyncTickPriority; } + } + + public SignalDefaultSyncModes DefaultSyncMode + { + get { return _defaultSyncMode; } + } + + public SignalMissingHandlerResponses MissingHandlerDefaultResponse + { + get { return _missingHandlerDefaultResponse; } + } + + public bool RequireStrictUnsubscribe + { + get { return _requireStrictUnsubscribe; } + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/ZenjectSettings.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/ZenjectSettings.cs.meta new file mode 100644 index 0000000..d023876 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Main/ZenjectSettings.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1581703805dca9046a9197095cbbf3d1 +timeCreated: 1527493251 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers.meta new file mode 100644 index 0000000..3315ee1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: bd5ba0ff0ad7f874f8938a3266c21d4f +folderAsset: yes +DefaultImporter: + userData: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/CachedOpenTypeProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/CachedOpenTypeProvider.cs new file mode 100644 index 0000000..bf4244b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/CachedOpenTypeProvider.cs @@ -0,0 +1,158 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class CachedOpenTypeProvider : IProvider + { + readonly IProvider _creator; + readonly List> _cachedInstances = new List>(); + +#if ZEN_MULTITHREADING + readonly object _locker = new object(); +#else + bool _isCreatingInstance; +#endif + + public CachedOpenTypeProvider(IProvider creator) + { + Assert.That(creator.TypeVariesBasedOnMemberType); + _creator = creator; + } + + public bool IsCached + { + get { return true; } + } + + public bool TypeVariesBasedOnMemberType + { + get + { + // Should not call this + throw Assert.CreateException(); + } + } + + public int NumInstances + { + get + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + return _cachedInstances.Select(x => x.Count).Sum(); + } + } + } + + // This method can be called if you want to clear the memory for an AsSingle instance, + // See isssue https://github.com/svermeulen/Zenject/issues/441 + public void ClearCache() + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + _cachedInstances.Clear(); + } + } + + public Type GetInstanceType(InjectContext context) + { + return _creator.GetInstanceType(context); + } + + List TryGetMatchFromCache(Type memberType) + { + List result = null; + + for (int i = 0; i < _cachedInstances.Count; i++) + { + var instanceList = _cachedInstances[i]; + + bool matchesAll = true; + + for (int k = 0; k < instanceList.Count; k++) + { + var instance = instanceList[k]; + + if (instance == null) + { + if (memberType.IsValueType()) + { + matchesAll = false; + break; + } + + continue; + } + + if (!instance.GetType().DerivesFromOrEqual(memberType)) + { + matchesAll = false; + break; + } + } + + if (matchesAll) + { + Assert.IsNull(result); // Is there any case where this is hit? + result = instanceList; + } + } + + return result; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsNotNull(context); + +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + var instances = TryGetMatchFromCache(context.MemberType); + + if (instances != null) + { + injectAction = null; + buffer.AllocFreeAddRange(instances); + return; + } + +#if !ZEN_MULTITHREADING + // This should only happen with constructor injection + // Field or property injection should allow circular dependencies + if (_isCreatingInstance) + { + var instanceType = _creator.GetInstanceType(context); + throw Assert.CreateException( + "Found circular dependency when creating type '{0}'. Object graph:\n {1}{2}\n", + instanceType, context.GetObjectGraphString(), instanceType); + } + + _isCreatingInstance = true; +#endif + + instances = new List(); + _creator.GetAllInstancesWithInjectSplit( + context, args, out injectAction, instances); + Assert.IsNotNull(instances); + + _cachedInstances.Add(instances); +#if !ZEN_MULTITHREADING + _isCreatingInstance = false; +#endif + buffer.AllocFreeAddRange(instances); + } + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/CachedOpenTypeProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/CachedOpenTypeProvider.cs.meta new file mode 100644 index 0000000..662b721 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/CachedOpenTypeProvider.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 4a09a4770eaace44a84d9d627f0bd161 +timeCreated: 1528211680 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/CachedProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/CachedProvider.cs new file mode 100644 index 0000000..f883a44 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/CachedProvider.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class CachedProvider : IProvider + { + readonly IProvider _creator; + + List _instances; + +#if ZEN_MULTITHREADING + readonly object _locker = new object(); +#else + bool _isCreatingInstance; +#endif + + public CachedProvider(IProvider creator) + { + _creator = creator; + } + + public bool IsCached + { + get { return true; } + } + + public bool TypeVariesBasedOnMemberType + { + get + { + // Should not call this + throw Assert.CreateException(); + } + } + + public int NumInstances + { + get + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + return _instances == null ? 0 : _instances.Count; + } + } + } + + // This method can be called if you want to clear the memory for an AsSingle instance, + // See isssue https://github.com/svermeulen/Zenject/issues/441 + public void ClearCache() + { +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + _instances = null; + } + } + + public Type GetInstanceType(InjectContext context) + { + return _creator.GetInstanceType(context); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsNotNull(context); + +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + if (_instances != null) + { + injectAction = null; + buffer.AllocFreeAddRange(_instances); + return; + } + +#if !ZEN_MULTITHREADING + // This should only happen with constructor injection + // Field or property injection should allow circular dependencies + if (_isCreatingInstance) + { + var instanceType = _creator.GetInstanceType(context); + throw Assert.CreateException( + "Found circular dependency when creating type '{0}'. Object graph:\n {1}{2}\n", + instanceType, context.GetObjectGraphString(), instanceType); + } + + _isCreatingInstance = true; +#endif + + var instances = new List(); + _creator.GetAllInstancesWithInjectSplit(context, args, out injectAction, instances); + Assert.IsNotNull(instances); + + _instances = instances; +#if !ZEN_MULTITHREADING + _isCreatingInstance = false; +#endif + buffer.AllocFreeAddRange(instances); + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/CachedProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/CachedProvider.cs.meta new file mode 100644 index 0000000..ed7eb76 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/CachedProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6e16beb21a2f0d4db901700c6ed3099 +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders.meta new file mode 100644 index 0000000..6f2ac18 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d80a7db637267834388a31f2b7ddcf36 +folderAsset: yes +timeCreated: 1461708046 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders.meta new file mode 100644 index 0000000..0c09486 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5a0ec9eb479742940a10701ec8a1d087 +folderAsset: yes +timeCreated: 1461708047 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToCurrentGameObjectComponentProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToCurrentGameObjectComponentProvider.cs new file mode 100644 index 0000000..d12444f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToCurrentGameObjectComponentProvider.cs @@ -0,0 +1,121 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using UnityEngine; +using Zenject.Internal; + +namespace Zenject +{ + [NoReflectionBaking] + public class AddToCurrentGameObjectComponentProvider : IProvider + { + readonly Type _componentType; + readonly DiContainer _container; + readonly List _extraArguments; + readonly object _concreteIdentifier; + readonly Action _instantiateCallback; + + public AddToCurrentGameObjectComponentProvider( + DiContainer container, Type componentType, + IEnumerable extraArguments, object concreteIdentifier, + Action instantiateCallback) + { + Assert.That(componentType.DerivesFrom()); + + _extraArguments = extraArguments.ToList(); + _componentType = componentType; + _container = container; + _concreteIdentifier = concreteIdentifier; + _instantiateCallback = instantiateCallback; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + protected DiContainer Container + { + get { return _container; } + } + + protected Type ComponentType + { + get { return _componentType; } + } + + public Type GetInstanceType(InjectContext context) + { + return _componentType; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsNotNull(context); + + Assert.That(context.ObjectType.DerivesFrom(), + "Object '{0}' can only be injected into MonoBehaviour's since it was bound with 'FromNewComponentSibling'. Attempted to inject into non-MonoBehaviour '{1}'", + context.MemberType, context.ObjectType); + + object instance; + + if (!_container.IsValidating || TypeAnalyzer.ShouldAllowDuringValidation(_componentType)) + { + var gameObj = ((Component)context.ObjectInstance).gameObject; + + var componentInstance = gameObj.GetComponent(_componentType); + instance = componentInstance; + + // Use componentInstance so that it triggers unity's overloaded comparison operator + // So if the component is there but missing then it returns null + // (https://github.com/svermeulen/Zenject/issues/582) + if (componentInstance != null) + { + injectAction = null; + buffer.Add(instance); + return; + } + + instance = gameObj.AddComponent(_componentType); + } + else + { + instance = new ValidationMarker(_componentType); + } + + // Note that we don't just use InstantiateComponentOnNewGameObjectExplicit here + // because then circular references don't work + + injectAction = () => + { + var extraArgs = ZenPools.SpawnList(); + + extraArgs.AllocFreeAddRange(_extraArguments); + extraArgs.AllocFreeAddRange(args); + + _container.InjectExplicit(instance, _componentType, extraArgs, context, _concreteIdentifier); + + Assert.That(extraArgs.IsEmpty()); + ZenPools.DespawnList(extraArgs); + + if (_instantiateCallback != null) + { + _instantiateCallback(context, instance); + } + }; + + buffer.Add(instance); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToCurrentGameObjectComponentProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToCurrentGameObjectComponentProvider.cs.meta new file mode 100644 index 0000000..f9b0a01 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToCurrentGameObjectComponentProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3b0521d85aeb9ee479dcb29ef4d88547 +timeCreated: 1465651364 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToExistingGameObjectComponentProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToExistingGameObjectComponentProvider.cs new file mode 100644 index 0000000..a57e3f9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToExistingGameObjectComponentProvider.cs @@ -0,0 +1,69 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using ModestTree; +using UnityEngine; + +namespace Zenject +{ + [NoReflectionBaking] + public class AddToExistingGameObjectComponentProvider : AddToGameObjectComponentProviderBase + { + readonly GameObject _gameObject; + + public AddToExistingGameObjectComponentProvider( + GameObject gameObject, DiContainer container, Type componentType, + IEnumerable extraArguments, object concreteIdentifier, + Action instantiateCallback) + : base(container, componentType, extraArguments, concreteIdentifier, instantiateCallback) + { + _gameObject = gameObject; + } + + // This will cause [Inject] to be triggered after awake / start + // We could return true, but what if toggling active has other negative repercussions? + // For now let's just not do anything + protected override bool ShouldToggleActive + { + get { return false; } + } + + protected override GameObject GetGameObject(InjectContext context) + { + return _gameObject; + } + } + + [NoReflectionBaking] + public class AddToExistingGameObjectComponentProviderGetter : AddToGameObjectComponentProviderBase + { + readonly Func _gameObjectGetter; + + public AddToExistingGameObjectComponentProviderGetter( + Func gameObjectGetter, DiContainer container, Type componentType, + List extraArguments, object concreteIdentifier, + Action instantiateCallback) + : base(container, componentType, extraArguments, concreteIdentifier, instantiateCallback) + { + _gameObjectGetter = gameObjectGetter; + } + + // This will cause [Inject] to be triggered after awake / start + // We could return true, but what if toggling active has other negative repercussions? + // For now let's just not do anything + protected override bool ShouldToggleActive + { + get { return false; } + } + + protected override GameObject GetGameObject(InjectContext context) + { + var gameObj = _gameObjectGetter(context); + Assert.IsNotNull(gameObj, "Provided Func returned null value for game object when using FromComponentOn"); + return gameObj; + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToExistingGameObjectComponentProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToExistingGameObjectComponentProvider.cs.meta new file mode 100644 index 0000000..b64a7df --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToExistingGameObjectComponentProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 669e8af5b17774d45acea73d348e6dca +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToGameObjectComponentProviderBase.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToGameObjectComponentProviderBase.cs new file mode 100644 index 0000000..3ab95aa --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToGameObjectComponentProviderBase.cs @@ -0,0 +1,142 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using UnityEngine; +using Zenject.Internal; + +namespace Zenject +{ + [NoReflectionBaking] + public abstract class AddToGameObjectComponentProviderBase : IProvider + { + readonly Type _componentType; + readonly DiContainer _container; + readonly List _extraArguments; + readonly object _concreteIdentifier; + readonly Action _instantiateCallback; + + public AddToGameObjectComponentProviderBase( + DiContainer container, Type componentType, + IEnumerable extraArguments, object concreteIdentifier, + Action instantiateCallback) + { + Assert.That(componentType.DerivesFrom()); + + _extraArguments = extraArguments.ToList(); + _componentType = componentType; + _container = container; + _concreteIdentifier = concreteIdentifier; + _instantiateCallback = instantiateCallback; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + protected DiContainer Container + { + get { return _container; } + } + + protected Type ComponentType + { + get { return _componentType; } + } + + protected abstract bool ShouldToggleActive + { + get; + } + + public Type GetInstanceType(InjectContext context) + { + return _componentType; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsNotNull(context); + + object instance; + + // We still want to make sure we can get the game object during validation + var gameObj = GetGameObject(context); + + var wasActive = gameObj.activeSelf; + + if (wasActive && ShouldToggleActive) + { + // We need to do this in some cases to ensure that [Inject] always gets + // called before awake / start + gameObj.SetActive(false); + } + + if (!_container.IsValidating || TypeAnalyzer.ShouldAllowDuringValidation(_componentType)) + { + if (_componentType == typeof(Transform)) + // Treat transform as a special case because it's the one component that's always automatically added + // Otherwise, calling AddComponent below will fail and return null + // This is nice to allow doing things like + // Container.Bind().FromNewComponentOnNewGameObject(); + { + instance = gameObj.transform; + } + else + { + instance = gameObj.AddComponent(_componentType); + } + + Assert.IsNotNull(instance); + } + else + { + instance = new ValidationMarker(_componentType); + } + + injectAction = () => + { + try + { + var extraArgs = ZenPools.SpawnList(); + + extraArgs.AllocFreeAddRange(_extraArguments); + extraArgs.AllocFreeAddRange(args); + + _container.InjectExplicit(instance, _componentType, extraArgs, context, _concreteIdentifier); + + Assert.That(extraArgs.Count == 0); + + ZenPools.DespawnList(extraArgs); + + if (_instantiateCallback != null) + { + _instantiateCallback(context, instance); + } + } + finally + { + if (wasActive && ShouldToggleActive) + { + gameObj.SetActive(true); + } + } + }; + + buffer.Add(instance); + } + + protected abstract GameObject GetGameObject(InjectContext context); + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToGameObjectComponentProviderBase.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToGameObjectComponentProviderBase.cs.meta new file mode 100644 index 0000000..8387b14 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToGameObjectComponentProviderBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d818f8110e5b31d4eb27001e5c5b3eb9 +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToNewGameObjectComponentProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToNewGameObjectComponentProvider.cs new file mode 100644 index 0000000..099f17a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToNewGameObjectComponentProvider.cs @@ -0,0 +1,41 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace Zenject +{ + [NoReflectionBaking] + public class AddToNewGameObjectComponentProvider : AddToGameObjectComponentProviderBase + { + readonly GameObjectCreationParameters _gameObjectBindInfo; + + public AddToNewGameObjectComponentProvider( + DiContainer container, Type componentType, + IEnumerable extraArguments, GameObjectCreationParameters gameObjectBindInfo, + object concreteIdentifier, + Action instantiateCallback) + : base(container, componentType, extraArguments, concreteIdentifier, instantiateCallback) + { + _gameObjectBindInfo = gameObjectBindInfo; + } + + protected override bool ShouldToggleActive + { + get { return true; } + } + + protected override GameObject GetGameObject(InjectContext context) + { + if (_gameObjectBindInfo.Name == null) + { + _gameObjectBindInfo.Name = ComponentType.Name; + } + + return Container.CreateEmptyGameObject(_gameObjectBindInfo, context); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToNewGameObjectComponentProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToNewGameObjectComponentProvider.cs.meta new file mode 100644 index 0000000..822f329 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/AddToGameObjectComponentProviders/AddToNewGameObjectComponentProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6e1085d337c03dd42a1d5493c11d9d23 +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromGameObjectComponentProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromGameObjectComponentProvider.cs new file mode 100644 index 0000000..c9ba453 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromGameObjectComponentProvider.cs @@ -0,0 +1,71 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using ModestTree; +using UnityEngine; + +namespace Zenject +{ + [NoReflectionBaking] + public class GetFromGameObjectComponentProvider : IProvider + { + readonly GameObject _gameObject; + readonly Type _componentType; + readonly bool _matchSingle; + + // if concreteType is null we use the contract type from inject context + public GetFromGameObjectComponentProvider( + Type componentType, GameObject gameObject, bool matchSingle) + { + _componentType = componentType; + _matchSingle = matchSingle; + _gameObject = gameObject; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return _componentType; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsNotNull(context); + + injectAction = null; + + if (_matchSingle) + { + var match = _gameObject.GetComponent(_componentType); + + Assert.IsNotNull(match, "Could not find component with type '{0}' on prefab '{1}'", + _componentType, _gameObject.name); + + buffer.Add(match); + return; + } + + var allComponents = _gameObject.GetComponents(_componentType); + + Assert.That(allComponents.Length >= 1, + "Expected to find at least one component with type '{0}' on prefab '{1}'", + _componentType, _gameObject.name); + + buffer.AllocFreeAddRange(allComponents); + } + } +} + +#endif + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromGameObjectComponentProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromGameObjectComponentProvider.cs.meta new file mode 100644 index 0000000..b4a63a5 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromGameObjectComponentProvider.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 8d5cdba9f2e79364dbf4f3d242fd22da +timeCreated: 1529229722 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromGameObjectGetterComponentProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromGameObjectGetterComponentProvider.cs new file mode 100644 index 0000000..7d9bbc7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromGameObjectGetterComponentProvider.cs @@ -0,0 +1,81 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using ModestTree; +using UnityEngine; + +namespace Zenject +{ + [NoReflectionBaking] + public class GetFromGameObjectGetterComponentProvider : IProvider + { + readonly Func _gameObjectGetter; + readonly Type _componentType; + readonly bool _matchSingle; + + // if concreteType is null we use the contract type from inject context + public GetFromGameObjectGetterComponentProvider( + Type componentType, Func gameObjectGetter, bool matchSingle) + { + _componentType = componentType; + _matchSingle = matchSingle; + _gameObjectGetter = gameObjectGetter; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return _componentType; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsNotNull(context); + + injectAction = null; + + if (context.Container.IsValidating) + { + buffer.Add(new ValidationMarker(_componentType)); + } + else + { + var gameObject = _gameObjectGetter(context); + + if (_matchSingle) + { + var match = gameObject.GetComponent(_componentType); + + Assert.IsNotNull(match, "Could not find component with type '{0}' on game object '{1}'", + _componentType, gameObject.name); + + buffer.Add(match); + return; + } + + var allComponents = gameObject.GetComponents(_componentType); + + Assert.That(allComponents.Length >= 1, + "Expected to find at least one component with type '{0}' on prefab '{1}'", + _componentType, gameObject.name); + + buffer.AllocFreeAddRange(allComponents); + } + } + } +} + +#endif + + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromGameObjectGetterComponentProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromGameObjectGetterComponentProvider.cs.meta new file mode 100644 index 0000000..a93b96c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromGameObjectGetterComponentProvider.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 766643a5935eb704a929da28681bf70e +timeCreated: 1529230207 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromPrefabComponentProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromPrefabComponentProvider.cs new file mode 100644 index 0000000..ff16b47 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromPrefabComponentProvider.cs @@ -0,0 +1,74 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class GetFromPrefabComponentProvider : IProvider + { + readonly IPrefabInstantiator _prefabInstantiator; + readonly Type _componentType; + readonly bool _matchSingle; + + // if concreteType is null we use the contract type from inject context + public GetFromPrefabComponentProvider( + Type componentType, + IPrefabInstantiator prefabInstantiator, bool matchSingle) + { + _prefabInstantiator = prefabInstantiator; + _componentType = componentType; + _matchSingle = matchSingle; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return _componentType; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsNotNull(context); + + var gameObject = _prefabInstantiator.Instantiate(context, args, out injectAction); + + // NOTE: Need to set includeInactive to true here, because prefabs are always + // instantiated as disabled until injection occurs, so that Awake / OnEnabled is executed + // after injection has occurred + + if (_matchSingle) + { + var match = gameObject.GetComponentInChildren(_componentType, true); + + Assert.IsNotNull(match, "Could not find component with type '{0}' on prefab '{1}'", + _componentType, _prefabInstantiator.GetPrefab(context).name); + + buffer.Add(match); + return; + } + + var allComponents = gameObject.GetComponentsInChildren(_componentType, true); + + Assert.That(allComponents.Length >= 1, + "Expected to find at least one component with type '{0}' on prefab '{1}'", + _componentType, _prefabInstantiator.GetPrefab(context).name); + + buffer.AllocFreeAddRange(allComponents); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromPrefabComponentProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromPrefabComponentProvider.cs.meta new file mode 100644 index 0000000..f27ab99 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/GetFromPrefabComponentProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a49432e004bd8409d3ddea6a45a3f8 +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/InstantiateOnPrefabComponentProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/InstantiateOnPrefabComponentProvider.cs new file mode 100644 index 0000000..dd691f2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/InstantiateOnPrefabComponentProvider.cs @@ -0,0 +1,54 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class InstantiateOnPrefabComponentProvider : IProvider + { + readonly IPrefabInstantiator _prefabInstantiator; + readonly Type _componentType; + + // if concreteType is null we use the contract type from inject context + public InstantiateOnPrefabComponentProvider( + Type componentType, + IPrefabInstantiator prefabInstantiator) + { + _prefabInstantiator = prefabInstantiator; + _componentType = componentType; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return _componentType; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsNotNull(context); + + var gameObject = _prefabInstantiator.Instantiate(context, args, out injectAction); + + var component = gameObject.AddComponent(_componentType); + + buffer.Add(component); + } + } +} + +#endif + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/InstantiateOnPrefabComponentProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/InstantiateOnPrefabComponentProvider.cs.meta new file mode 100644 index 0000000..58730dc --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ComponentProviders/InstantiateOnPrefabComponentProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6836adf19243a045ba39e67ade6dd59 +timeCreated: 1505729206 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/Decorator.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/Decorator.meta new file mode 100644 index 0000000..284dab6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/Decorator.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 88c8658f07bf600408a596245682c306 +folderAsset: yes +timeCreated: 1528368268 +licenseType: Store +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/Decorator/DecoratorProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/Decorator/DecoratorProvider.cs new file mode 100644 index 0000000..c3e7b2f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/Decorator/DecoratorProvider.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject.Internal +{ + public interface IDecoratorProvider + { + void GetAllInstances( + IProvider provider, InjectContext context, List buffer); + } + + [NoReflectionBaking] + public class DecoratorProvider : IDecoratorProvider + { + readonly Dictionary> _cachedInstances = + new Dictionary>(); + + readonly DiContainer _container; + readonly List _factoryBindIds = new List(); + + List> _decoratorFactories; + +#if ZEN_MULTITHREADING + readonly object _locker = new object(); +#endif + + public DecoratorProvider(DiContainer container) + { + _container = container; + } + + public void AddFactoryId(Guid factoryBindId) + { + _factoryBindIds.Add(factoryBindId); + } + + void LazyInitializeDecoratorFactories() + { + if (_decoratorFactories == null) + { + _decoratorFactories = new List>(); + + for (int i = 0; i < _factoryBindIds.Count; i++) + { + var bindId = _factoryBindIds[i]; + var factory = _container.ResolveId>(bindId); + _decoratorFactories.Add(factory); + } + } + } + + public void GetAllInstances( + IProvider provider, InjectContext context, List buffer) + { + if (provider.IsCached) + { + List instances; + +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + if (!_cachedInstances.TryGetValue(provider, out instances)) + { + instances = new List(); + WrapProviderInstances(provider, context, instances); + _cachedInstances.Add(provider, instances); + } + } + + buffer.AllocFreeAddRange(instances); + } + else + { + WrapProviderInstances(provider, context, buffer); + } + } + + void WrapProviderInstances(IProvider provider, InjectContext context, List buffer) + { + LazyInitializeDecoratorFactories(); + + provider.GetAllInstances(context, buffer); + + for (int i = 0; i < buffer.Count; i++) + { + buffer[i] = DecorateInstance(buffer[i], context); + } + } + + object DecorateInstance(object instance, InjectContext context) + { + for (int i = 0; i < _decoratorFactories.Count; i++) + { + instance = _decoratorFactories[i].Create( + context.Container.IsValidating ? default(TContract) : (TContract)instance); + } + + return instance; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/Decorator/DecoratorProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/Decorator/DecoratorProvider.cs.meta new file mode 100644 index 0000000..ae8ea79 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/Decorator/DecoratorProvider.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7a9aaabef2c47874a8b557ade27987eb +timeCreated: 1528368269 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders.meta new file mode 100644 index 0000000..29bf2a7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5c4a4be4639cdfc4c8d00456887fefb6 +folderAsset: yes +timeCreated: 1461708046 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders/EmptyGameObjectProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders/EmptyGameObjectProvider.cs new file mode 100644 index 0000000..81e303e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders/EmptyGameObjectProvider.cs @@ -0,0 +1,52 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using ModestTree; +using UnityEngine; + +namespace Zenject +{ + [NoReflectionBaking] + public class EmptyGameObjectProvider : IProvider + { + readonly DiContainer _container; + readonly GameObjectCreationParameters _gameObjectBindInfo; + + public EmptyGameObjectProvider( + DiContainer container, GameObjectCreationParameters gameObjectBindInfo) + { + _gameObjectBindInfo = gameObjectBindInfo; + _container = container; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(GameObject); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEmpty(args); + + injectAction = null; + + var gameObj = _container.CreateEmptyGameObject(_gameObjectBindInfo, context); + buffer.Add(gameObj); + } + } +} + +#endif + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders/EmptyGameObjectProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders/EmptyGameObjectProvider.cs.meta new file mode 100644 index 0000000..279d2bc --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders/EmptyGameObjectProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f8f4db421196f5849b2139200fdea1a3 +timeCreated: 1461708055 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders/PrefabGameObjectProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders/PrefabGameObjectProvider.cs new file mode 100644 index 0000000..4b8687a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders/PrefabGameObjectProvider.cs @@ -0,0 +1,45 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace Zenject +{ + [NoReflectionBaking] + public class PrefabGameObjectProvider : IProvider + { + readonly IPrefabInstantiator _prefabCreator; + + public PrefabGameObjectProvider( + IPrefabInstantiator prefabCreator) + { + _prefabCreator = prefabCreator; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(GameObject); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + var instance = _prefabCreator.Instantiate(context, args, out injectAction); + + buffer.Add(instance); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders/PrefabGameObjectProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders/PrefabGameObjectProvider.cs.meta new file mode 100644 index 0000000..9cbff6c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GameObjectProviders/PrefabGameObjectProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d776b7406750d7f4c816cd0c03e4e254 +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GetterProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GetterProvider.cs new file mode 100644 index 0000000..23fd5dc --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GetterProvider.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class GetterProvider : IProvider + { + readonly DiContainer _container; + readonly object _identifier; + readonly Func _method; + readonly bool _matchAll; + readonly InjectSources _sourceType; + + public GetterProvider( + object identifier, Func method, + DiContainer container, InjectSources sourceType, bool matchAll) + { + _container = container; + _identifier = identifier; + _method = method; + _matchAll = matchAll; + _sourceType = sourceType; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(TResult); + } + + InjectContext GetSubContext(InjectContext parent) + { + var subContext = parent.CreateSubContext( + typeof(TObj), _identifier); + + subContext.Optional = false; + subContext.SourceType = _sourceType; + + return subContext; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEmpty(args); + Assert.IsNotNull(context); + + Assert.That(typeof(TResult).DerivesFromOrEqual(context.MemberType)); + + injectAction = null; + + if (_container.IsValidating) + { + // All we can do is validate that the getter object can be resolved + if (_matchAll) + { + _container.ResolveAll(GetSubContext(context)); + } + else + { + _container.Resolve(GetSubContext(context)); + } + + buffer.Add(new ValidationMarker(typeof(TResult))); + return; + } + + if (_matchAll) + { + Assert.That(buffer.Count == 0); + _container.ResolveAll(GetSubContext(context), buffer); + + for (int i = 0; i < buffer.Count; i++) + { + buffer[i] = _method((TObj)buffer[i]); + } + } + else + { + buffer.Add(_method( + (TObj)_container.Resolve(GetSubContext(context)))); + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GetterProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GetterProvider.cs.meta new file mode 100644 index 0000000..6422753 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/GetterProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ce3e2ecdd52e4db469d9bc497ff5e5f5 +timeCreated: 1461708053 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IFactoryProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IFactoryProvider.cs new file mode 100644 index 0000000..517ccca --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IFactoryProvider.cs @@ -0,0 +1,396 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + public abstract class IFactoryProviderBase : IProvider + { + public IFactoryProviderBase( + DiContainer container, Guid factoryId) + { + Container = container; + FactoryId = factoryId; + } + + public bool IsCached + { + get { return false; } + } + + protected Guid FactoryId + { + get; + private set; + } + + protected DiContainer Container + { + get; + private set; + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(TContract); + } + + public abstract void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer); + } + + // Zero parameters + + [NoReflectionBaking] + public class IFactoryProvider : IFactoryProviderBase + { + public IFactoryProvider( + DiContainer container, Guid factoryId) + : base(container, factoryId) + { + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.That(args.IsEmpty()); + + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + + // Do this even when validating in case it has its own dependencies + var factory = Container.ResolveId(typeof(IFactory), FactoryId); + + injectAction = null; + if (Container.IsValidating) + { + // We assume here that we are creating a user-defined factory so there's + // nothing else we can validate here + buffer.Add(new ValidationMarker(typeof(TContract))); + } + else + { + buffer.Add(((IFactory)factory).Create()); + } + } + } + + // One parameter + + [NoReflectionBaking] + public class IFactoryProvider : IFactoryProviderBase + { + public IFactoryProvider(DiContainer container, Guid factoryId) + : base(container, factoryId) + { + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 1); + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual()); + + // Do this even when validating in case it has its own dependencies + var factory = Container.ResolveId(typeof(IFactory), FactoryId); + + injectAction = null; + if (Container.IsValidating) + { + // We assume here that we are creating a user-defined factory so there's + // nothing else we can validate here + + buffer.Add(new ValidationMarker(typeof(TContract))); + } + else + { + buffer.Add(((IFactory)factory).Create((TParam1)args[0].Value)); + } + } + } + + // Two parameters + + [NoReflectionBaking] + public class IFactoryProvider : IFactoryProviderBase + { + public IFactoryProvider(DiContainer container, Guid factoryId) + : base(container, factoryId) + { + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 2); + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + + // Do this even when validating in case it has its own dependencies + var factory = Container.ResolveId(typeof(IFactory), FactoryId); + + injectAction = null; + if (Container.IsValidating) + { + // We assume here that we are creating a user-defined factory so there's + // nothing else we can validate here + buffer.Add(new ValidationMarker(typeof(TContract))); + } + else + { + buffer.Add( + ((IFactory)factory).Create( + (TParam1)args[0].Value, + (TParam2)args[1].Value)); + } + } + } + + // Three parameters + + [NoReflectionBaking] + public class IFactoryProvider : IFactoryProviderBase + { + public IFactoryProvider(DiContainer container, Guid factoryId) + : base(container, factoryId) + { + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 3); + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + + // Do this even when validating in case it has its own dependencies + var factory = Container.ResolveId(typeof(IFactory), FactoryId); + + injectAction = null; + if (Container.IsValidating) + { + // We assume here that we are creating a user-defined factory so there's + // nothing else we can validate here + buffer.Add(new ValidationMarker(typeof(TContract))); + } + else + { + buffer.Add( + ((IFactory)factory).Create( + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value)); + } + } + } + + // Four parameters + + [NoReflectionBaking] + public class IFactoryProvider : IFactoryProviderBase + { + public IFactoryProvider(DiContainer container, Guid factoryId) + : base(container, factoryId) + { + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 4); + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + + // Do this even when validating in case it has its own dependencies + var factory = Container.ResolveId(typeof(IFactory), FactoryId); + + injectAction = null; + if (Container.IsValidating) + { + // We assume here that we are creating a user-defined factory so there's + // nothing else we can validate here + buffer.Add(new ValidationMarker(typeof(TContract))); + } + else + { + buffer.Add( + ((IFactory)factory).Create( + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value)); + } + } + } + + // Five parameters + + [NoReflectionBaking] + public class IFactoryProvider : IFactoryProviderBase + { + public IFactoryProvider(DiContainer container, Guid factoryId) + : base(container, factoryId) + { + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 5); + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + Assert.That(args[4].Type.DerivesFromOrEqual()); + + // Do this even when validating in case it has its own dependencies + var factory = Container.ResolveId(typeof(IFactory), FactoryId); + + injectAction = null; + if (Container.IsValidating) + { + // We assume here that we are creating a user-defined factory so there's + // nothing else we can validate here + buffer.Add(new ValidationMarker(typeof(TContract))); + } + else + { + buffer.Add( + ((IFactory)factory).Create( + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value)); + } + } + } + + // Six parameters + + [NoReflectionBaking] + public class IFactoryProvider : IFactoryProviderBase + { + public IFactoryProvider(DiContainer container, Guid factoryId) + : base(container, factoryId) + { + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 6); + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + Assert.That(args[4].Type.DerivesFromOrEqual()); + Assert.That(args[5].Type.DerivesFromOrEqual()); + + // Do this even when validating in case it has its own dependencies + var factory = Container.ResolveId(typeof(IFactory), FactoryId); + + injectAction = null; + if (Container.IsValidating) + { + // We assume here that we are creating a user-defined factory so there's + // nothing else we can validate here + buffer.Add(new ValidationMarker(typeof(TContract))); + } + else + { + buffer.Add( + ((IFactory)factory).Create( + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value, + (TParam6)args[5].Value)); + } + } + } + + // Ten parameters + + [NoReflectionBaking] + public class IFactoryProvider : IFactoryProviderBase + { + public IFactoryProvider(DiContainer container, Guid factoryId) + : base(container, factoryId) + { + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 10); + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + Assert.That(args[4].Type.DerivesFromOrEqual()); + Assert.That(args[5].Type.DerivesFromOrEqual()); + Assert.That(args[6].Type.DerivesFromOrEqual()); + Assert.That(args[7].Type.DerivesFromOrEqual()); + Assert.That(args[8].Type.DerivesFromOrEqual()); + Assert.That(args[9].Type.DerivesFromOrEqual()); + + // Do this even when validating in case it has its own dependencies + var factory = Container.ResolveId(typeof(IFactory), FactoryId); + + injectAction = null; + if (Container.IsValidating) + { + // We assume here that we are creating a user-defined factory so there's + // nothing else we can validate here + buffer.Add(new ValidationMarker(typeof(TContract))); + } + else + { + buffer.Add( + ((IFactory)factory).Create( + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value, + (TParam6)args[5].Value, + (TParam7)args[6].Value, + (TParam8)args[7].Value, + (TParam9)args[8].Value, + (TParam10)args[9].Value)); + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IFactoryProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IFactoryProvider.cs.meta new file mode 100644 index 0000000..a78a01c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IFactoryProvider.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: eaf07c2b7ad9f684dac7f1da2ee67f5c +timeCreated: 1520700396 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IProvider.cs new file mode 100644 index 0000000..7e0b2a7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IProvider.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; + +namespace Zenject +{ + // The given InjectContext values here should always be non-null + public interface IProvider + { + bool TypeVariesBasedOnMemberType + { + get; + } + + bool IsCached + { + get; + } + + Type GetInstanceType(InjectContext context); + + // Return an instance which might be not yet injected to. + // injectAction should handle the actual injection + // This way, providers that call CreateInstance() can store the instance immediately, + // and then return that if something gets created during injection that refers back + // to the newly created instance + void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List instances); + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IProvider.cs.meta new file mode 100644 index 0000000..551bd0e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 438b6366f2f1221448e9a71e09ac0329 +timeCreated: 1461708050 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IProviderExtensions.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IProviderExtensions.cs new file mode 100644 index 0000000..67a1a60 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IProviderExtensions.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using ModestTree; +using Zenject.Internal; + +namespace Zenject +{ + public static class IProviderExtensions + { + static readonly List EmptyArgList = new List(); + + public static void GetAllInstancesWithInjectSplit( + this IProvider creator, InjectContext context, out Action injectAction, List buffer) + { + creator.GetAllInstancesWithInjectSplit( + context, EmptyArgList, out injectAction, buffer); + } + + public static void GetAllInstances( + this IProvider creator, InjectContext context, List buffer) + { + creator.GetAllInstances(context, EmptyArgList, buffer); + } + + public static void GetAllInstances( + this IProvider creator, InjectContext context, List args, List buffer) + { + Assert.IsNotNull(context); + + Action injectAction; + creator.GetAllInstancesWithInjectSplit(context, args, out injectAction, buffer); + + if (injectAction != null) + { + injectAction.Invoke(); + } + } + + public static object TryGetInstance( + this IProvider creator, InjectContext context) + { + return creator.TryGetInstance(context, EmptyArgList); + } + + public static object TryGetInstance( + this IProvider creator, InjectContext context, List args) + { + var allInstances = ZenPools.SpawnList(); + + try + { + creator.GetAllInstances(context, args, allInstances); + + if (allInstances.Count == 0) + { + return null; + } + + Assert.That(allInstances.Count == 1, + "Provider returned multiple instances when one or zero was expected"); + + return allInstances[0]; + } + finally + { + ZenPools.DespawnList(allInstances); + } + } + + public static object GetInstance( + this IProvider creator, InjectContext context) + { + return creator.GetInstance(context, EmptyArgList); + } + + public static object GetInstance( + this IProvider creator, InjectContext context, List args) + { + var allInstances = ZenPools.SpawnList(); + + try + { + creator.GetAllInstances(context, args, allInstances); + + Assert.That(allInstances.Count > 0, + "Provider returned zero instances when one was expected when looking up type '{0}'", context.MemberType); + + Assert.That(allInstances.Count == 1, + "Provider returned multiple instances when only one was expected when looking up type '{0}'", context.MemberType); + + return allInstances[0]; + } + finally + { + ZenPools.DespawnList(allInstances); + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IProviderExtensions.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IProviderExtensions.cs.meta new file mode 100644 index 0000000..6f60c56 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/IProviderExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2377e3000d1616e4d8cb29c183f216b4 +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/InstanceProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/InstanceProvider.cs new file mode 100644 index 0000000..a29f15e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/InstanceProvider.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class InstanceProvider : IProvider + { + readonly object _instance; + readonly Type _instanceType; + readonly DiContainer _container; + readonly Action _instantiateCallback; + + public InstanceProvider( + Type instanceType, object instance, DiContainer container, Action instantiateCallback) + { + _instanceType = instanceType; + _instance = instance; + _container = container; + _instantiateCallback = instantiateCallback; + } + + public bool IsCached + { + get { return true; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return _instanceType; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.That(args.Count == 0); + Assert.IsNotNull(context); + + Assert.That(_instanceType.DerivesFromOrEqual(context.MemberType)); + + injectAction = () => + { + object instance = _container.LazyInject(_instance); + + if (_instantiateCallback != null) + { + _instantiateCallback(context, instance); + } + }; + + buffer.Add(_instance); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/InstanceProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/InstanceProvider.cs.meta new file mode 100644 index 0000000..2984227 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/InstanceProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1d3d5b3bdf966444099f2dfdf3a313fd +timeCreated: 1461708048 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodMultipleProviderUntyped.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodMultipleProviderUntyped.cs new file mode 100644 index 0000000..39385eb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodMultipleProviderUntyped.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class MethodMultipleProviderUntyped : IProvider + { + readonly DiContainer _container; + readonly Func> _method; + + public MethodMultipleProviderUntyped( + Func> method, + DiContainer container) + { + _container = container; + _method = method; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return context.MemberType; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEmpty(args); + Assert.IsNotNull(context); + + injectAction = null; + if (_container.IsValidating && !TypeAnalyzer.ShouldAllowDuringValidation(context.MemberType)) + { + buffer.Add(new ValidationMarker(context.MemberType)); + } + else + { + var result = _method(context); + + if (result == null) + { + throw Assert.CreateException( + "Method '{0}' returned null when list was expected. Object graph:\n {1}", + _method.ToDebugString(), context.GetObjectGraphString()); + } + + foreach (var obj in result) + { + buffer.Add(obj); + } + } + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodMultipleProviderUntyped.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodMultipleProviderUntyped.cs.meta new file mode 100644 index 0000000..7476e9d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodMultipleProviderUntyped.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: dd9674ffe36a06141afeab1ebbc399f0 +timeCreated: 1529046908 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProvider.cs new file mode 100644 index 0000000..609350b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProvider.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class MethodProvider : IProvider + { + readonly DiContainer _container; + readonly Func _method; + + public MethodProvider( + Func method, + DiContainer container) + { + _container = container; + _method = method; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(TReturn); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEmpty(args); + Assert.IsNotNull(context); + + Assert.That(typeof(TReturn).DerivesFromOrEqual(context.MemberType)); + + injectAction = null; + if (_container.IsValidating && !TypeAnalyzer.ShouldAllowDuringValidation(context.MemberType)) + { + buffer.Add(new ValidationMarker(typeof(TReturn))); + } + else + { + // We cannot do a null assert here because in some cases they might intentionally + // return null + buffer.Add(_method(context)); + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProvider.cs.meta new file mode 100644 index 0000000..18c0ae0 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 22a7321581383d141b4c11983b83e67b +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderMultiple.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderMultiple.cs new file mode 100644 index 0000000..cf68515 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderMultiple.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class MethodProviderMultiple : IProvider + { + readonly DiContainer _container; + readonly Func> _method; + + public MethodProviderMultiple( + Func> method, + DiContainer container) + { + _container = container; + _method = method; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(TReturn); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEmpty(args); + Assert.IsNotNull(context); + + Assert.That(typeof(TReturn).DerivesFromOrEqual(context.MemberType)); + + injectAction = null; + if (_container.IsValidating && !TypeAnalyzer.ShouldAllowDuringValidation(context.MemberType)) + { + buffer.Add(new ValidationMarker(typeof(TReturn))); + } + else + { + var result = _method(context); + + if (result == null) + { + throw Assert.CreateException( + "Method '{0}' returned null when list was expected. Object graph:\n {1}", + _method.ToDebugString(), context.GetObjectGraphString()); + } + + foreach (var obj in result) + { + buffer.Add(obj); + } + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderMultiple.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderMultiple.cs.meta new file mode 100644 index 0000000..847f7a7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderMultiple.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0e5a590d4406d6e46ba319046057db53 +timeCreated: 1485738781 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderSimple.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderSimple.cs new file mode 100644 index 0000000..db4d767 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderSimple.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class MethodProviderSimple : IProvider + { + readonly Func _method; + + public MethodProviderSimple(Func method) + { + _method = method; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(TReturn); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEmpty(args); + Assert.IsNotNull(context); + + Assert.That(typeof(TReturn).DerivesFromOrEqual(context.MemberType)); + + injectAction = null; + buffer.Add(_method()); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderSimple.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderSimple.cs.meta new file mode 100644 index 0000000..398eb70 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderSimple.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: eee2b774c35c53641b09b0c1e9620e03 +timeCreated: 1461708055 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderUntyped.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderUntyped.cs new file mode 100644 index 0000000..76a286b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderUntyped.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class MethodProviderUntyped : IProvider + { + readonly DiContainer _container; + readonly Func _method; + + public MethodProviderUntyped( + Func method, + DiContainer container) + { + _container = container; + _method = method; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return context.MemberType; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEmpty(args); + Assert.IsNotNull(context); + + injectAction = null; + if (_container.IsValidating && !TypeAnalyzer.ShouldAllowDuringValidation(context.MemberType)) + { + buffer.Add(new ValidationMarker(context.MemberType)); + } + else + { + var result = _method(context); + + if (result == null) + { + Assert.That(!context.MemberType.IsPrimitive(), + "Invalid value returned from FromMethod. Expected non-null."); + } + else + { + Assert.That(result.GetType().DerivesFromOrEqual(context.MemberType)); + } + + buffer.Add(result); + } + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderUntyped.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderUntyped.cs.meta new file mode 100644 index 0000000..285f7f7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderUntyped.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: bddc7ee81ed8fd84cbf60eebf5cb3e41 +timeCreated: 1465495310 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderWithContainer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderWithContainer.cs new file mode 100644 index 0000000..0be93f1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderWithContainer.cs @@ -0,0 +1,499 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + // Zero params + + [NoReflectionBaking] + public class MethodProviderWithContainer : IProvider + { + readonly Func _method; + + public MethodProviderWithContainer(Func method) + { + _method = method; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(TValue); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEmpty(args); + Assert.IsNotNull(context); + + Assert.That(typeof(TValue).DerivesFromOrEqual(context.MemberType)); + + injectAction = null; + if (context.Container.IsValidating) + { + // Don't do anything when validating, we can't make any assumptions on the given method + buffer.Add(new ValidationMarker(typeof(TValue))); + } + else + { + buffer.Add(_method(context.Container)); + } + } + } + + // One params + + [NoReflectionBaking] + public class MethodProviderWithContainer : IProvider + { + readonly Func _method; + + public MethodProviderWithContainer(Func method) + { + _method = method; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(TValue); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 1); + Assert.IsNotNull(context); + + Assert.That(typeof(TValue).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual(typeof(TParam1))); + + injectAction = null; + if (context.Container.IsValidating) + { + // Don't do anything when validating, we can't make any assumptions on the given method + buffer.Add(new ValidationMarker(typeof(TValue))); + } + else + { + buffer.Add( + _method( + context.Container, + (TParam1)args[0].Value)); + } + } + } + + // Two params + + [NoReflectionBaking] + public class MethodProviderWithContainer : IProvider + { + readonly Func _method; + + public MethodProviderWithContainer(Func method) + { + _method = method; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(TValue); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 2); + Assert.IsNotNull(context); + + Assert.That(typeof(TValue).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual(typeof(TParam1))); + Assert.That(args[1].Type.DerivesFromOrEqual(typeof(TParam2))); + + injectAction = null; + if (context.Container.IsValidating) + { + // Don't do anything when validating, we can't make any assumptions on the given method + buffer.Add(new ValidationMarker(typeof(TValue))); + } + else + { + buffer.Add( + _method( + context.Container, + (TParam1)args[0].Value, + (TParam2)args[1].Value)); + } + } + } + + // Three params + + [NoReflectionBaking] + public class MethodProviderWithContainer : IProvider + { + readonly Func _method; + + public MethodProviderWithContainer(Func method) + { + _method = method; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(TValue); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 3); + Assert.IsNotNull(context); + + Assert.That(typeof(TValue).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual(typeof(TParam1))); + Assert.That(args[1].Type.DerivesFromOrEqual(typeof(TParam2))); + Assert.That(args[2].Type.DerivesFromOrEqual(typeof(TParam3))); + + injectAction = null; + if (context.Container.IsValidating) + { + // Don't do anything when validating, we can't make any assumptions on the given method + buffer.Add(new ValidationMarker(typeof(TValue))); + } + else + { + buffer.Add( + _method( + context.Container, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value)); + } + } + } + + // Four params + + [NoReflectionBaking] + public class MethodProviderWithContainer : IProvider + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Func _method; + + public MethodProviderWithContainer( +#if !NET_4_6 + ModestTree.Util. +#endif + Func method) + { + _method = method; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(TValue); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 4); + Assert.IsNotNull(context); + + Assert.That(typeof(TValue).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual(typeof(TParam1))); + Assert.That(args[1].Type.DerivesFromOrEqual(typeof(TParam2))); + Assert.That(args[2].Type.DerivesFromOrEqual(typeof(TParam3))); + Assert.That(args[3].Type.DerivesFromOrEqual(typeof(TParam4))); + + injectAction = null; + if (context.Container.IsValidating) + { + // Don't do anything when validating, we can't make any assumptions on the given method + buffer.Add(new ValidationMarker(typeof(TValue))); + } + else + { + buffer.Add( + _method( + context.Container, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value)); + } + } + } + + // Five params + + [NoReflectionBaking] + public class MethodProviderWithContainer : IProvider + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Func _method; + + public MethodProviderWithContainer( +#if !NET_4_6 + ModestTree.Util. +#endif + Func method) + { + _method = method; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(TValue); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 5); + Assert.IsNotNull(context); + + Assert.That(typeof(TValue).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual(typeof(TParam1))); + Assert.That(args[1].Type.DerivesFromOrEqual(typeof(TParam2))); + Assert.That(args[2].Type.DerivesFromOrEqual(typeof(TParam3))); + Assert.That(args[3].Type.DerivesFromOrEqual(typeof(TParam4))); + Assert.That(args[4].Type.DerivesFromOrEqual(typeof(TParam5))); + + injectAction = null; + if (context.Container.IsValidating) + { + // Don't do anything when validating, we can't make any assumptions on the given method + buffer.Add(new ValidationMarker(typeof(TValue))); + } + else + { + buffer.Add( + _method( + context.Container, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value)); + } + } + } + + // Six params + + [NoReflectionBaking] + public class MethodProviderWithContainer : IProvider + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Func _method; + + public MethodProviderWithContainer( +#if !NET_4_6 + ModestTree.Util. +#endif + Func method) + { + _method = method; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(TValue); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 5); + Assert.IsNotNull(context); + + Assert.That(typeof(TValue).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual(typeof(TParam1))); + Assert.That(args[1].Type.DerivesFromOrEqual(typeof(TParam2))); + Assert.That(args[2].Type.DerivesFromOrEqual(typeof(TParam3))); + Assert.That(args[3].Type.DerivesFromOrEqual(typeof(TParam4))); + Assert.That(args[4].Type.DerivesFromOrEqual(typeof(TParam5))); + Assert.That(args[5].Type.DerivesFromOrEqual(typeof(TParam6))); + + injectAction = null; + if (context.Container.IsValidating) + { + // Don't do anything when validating, we can't make any assumptions on the given method + buffer.Add(new ValidationMarker(typeof(TValue))); + } + else + { + buffer.Add( + _method( + context.Container, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value, + (TParam6)args[5].Value)); + } + } + } + + // Ten params + + [NoReflectionBaking] + public class MethodProviderWithContainer : IProvider + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Func _method; + + public MethodProviderWithContainer( +#if !NET_4_6 + ModestTree.Util. +#endif + Func method) + { + _method = method; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(TValue); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 10); + Assert.IsNotNull(context); + + Assert.That(typeof(TValue).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual(typeof(TParam1))); + Assert.That(args[1].Type.DerivesFromOrEqual(typeof(TParam2))); + Assert.That(args[2].Type.DerivesFromOrEqual(typeof(TParam3))); + Assert.That(args[3].Type.DerivesFromOrEqual(typeof(TParam4))); + Assert.That(args[4].Type.DerivesFromOrEqual(typeof(TParam5))); + Assert.That(args[5].Type.DerivesFromOrEqual(typeof(TParam6))); + Assert.That(args[6].Type.DerivesFromOrEqual(typeof(TParam7))); + Assert.That(args[7].Type.DerivesFromOrEqual(typeof(TParam8))); + Assert.That(args[8].Type.DerivesFromOrEqual(typeof(TParam9))); + Assert.That(args[9].Type.DerivesFromOrEqual(typeof(TParam10))); + + injectAction = null; + if (context.Container.IsValidating) + { + // Don't do anything when validating, we can't make any assumptions on the given method + buffer.Add(new ValidationMarker(typeof(TValue))); + } + else + { + buffer.Add( + _method( + context.Container, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value, + (TParam6)args[5].Value, + (TParam7)args[6].Value, + (TParam8)args[7].Value, + (TParam9)args[8].Value, + (TParam10)args[9].Value)); + } + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderWithContainer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderWithContainer.cs.meta new file mode 100644 index 0000000..9fb937c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/MethodProviderWithContainer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: eb5886f51fc492043bf8d0cc8f4daa2e +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PoolableMemoryPoolProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PoolableMemoryPoolProvider.cs new file mode 100644 index 0000000..0b04139 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PoolableMemoryPoolProvider.cs @@ -0,0 +1,367 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + public abstract class PoolableMemoryPoolProviderBase : IProvider + { + public PoolableMemoryPoolProviderBase( + DiContainer container, Guid poolId) + { + Container = container; + PoolId = poolId; + } + + public bool IsCached + { + get { return false; } + } + + protected Guid PoolId + { + get; + private set; + } + + protected DiContainer Container + { + get; + private set; + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return typeof(TContract); + } + + public abstract void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer); + } + + // Zero parameters + + [NoReflectionBaking] + public class PoolableMemoryPoolProvider : PoolableMemoryPoolProviderBase, IValidatable + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + TMemoryPool _pool; + + public PoolableMemoryPoolProvider( + DiContainer container, Guid poolId) + : base(container, poolId) + { + } + + public void Validate() + { + Container.ResolveId(PoolId); + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.That(args.IsEmpty()); + + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + + injectAction = null; + + if (_pool == null) + { + _pool = Container.ResolveId(PoolId); + } + + buffer.Add(_pool.Spawn(_pool)); + } + } + + // One parameters + + [NoReflectionBaking] + public class PoolableMemoryPoolProvider : PoolableMemoryPoolProviderBase, IValidatable + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + TMemoryPool _pool; + + public PoolableMemoryPoolProvider( + DiContainer container, Guid poolId) + : base(container, poolId) + { + } + + public void Validate() + { + Container.ResolveId(PoolId); + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 1); + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual()); + + injectAction = null; + + if (_pool == null) + { + _pool = Container.ResolveId(PoolId); + } + + buffer.Add(_pool.Spawn((TParam1)args[0].Value, _pool)); + } + } + + // Two parameters + + [NoReflectionBaking] + public class PoolableMemoryPoolProvider : PoolableMemoryPoolProviderBase, IValidatable + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + TMemoryPool _pool; + + public PoolableMemoryPoolProvider( + DiContainer container, Guid poolId) + : base(container, poolId) + { + } + + public void Validate() + { + Container.ResolveId(PoolId); + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 2); + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + + injectAction = null; + + if (_pool == null) + { + _pool = Container.ResolveId(PoolId); + } + + buffer.Add(_pool.Spawn( + (TParam1)args[0].Value, + (TParam2)args[1].Value, + _pool)); + } + } + + // Three parameters + + [NoReflectionBaking] + public class PoolableMemoryPoolProvider : PoolableMemoryPoolProviderBase, IValidatable + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + TMemoryPool _pool; + + public PoolableMemoryPoolProvider( + DiContainer container, Guid poolId) + : base(container, poolId) + { + } + + public void Validate() + { + Container.ResolveId(PoolId); + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 3); + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + + injectAction = null; + + if (_pool == null) + { + _pool = Container.ResolveId(PoolId); + } + + buffer.Add(_pool.Spawn( + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + _pool)); + } + } + + // Four parameters + + [NoReflectionBaking] + public class PoolableMemoryPoolProvider : PoolableMemoryPoolProviderBase, IValidatable + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + TMemoryPool _pool; + + public PoolableMemoryPoolProvider( + DiContainer container, Guid poolId) + : base(container, poolId) + { + } + + public void Validate() + { + Container.ResolveId(PoolId); + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 4); + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + + injectAction = null; + + if (_pool == null) + { + _pool = Container.ResolveId(PoolId); + } + + buffer.Add(_pool.Spawn( + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + _pool)); + } + } + + // Five parameters + + [NoReflectionBaking] + public class PoolableMemoryPoolProvider : PoolableMemoryPoolProviderBase, IValidatable + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + TMemoryPool _pool; + + public PoolableMemoryPoolProvider( + DiContainer container, Guid poolId) + : base(container, poolId) + { + } + + public void Validate() + { + Container.ResolveId(PoolId); + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 5); + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + Assert.That(args[4].Type.DerivesFromOrEqual()); + + injectAction = null; + + if (_pool == null) + { + _pool = Container.ResolveId(PoolId); + } + + buffer.Add(_pool.Spawn( + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value, + _pool)); + } + } + + // Six parameters + + [NoReflectionBaking] + public class PoolableMemoryPoolProvider : PoolableMemoryPoolProviderBase, IValidatable + where TContract : IPoolable + where TMemoryPool : MemoryPool + { + TMemoryPool _pool; + + public PoolableMemoryPoolProvider( + DiContainer container, Guid poolId) + : base(container, poolId) + { + } + + public void Validate() + { + Container.ResolveId(PoolId); + } + + public override void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEqual(args.Count, 6); + Assert.IsNotNull(context); + + Assert.That(typeof(TContract).DerivesFromOrEqual(context.MemberType)); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + Assert.That(args[4].Type.DerivesFromOrEqual()); + Assert.That(args[5].Type.DerivesFromOrEqual()); + + injectAction = null; + + if (_pool == null) + { + _pool = Container.ResolveId(PoolId); + } + + buffer.Add(_pool.Spawn( + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value, + (TParam6)args[5].Value, + _pool)); + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PoolableMemoryPoolProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PoolableMemoryPoolProvider.cs.meta new file mode 100644 index 0000000..3e26db9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PoolableMemoryPoolProvider.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 6857585e55699ab4da01454c662e0e3b +timeCreated: 1528529860 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators.meta new file mode 100644 index 0000000..90ab037 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 4a029f9358245bf4e99fcb7fcc19ba28 +folderAsset: yes +timeCreated: 1461708046 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/IPrefabInstantiator.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/IPrefabInstantiator.cs new file mode 100644 index 0000000..55964c5 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/IPrefabInstantiator.cs @@ -0,0 +1,32 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace Zenject +{ + public interface IPrefabInstantiator + { + Type ArgumentTarget + { + get; + } + + List ExtraArguments + { + get; + } + + GameObjectCreationParameters GameObjectCreationParameters + { + get; + } + + GameObject Instantiate(InjectContext context, List args, out Action injectAction); + + UnityEngine.Object GetPrefab(InjectContext context); + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/IPrefabInstantiator.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/IPrefabInstantiator.cs.meta new file mode 100644 index 0000000..341eb3e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/IPrefabInstantiator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 45b8fa051fd4fb84b94f6384e6dbe092 +timeCreated: 1461708050 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/PrefabInstantiator.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/PrefabInstantiator.cs new file mode 100644 index 0000000..f4c9094 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/PrefabInstantiator.cs @@ -0,0 +1,136 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using System.Linq; +using Zenject.Internal; +using ModestTree; +using UnityEngine; + +namespace Zenject +{ + [NoReflectionBaking] + public class PrefabInstantiator : IPrefabInstantiator + { + readonly IPrefabProvider _prefabProvider; + readonly DiContainer _container; + readonly List _extraArguments; + readonly GameObjectCreationParameters _gameObjectBindInfo; + readonly Type _argumentTarget; + readonly List _instantiateCallbackTypes; + readonly Action _instantiateCallback; + + public PrefabInstantiator( + DiContainer container, + GameObjectCreationParameters gameObjectBindInfo, + Type argumentTarget, + IEnumerable instantiateCallbackTypes, + IEnumerable extraArguments, + IPrefabProvider prefabProvider, + Action instantiateCallback) + { + _prefabProvider = prefabProvider; + _extraArguments = extraArguments.ToList(); + _container = container; + _gameObjectBindInfo = gameObjectBindInfo; + _argumentTarget = argumentTarget; + _instantiateCallbackTypes = instantiateCallbackTypes.ToList(); + _instantiateCallback = instantiateCallback; + } + + public GameObjectCreationParameters GameObjectCreationParameters + { + get { return _gameObjectBindInfo; } + } + + public Type ArgumentTarget + { + get { return _argumentTarget; } + } + + public List ExtraArguments + { + get { return _extraArguments; } + } + + public UnityEngine.Object GetPrefab(InjectContext context) + { + return _prefabProvider.GetPrefab(context); + } + + public GameObject Instantiate(InjectContext context, List args, out Action injectAction) + { + Assert.That(_argumentTarget == null || _argumentTarget.DerivesFromOrEqual(context.MemberType)); + + bool shouldMakeActive; + var gameObject = _container.CreateAndParentPrefab( + GetPrefab(context), _gameObjectBindInfo, context, out shouldMakeActive); + Assert.IsNotNull(gameObject); + + injectAction = () => + { + var allArgs = ZenPools.SpawnList(); + + allArgs.AllocFreeAddRange(_extraArguments); + allArgs.AllocFreeAddRange(args); + + if (_argumentTarget == null) + { + Assert.That( + allArgs.IsEmpty(), + "Unexpected arguments provided to prefab instantiator. Arguments are not allowed if binding multiple components in the same binding"); + } + + if (_argumentTarget == null || allArgs.IsEmpty()) + { + _container.InjectGameObject(gameObject); + } + else + { + _container.InjectGameObjectForComponentExplicit( + gameObject, _argumentTarget, allArgs, context, null); + + Assert.That(allArgs.Count == 0); + } + + ZenPools.DespawnList(allArgs); + + if (shouldMakeActive && !_container.IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif + { + gameObject.SetActive(true); + } + } + + if (_instantiateCallback != null) + { + var callbackObjects = ZenPools.SpawnHashSet(); + + foreach (var type in _instantiateCallbackTypes) + { + var obj = gameObject.GetComponentInChildren(type); + + if (obj != null) + { + callbackObjects.Add(obj); + } + } + + foreach (var obj in callbackObjects) + { + _instantiateCallback(context, obj); + } + + ZenPools.DespawnHashSet(callbackObjects); + } + }; + + return gameObject; + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/PrefabInstantiator.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/PrefabInstantiator.cs.meta new file mode 100644 index 0000000..ad7d6de --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/PrefabInstantiator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7dfc3341d0446554996b2969abf2d1ff +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/PrefabInstantiatorCached.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/PrefabInstantiatorCached.cs new file mode 100644 index 0000000..d3adb2f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/PrefabInstantiatorCached.cs @@ -0,0 +1,60 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using ModestTree; +using UnityEngine; + +namespace Zenject +{ + [NoReflectionBaking] + public class PrefabInstantiatorCached : IPrefabInstantiator + { + readonly IPrefabInstantiator _subInstantiator; + + GameObject _gameObject; + + public PrefabInstantiatorCached(IPrefabInstantiator subInstantiator) + { + _subInstantiator = subInstantiator; + } + + public List ExtraArguments + { + get { return _subInstantiator.ExtraArguments; } + } + + public Type ArgumentTarget + { + get { return _subInstantiator.ArgumentTarget; } + } + + public GameObjectCreationParameters GameObjectCreationParameters + { + get { return _subInstantiator.GameObjectCreationParameters; } + } + + public UnityEngine.Object GetPrefab(InjectContext context) + { + return _subInstantiator.GetPrefab(context); + } + + public GameObject Instantiate(InjectContext context, List args, out Action injectAction) + { + // We can't really support arguments if we are using the cached value since + // the arguments might change when called after the first time + Assert.IsEmpty(args); + + if (_gameObject != null) + { + injectAction = null; + return _gameObject; + } + + _gameObject = _subInstantiator.Instantiate(context, new List(), out injectAction); + return _gameObject; + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/PrefabInstantiatorCached.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/PrefabInstantiatorCached.cs.meta new file mode 100644 index 0000000..96a64e8 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabCreators/PrefabInstantiatorCached.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 293ee607ccfdf63458a26d0e6bdebaaa +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders.meta new file mode 100644 index 0000000..8d40760 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 4248afcd0d89aa54da8d2c34a41c5712 +folderAsset: yes +timeCreated: 1461708046 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/IPrefabProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/IPrefabProvider.cs new file mode 100644 index 0000000..13ff896 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/IPrefabProvider.cs @@ -0,0 +1,12 @@ +#if !NOT_UNITY3D + +namespace Zenject +{ + public interface IPrefabProvider + { + UnityEngine.Object GetPrefab(InjectContext context); + } +} + +#endif + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/IPrefabProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/IPrefabProvider.cs.meta new file mode 100644 index 0000000..8688ed7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/IPrefabProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3b63b8088376c9a499e7f506a237392d +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProvider.cs new file mode 100644 index 0000000..f60828e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProvider.cs @@ -0,0 +1,27 @@ +#if !NOT_UNITY3D + +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class PrefabProvider : IPrefabProvider + { + readonly UnityEngine.Object _prefab; + + public PrefabProvider(UnityEngine.Object prefab) + { + Assert.IsNotNull(prefab); + _prefab = prefab; + } + + public UnityEngine.Object GetPrefab(InjectContext _) + { + return _prefab; + } + } +} + +#endif + + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProvider.cs.meta new file mode 100644 index 0000000..97cd814 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3628433a045792f4297abd34b5a1a34c +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProviderCustom.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProviderCustom.cs new file mode 100644 index 0000000..1e4ee13 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProviderCustom.cs @@ -0,0 +1,29 @@ +#if !NOT_UNITY3D + +using ModestTree; +using UnityEngine; +using System; + +namespace Zenject +{ + [NoReflectionBaking] + public class PrefabProviderCustom : IPrefabProvider + { + readonly Func _getter; + + public PrefabProviderCustom(Func getter) + { + _getter = getter; + } + + public UnityEngine.Object GetPrefab(InjectContext context) + { + var prefab = _getter(context); + Assert.That(prefab != null, "Custom prefab provider returned null"); + return prefab; + } + } +} + +#endif + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProviderCustom.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProviderCustom.cs.meta new file mode 100644 index 0000000..2217837 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProviderCustom.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f6f578cfe9da346348878e4a26617ee0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProviderResource.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProviderResource.cs new file mode 100644 index 0000000..35faaa8 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProviderResource.cs @@ -0,0 +1,31 @@ +#if !NOT_UNITY3D + +using ModestTree; +using UnityEngine; + +namespace Zenject +{ + [NoReflectionBaking] + public class PrefabProviderResource : IPrefabProvider + { + readonly string _resourcePath; + + public PrefabProviderResource(string resourcePath) + { + _resourcePath = resourcePath; + } + + public UnityEngine.Object GetPrefab(InjectContext context) + { + var prefab = (GameObject)Resources.Load(_resourcePath); + + Assert.That(prefab != null, + "Expected to find prefab at resource path '{0}'", _resourcePath); + + return prefab; + } + } +} + +#endif + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProviderResource.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProviderResource.cs.meta new file mode 100644 index 0000000..1cfa67c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/PrefabProviders/PrefabProviderResource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6fa6b8670ec5932489c4102d45d987ff +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ProviderUtil.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ProviderUtil.cs new file mode 100644 index 0000000..bee9115 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ProviderUtil.cs @@ -0,0 +1,24 @@ +using System; +using ModestTree; + +namespace Zenject +{ + public static class ProviderUtil + { + public static Type GetTypeToInstantiate(Type contractType, Type concreteType) + { +#if !(UNITY_WSA && ENABLE_DOTNET) + // TODO: Is it possible to do this on WSA? + + if (concreteType.IsOpenGenericType()) + { + return concreteType.MakeGenericType(contractType.GetGenericArguments()); + } +#endif + + Assert.DerivesFromOrEqual(concreteType, contractType); + return concreteType; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ProviderUtil.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ProviderUtil.cs.meta new file mode 100644 index 0000000..ed0c87d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ProviderUtil.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 278c72df466e8b049bc7ce6feb535cb1 +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ResolveProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ResolveProvider.cs new file mode 100644 index 0000000..4945734 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ResolveProvider.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class ResolveProvider : IProvider + { + readonly object _identifier; + readonly DiContainer _container; + readonly Type _contractType; + readonly bool _isOptional; + readonly InjectSources _source; + readonly bool _matchAll; + + public ResolveProvider( + Type contractType, DiContainer container, object identifier, + bool isOptional, InjectSources source, bool matchAll) + { + _contractType = contractType; + _identifier = identifier; + _container = container; + _isOptional = isOptional; + _source = source; + _matchAll = matchAll; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return _contractType; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEmpty(args); + Assert.IsNotNull(context); + + Assert.That(_contractType.DerivesFromOrEqual(context.MemberType)); + + injectAction = null; + if (_matchAll) + { + _container.ResolveAll(GetSubContext(context), buffer); + } + else + { + buffer.Add(_container.Resolve(GetSubContext(context))); + } + } + + InjectContext GetSubContext(InjectContext parent) + { + var subContext = parent.CreateSubContext(_contractType, _identifier); + + subContext.SourceType = _source; + subContext.Optional = _isOptional; + + return subContext; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ResolveProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ResolveProvider.cs.meta new file mode 100644 index 0000000..0292729 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ResolveProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 35df94e99ddd0c04c86cf0bcefa85ad8 +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ResourceProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ResourceProvider.cs new file mode 100644 index 0000000..6c604ba --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ResourceProvider.cs @@ -0,0 +1,75 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using ModestTree; +using UnityEngine; + +namespace Zenject +{ + [NoReflectionBaking] + public class ResourceProvider : IProvider + { + readonly Type _resourceType; + readonly string _resourcePath; + readonly bool _matchSingle; + + public ResourceProvider( + string resourcePath, Type resourceType, bool matchSingle) + { + _resourceType = resourceType; + _resourcePath = resourcePath; + _matchSingle = matchSingle; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return _resourceType; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsEmpty(args); + + Assert.IsNotNull(context); + + if (_matchSingle) + { + var obj = Resources.Load(_resourcePath, _resourceType); + + Assert.That(obj != null, + "Could not find resource at path '{0}' with type '{1}'", _resourcePath, _resourceType); + + // Are there any resource types which can be injected? + injectAction = null; + buffer.Add(obj); + return; + } + + var objects = Resources.LoadAll(_resourcePath, _resourceType); + + Assert.That(objects.Length > 0, + "Could not find resource at path '{0}' with type '{1}'", _resourcePath, _resourceType); + + // Are there any resource types which can be injected? + injectAction = null; + + buffer.AllocFreeAddRange(objects); + } + } +} + +#endif + + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ResourceProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ResourceProvider.cs.meta new file mode 100644 index 0000000..366d645 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ResourceProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f16c8e5eed02ac8478e8c236c1677db3 +timeCreated: 1461708055 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ScriptableObjectInstanceProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ScriptableObjectInstanceProvider.cs new file mode 100644 index 0000000..a0c58c5 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ScriptableObjectInstanceProvider.cs @@ -0,0 +1,96 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using UnityEngine; +using Zenject.Internal; + +namespace Zenject +{ + [NoReflectionBaking] + public class ScriptableObjectInstanceProvider : IProvider + { + readonly DiContainer _container; + readonly Type _resourceType; + readonly List _extraArguments; + readonly bool _createNew; + readonly object _concreteIdentifier; + readonly Action _instantiateCallback; + readonly UnityEngine.Object _resource; + + public ScriptableObjectInstanceProvider( + UnityEngine.Object resource, Type resourceType, + DiContainer container, IEnumerable extraArguments, + bool createNew, object concreteIdentifier, + Action instantiateCallback) + { + _container = container; + Assert.DerivesFromOrEqual(resourceType); + + _resource = resource; + _extraArguments = extraArguments.ToList(); + _resourceType = resourceType; + _createNew = createNew; + _concreteIdentifier = concreteIdentifier; + _instantiateCallback = instantiateCallback; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return _resourceType; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsNotNull(context); + + if (_createNew) + { + buffer.Add(UnityEngine.ScriptableObject.Instantiate(_resource)); + } + else + { + buffer.Add(_resource); + } + + injectAction = () => + { + for (int i = 0; i < buffer.Count; i++) + { + var obj = buffer[i]; + + var extraArgs = ZenPools.SpawnList(); + + extraArgs.AllocFreeAddRange(_extraArguments); + extraArgs.AllocFreeAddRange(args); + + _container.InjectExplicit( + obj, _resourceType, extraArgs, context, _concreteIdentifier); + + ZenPools.DespawnList(extraArgs); + + if (_instantiateCallback != null) + { + _instantiateCallback(context, obj); + } + } + }; + } + } +} + +#endif + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ScriptableObjectInstanceProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ScriptableObjectInstanceProvider.cs.meta new file mode 100644 index 0000000..be7550e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ScriptableObjectInstanceProvider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dd4cee241217b5947b3a223dabefec0a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ScriptableObjectResourceProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ScriptableObjectResourceProvider.cs new file mode 100644 index 0000000..5244152 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ScriptableObjectResourceProvider.cs @@ -0,0 +1,104 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using UnityEngine; +using Zenject.Internal; + +namespace Zenject +{ + [NoReflectionBaking] + public class ScriptableObjectResourceProvider : IProvider + { + readonly DiContainer _container; + readonly Type _resourceType; + readonly string _resourcePath; + readonly List _extraArguments; + readonly bool _createNew; + readonly object _concreteIdentifier; + readonly Action _instantiateCallback; + + public ScriptableObjectResourceProvider( + string resourcePath, Type resourceType, + DiContainer container, IEnumerable extraArguments, + bool createNew, object concreteIdentifier, + Action instantiateCallback) + { + _container = container; + Assert.DerivesFromOrEqual(resourceType); + + _extraArguments = extraArguments.ToList(); + _resourceType = resourceType; + _resourcePath = resourcePath; + _createNew = createNew; + _concreteIdentifier = concreteIdentifier; + _instantiateCallback = instantiateCallback; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return _resourceType; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsNotNull(context); + + if (_createNew) + { + var objects = Resources.LoadAll(_resourcePath, _resourceType); + + for (int i = 0; i < objects.Length; i++) + { + buffer.Add(ScriptableObject.Instantiate(objects[i])); + } + } + else + { + buffer.AllocFreeAddRange( + Resources.LoadAll(_resourcePath, _resourceType)); + } + + Assert.That(buffer.Count > 0, + "Could not find resource at path '{0}' with type '{1}'", _resourcePath, _resourceType); + + injectAction = () => + { + for (int i = 0; i < buffer.Count; i++) + { + var obj = buffer[i]; + + var extraArgs = ZenPools.SpawnList(); + + extraArgs.AllocFreeAddRange(_extraArguments); + extraArgs.AllocFreeAddRange(args); + + _container.InjectExplicit( + obj, _resourceType, extraArgs, context, _concreteIdentifier); + + ZenPools.DespawnList(extraArgs); + + if (_instantiateCallback != null) + { + _instantiateCallback(context, obj); + } + } + }; + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ScriptableObjectResourceProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ScriptableObjectResourceProvider.cs.meta new file mode 100644 index 0000000..601dde8 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/ScriptableObjectResourceProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5753f1f4d468e7649b017dee98c6301d +timeCreated: 1486668547 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators.meta new file mode 100644 index 0000000..61e134e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 60492d3348bd7624a9f7f00d1e20ae8e +folderAsset: yes +timeCreated: 1461708046 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/ISubContainerCreator.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/ISubContainerCreator.cs new file mode 100644 index 0000000..c7195e3 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/ISubContainerCreator.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using System; + +namespace Zenject +{ + public interface ISubContainerCreator + { + DiContainer CreateSubContainer(List args, InjectContext context, out Action injectAction); + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/ISubContainerCreator.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/ISubContainerCreator.cs.meta new file mode 100644 index 0000000..7a3fc05 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/ISubContainerCreator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 83273a08f84aa9a48b37fe0b1bae0958 +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorBindInfo.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorBindInfo.cs new file mode 100644 index 0000000..de51934 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorBindInfo.cs @@ -0,0 +1,24 @@ +using System; + +namespace Zenject +{ + [NoReflectionBaking] + public class SubContainerCreatorBindInfo + { + // Null = means no custom default parent + public string DefaultParentName + { + get; set; + } + + public bool CreateKernel + { + get; set; + } + + public Type KernelType + { + get; set; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorBindInfo.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorBindInfo.cs.meta new file mode 100644 index 0000000..5d71c07 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorBindInfo.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2d894c838f0dcc34bb38d1311af9ea56 +timeCreated: 1534923025 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstaller.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstaller.cs new file mode 100644 index 0000000..acd18bd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstaller.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using Zenject.Internal; + +namespace Zenject +{ + [NoReflectionBaking] + public class SubContainerCreatorByInstaller : ISubContainerCreator + { + readonly Type _installerType; + readonly DiContainer _container; + readonly List _extraArgs; + readonly SubContainerCreatorBindInfo _containerBindInfo; + + public SubContainerCreatorByInstaller( + DiContainer container, + SubContainerCreatorBindInfo containerBindInfo, + Type installerType, + IEnumerable extraArgs) + { + _installerType = installerType; + _container = container; + _extraArgs = extraArgs.ToList(); + _containerBindInfo = containerBindInfo; + + Assert.That(installerType.DerivesFrom(), + "Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType); + } + + public SubContainerCreatorByInstaller( + DiContainer container, + SubContainerCreatorBindInfo containerBindInfo, + Type installerType) + : this(container, containerBindInfo, installerType, new List()) + { + } + + public DiContainer CreateSubContainer(List args, InjectContext context, out Action injectAction) + { + var subContainer = _container.CreateSubContainer(); + + SubContainerCreatorUtil.ApplyBindSettings(_containerBindInfo, subContainer); + + var extraArgs = ZenPools.SpawnList(); + + extraArgs.AllocFreeAddRange(_extraArgs); + extraArgs.AllocFreeAddRange(args); + + var installer = (InstallerBase)subContainer.InstantiateExplicit( + _installerType, extraArgs); + + ZenPools.DespawnList(extraArgs); + + installer.InstallBindings(); + + injectAction = () => + { + subContainer.ResolveRoots(); + }; + + return subContainer; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstaller.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstaller.cs.meta new file mode 100644 index 0000000..716d029 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstaller.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d932bdf1cc240394a94c9fd81dfa9218 +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstance.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstance.cs new file mode 100644 index 0000000..6203e58 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstance.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using System; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class SubContainerCreatorByInstance : ISubContainerCreator + { + readonly DiContainer _subcontainer; + + public SubContainerCreatorByInstance(DiContainer subcontainer) + { + _subcontainer = subcontainer; + } + + public DiContainer CreateSubContainer(List args, InjectContext context, out Action injectAction) + { + Assert.That(args.IsEmpty()); + + injectAction = null; + + // It is assumed here that the subcontainer has already had ResolveRoots called elsewhere + // Since most likely you are adding a subcontainer that is already in a context or + // something rather than directly using DiContainer.CreateSubContainer + return _subcontainer; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstance.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstance.cs.meta new file mode 100644 index 0000000..3e5707c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstance.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1ea58c024bbd4e846be07059bf23c524 +timeCreated: 1535189469 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstanceGetter.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstanceGetter.cs new file mode 100644 index 0000000..8bad289 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstanceGetter.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class SubContainerCreatorByInstanceGetter : ISubContainerCreator + { + readonly Func _subcontainerGetter; + + public SubContainerCreatorByInstanceGetter( + Func subcontainerGetter) + { + _subcontainerGetter = subcontainerGetter; + } + + public DiContainer CreateSubContainer(List args, InjectContext context, out Action injectAction) + { + Assert.That(args.IsEmpty()); + + injectAction = null; + + // It is assumed here that the subcontainer has already had ResolveRoots called elsewhere + // Since most likely you are adding a subcontainer that is already in a context or + // something rather than directly using DiContainer.CreateSubContainer + return _subcontainerGetter(context); + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstanceGetter.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstanceGetter.cs.meta new file mode 100644 index 0000000..4c952e2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByInstanceGetter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 164cf97cfe8f32441beb85b9b3c05868 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByMethod.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByMethod.cs new file mode 100644 index 0000000..8530f9c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByMethod.cs @@ -0,0 +1,390 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + // Zero parameters + + [NoReflectionBaking] + public abstract class SubContainerCreatorByMethodBase : ISubContainerCreator + { + readonly DiContainer _container; + readonly SubContainerCreatorBindInfo _containerBindInfo; + + public SubContainerCreatorByMethodBase( + DiContainer container, SubContainerCreatorBindInfo containerBindInfo) + { + _container = container; + _containerBindInfo = containerBindInfo; + } + + public abstract DiContainer CreateSubContainer( + List args, InjectContext context, out Action injectAction); + + protected DiContainer CreateEmptySubContainer() + { + var subContainer = _container.CreateSubContainer(); + SubContainerCreatorUtil.ApplyBindSettings(_containerBindInfo, subContainer); + return subContainer; + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByMethod : SubContainerCreatorByMethodBase + { + readonly Action _installMethod; + + public SubContainerCreatorByMethod( + DiContainer container, + SubContainerCreatorBindInfo containerBindInfo, + Action installMethod) + : base(container, containerBindInfo) + { + _installMethod = installMethod; + } + + public override DiContainer CreateSubContainer(List args, InjectContext context, out Action injectAction) + { + Assert.IsEmpty(args); + + var subContainer = CreateEmptySubContainer(); + + _installMethod(subContainer); + + injectAction = () => + { + subContainer.ResolveRoots(); + }; + + return subContainer; + } + } + + // One parameters + + [NoReflectionBaking] + public class SubContainerCreatorByMethod : SubContainerCreatorByMethodBase + { + readonly Action _installMethod; + + public SubContainerCreatorByMethod( + DiContainer container, + SubContainerCreatorBindInfo containerBindInfo, + Action installMethod) + : base(container, containerBindInfo) + { + _installMethod = installMethod; + } + + public override DiContainer CreateSubContainer(List args, InjectContext context, out Action injectAction) + { + Assert.IsEqual(args.Count, 1); + Assert.That(args[0].Type.DerivesFromOrEqual()); + + var subContainer = CreateEmptySubContainer(); + + _installMethod(subContainer, (TParam1)args[0].Value); + + injectAction = () => + { + subContainer.ResolveRoots(); + }; + + return subContainer; + } + } + + // Two parameters + + [NoReflectionBaking] + public class SubContainerCreatorByMethod : SubContainerCreatorByMethodBase + { + readonly Action _installMethod; + + public SubContainerCreatorByMethod( + DiContainer container, + SubContainerCreatorBindInfo containerBindInfo, + Action installMethod) + : base(container, containerBindInfo) + { + _installMethod = installMethod; + } + + public override DiContainer CreateSubContainer(List args, InjectContext context, out Action injectAction) + { + Assert.IsEqual(args.Count, 2); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + + var subContainer = CreateEmptySubContainer(); + + _installMethod( + subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value); + + injectAction = () => + { + subContainer.ResolveRoots(); + }; + + return subContainer; + } + } + + // Three parameters + + [NoReflectionBaking] + public class SubContainerCreatorByMethod : SubContainerCreatorByMethodBase + { + readonly Action _installMethod; + + public SubContainerCreatorByMethod( + DiContainer container, + SubContainerCreatorBindInfo containerBindInfo, + Action installMethod) + : base(container, containerBindInfo) + { + _installMethod = installMethod; + } + + public override DiContainer CreateSubContainer(List args, InjectContext context, out Action injectAction) + { + Assert.IsEqual(args.Count, 3); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + + var subContainer = CreateEmptySubContainer(); + + _installMethod( + subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value); + + injectAction = () => + { + subContainer.ResolveRoots(); + }; + + return subContainer; + } + } + + // Four parameters + + [NoReflectionBaking] + public class SubContainerCreatorByMethod : SubContainerCreatorByMethodBase + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Action _installMethod; + + public SubContainerCreatorByMethod( + DiContainer container, + SubContainerCreatorBindInfo containerBindInfo, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installMethod) + : base(container, containerBindInfo) + { + _installMethod = installMethod; + } + + public override DiContainer CreateSubContainer(List args, InjectContext context, out Action injectAction) + { + Assert.IsEqual(args.Count, 4); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + + var subContainer = CreateEmptySubContainer(); + + _installMethod( + subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value); + + injectAction = () => + { + subContainer.ResolveRoots(); + }; + + return subContainer; + } + } + + // Five parameters + + [NoReflectionBaking] + public class SubContainerCreatorByMethod : SubContainerCreatorByMethodBase + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Action _installMethod; + + public SubContainerCreatorByMethod( + DiContainer container, + SubContainerCreatorBindInfo containerBindInfo, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installMethod) + : base(container, containerBindInfo) + { + _installMethod = installMethod; + } + + public override DiContainer CreateSubContainer(List args, InjectContext context, out Action injectAction) + { + Assert.IsEqual(args.Count, 5); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + Assert.That(args[4].Type.DerivesFromOrEqual()); + + var subContainer = CreateEmptySubContainer(); + + _installMethod( + subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value); + + injectAction = () => + { + subContainer.ResolveRoots(); + }; + + return subContainer; + } + } + + // Six parameters + + [NoReflectionBaking] + public class SubContainerCreatorByMethod : SubContainerCreatorByMethodBase + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Action _installMethod; + + public SubContainerCreatorByMethod( + DiContainer container, + SubContainerCreatorBindInfo containerBindInfo, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installMethod) + : base(container, containerBindInfo) + { + _installMethod = installMethod; + } + + public override DiContainer CreateSubContainer(List args, InjectContext context, out Action injectAction) + { + Assert.IsEqual(args.Count, 5); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + Assert.That(args[4].Type.DerivesFromOrEqual()); + Assert.That(args[5].Type.DerivesFromOrEqual()); + + var subContainer = CreateEmptySubContainer(); + + _installMethod( + subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value, + (TParam6)args[5].Value); + + injectAction = () => + { + subContainer.ResolveRoots(); + }; + + return subContainer; + } + } + + // 10 parameters + + [NoReflectionBaking] + public class SubContainerCreatorByMethod : SubContainerCreatorByMethodBase + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Action _installMethod; + + public SubContainerCreatorByMethod( + DiContainer container, + SubContainerCreatorBindInfo containerBindInfo, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installMethod) + : base(container, containerBindInfo) + { + _installMethod = installMethod; + } + + public override DiContainer CreateSubContainer(List args, InjectContext context, out Action injectAction) + { + Assert.IsEqual(args.Count, 10); + + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + Assert.That(args[4].Type.DerivesFromOrEqual()); + Assert.That(args[5].Type.DerivesFromOrEqual()); + Assert.That(args[6].Type.DerivesFromOrEqual()); + Assert.That(args[7].Type.DerivesFromOrEqual()); + Assert.That(args[8].Type.DerivesFromOrEqual()); + Assert.That(args[9].Type.DerivesFromOrEqual()); + + var subContainer = CreateEmptySubContainer(); + + _installMethod( + subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value, + (TParam6)args[5].Value, + (TParam7)args[6].Value, + (TParam8)args[7].Value, + (TParam9)args[8].Value, + (TParam10)args[9].Value); + + injectAction = () => + { + subContainer.ResolveRoots(); + }; + + return subContainer; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByMethod.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByMethod.cs.meta new file mode 100644 index 0000000..bff0242 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByMethod.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5f4bb37c4e2a5bf44865ed1ab3bef21e +timeCreated: 1461708050 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewGameObjectDynamicContext.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewGameObjectDynamicContext.cs new file mode 100644 index 0000000..5d5f900 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewGameObjectDynamicContext.cs @@ -0,0 +1,366 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using UnityEngine; +using ModestTree; +using Zenject.Internal; + +namespace Zenject +{ + [NoReflectionBaking] + public abstract class SubContainerCreatorByNewGameObjectDynamicContext : SubContainerCreatorDynamicContext + { + readonly GameObjectCreationParameters _gameObjectBindInfo; + + public SubContainerCreatorByNewGameObjectDynamicContext( + DiContainer container, GameObjectCreationParameters gameObjectBindInfo) + : base(container) + { + _gameObjectBindInfo = gameObjectBindInfo; + } + + protected override GameObject CreateGameObject(InjectContext context, out bool shouldMakeActive) + { + shouldMakeActive = true; + var gameObject = Container.CreateEmptyGameObject(_gameObjectBindInfo, null); + gameObject.SetActive(false); + return gameObject; + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewGameObjectInstaller : SubContainerCreatorByNewGameObjectDynamicContext + { + readonly Type _installerType; + readonly List _extraArgs; + + public SubContainerCreatorByNewGameObjectInstaller( + DiContainer container, + GameObjectCreationParameters gameObjectBindInfo, + Type installerType, List extraArgs) + : base(container, gameObjectBindInfo) + { + _installerType = installerType; + _extraArgs = extraArgs; + + Assert.That(installerType.DerivesFrom(), + "Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType); + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + var extraArgs = ZenPools.SpawnList(); + + extraArgs.AllocFreeAddRange(_extraArgs); + extraArgs.AllocFreeAddRange(args); + + var installer = (InstallerBase)subContainer.InstantiateExplicit( + _installerType, extraArgs); + + ZenPools.DespawnList(extraArgs); + + installer.InstallBindings(); + })); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewGameObjectMethod : SubContainerCreatorByNewGameObjectDynamicContext + { + readonly Action _installerMethod; + + public SubContainerCreatorByNewGameObjectMethod( + DiContainer container, + GameObjectCreationParameters gameObjectBindInfo, + Action installerMethod) + : base(container, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.That(args.IsEmpty()); + context.AddNormalInstaller( + new ActionInstaller(_installerMethod)); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewGameObjectMethod : SubContainerCreatorByNewGameObjectDynamicContext + { + readonly Action _installerMethod; + + public SubContainerCreatorByNewGameObjectMethod( + DiContainer container, + GameObjectCreationParameters gameObjectBindInfo, + Action installerMethod) + : base(container, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.IsEqual(args.Count, 1); + Assert.That(args[0].Type.DerivesFromOrEqual()); + + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + _installerMethod(subContainer, (TParam1)args[0].Value); + })); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewGameObjectMethod : SubContainerCreatorByNewGameObjectDynamicContext + { + readonly Action _installerMethod; + + public SubContainerCreatorByNewGameObjectMethod( + DiContainer container, + GameObjectCreationParameters gameObjectBindInfo, + Action installerMethod) + : base(container, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.IsEqual(args.Count, 2); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + _installerMethod(subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value); + })); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewGameObjectMethod : SubContainerCreatorByNewGameObjectDynamicContext + { + readonly Action _installerMethod; + + public SubContainerCreatorByNewGameObjectMethod( + DiContainer container, + GameObjectCreationParameters gameObjectBindInfo, + Action installerMethod) + : base(container, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.IsEqual(args.Count, 3); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + _installerMethod(subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value); + })); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewGameObjectMethod : SubContainerCreatorByNewGameObjectDynamicContext + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Action _installerMethod; + + public SubContainerCreatorByNewGameObjectMethod( + DiContainer container, + GameObjectCreationParameters gameObjectBindInfo, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + : base(container, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.IsEqual(args.Count, 4); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + _installerMethod(subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value); + })); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewGameObjectMethod : SubContainerCreatorByNewGameObjectDynamicContext + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Action _installerMethod; + + public SubContainerCreatorByNewGameObjectMethod( + DiContainer container, + GameObjectCreationParameters gameObjectBindInfo, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + : base(container, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.IsEqual(args.Count, 5); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + Assert.That(args[4].Type.DerivesFromOrEqual()); + + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + _installerMethod(subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value); + })); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewGameObjectMethod : SubContainerCreatorByNewGameObjectDynamicContext + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Action _installerMethod; + + public SubContainerCreatorByNewGameObjectMethod( + DiContainer container, + GameObjectCreationParameters gameObjectBindInfo, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + : base(container, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.IsEqual(args.Count, 5); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + Assert.That(args[4].Type.DerivesFromOrEqual()); + Assert.That(args[5].Type.DerivesFromOrEqual()); + + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + _installerMethod(subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value, + (TParam6)args[5].Value); + })); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewGameObjectMethod : SubContainerCreatorByNewGameObjectDynamicContext + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Action _installerMethod; + + public SubContainerCreatorByNewGameObjectMethod( + DiContainer container, + GameObjectCreationParameters gameObjectBindInfo, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + : base(container, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.IsEqual(args.Count, 10); + + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + Assert.That(args[4].Type.DerivesFromOrEqual()); + Assert.That(args[5].Type.DerivesFromOrEqual()); + Assert.That(args[6].Type.DerivesFromOrEqual()); + Assert.That(args[7].Type.DerivesFromOrEqual()); + Assert.That(args[8].Type.DerivesFromOrEqual()); + Assert.That(args[9].Type.DerivesFromOrEqual()); + + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + _installerMethod(subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value, + (TParam6)args[5].Value, + (TParam7)args[6].Value, + (TParam8)args[7].Value, + (TParam9)args[8].Value, + (TParam10)args[9].Value); + })); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewGameObjectDynamicContext.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewGameObjectDynamicContext.cs.meta new file mode 100644 index 0000000..a22d7c9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewGameObjectDynamicContext.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7c2c6880c82d78140818fe3204a0279b +timeCreated: 1538467080 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefab.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefab.cs new file mode 100644 index 0000000..3108ad6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefab.cs @@ -0,0 +1,64 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class SubContainerCreatorByNewPrefab : ISubContainerCreator + { + readonly GameObjectCreationParameters _gameObjectBindInfo; + readonly IPrefabProvider _prefabProvider; + readonly DiContainer _container; + + public SubContainerCreatorByNewPrefab( + DiContainer container, IPrefabProvider prefabProvider, + GameObjectCreationParameters gameObjectBindInfo) + { + _gameObjectBindInfo = gameObjectBindInfo; + _prefabProvider = prefabProvider; + _container = container; + } + + public DiContainer CreateSubContainer( + List args, InjectContext parentContext, out Action injectAction) + { + Assert.That(args.IsEmpty()); + + var prefab = _prefabProvider.GetPrefab(parentContext); + + bool shouldMakeActive; + var gameObject = _container.CreateAndParentPrefab( + prefab, _gameObjectBindInfo, null, out shouldMakeActive); + + var context = gameObject.GetComponent(); + + Assert.That(context != null, + "Expected prefab with name '{0}' to contain a component of type 'GameObjectContext' on the root", prefab.name); + + context.Install(_container); + + injectAction = () => + { + // Note: We don't need to call ResolveRoots here because GameObjectContext does this for us + _container.Inject(context); + + if (shouldMakeActive && !_container.IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif + { + gameObject.SetActive(true); + } + } + }; + + return context.Container; + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefab.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefab.cs.meta new file mode 100644 index 0000000..93e5576 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefab.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 17fc7cad09fe4e94f939551c85abf6d9 +timeCreated: 1486859770 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefabDynamicContext.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefabDynamicContext.cs new file mode 100644 index 0000000..79972d1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefabDynamicContext.cs @@ -0,0 +1,377 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using UnityEngine; +using ModestTree; +using Zenject.Internal; + +namespace Zenject +{ + [NoReflectionBaking] + public abstract class SubContainerCreatorByNewPrefabDynamicContext : SubContainerCreatorDynamicContext + { + readonly IPrefabProvider _prefabProvider; + readonly GameObjectCreationParameters _gameObjectBindInfo; + + public SubContainerCreatorByNewPrefabDynamicContext( + DiContainer container, + IPrefabProvider prefabProvider, GameObjectCreationParameters gameObjectBindInfo) + : base(container) + { + _prefabProvider = prefabProvider; + _gameObjectBindInfo = gameObjectBindInfo; + } + + protected override GameObject CreateGameObject(InjectContext context, out bool shouldMakeActive) + { + var prefab = _prefabProvider.GetPrefab(context); + + var gameObj = Container.CreateAndParentPrefab( + prefab, _gameObjectBindInfo, null, out shouldMakeActive); + + if (gameObj.GetComponent() != null) + { + throw Assert.CreateException( + "Found GameObjectContext already attached to prefab with name '{0}'! When using ByNewPrefabMethod or ByNewPrefabInstaller, the GameObjectContext is added to the prefab dynamically", prefab.name); + } + + return gameObj; + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewPrefabInstaller : SubContainerCreatorByNewPrefabDynamicContext + { + readonly Type _installerType; + readonly List _extraArgs; + + public SubContainerCreatorByNewPrefabInstaller( + DiContainer container, IPrefabProvider prefabProvider, + GameObjectCreationParameters gameObjectBindInfo, + Type installerType, List extraArgs) + : base(container, prefabProvider, gameObjectBindInfo) + { + _installerType = installerType; + _extraArgs = extraArgs; + + Assert.That(installerType.DerivesFrom(), + "Invalid installer type given during bind command. Expected type '{0}' to derive from 'Installer<>'", installerType); + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + var extraArgs = ZenPools.SpawnList(); + + extraArgs.AllocFreeAddRange(_extraArgs); + extraArgs.AllocFreeAddRange(args); + + var installer = (InstallerBase)subContainer.InstantiateExplicit( + _installerType, extraArgs); + + ZenPools.DespawnList(extraArgs); + + installer.InstallBindings(); + })); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewPrefabMethod : SubContainerCreatorByNewPrefabDynamicContext + { + readonly Action _installerMethod; + + public SubContainerCreatorByNewPrefabMethod( + DiContainer container, IPrefabProvider prefabProvider, + GameObjectCreationParameters gameObjectBindInfo, + Action installerMethod) + : base(container, prefabProvider, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.That(args.IsEmpty()); + context.AddNormalInstaller( + new ActionInstaller(_installerMethod)); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewPrefabMethod : SubContainerCreatorByNewPrefabDynamicContext + { + readonly Action _installerMethod; + + public SubContainerCreatorByNewPrefabMethod( + DiContainer container, IPrefabProvider prefabProvider, + GameObjectCreationParameters gameObjectBindInfo, + Action installerMethod) + : base(container, prefabProvider, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.IsEqual(args.Count, 1); + Assert.That(args[0].Type.DerivesFromOrEqual()); + + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + _installerMethod(subContainer, (TParam1)args[0].Value); + })); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewPrefabMethod : SubContainerCreatorByNewPrefabDynamicContext + { + readonly Action _installerMethod; + + public SubContainerCreatorByNewPrefabMethod( + DiContainer container, IPrefabProvider prefabProvider, + GameObjectCreationParameters gameObjectBindInfo, + Action installerMethod) + : base(container, prefabProvider, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.IsEqual(args.Count, 2); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + _installerMethod(subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value); + })); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewPrefabMethod : SubContainerCreatorByNewPrefabDynamicContext + { + readonly Action _installerMethod; + + public SubContainerCreatorByNewPrefabMethod( + DiContainer container, IPrefabProvider prefabProvider, + GameObjectCreationParameters gameObjectBindInfo, + Action installerMethod) + : base(container, prefabProvider, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.IsEqual(args.Count, 3); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + _installerMethod(subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value); + })); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewPrefabMethod : SubContainerCreatorByNewPrefabDynamicContext + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Action _installerMethod; + + public SubContainerCreatorByNewPrefabMethod( + DiContainer container, IPrefabProvider prefabProvider, + GameObjectCreationParameters gameObjectBindInfo, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + : base(container, prefabProvider, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.IsEqual(args.Count, 4); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + _installerMethod(subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value); + })); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewPrefabMethod : SubContainerCreatorByNewPrefabDynamicContext + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Action _installerMethod; + + public SubContainerCreatorByNewPrefabMethod( + DiContainer container, IPrefabProvider prefabProvider, + GameObjectCreationParameters gameObjectBindInfo, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + : base(container, prefabProvider, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.IsEqual(args.Count, 5); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + Assert.That(args[4].Type.DerivesFromOrEqual()); + + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + _installerMethod(subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value); + })); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewPrefabMethod : SubContainerCreatorByNewPrefabDynamicContext + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Action _installerMethod; + + public SubContainerCreatorByNewPrefabMethod( + DiContainer container, IPrefabProvider prefabProvider, + GameObjectCreationParameters gameObjectBindInfo, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + : base(container, prefabProvider, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.IsEqual(args.Count, 5); + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + Assert.That(args[4].Type.DerivesFromOrEqual()); + Assert.That(args[5].Type.DerivesFromOrEqual()); + + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + _installerMethod(subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value, + (TParam6)args[5].Value); + })); + } + } + + [NoReflectionBaking] + public class SubContainerCreatorByNewPrefabMethod : SubContainerCreatorByNewPrefabDynamicContext + { + readonly +#if !NET_4_6 + ModestTree.Util. +#endif + Action _installerMethod; + + public SubContainerCreatorByNewPrefabMethod( + DiContainer container, IPrefabProvider prefabProvider, + GameObjectCreationParameters gameObjectBindInfo, +#if !NET_4_6 + ModestTree.Util. +#endif + Action installerMethod) + : base(container, prefabProvider, gameObjectBindInfo) + { + _installerMethod = installerMethod; + } + + protected override void AddInstallers(List args, GameObjectContext context) + { + Assert.IsEqual(args.Count, 10); + + Assert.That(args[0].Type.DerivesFromOrEqual()); + Assert.That(args[1].Type.DerivesFromOrEqual()); + Assert.That(args[2].Type.DerivesFromOrEqual()); + Assert.That(args[3].Type.DerivesFromOrEqual()); + Assert.That(args[4].Type.DerivesFromOrEqual()); + Assert.That(args[5].Type.DerivesFromOrEqual()); + Assert.That(args[6].Type.DerivesFromOrEqual()); + Assert.That(args[7].Type.DerivesFromOrEqual()); + Assert.That(args[8].Type.DerivesFromOrEqual()); + Assert.That(args[9].Type.DerivesFromOrEqual()); + + context.AddNormalInstaller( + new ActionInstaller(subContainer => + { + _installerMethod(subContainer, + (TParam1)args[0].Value, + (TParam2)args[1].Value, + (TParam3)args[2].Value, + (TParam4)args[3].Value, + (TParam5)args[4].Value, + (TParam6)args[5].Value, + (TParam7)args[6].Value, + (TParam8)args[7].Value, + (TParam9)args[8].Value, + (TParam10)args[9].Value); + })); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefabDynamicContext.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefabDynamicContext.cs.meta new file mode 100644 index 0000000..7171fcb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefabDynamicContext.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 53f151c86cd3c4c46ada71b737004d36 +timeCreated: 1505722322 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefabWithParams.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefabWithParams.cs new file mode 100644 index 0000000..c8ca81e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefabWithParams.cs @@ -0,0 +1,114 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using Zenject.Internal; + +namespace Zenject +{ + [NoReflectionBaking] + public class SubContainerCreatorByNewPrefabWithParams : ISubContainerCreator + { + readonly DiContainer _container; + readonly IPrefabProvider _prefabProvider; + readonly Type _installerType; + readonly GameObjectCreationParameters _gameObjectBindInfo; + + public SubContainerCreatorByNewPrefabWithParams( + Type installerType, DiContainer container, IPrefabProvider prefabProvider, + GameObjectCreationParameters gameObjectBindInfo) + { + _gameObjectBindInfo = gameObjectBindInfo; + _prefabProvider = prefabProvider; + _container = container; + _installerType = installerType; + } + + protected DiContainer Container + { + get { return _container; } + } + + IEnumerable GetAllInjectableIncludingBaseTypes() + { + var info = TypeAnalyzer.GetInfo(_installerType); + + while (info != null) + { + foreach (var injectable in info.AllInjectables) + { + yield return injectable; + } + + info = info.BaseTypeInfo; + } + } + + DiContainer CreateTempContainer(List args) + { + var tempSubContainer = Container.CreateSubContainer(); + + var allInjectables = GetAllInjectableIncludingBaseTypes(); + + foreach (var argPair in args) + { + // We need to intelligently match on the exact parameters here to avoid the issue + // brought up in github issue #217 + var match = allInjectables + .Where(x => argPair.Type.DerivesFromOrEqual(x.MemberType)) + .OrderBy(x => ZenUtilInternal.GetInheritanceDelta(argPair.Type, x.MemberType)).FirstOrDefault(); + + Assert.That(match != null, + "Could not find match for argument type '{0}' when injecting into sub container installer '{1}'", + argPair.Type, _installerType); + + tempSubContainer.Bind(match.MemberType) + .FromInstance(argPair.Value).WhenInjectedInto(_installerType); + } + + return tempSubContainer; + } + + public DiContainer CreateSubContainer(List args, InjectContext parentContext, out Action injectAction) + { + Assert.That(!args.IsEmpty()); + + var prefab = _prefabProvider.GetPrefab(parentContext); + var tempContainer = CreateTempContainer(args); + + bool shouldMakeActive; + var gameObject = tempContainer.CreateAndParentPrefab( + prefab, _gameObjectBindInfo, null, out shouldMakeActive); + + var context = gameObject.GetComponent(); + + Assert.That(context != null, + "Expected prefab with name '{0}' to container a component of type 'GameObjectContext'", prefab.name); + + context.Install(tempContainer); + + injectAction = () => + { + // Note: We don't need to call ResolveRoots here because GameObjectContext does this for us + tempContainer.Inject(context); + + if (shouldMakeActive && !_container.IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif + { + gameObject.SetActive(true); + } + } + }; + + return context.Container; + } + } +} + +#endif + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefabWithParams.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefabWithParams.cs.meta new file mode 100644 index 0000000..5775ca9 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorByNewPrefabWithParams.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 07cb33e44f032a840a46b8b699927d0a +timeCreated: 1486859770 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorCached.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorCached.cs new file mode 100644 index 0000000..b099aae --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorCached.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class SubContainerCreatorCached : ISubContainerCreator + { + readonly ISubContainerCreator _subCreator; + +#if ZEN_MULTITHREADING + readonly object _locker = new object(); +#else + bool _isLookingUp; +#endif + DiContainer _subContainer; + + public SubContainerCreatorCached(ISubContainerCreator subCreator) + { + _subCreator = subCreator; + } + + public DiContainer CreateSubContainer(List args, InjectContext context, out Action injectAction) + { + // We can't really support arguments if we are using the cached value since + // the arguments might change when called after the first time + Assert.IsEmpty(args); + +#if ZEN_MULTITHREADING + lock (_locker) +#endif + { + if (_subContainer == null) + { +#if !ZEN_MULTITHREADING + Assert.That(!_isLookingUp, + "Found unresolvable circular dependency when looking up sub container! Object graph:\n {0}", context.GetObjectGraphString()); + _isLookingUp = true; +#endif + + _subContainer = _subCreator.CreateSubContainer( + new List(), context, out injectAction); + +#if !ZEN_MULTITHREADING + _isLookingUp = false; +#endif + + Assert.IsNotNull(_subContainer); + } + else + { + injectAction = null; + } + + return _subContainer; + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorCached.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorCached.cs.meta new file mode 100644 index 0000000..49db761 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorCached.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 64db75da3b9de56409556af4513979c2 +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorDynamicContext.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorDynamicContext.cs new file mode 100644 index 0000000..bc21317 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorDynamicContext.cs @@ -0,0 +1,62 @@ +#if !NOT_UNITY3D + +using System; +using System.Collections.Generic; +using UnityEngine; +using ModestTree; +using Zenject.Internal; + +namespace Zenject +{ + [NoReflectionBaking] + public abstract class SubContainerCreatorDynamicContext : ISubContainerCreator + { + readonly DiContainer _container; + + public SubContainerCreatorDynamicContext(DiContainer container) + { + _container = container; + } + + protected DiContainer Container + { + get { return _container; } + } + + public DiContainer CreateSubContainer( + List args, InjectContext parentContext, out Action injectAction) + { + bool shouldMakeActive; + var gameObj = CreateGameObject(parentContext, out shouldMakeActive); + + var context = gameObj.AddComponent(); + + AddInstallers(args, context); + + context.Install(_container); + + injectAction = () => + { + // Note: We don't need to call ResolveRoots here because GameObjectContext does this for us + _container.Inject(context); + + if (shouldMakeActive && !_container.IsValidating) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif + { + gameObj.SetActive(true); + } + } + }; + + return context.Container; + } + + protected abstract void AddInstallers(List args, GameObjectContext context); + protected abstract GameObject CreateGameObject(InjectContext context, out bool shouldMakeActive); + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorDynamicContext.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorDynamicContext.cs.meta new file mode 100644 index 0000000..b95f102 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorDynamicContext.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ba4736ebcee13cb4b9feca861072c740 +timeCreated: 1538467080 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorUtil.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorUtil.cs new file mode 100644 index 0000000..2e20a6a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorUtil.cs @@ -0,0 +1,43 @@ +using System; +using ModestTree; +#if !NOT_UNITY3D +using UnityEngine; +#endif + +namespace Zenject +{ + public static class SubContainerCreatorUtil + { + public static void ApplyBindSettings( + SubContainerCreatorBindInfo subContainerBindInfo, DiContainer subContainer) + { + if (subContainerBindInfo.CreateKernel) + { + var parentContainer = subContainer.ParentContainers.OnlyOrDefault(); + Assert.IsNotNull(parentContainer, "Could not find unique container when using WithKernel!"); + + if (subContainerBindInfo.KernelType != null) + { + parentContainer.Bind(typeof(Kernel).Interfaces()).To(subContainerBindInfo.KernelType) + .FromSubContainerResolve() + .ByInstance(subContainer).AsCached(); + subContainer.Bind(subContainerBindInfo.KernelType).AsCached(); + } + else + { + parentContainer.BindInterfacesTo().FromSubContainerResolve() + .ByInstance(subContainer).AsCached(); + subContainer.Bind().AsCached(); + } + +#if !NOT_UNITY3D + if (subContainerBindInfo.DefaultParentName != null) + { + DefaultGameObjectParentInstaller.Install( + subContainer, subContainerBindInfo.DefaultParentName); + } +#endif + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorUtil.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorUtil.cs.meta new file mode 100644 index 0000000..68c9cf4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerCreators/SubContainerCreatorUtil.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c07a01bd5fbd00d43a50854896a92472 +timeCreated: 1534923026 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerDependencyProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerDependencyProvider.cs new file mode 100644 index 0000000..f55d6e8 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerDependencyProvider.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class SubContainerDependencyProvider : IProvider + { + readonly ISubContainerCreator _subContainerCreator; + readonly Type _dependencyType; + readonly object _identifier; + readonly bool _resolveAll; + + // if concreteType is null we use the contract type from inject context + public SubContainerDependencyProvider( + Type dependencyType, + object identifier, + ISubContainerCreator subContainerCreator, bool resolveAll) + { + _subContainerCreator = subContainerCreator; + _dependencyType = dependencyType; + _identifier = identifier; + _resolveAll = resolveAll; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return false; } + } + + public Type GetInstanceType(InjectContext context) + { + return _dependencyType; + } + + InjectContext CreateSubContext( + InjectContext parent, DiContainer subContainer) + { + var subContext = parent.CreateSubContext(_dependencyType, _identifier); + + subContext.Container = subContainer; + + // This is important to avoid infinite loops + subContext.SourceType = InjectSources.Local; + + return subContext; + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsNotNull(context); + + var subContainer = _subContainerCreator.CreateSubContainer(args, context, out injectAction); + + var subContext = CreateSubContext(context, subContainer); + + if (_resolveAll) + { + subContainer.ResolveAll(subContext, buffer); + return; + } + + buffer.Add(subContainer.Resolve(subContext)); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerDependencyProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerDependencyProvider.cs.meta new file mode 100644 index 0000000..d742c32 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/SubContainerDependencyProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d569147915c61b64f9841ca4948f7d3f +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/TransientProvider.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/TransientProvider.cs new file mode 100644 index 0000000..998cbc6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/TransientProvider.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using Zenject.Internal; + +namespace Zenject +{ + [NoReflectionBaking] + public class TransientProvider : IProvider + { + readonly DiContainer _container; + readonly Type _concreteType; + readonly List _extraArguments; + readonly object _concreteIdentifier; + readonly Action _instantiateCallback; + + public TransientProvider( + Type concreteType, DiContainer container, + IEnumerable extraArguments, string bindingContext, + object concreteIdentifier, + Action instantiateCallback) + { + Assert.That(!concreteType.IsAbstract(), + "Expected non-abstract type for given binding but instead found type '{0}'{1}", + concreteType, bindingContext == null ? "" : " when binding '{0}'".Fmt(bindingContext)); + + _container = container; + _concreteType = concreteType; + _extraArguments = extraArguments.ToList(); + _concreteIdentifier = concreteIdentifier; + _instantiateCallback = instantiateCallback; + } + + public bool IsCached + { + get { return false; } + } + + public bool TypeVariesBasedOnMemberType + { + get { return _concreteType.IsOpenGenericType(); } + } + + public Type GetInstanceType(InjectContext context) + { + if (!_concreteType.DerivesFromOrEqual(context.MemberType)) + { + return null; + } + + return GetTypeToCreate(context.MemberType); + } + + public void GetAllInstancesWithInjectSplit( + InjectContext context, List args, out Action injectAction, List buffer) + { + Assert.IsNotNull(context); + + var instanceType = GetTypeToCreate(context.MemberType); + + var extraArgs = ZenPools.SpawnList(); + + extraArgs.AllocFreeAddRange(_extraArguments); + extraArgs.AllocFreeAddRange(args); + + var instance = _container.InstantiateExplicit(instanceType, false, extraArgs, context, _concreteIdentifier); + + injectAction = () => + { + _container.InjectExplicit( + instance, instanceType, extraArgs, context, _concreteIdentifier); + + Assert.That(extraArgs.Count == 0); + ZenPools.DespawnList(extraArgs); + + if (_instantiateCallback != null) + { + _instantiateCallback(context, instance); + } + }; + + buffer.Add(instance); + } + + Type GetTypeToCreate(Type contractType) + { + return ProviderUtil.GetTypeToInstantiate(contractType, _concreteType); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/TransientProvider.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/TransientProvider.cs.meta new file mode 100644 index 0000000..8cae4a0 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Providers/TransientProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 84c5bc61bc03f17468a1953edb7dcd42 +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime.meta new file mode 100644 index 0000000..df52aaf --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: fb9242e26ea385743abb8476b18d1e9f +folderAsset: yes +timeCreated: 1459463884 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces.meta new file mode 100644 index 0000000..84f10f4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 3c5ae8c1093da554d8bf77c912cc5433 +folderAsset: yes +timeCreated: 1487820668 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorIkHandlerManager.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorIkHandlerManager.cs new file mode 100644 index 0000000..2c42706 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorIkHandlerManager.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace Zenject +{ + public class AnimatorIkHandlerManager : MonoBehaviour + { + List _handlers; + + [Inject] + public void Construct( + // Use local to avoid inheriting handlers from a parent context + [Inject(Source = InjectSources.Local)] + List handlers) + { + _handlers = handlers; + } + + public void OnAnimatorIk() + { + foreach (var handler in _handlers) + { + handler.OnAnimatorIk(); + } + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorIkHandlerManager.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorIkHandlerManager.cs.meta new file mode 100644 index 0000000..0ce1485 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorIkHandlerManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 34ee2459debfb734d968c54ced01b9af +timeCreated: 1487820668 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorInstaller.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorInstaller.cs new file mode 100644 index 0000000..243a7bc --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorInstaller.cs @@ -0,0 +1,21 @@ +using UnityEngine; + +namespace Zenject +{ + public class AnimatorInstaller : Installer + { + readonly Animator _animator; + + public AnimatorInstaller(Animator animator) + { + _animator = animator; + } + + public override void InstallBindings() + { + Container.Bind().FromNewComponentOn(_animator.gameObject); + Container.Bind().FromNewComponentOn(_animator.gameObject); + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorInstaller.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorInstaller.cs.meta new file mode 100644 index 0000000..0d10d32 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorInstaller.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f4cbf7c6883911843ae4a64582422dda +timeCreated: 1487820669 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorMoveHandlerManager.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorMoveHandlerManager.cs new file mode 100644 index 0000000..4293e33 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorMoveHandlerManager.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace Zenject +{ + public class AnimatorMoveHandlerManager : MonoBehaviour + { + List _handlers; + + [Inject] + public void Construct( + // Use local to avoid inheriting handlers from a parent context + [Inject(Source = InjectSources.Local)] + List handlers) + { + _handlers = handlers; + } + + public void OnAnimatorMove() + { + foreach (var handler in _handlers) + { + handler.OnAnimatorMove(); + } + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorMoveHandlerManager.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorMoveHandlerManager.cs.meta new file mode 100644 index 0000000..bb25a90 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorMoveHandlerManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a07f8d298d010b34ca694d0d124b66d2 +timeCreated: 1487820669 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/IAnimatorIkHandler.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/IAnimatorIkHandler.cs new file mode 100644 index 0000000..f2e023c --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/IAnimatorIkHandler.cs @@ -0,0 +1,8 @@ +namespace Zenject +{ + public interface IAnimatorIkHandler + { + void OnAnimatorIk(); + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/IAnimatorIkHandler.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/IAnimatorIkHandler.cs.meta new file mode 100644 index 0000000..d73febb --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/IAnimatorIkHandler.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 510bfbdebf6be804b92145cf677898b9 +timeCreated: 1487820668 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/IAnimatorMoveHandler.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/IAnimatorMoveHandler.cs new file mode 100644 index 0000000..2f23f03 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/IAnimatorMoveHandler.cs @@ -0,0 +1,8 @@ +namespace Zenject +{ + public interface IAnimatorMoveHandler + { + void OnAnimatorMove(); + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/IAnimatorMoveHandler.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/IAnimatorMoveHandler.cs.meta new file mode 100644 index 0000000..5951ce4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/IAnimatorMoveHandler.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8e42d79e9a3ccae46b54d9b173778a17 +timeCreated: 1487820669 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/DisposableManager.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/DisposableManager.cs new file mode 100644 index 0000000..b561e73 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/DisposableManager.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using ModestTree.Util; + +namespace Zenject +{ + public class DisposableManager : IDisposable + { + readonly List _disposables = new List(); + readonly List _lateDisposables = new List(); + bool _disposed; + bool _lateDisposed; + + [Inject] + public DisposableManager( + [Inject(Optional = true, Source = InjectSources.Local)] + List disposables, + [Inject(Optional = true, Source = InjectSources.Local)] + List> priorities, + [Inject(Optional = true, Source = InjectSources.Local)] + List lateDisposables, + [Inject(Id = "Late", Optional = true, Source = InjectSources.Local)] + List> latePriorities) + { + foreach (var disposable in disposables) + { + // Note that we use zero for unspecified priority + // This is nice because you can use negative or positive for before/after unspecified + var match = priorities.Where(x => disposable.GetType().DerivesFromOrEqual(x.First)).Select(x => (int?)x.Second).SingleOrDefault(); + int priority = match.HasValue ? match.Value : 0; + + _disposables.Add(new DisposableInfo(disposable, priority)); + } + + foreach (var lateDisposable in lateDisposables) + { + var match = latePriorities.Where(x => lateDisposable.GetType().DerivesFromOrEqual(x.First)).Select(x => (int?)x.Second).SingleOrDefault(); + int priority = match.HasValue ? match.Value : 0; + + _lateDisposables.Add(new LateDisposableInfo(lateDisposable, priority)); + } + } + + public void Add(IDisposable disposable) + { + Add(disposable, 0); + } + + public void Add(IDisposable disposable, int priority) + { + _disposables.Add( + new DisposableInfo(disposable, priority)); + } + + public void AddLate(ILateDisposable disposable) + { + AddLate(disposable, 0); + } + + public void AddLate(ILateDisposable disposable, int priority) + { + _lateDisposables.Add( + new LateDisposableInfo(disposable, priority)); + } + + public void Remove(IDisposable disposable) + { + _disposables.RemoveWithConfirm( + _disposables.Where(x => ReferenceEquals(x.Disposable, disposable)).Single()); + } + + public void LateDispose() + { + Assert.That(!_lateDisposed, "Tried to late dispose DisposableManager twice!"); + _lateDisposed = true; + + // Dispose in the reverse order that they are initialized in + var disposablesOrdered = _lateDisposables.OrderBy(x => x.Priority).Reverse().ToList(); + +#if UNITY_EDITOR + foreach (var disposable in disposablesOrdered.Select(x => x.LateDisposable).GetDuplicates()) + { + Assert.That(false, "Found duplicate ILateDisposable with type '{0}'".Fmt(disposable.GetType())); + } +#endif + + foreach (var disposable in disposablesOrdered) + { + try + { + disposable.LateDisposable.LateDispose(); + } + catch (Exception e) + { + throw Assert.CreateException( + e, "Error occurred while late disposing ILateDisposable with type '{0}'", disposable.LateDisposable.GetType()); + } + } + } + + public void Dispose() + { + Assert.That(!_disposed, "Tried to dispose DisposableManager twice!"); + _disposed = true; + + // Dispose in the reverse order that they are initialized in + var disposablesOrdered = _disposables.OrderBy(x => x.Priority).Reverse().ToList(); + +#if UNITY_EDITOR + foreach (var disposable in disposablesOrdered.Select(x => x.Disposable).GetDuplicates()) + { + Assert.That(false, "Found duplicate IDisposable with type '{0}'".Fmt(disposable.GetType())); + } +#endif + + foreach (var disposable in disposablesOrdered) + { + try + { + disposable.Disposable.Dispose(); + } + catch (Exception e) + { + throw Assert.CreateException( + e, "Error occurred while disposing IDisposable with type '{0}'", disposable.Disposable.GetType()); + } + } + } + + struct DisposableInfo + { + public IDisposable Disposable; + public int Priority; + + public DisposableInfo(IDisposable disposable, int priority) + { + Disposable = disposable; + Priority = priority; + } + } + + class LateDisposableInfo + { + public ILateDisposable LateDisposable; + public int Priority; + + public LateDisposableInfo(ILateDisposable lateDisposable, int priority) + { + LateDisposable = lateDisposable; + Priority = priority; + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/DisposableManager.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/DisposableManager.cs.meta new file mode 100644 index 0000000..8498f86 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/DisposableManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e62fabfe4695e4a439003c1c1fd5d008 +timeCreated: 1461708054 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/GuiRenderableManager.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/GuiRenderableManager.cs new file mode 100644 index 0000000..71e13ea --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/GuiRenderableManager.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using ModestTree.Util; + +namespace Zenject +{ + // See comment in IGuiRenderable.cs for usage + public class GuiRenderableManager + { + List _renderables; + + public GuiRenderableManager( + [Inject(Optional = true, Source = InjectSources.Local)] + List renderables, + [Inject(Optional = true, Source = InjectSources.Local)] + List> priorities) + { + _renderables = new List(); + + foreach (var renderable in renderables) + { + // Note that we use zero for unspecified priority + // This is nice because you can use negative or positive for before/after unspecified + var matches = priorities + .Where(x => renderable.GetType().DerivesFromOrEqual(x.First)) + .Select(x => x.Second).ToList(); + + int priority = matches.IsEmpty() ? 0 : matches.Distinct().Single(); + + _renderables.Add( + new RenderableInfo(renderable, priority)); + } + + _renderables = _renderables.OrderBy(x => x.Priority).ToList(); + +#if UNITY_EDITOR + foreach (var renderable in _renderables.Select(x => x.Renderable).GetDuplicates()) + { + Assert.That(false, "Found duplicate IGuiRenderable with type '{0}'".Fmt(renderable.GetType())); + } +#endif + } + + public void OnGui() + { + foreach (var renderable in _renderables) + { + try + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.GuiRender()", renderable.Renderable.GetType())) +#endif + { + renderable.Renderable.GuiRender(); + } + } + catch (Exception e) + { + throw Assert.CreateException( + e, "Error occurred while calling {0}.GuiRender", renderable.Renderable.GetType()); + } + } + } + + class RenderableInfo + { + public IGuiRenderable Renderable; + public int Priority; + + public RenderableInfo(IGuiRenderable renderable, int priority) + { + Renderable = renderable; + Priority = priority; + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/GuiRenderableManager.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/GuiRenderableManager.cs.meta new file mode 100644 index 0000000..e1b9a00 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/GuiRenderableManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5ca4a43d84d9d554080d313280363783 +timeCreated: 1484528928 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/GuiRenderer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/GuiRenderer.cs new file mode 100644 index 0000000..3e86cff --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/GuiRenderer.cs @@ -0,0 +1,20 @@ +using UnityEngine; + +namespace Zenject +{ + public class GuiRenderer : MonoBehaviour + { + GuiRenderableManager _renderableManager; + + [Inject] + void Construct(GuiRenderableManager renderableManager) + { + _renderableManager = renderableManager; + } + + public void OnGUI() + { + _renderableManager.OnGui(); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/GuiRenderer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/GuiRenderer.cs.meta new file mode 100644 index 0000000..da876cd --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/GuiRenderer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d6ee197c5aed3b048b76b82a9be3d094 +timeCreated: 1484530704 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: -9995 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/InitializableManager.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/InitializableManager.cs new file mode 100644 index 0000000..680b2c7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/InitializableManager.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using ModestTree.Util; + +namespace Zenject +{ + // Responsibilities: + // - Run Initialize() on all Iinitializable's, in the order specified by InitPriority + public class InitializableManager + { + List _initializables; + + protected bool _hasInitialized; + + [Inject] + public InitializableManager( + [Inject(Optional = true, Source = InjectSources.Local)] + List initializables, + [Inject(Optional = true, Source = InjectSources.Local)] + List> priorities) + { + _initializables = new List(); + + for (int i = 0; i < initializables.Count; i++) + { + var initializable = initializables[i]; + + // Note that we use zero for unspecified priority + // This is nice because you can use negative or positive for before/after unspecified + var matches = priorities.Where(x => initializable.GetType().DerivesFromOrEqual(x.First)).Select(x => x.Second).ToList(); + int priority = matches.IsEmpty() ? 0 : matches.Distinct().Single(); + + _initializables.Add(new InitializableInfo(initializable, priority)); + } + } + + public void Add(IInitializable initializable) + { + Add(initializable, 0); + } + + public void Add(IInitializable initializable, int priority) + { + Assert.That(!_hasInitialized); + _initializables.Add( + new InitializableInfo(initializable, priority)); + } + + public void Initialize() + { + Assert.That(!_hasInitialized); + _hasInitialized = true; + + _initializables = _initializables.OrderBy(x => x.Priority).ToList(); + +#if UNITY_EDITOR + foreach (var initializable in _initializables.Select(x => x.Initializable).GetDuplicates()) + { + Assert.That(false, "Found duplicate IInitializable with type '{0}'".Fmt(initializable.GetType())); + } +#endif + + foreach (var initializable in _initializables) + { + try + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.Initialize()", initializable.Initializable.GetType())) +#endif + { + initializable.Initializable.Initialize(); + } + } + catch (Exception e) + { + throw Assert.CreateException( + e, "Error occurred while initializing IInitializable with type '{0}'", initializable.Initializable.GetType()); + } + } + } + + class InitializableInfo + { + public IInitializable Initializable; + public int Priority; + + public InitializableInfo(IInitializable initializable, int priority) + { + Initializable = initializable; + Priority = priority; + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/InitializableManager.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/InitializableManager.cs.meta new file mode 100644 index 0000000..1b005e7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/InitializableManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8e5838132ef34e14ea93d2e3b30b7140 +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels.meta new file mode 100644 index 0000000..db4891b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 605550c45d7550e498dfe6968192459d +folderAsset: yes +timeCreated: 1462650136 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/DecoratableMonoKernel.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/DecoratableMonoKernel.cs new file mode 100644 index 0000000..b96d050 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/DecoratableMonoKernel.cs @@ -0,0 +1,73 @@ +namespace Zenject +{ + public interface IDecoratableMonoKernel + { + bool ShouldInitializeOnStart(); + void Initialize(); + void Update(); + void FixedUpdate(); + void LateUpdate(); + void Dispose(); + void LateDispose(); + } + + public class DecoratableMonoKernel : IDecoratableMonoKernel + { + [InjectLocal] + public TickableManager TickableManager { get; protected set; } = null; + + [InjectLocal] + public InitializableManager InitializableManager { get; protected set; } = null; + + [InjectLocal] + public DisposableManager DisposablesManager { get; protected set; } = null; + + + public virtual bool ShouldInitializeOnStart() => true; + + public virtual void Initialize() + { + InitializableManager.Initialize(); + } + + public void Update() + { + TickableManager.Update(); + } + + public void FixedUpdate() + { + TickableManager.FixedUpdate(); + } + + public void LateUpdate() + { + TickableManager.LateUpdate(); + } + + public void Dispose() + { + DisposablesManager.Dispose(); + } + + public void LateDispose() + { + DisposablesManager.LateDispose(); + } + } + + public abstract class BaseMonoKernelDecorator : IDecoratableMonoKernel + { + [Inject] + protected IDecoratableMonoKernel DecoratedMonoKernel; + + public virtual bool ShouldInitializeOnStart() => DecoratedMonoKernel.ShouldInitializeOnStart(); + public virtual void Initialize() => DecoratedMonoKernel.Initialize(); + public virtual void Update() => DecoratedMonoKernel.Update(); + public virtual void FixedUpdate() => DecoratedMonoKernel.FixedUpdate(); + public virtual void LateUpdate() => DecoratedMonoKernel.LateUpdate(); + public virtual void Dispose() => DecoratedMonoKernel.Dispose(); + public virtual void LateDispose() => DecoratedMonoKernel.LateDispose(); + } + +} \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/DecoratableMonoKernel.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/DecoratableMonoKernel.cs.meta new file mode 100644 index 0000000..9045b03 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/DecoratableMonoKernel.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f054684b4d0f44a1904823270ae3f137 +timeCreated: 1587868417 \ No newline at end of file diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/DefaultGameObjectKernel.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/DefaultGameObjectKernel.cs new file mode 100644 index 0000000..f2f7863 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/DefaultGameObjectKernel.cs @@ -0,0 +1,10 @@ +#if !NOT_UNITY3D + +namespace Zenject +{ + public class DefaultGameObjectKernel : MonoKernel + { + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/DefaultGameObjectKernel.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/DefaultGameObjectKernel.cs.meta new file mode 100644 index 0000000..c9fa1f2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/DefaultGameObjectKernel.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1c47912ae4e51a84d92f1acf689997c8 +timeCreated: 1461708048 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: -9996 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/Kernel.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/Kernel.cs new file mode 100644 index 0000000..c1e305a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/Kernel.cs @@ -0,0 +1,48 @@ +using System; +using System.Diagnostics; + +namespace Zenject +{ + [DebuggerStepThrough] + public class Kernel : IInitializable, IDisposable, ITickable, ILateTickable, IFixedTickable, ILateDisposable + { + [InjectLocal] + TickableManager _tickableManager = null; + + [InjectLocal] + InitializableManager _initializableManager = null; + + [InjectLocal] + DisposableManager _disposablesManager = null; + + public virtual void Initialize() + { + _initializableManager.Initialize(); + } + + public virtual void Dispose() + { + _disposablesManager.Dispose(); + } + + public virtual void LateDispose() + { + _disposablesManager.LateDispose(); + } + + public virtual void Tick() + { + _tickableManager.Update(); + } + + public virtual void LateTick() + { + _tickableManager.LateUpdate(); + } + + public virtual void FixedTick() + { + _tickableManager.FixedUpdate(); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/Kernel.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/Kernel.cs.meta new file mode 100644 index 0000000..530ef1a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/Kernel.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8a25347f1a9a6b544b4ef8b643824a6f +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/MonoKernel.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/MonoKernel.cs new file mode 100644 index 0000000..8d40dbc --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/MonoKernel.cs @@ -0,0 +1,130 @@ +#if !NOT_UNITY3D + +#pragma warning disable 649 + +using ModestTree; +using UnityEngine; +using UnityEngine.Analytics; + +namespace Zenject +{ + public abstract class MonoKernel : MonoBehaviour + { + [InjectLocal] + TickableManager _tickableManager = null; + + [InjectLocal] + InitializableManager _initializableManager = null; + + [InjectLocal] + DisposableManager _disposablesManager = null; + + [InjectOptional] + private IDecoratableMonoKernel decoratableMonoKernel; + + bool _hasInitialized; + bool _isDestroyed; + + protected bool IsDestroyed + { + get { return _isDestroyed; } + } + + public virtual void Start() + { + if (decoratableMonoKernel?.ShouldInitializeOnStart()??true) + { + Initialize(); + } + } + + public void Initialize() + { + // We don't put this in start in case Start is overridden + if (!_hasInitialized) + { + _hasInitialized = true; + + if (decoratableMonoKernel != null) + { + decoratableMonoKernel.Initialize(); + } + else + { + _initializableManager.Initialize(); + } + } + } + + public virtual void Update() + { + // Don't spam the log every frame if initialization fails and leaves it as null + if (_tickableManager != null) + { + if (decoratableMonoKernel != null) + { + decoratableMonoKernel.Update(); + } + else + { + _tickableManager.Update(); + } + } + } + + public virtual void FixedUpdate() + { + // Don't spam the log every frame if initialization fails and leaves it as null + if (_tickableManager != null) + { + if (decoratableMonoKernel != null) + { + decoratableMonoKernel.FixedUpdate(); + } + else + { + _tickableManager.FixedUpdate(); + } + } + } + + public virtual void LateUpdate() + { + // Don't spam the log every frame if initialization fails and leaves it as null + if (_tickableManager != null) + { + if (decoratableMonoKernel != null) + { + decoratableMonoKernel.LateUpdate(); + } + else + { + _tickableManager.LateUpdate(); + } + } + } + + public virtual void OnDestroy() + { + // _disposablesManager can be null if we get destroyed before the Start event + if (_disposablesManager != null) + { + Assert.That(!_isDestroyed); + _isDestroyed = true; + + if (decoratableMonoKernel != null) + { + decoratableMonoKernel.Dispose(); + decoratableMonoKernel.LateDispose(); + } + else + { + _disposablesManager.Dispose(); + _disposablesManager.LateDispose(); + } + } + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/MonoKernel.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/MonoKernel.cs.meta new file mode 100644 index 0000000..12e5b67 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/MonoKernel.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0ed09ac17d1c3ca44b8064ce22ebba27 +timeCreated: 1461708048 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/ProjectKernel.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/ProjectKernel.cs new file mode 100644 index 0000000..6db9c0b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/ProjectKernel.cs @@ -0,0 +1,87 @@ +#if !NOT_UNITY3D + +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using UnityEngine.SceneManagement; + +namespace Zenject +{ + public class ProjectKernel : MonoKernel + { + [Inject] + ZenjectSettings _settings = null; + + [Inject] + SceneContextRegistry _contextRegistry = null; + + // One issue with relying on MonoKernel.OnDestroy to call IDisposable.Dispose + // is that the order that OnDestroy is called in is difficult to predict + // One good thing is that it does follow the heirarchy order (so root game objects + // will have thier OnDestroy called before child objects) + // However, the order that OnDestroy is called for the root game objects themselves + // is largely random + // Within an individual scene, this can be helped somewhat by placing all game objects + // underneath the SceneContext and then also checking the 'ParentNewObjectsUnderRoot' + // property to ensure any new game objects will also be parented underneath SceneContext + // By doing this, we can be guaranteed to have any bound IDisposable's have their + // Dispose called before any game object is destroyed in the scene + // However, when using multiple scenes (each with their own SceneContext) the order + // that these SceneContext game objects are destroyed is random + // So to address that, we explicitly call GameObject.DestroyImmediate for all + // SceneContext's in the reverse order that the scenes were loaded in below + // (this works because OnApplicationQuit is always called before OnDestroy) + // Note that this only works when stopping the app and not when changing scenes + // When changing scenes, if you have multiple scenes loaded at once, you will have to + // manually unload the scenes in the reverse order they were loaded before going to + // the new scene, if you require a predictable destruction order. Or you can always use + // ZenjectSceneLoader which will do this for you + public void OnApplicationQuit() + { + if (_settings.EnsureDeterministicDestructionOrderOnApplicationQuit) + { + DestroyEverythingInOrder(); + } + } + + public void DestroyEverythingInOrder() + { + ForceUnloadAllScenes(true); + + // Destroy project context after all scenes + Assert.That(!IsDestroyed); + DestroyImmediate(gameObject); + Assert.That(IsDestroyed); + } + + public void ForceUnloadAllScenes(bool immediate = false) + { + // OnApplicationQuit should always be called before OnDestroy + // (Unless it is destroyed manually) + Assert.That(!IsDestroyed); + + var sceneOrder = new List(); + + for (int i = 0; i < SceneManager.sceneCount; i++) + { + sceneOrder.Add(SceneManager.GetSceneAt(i)); + } + + // Destroy the scene contexts from bottom to top + // Since this is the reverse order that they were loaded in + foreach (var sceneContext in _contextRegistry.SceneContexts.OrderByDescending(x => sceneOrder.IndexOf(x.gameObject.scene)).ToList()) + { + if (immediate) + { + DestroyImmediate(sceneContext.gameObject); + } + else + { + Destroy(sceneContext.gameObject); + } + } + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/ProjectKernel.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/ProjectKernel.cs.meta new file mode 100644 index 0000000..0cb8da1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/ProjectKernel.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 374b2cd725ea28a46a6377959bb73c9c +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: -9998 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/SceneKernel.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/SceneKernel.cs new file mode 100644 index 0000000..19705b1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/SceneKernel.cs @@ -0,0 +1,21 @@ +#if !NOT_UNITY3D + +using ModestTree; + +namespace Zenject +{ + public class SceneKernel : MonoKernel + { + // Only needed to set "script execution order" in unity project settings + +#if ZEN_INTERNAL_PROFILING + public override void Start() + { + base.Start(); + Log.Info("SceneContext.Awake detailed profiling: {0}", ProfileTimers.FormatResults()); + } +#endif + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/SceneKernel.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/SceneKernel.cs.meta new file mode 100644 index 0000000..778fa0d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/Kernels/SceneKernel.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: aff38aaefd39d0d41a92c2707718d15c +timeCreated: 1461708052 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: -9997 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/PoolableManager.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/PoolableManager.cs new file mode 100644 index 0000000..ea8a169 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/PoolableManager.cs @@ -0,0 +1,485 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using ModestTree.Util; + +namespace Zenject +{ + public class PoolableManager + { + readonly List _poolables; + + bool _isSpawned; + + public PoolableManager( + [InjectLocal] + List poolables, + [Inject(Optional = true, Source = InjectSources.Local)] + List> priorities) + { + _poolables = poolables.Select(x => CreatePoolableInfo(x, priorities)) + .OrderBy(x => x.Priority).Select(x => x.Poolable).ToList(); + } + + PoolableInfo CreatePoolableInfo(IPoolable poolable, List> priorities) + { + var match = priorities.Where(x => poolable.GetType().DerivesFromOrEqual(x.First)).Select(x => (int?)(x.Second)).SingleOrDefault(); + int priority = match.HasValue ? match.Value : 0; + + return new PoolableInfo(poolable, priority); + } + + public void TriggerOnSpawned() + { + Assert.That(!_isSpawned); + _isSpawned = true; + + for (int i = 0; i < _poolables.Count; i++) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.OnSpawned", _poolables[i].GetType())) +#endif + { + _poolables[i].OnSpawned(); + } + } + } + + public void TriggerOnDespawned() + { + Assert.That(_isSpawned); + _isSpawned = false; + + // Call OnDespawned in the reverse order just like how dispose works + for (int i = _poolables.Count - 1; i >= 0; i--) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.OnDespawned", _poolables[i].GetType())) +#endif + { + _poolables[i].OnDespawned(); + } + } + } + + struct PoolableInfo + { + public IPoolable Poolable; + public int Priority; + + public PoolableInfo(IPoolable poolable, int priority) + { + Poolable = poolable; + Priority = priority; + } + } + } + + /// + /// A modified version of PoolableManager that adds a generic argument, allowing + /// the passing of a parameter to all IPoolable objects in the container. + /// + public class PoolableManager + { + readonly List> _poolables; + + bool _isSpawned; + + public PoolableManager( + [InjectLocal] + List> poolables, + [Inject(Optional = true, Source = InjectSources.Local)] + List> priorities) + { + _poolables = poolables.Select(x => CreatePoolableInfo(x, priorities)) + .OrderBy(x => x.Priority).Select(x => x.Poolable).ToList(); + } + + PoolableInfo CreatePoolableInfo(IPoolable poolable, List> priorities) + { + var match = priorities.Where(x => poolable.GetType().DerivesFromOrEqual(x.First)).Select(x => (int?)(x.Second)).SingleOrDefault(); + int priority = match.HasValue ? match.Value : 0; + + return new PoolableInfo(poolable, priority); + } + + public void TriggerOnSpawned(T param) + { + Assert.That(!_isSpawned); + _isSpawned = true; + + for (int i = 0; i < _poolables.Count; i++) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.OnSpawned", _poolables[i].GetType())) +#endif + { + _poolables[i].OnSpawned(param); + } + } + } + + public void TriggerOnDespawned() + { + Assert.That(_isSpawned); + _isSpawned = false; + + // Call OnDespawned in the reverse order just like how dispose works + for (int i = _poolables.Count - 1; i >= 0; i--) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.OnDespawned", _poolables[i].GetType())) +#endif + { + _poolables[i].OnDespawned(); + } + } + } + + struct PoolableInfo + { + public IPoolable Poolable; + public int Priority; + + public PoolableInfo(IPoolable poolable, int priority) + { + Poolable = poolable; + Priority = priority; + } + } + } + + /// + /// A modified version of PoolableManager that adds a generic argument, allowing + /// the passing of a parameter to all IPoolable objects in the container. + /// + public class PoolableManager + { + readonly List> _poolables; + + bool _isSpawned; + + public PoolableManager( + [InjectLocal] + List> poolables, + [Inject(Optional = true, Source = InjectSources.Local)] + List> priorities) + { + _poolables = poolables.Select(x => CreatePoolableInfo(x, priorities)) + .OrderBy(x => x.Priority).Select(x => x.Poolable).ToList(); + } + + PoolableInfo CreatePoolableInfo(IPoolable poolable, List> priorities) + { + var match = priorities.Where(x => poolable.GetType().DerivesFromOrEqual(x.First)).Select(x => (int?)(x.Second)).SingleOrDefault(); + int priority = match.HasValue ? match.Value : 0; + + return new PoolableInfo(poolable, priority); + } + + public void TriggerOnSpawned(T1 p1, T2 p2) + { + Assert.That(!_isSpawned); + _isSpawned = true; + + for (int i = 0; i < _poolables.Count; i++) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.OnSpawned", _poolables[i].GetType())) +#endif + { + _poolables[i].OnSpawned(p1, p2); + } + } + } + + public void TriggerOnDespawned() + { + Assert.That(_isSpawned); + _isSpawned = false; + + // Call OnDespawned in the reverse order just like how dispose works + for (int i = _poolables.Count - 1; i >= 0; i--) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.OnDespawned", _poolables[i].GetType())) +#endif + { + _poolables[i].OnDespawned(); + } + } + } + + struct PoolableInfo + { + public IPoolable Poolable; + public int Priority; + + public PoolableInfo(IPoolable poolable, int priority) + { + Poolable = poolable; + Priority = priority; + } + } + } + + /// + /// A modified version of PoolableManager that adds a generic argument, allowing + /// the passing of a parameter to all IPoolable objects in the container. + /// + public class PoolableManager + { + readonly List> _poolables; + + bool _isSpawned; + + public PoolableManager( + [InjectLocal] + List> poolables, + [Inject(Optional = true, Source = InjectSources.Local)] + List> priorities) + { + _poolables = poolables.Select(x => CreatePoolableInfo(x, priorities)) + .OrderBy(x => x.Priority).Select(x => x.Poolable).ToList(); + } + + PoolableInfo CreatePoolableInfo(IPoolable poolable, List> priorities) + { + var match = priorities.Where(x => poolable.GetType().DerivesFromOrEqual(x.First)).Select(x => (int?)(x.Second)).SingleOrDefault(); + int priority = match.HasValue ? match.Value : 0; + + return new PoolableInfo(poolable, priority); + } + + public void TriggerOnSpawned(T1 p1, T2 p2, T3 p3) + { + Assert.That(!_isSpawned); + _isSpawned = true; + + for (int i = 0; i < _poolables.Count; i++) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.OnSpawned", _poolables[i].GetType())) +#endif + { + _poolables[i].OnSpawned(p1, p2, p3); + } + } + } + + public void TriggerOnDespawned() + { + Assert.That(_isSpawned); + _isSpawned = false; + + // Call OnDespawned in the reverse order just like how dispose works + for (int i = _poolables.Count - 1; i >= 0; i--) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.OnDespawned", _poolables[i].GetType())) +#endif + { + _poolables[i].OnDespawned(); + } + } + } + + struct PoolableInfo + { + public IPoolable Poolable; + public int Priority; + + public PoolableInfo(IPoolable poolable, int priority) + { + Poolable = poolable; + Priority = priority; + } + } + } + + /// + /// A modified version of PoolableManager that adds a generic argument, allowing + /// the passing of a parameter to all IPoolable objects in the container. + /// + public class PoolableManager + { + readonly List> _poolables; + + bool _isSpawned; + + public PoolableManager( + [InjectLocal] + List> poolables, + [Inject(Optional = true, Source = InjectSources.Local)] + List> priorities) + { + _poolables = poolables.Select(x => CreatePoolableInfo(x, priorities)) + .OrderBy(x => x.Priority).Select(x => x.Poolable).ToList(); + } + + PoolableInfo CreatePoolableInfo(IPoolable poolable, List> priorities) + { + var match = priorities.Where(x => poolable.GetType().DerivesFromOrEqual(x.First)).Select(x => (int?)(x.Second)).SingleOrDefault(); + int priority = match.HasValue ? match.Value : 0; + + return new PoolableInfo(poolable, priority); + } + + public void TriggerOnSpawned(T1 p1, T2 p2, T3 p3, T4 p4) + { + Assert.That(!_isSpawned); + _isSpawned = true; + + for (int i = 0; i < _poolables.Count; i++) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.OnSpawned", _poolables[i].GetType())) +#endif + { + _poolables[i].OnSpawned(p1, p2, p3, p4); + } + } + } + + public void TriggerOnDespawned() + { + Assert.That(_isSpawned); + _isSpawned = false; + + // Call OnDespawned in the reverse order just like how dispose works + for (int i = _poolables.Count - 1; i >= 0; i--) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.OnDespawned", _poolables[i].GetType())) +#endif + { + _poolables[i].OnDespawned(); + } + } + } + + struct PoolableInfo + { + public IPoolable Poolable; + public int Priority; + + public PoolableInfo(IPoolable poolable, int priority) + { + Poolable = poolable; + Priority = priority; + } + } + } + + + /// + /// A modified version of PoolableManager that adds a generic argument, allowing + /// the passing of a parameter to all IPoolable objects in the container. + /// + public class PoolableManager + { + readonly List> _poolables; + + bool _isSpawned; + + public PoolableManager( + [InjectLocal] + List> poolables, + [Inject(Optional = true, Source = InjectSources.Local)] + List> priorities) + { + _poolables = poolables.Select(x => CreatePoolableInfo(x, priorities)) + .OrderBy(x => x.Priority).Select(x => x.Poolable).ToList(); + } + + PoolableInfo CreatePoolableInfo(IPoolable poolable, List> priorities) + { + var match = priorities.Where(x => poolable.GetType().DerivesFromOrEqual(x.First)).Select(x => (int?)(x.Second)).SingleOrDefault(); + int priority = match.HasValue ? match.Value : 0; + + return new PoolableInfo(poolable, priority); + } + + public void TriggerOnSpawned(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5) + { + Assert.That(!_isSpawned); + _isSpawned = true; + + for (int i = 0; i < _poolables.Count; i++) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.OnSpawned", _poolables[i].GetType())) +#endif + { + _poolables[i].OnSpawned(p1, p2, p3, p4, p5); + } + } + } + + public void TriggerOnDespawned() + { + Assert.That(_isSpawned); + _isSpawned = false; + + // Call OnDespawned in the reverse order just like how dispose works + for (int i = _poolables.Count - 1; i >= 0; i--) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.OnDespawned", _poolables[i].GetType())) +#endif + { + _poolables[i].OnDespawned(); + } + } + } + + struct PoolableInfo + { + public IPoolable Poolable; + public int Priority; + + public PoolableInfo(IPoolable poolable, int priority) + { + Poolable = poolable; + Priority = priority; + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/PoolableManager.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/PoolableManager.cs.meta new file mode 100644 index 0000000..260c863 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/PoolableManager.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: aef2cb2ede47a96439cbb34a8935111a +timeCreated: 1528650779 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/SceneContextRegistry.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/SceneContextRegistry.cs new file mode 100644 index 0000000..a40a033 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/SceneContextRegistry.cs @@ -0,0 +1,94 @@ +using System.Collections.Generic; +using ModestTree; +using UnityEngine.SceneManagement; + +namespace Zenject +{ + public class SceneContextRegistry + { + readonly Dictionary _map = new Dictionary(); + + public IEnumerable SceneContexts + { + get { return _map.Values; } + } + + public void Add(SceneContext context) + { + Assert.That(!_map.ContainsKey(context.gameObject.scene)); + _map.Add(context.gameObject.scene, context); + } + + public SceneContext GetSceneContextForScene(string name) + { + var scene = SceneManager.GetSceneByName(name); + Assert.That(scene.IsValid(), "Could not find scene with name '{0}'", name); + return GetSceneContextForScene(scene); + } + + public SceneContext GetSceneContextForScene(Scene scene) + { + return _map[scene]; + } + + public SceneContext TryGetSceneContextForScene(string name) + { + var scene = SceneManager.GetSceneByName(name); + Assert.That(scene.IsValid(), "Could not find scene with name '{0}'", name); + return TryGetSceneContextForScene(scene); + } + + public SceneContext TryGetSceneContextForScene(Scene scene) + { + SceneContext context; + + if (_map.TryGetValue(scene, out context)) + { + return context; + } + + return null; + } + + public DiContainer GetContainerForScene(Scene scene) + { + var container = TryGetContainerForScene(scene); + + if (container != null) + { + return container; + } + + throw Assert.CreateException( + "Unable to find DiContainer for scene '{0}'", scene.name); + } + + public DiContainer TryGetContainerForScene(Scene scene) + { + if (scene == ProjectContext.Instance.gameObject.scene) + { + return ProjectContext.Instance.Container; + } + + var sceneContext = TryGetSceneContextForScene(scene); + + if (sceneContext != null) + { + return sceneContext.Container; + } + + return null; + } + + public void Remove(SceneContext context) + { + bool removed = _map.Remove(context.gameObject.scene); + + if (!removed) + { + Log.Warn("Failed to remove SceneContext from SceneContextRegistry"); + } + } + } + +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/SceneContextRegistry.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/SceneContextRegistry.cs.meta new file mode 100644 index 0000000..2687659 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/SceneContextRegistry.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 11e438b2dc7552349949f24c14de14be +timeCreated: 1510660712 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/SceneContextRegistryAdderAndRemover.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/SceneContextRegistryAdderAndRemover.cs new file mode 100644 index 0000000..faafa65 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/SceneContextRegistryAdderAndRemover.cs @@ -0,0 +1,29 @@ +using System; + +namespace Zenject +{ + public class SceneContextRegistryAdderAndRemover : IInitializable, IDisposable + { + readonly SceneContextRegistry _registry; + readonly SceneContext _sceneContext; + + public SceneContextRegistryAdderAndRemover( + SceneContext sceneContext, + SceneContextRegistry registry) + { + _registry = registry; + _sceneContext = sceneContext; + } + + public void Initialize() + { + _registry.Add(_sceneContext); + } + + public void Dispose() + { + _registry.Remove(_sceneContext); + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/SceneContextRegistryAdderAndRemover.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/SceneContextRegistryAdderAndRemover.cs.meta new file mode 100644 index 0000000..a384bc7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/SceneContextRegistryAdderAndRemover.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b13656f05675c384181e749264e6bcf9 +timeCreated: 1510660712 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/TaskUpdater.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/TaskUpdater.cs new file mode 100644 index 0000000..cfb7f53 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/TaskUpdater.cs @@ -0,0 +1,194 @@ +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using ModestTree; + +namespace Zenject +{ + // Update tasks once per frame based on a priority + [DebuggerStepThrough] + public abstract class TaskUpdater + { + readonly LinkedList _tasks = new LinkedList(); + readonly List _queuedTasks = new List(); + + IEnumerable AllTasks + { + get { return ActiveTasks.Concat(_queuedTasks); } + } + + IEnumerable ActiveTasks + { + get { return _tasks; } + } + + public void AddTask(TTask task, int priority) + { + AddTaskInternal(task, priority); + } + + void AddTaskInternal(TTask task, int priority) + { + Assert.That(!AllTasks.Select(x => x.Task).ContainsItem(task), + "Duplicate task added to DependencyRoot with name '" + task.GetType().FullName + "'"); + + // Wait until next frame to add the task, otherwise whether it gets updated + // on the current frame depends on where in the update order it was added + // from, so you might get off by one frame issues + _queuedTasks.Add(new TaskInfo(task, priority)); + } + + public void RemoveTask(TTask task) + { + var info = AllTasks.Where(x => ReferenceEquals(x.Task, task)).SingleOrDefault(); + + Assert.IsNotNull(info, "Tried to remove a task not added to DependencyRoot, task = " + task.GetType().Name); + + Assert.That(!info.IsRemoved, "Tried to remove task twice, task = " + task.GetType().Name); + info.IsRemoved = true; + } + + public void OnFrameStart() + { + // See above comment + AddQueuedTasks(); + } + + public void UpdateAll() + { + UpdateRange(int.MinValue, int.MaxValue); + } + + public void UpdateRange(int minPriority, int maxPriority) + { + var node = _tasks.First; + + while (node != null) + { + var next = node.Next; + var taskInfo = node.Value; + + // Make sure that tasks with priority of int.MaxValue are updated when maxPriority is int.MaxValue + if (!taskInfo.IsRemoved && taskInfo.Priority >= minPriority + && (maxPriority == int.MaxValue || taskInfo.Priority < maxPriority)) + { + UpdateItem(taskInfo.Task); + } + + node = next; + } + + ClearRemovedTasks(_tasks); + } + + void ClearRemovedTasks(LinkedList tasks) + { + var node = tasks.First; + + while (node != null) + { + var next = node.Next; + var info = node.Value; + + if (info.IsRemoved) + { + //ModestTree.Log.Debug("Removed task '" + info.Task.GetType().ToString() + "'"); + tasks.Remove(node); + } + + node = next; + } + } + + void AddQueuedTasks() + { + for (int i = 0; i < _queuedTasks.Count; i++) + { + var task = _queuedTasks[i]; + + if (!task.IsRemoved) + { + InsertTaskSorted(task); + } + } + _queuedTasks.Clear(); + } + + void InsertTaskSorted(TaskInfo task) + { + for (var current = _tasks.First; current != null; current = current.Next) + { + if (current.Value.Priority > task.Priority) + { + _tasks.AddBefore(current, task); + return; + } + } + + _tasks.AddLast(task); + } + + protected abstract void UpdateItem(TTask task); + + class TaskInfo + { + public TTask Task; + public int Priority; + public bool IsRemoved; + + public TaskInfo(TTask task, int priority) + { + Task = task; + Priority = priority; + } + } + } + + public class TickablesTaskUpdater : TaskUpdater + { + protected override void UpdateItem(ITickable task) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.Tick()", task.GetType())) +#endif + { + task.Tick(); + } + } + } + + public class LateTickablesTaskUpdater : TaskUpdater + { + protected override void UpdateItem(ILateTickable task) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.LateTick()", task.GetType())) +#endif + { + task.LateTick(); + } + } + } + + public class FixedTickablesTaskUpdater : TaskUpdater + { + protected override void UpdateItem(IFixedTickable task) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("User Code")) +#endif +#if UNITY_EDITOR + using (ProfileBlock.Start("{0}.FixedTick()", task.GetType())) +#endif + { + task.FixedTick(); + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/TaskUpdater.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/TaskUpdater.cs.meta new file mode 100644 index 0000000..34c7ea7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/TaskUpdater.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4e52124c243adb44aaf26eed3a8413c8 +timeCreated: 1461708050 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/TickableManager.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/TickableManager.cs new file mode 100644 index 0000000..72474d7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/TickableManager.cs @@ -0,0 +1,232 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using ModestTree.Util; +#if ZEN_SIGNALS_ADD_UNIRX +using UniRx; +#endif + +namespace Zenject +{ + public class TickableManager + { + [Inject(Optional = true, Source = InjectSources.Local)] + readonly List _tickables = null; + + [Inject(Optional = true, Source = InjectSources.Local)] + readonly List _fixedTickables = null; + + [Inject(Optional = true, Source = InjectSources.Local)] + readonly List _lateTickables = null; + + [Inject(Optional = true, Source = InjectSources.Local)] + readonly List> _priorities = null; + + [Inject(Optional = true, Id = "Fixed", Source = InjectSources.Local)] + readonly List> _fixedPriorities = null; + + [Inject(Optional = true, Id = "Late", Source = InjectSources.Local)] + readonly List> _latePriorities = null; + +#if ZEN_SIGNALS_ADD_UNIRX + readonly Subject _tickStream = new Subject(); + readonly Subject _lateTickStream = new Subject(); + readonly Subject _fixedTickStream = new Subject(); +#endif + + readonly TickablesTaskUpdater _updater = new TickablesTaskUpdater(); + readonly FixedTickablesTaskUpdater _fixedUpdater = new FixedTickablesTaskUpdater(); + readonly LateTickablesTaskUpdater _lateUpdater = new LateTickablesTaskUpdater(); + + bool _isPaused; + + [Inject] + public TickableManager() + { + } + +#if ZEN_SIGNALS_ADD_UNIRX + public IObservable TickStream + { + get { return _tickStream; } + } + + public IObservable LateTickStream + { + get { return _lateTickStream; } + } + + public IObservable FixedTickStream + { + get { return _fixedTickStream; } + } +#endif + + public IEnumerable Tickables + { + get { return _tickables; } + } + + public bool IsPaused + { + get { return _isPaused; } + set { _isPaused = value; } + } + + [Inject] + public void Initialize() + { + InitTickables(); + InitFixedTickables(); + InitLateTickables(); + } + + void InitFixedTickables() + { + foreach (var type in _fixedPriorities.Select(x => x.First)) + { + Assert.That(type.DerivesFrom(), + "Expected type '{0}' to drive from IFixedTickable while checking priorities in TickableHandler", type); + } + + foreach (var tickable in _fixedTickables) + { + // Note that we use zero for unspecified priority + // This is nice because you can use negative or positive for before/after unspecified + var matches = _fixedPriorities.Where(x => tickable.GetType().DerivesFromOrEqual(x.First)).Select(x => x.Second).ToList(); + int priority = matches.IsEmpty() ? 0 : matches.Distinct().Single(); + + _fixedUpdater.AddTask(tickable, priority); + } + } + + void InitTickables() + { + foreach (var type in _priorities.Select(x => x.First)) + { + Assert.That(type.DerivesFrom(), + "Expected type '{0}' to drive from ITickable while checking priorities in TickableHandler", type); + } + + foreach (var tickable in _tickables) + { + // Note that we use zero for unspecified priority + // This is nice because you can use negative or positive for before/after unspecified + var matches = _priorities.Where(x => tickable.GetType().DerivesFromOrEqual(x.First)).Select(x => x.Second).ToList(); + int priority = matches.IsEmpty() ? 0 : matches.Distinct().Single(); + + _updater.AddTask(tickable, priority); + } + } + + void InitLateTickables() + { + foreach (var type in _latePriorities.Select(x => x.First)) + { + Assert.That(type.DerivesFrom(), + "Expected type '{0}' to drive from ILateTickable while checking priorities in TickableHandler", type); + } + + foreach (var tickable in _lateTickables) + { + // Note that we use zero for unspecified priority + // This is nice because you can use negative or positive for before/after unspecified + var matches = _latePriorities.Where(x => tickable.GetType().DerivesFromOrEqual(x.First)).Select(x => x.Second).ToList(); + int priority = matches.IsEmpty() ? 0 : matches.Distinct().Single(); + + _lateUpdater.AddTask(tickable, priority); + } + } + + public void Add(ITickable tickable, int priority) + { + _updater.AddTask(tickable, priority); + } + + public void Add(ITickable tickable) + { + Add(tickable, 0); + } + + public void AddLate(ILateTickable tickable, int priority) + { + _lateUpdater.AddTask(tickable, priority); + } + + public void AddLate(ILateTickable tickable) + { + AddLate(tickable, 0); + } + + public void AddFixed(IFixedTickable tickable, int priority) + { + _fixedUpdater.AddTask(tickable, priority); + } + + public void AddFixed(IFixedTickable tickable) + { + _fixedUpdater.AddTask(tickable, 0); + } + + public void Remove(ITickable tickable) + { + _updater.RemoveTask(tickable); + } + + public void RemoveLate(ILateTickable tickable) + { + _lateUpdater.RemoveTask(tickable); + } + + public void RemoveFixed(IFixedTickable tickable) + { + _fixedUpdater.RemoveTask(tickable); + } + + public void Update() + { + if(IsPaused) + { + return; + } + + _updater.OnFrameStart(); + _updater.UpdateAll(); + +#if ZEN_SIGNALS_ADD_UNIRX + _tickStream.OnNext(Unit.Default); +#endif + } + + public void FixedUpdate() + { + if(IsPaused) + { + return; + } + + _fixedUpdater.OnFrameStart(); + _fixedUpdater.UpdateAll(); + +#if ZEN_SIGNALS_ADD_UNIRX + _fixedTickStream.OnNext(Unit.Default); +#endif + } + + public void LateUpdate() + { + if(IsPaused) + { + return; + } + + _lateUpdater.OnFrameStart(); + _lateUpdater.UpdateAll(); + +#if ZEN_SIGNALS_ADD_UNIRX + _lateTickStream.OnNext(Unit.Default); +#endif + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/TickableManager.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/TickableManager.cs.meta new file mode 100644 index 0000000..6e56bb7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Runtime/TickableManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2fa54cf0e36bd194faa8f877e9f699a4 +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage.meta new file mode 100644 index 0000000..d8fcd31 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a5896143fdd47624ebc6ddd933f1ed1b +folderAsset: yes +timeCreated: 1427464099 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage/Zenject-usage.dll b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage/Zenject-usage.dll new file mode 100644 index 0000000..e974d3f Binary files /dev/null and b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage/Zenject-usage.dll differ diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage/Zenject-usage.dll.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage/Zenject-usage.dll.meta new file mode 100644 index 0000000..952e216 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage/Zenject-usage.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 700aed094b237904eb96e963264dd6ff +timeCreated: 1527419737 +licenseType: Store +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage/link.xml b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage/link.xml new file mode 100644 index 0000000..39175d1 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage/link.xml @@ -0,0 +1,3 @@ + + + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage/link.xml.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage/link.xml.meta new file mode 100644 index 0000000..166058b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Usage/link.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 78cde942f7000eb41900aa4d3c9249d7 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util.meta new file mode 100644 index 0000000..0054272 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 3f550a9d7385fce4e9bc4a0e5fa52daf +folderAsset: yes +DefaultImporter: + userData: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ActionInstaller.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ActionInstaller.cs new file mode 100644 index 0000000..4386b7e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ActionInstaller.cs @@ -0,0 +1,19 @@ +using System; + +namespace Zenject +{ + public class ActionInstaller : Installer + { + readonly Action _installMethod; + + public ActionInstaller(Action installMethod) + { + _installMethod = installMethod; + } + + public override void InstallBindings() + { + _installMethod(Container); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ActionInstaller.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ActionInstaller.cs.meta new file mode 100644 index 0000000..22e61ac --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ActionInstaller.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e182a0b67fa936e40bebc0dc2f28743a +timeCreated: 1476911606 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/CheatSheet.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/CheatSheet.cs new file mode 100644 index 0000000..3af1cd4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/CheatSheet.cs @@ -0,0 +1,438 @@ +using System.Linq; +using ModestTree; +using UnityEngine; + +#pragma warning disable 219 + +namespace Zenject +{ + public class CheatSheet : Installer + { + public override void InstallBindings() + { + // Create a new instance of Foo for every class that asks for it + Container.Bind().AsTransient(); + + // Create a new instance of Foo for every class that asks for an IFoo + Container.Bind().To().AsTransient(); + + // Non generic version of the above + Container.Bind(typeof(IFoo)).To(typeof(Foo)).AsTransient(); + + ///////////// AsSingle + + // Create one definitive instance of Foo and re-use that for every class that asks for it + Container.Bind().AsSingle(); + + // Create one definitive instance of Foo and re-use that for every class that asks for IFoo + Container.Bind().To().AsSingle(); + + // Bind the same instance to multiple types + // In this example, the same instance of Foo will be used for all three types + // (we have to use the non-generic version of Bind when mapping to multiple types) + Container.Bind(typeof(Foo), typeof(IFoo), typeof(IFoo2)).To().AsSingle(); + + ///////////// BindInterfaces + + // This will have the exact same effect as the above line + // Bind all interfaces that Foo implements and Foo itself to a new singleton of type Foo + Container.BindInterfacesAndSelfTo().AsSingle(); + + // Bind only the interfaces that Foo implements to an instance of Foo + // This can be useful if you don't want any classes to directly reference the concrete + // derived type + Container.BindInterfacesTo().AsSingle(); + + ///////////// FromInstance + + // Use the given instance everywhere that Foo is used + // Note that in this case there's no good reason to use FromInstance + Container.Bind().FromInstance(new Foo()); + + // This is simply a shortcut for the above binding + // This can be a bit nicer since the type argument can be deduced from the parameter + Container.BindInstance(new Foo()); + + // Bind multiple instances at once + Container.BindInstances(new Foo(), new Bar()); + + ///////////// Binding primitive types + + // BindInstance is more commonly used with primitive types + // Use the number 10 every time an int is requested + Container.Bind().FromInstance(10); + Container.Bind().FromInstance(false); + + // Or equivalently: + Container.BindInstance(10); + Container.BindInstance(false); + + // You'd never really want to do the above though - you should almost always use a When condition for primitive values + Container.BindInstance(10).WhenInjectedInto(); + + ///////////// FromMethod + + // Create instance of Foo when requested, using the given method + // Note that for more complex construction scenarios, you might consider using a factory + // instead with FromFactory + Container.Bind().FromMethod(GetFoo); + + // Randomly return one of several different implementations of IFoo + // We use Instantiate here instead of just new so that Foo1 gets its members injected + Container.Bind().FromMethod(GetRandomFoo); + + // You an also use an anonymouse delegate directly + Container.Bind().FromMethod(ctx => new Foo()); + + // This is equivalent to AsTransient + Container.Bind().FromMethod(ctx => ctx.Container.Instantiate()); + + InstallMore(); + } + + Foo GetFoo(InjectContext ctx) + { + return new Foo(); + } + + IFoo GetRandomFoo(InjectContext ctx) + { + switch (Random.Range(0, 3)) + { + case 0: + { + return ctx.Container.Instantiate(); + } + case 1: + { + return ctx.Container.Instantiate(); + } + } + + return ctx.Container.Instantiate(); + } + + void InstallMore() + { + ///////////// FromResolveGetter + + // Bind to a property on another dependency + // This can be helpful to reduce coupling between classes + Container.Bind().AsSingle(); + + Container.Bind().FromResolveGetter(foo => foo.GetBar()); + + // Another example using values + Container.Bind().FromResolveGetter(foo => foo.GetTitle()); + + ///////////// FromNewComponentOnNewGameObject + + // Create a new game object at the root of the scene and add the Foo MonoBehaviour to it + Container.Bind().FromNewComponentOnNewGameObject().AsSingle(); + + // You can also specify the game object name to use using WithGameObjectName + Container.Bind().FromNewComponentOnNewGameObject().WithGameObjectName("Foo1").AsSingle(); + + // Bind to an interface instead + Container.Bind().To().FromNewComponentOnNewGameObject().AsSingle(); + + ///////////// FromComponentInNewPrefab (singleton) + + // Create a new game object at the root of the scene using the given prefab + // After zenject creates a new GameObject from the given prefab, it will + // search the prefab for a component of type 'Foo' and return that + GameObject prefab = null; + Container.Bind().FromComponentInNewPrefab(prefab).AsSingle(); + + // Bind to interface instead + Container.Bind().To().FromComponentInNewPrefab(prefab).AsSingle(); + + // You can also add multiple components + // Note here that only one instance of the given prefab will be + // created + // For this to work, there must be both a Foo MonoBehaviour and + // a Bar MonoBehaviour somewhere on the prefab + Container.Bind(typeof(Foo), typeof(Bar)).FromComponentInNewPrefab(prefab).AsSingle(); + + ///////////// FromComponentInNewPrefab (Transient) + + // Instantiate a new copy of 'prefab' every time an instance of Foo is + // requested by a constructor parameter, injected field, etc. + Container.Bind().FromComponentInNewPrefab(prefab).AsTransient(); + + // Bind to interface instead + Container.Bind().To().FromComponentInNewPrefab(prefab); + + ///////////// Identifiers + + // Bind a globally accessible string with the name 'PlayerName' + // Note however that a better option might be to create a Settings object and bind + // that instead + Container.Bind().WithId("PlayerName").FromInstance("name of the player"); + + // This is the equivalent of the line above, and is a bit more readable + Container.BindInstance("name of the player").WithId("PlayerName"); + + // We can also use IDs to bind multiple instances of the same type: + Container.BindInstance("foo").WithId("FooA"); + Container.BindInstance("asdf").WithId("FooB"); + + InstallMore2(); + } + + // Then when we inject these dependencies we have to use the same ID: + public class Norf + { + [Inject(Id = "FooA")] + public string Foo; + } + + public class Qux + { + [Inject(Id = "FooB")] + public string Foo; + } + + public void InstallMore2() + { + ///////////// AsCached + + // In this example, we bind three instances of Foo, including one without an ID + // We have to use AsCached here because Foo is not a singleton, but we also + // do not want a new Foo created every time like AsTransient + // This will result in a maximum of 3 instances of Foo + Container.Bind().AsCached(); + Container.Bind().WithId("FooA").AsCached(); + Container.Bind().WithId("FooA").AsCached(); + + InstallMore3(); + } + + // When an ID is unspecified in an [Inject] field, it will use the first + // instance + // Bindings without IDs can therefore be used as a default and we can + // specify IDs for specific versions of the same type + public class Norf2 + { + [Inject] + public Foo Foo; + } + + // Qux2._foo will be the same instance as Norf2._foo + // This is because we are using AsCached rather than AsTransient + public class Qux2 + { + [Inject] + public Foo Foo; + + [Inject(Id = "FooA")] + public Foo Foo2; + } + + public void InstallMore3() + { + ///////////// Conditions + + // This will make Foo only visible to Bar + // If we add Foo to the constructor of any other class it won't find it + Container.Bind().AsSingle().WhenInjectedInto(); + + // Use different implementations of IFoo dependending on which + // class is being injected + Container.Bind().To().AsSingle().WhenInjectedInto(); + Container.Bind().To().AsSingle().WhenInjectedInto(); + + // Use "Foo1" as the default implementation except when injecting into + // class Qux, in which case use Foo2 + // This works because if there is a condition match, that takes precedence + Container.Bind().To().AsSingle(); + Container.Bind().To().AsSingle().WhenInjectedInto(); + + // Allow depending on Foo in only a few select classes + Container.Bind().AsSingle().WhenInjectedInto(typeof(Bar), typeof(Qux), typeof(Baz)); + + // Supply "my game" for any strings that are injected into the Gui class with the identifier "Title" + Container.BindInstance("my game").WithId("Title").WhenInjectedInto(); + + // Supply 5 for all ints that are injected into the Gui class + Container.BindInstance(5).WhenInjectedInto(); + + // Supply 5 for all ints that are injected into a parameter or field + // inside type Gui that is named 'width' + // Note that this is usually not a good idea since the name of a field can change + // easily and break the binding but shown here as an example of a more complex + // condition + Container.BindInstance(5.0f).When(ctx => + ctx.ObjectType == typeof(Gui) && ctx.MemberName == "width"); + + // Create a new 'Foo' for every class that is created as part of the + // construction of the 'Bar' class + // So if Bar has a constructor parameter of type Qux, and Qux has + // a constructor parameter of type IFoo, a new Foo will be created + // for that case + Container.Bind().To().AsTransient().When( + ctx => ctx.AllObjectTypes.Contains(typeof(Bar))); + + ///////////// Complex conditions example + + var foo1 = new Foo(); + var foo2 = new Foo(); + + Container.Bind().WithId("Bar1").AsCached(); + Container.Bind().WithId("Bar2").AsCached(); + + // Here we use the 'ParentContexts' property of inject context to sync multiple corresponding identifiers + Container.BindInstance(foo1).When(c => c.ParentContexts.Where(x => x.MemberType == typeof(Bar) && Equals(x.Identifier, "Bar1")).Any()); + Container.BindInstance(foo2).When(c => c.ParentContexts.Where(x => x.MemberType == typeof(Bar) && Equals(x.Identifier, "Bar2")).Any()); + + // This results in: + Assert.That(Container.ResolveId("Bar1").Foo == foo1); + Assert.That(Container.ResolveId("Bar2").Foo == foo2); + + ///////////// FromResolve + + // FromResolve does another lookup on the container + // This will result in IBar, IFoo, and Foo, all being bound to the same instance of + // Foo which is assume to exist somewhere on the given prefab + GameObject fooPrefab = null; + Container.Bind().FromComponentInNewPrefab(fooPrefab).AsSingle(); + Container.Bind().To().FromResolve(); + Container.Bind().To().FromResolve(); + + // This will result in the same behaviour as the above + Container.Bind(typeof(Foo), typeof(IBar), typeof(IFoo)).To().FromComponentInNewPrefab(fooPrefab).AsSingle(); + + InstallMore4(); + } + + public class FooInstaller : Installer + { + public FooInstaller(string foo) + { + } + + public override void InstallBindings() + { + } + } + + public class FooInstallerWithArgs : Installer + { + public FooInstallerWithArgs(string foo) + { + } + + public override void InstallBindings() + { + } + } + + void InstallMore4() + { + ///////////// Installing Other Installers + + // Immediately call InstallBindings() on FooInstaller + FooInstaller.Install(Container); + + // Before calling FooInstaller, configure a property of it + Container.BindInstance("foo").WhenInjectedInto(); + FooInstaller.Install(Container); + + // The arguments can also be added to the Installer<> generic arguments to make them + // strongly typed + FooInstallerWithArgs.Install(Container, "foo"); + + ///////////// Manual Use of Container + + // This will fill in any parameters marked as [Inject] and also call any [Inject] methods + var foo = new Foo(); + Container.Inject(foo); + + // Return an instance for IFoo, using the bindings that have been added previously + // Internally it is what is triggered when you fill in a constructor parameter of type IFoo + // Note: It will throw an exception if it cannot find a match + Container.Resolve(); + + // Same as the above except returns null when it can't find the given type + Container.TryResolve(); + + // Return a list of 2 instances of type Foo + // Note that in this case simply calling Resolve will trigger an exception + Container.BindInstance(new Foo()); + Container.BindInstance(new Foo()); + var foos = Container.ResolveAll(); + + // Create a new instance of Foo and inject on any of its members + // And fill in any constructor parameters Foo might have + Container.Instantiate(); + + GameObject prefab1 = null; + GameObject prefab2 = null; + + // Instantiate a new prefab and have any injectables filled in on the prefab + GameObject go = Container.InstantiatePrefab(prefab1); + + // Instantiate a new prefab and return a specific monobehaviour + Foo foo2 = Container.InstantiatePrefabForComponent(prefab2); + + // Add a new component to an existing game object + Foo foo3 = Container.InstantiateComponent(go); + } + + public interface IFoo2 + { + } + + public interface IFoo + { + } + + public interface IBar : IFoo + { + } + + public class Foo : MonoBehaviour, IFoo, IFoo2, IBar + { + public Bar GetBar() + { + return new Bar(); + } + + public string GetTitle() + { + return "title"; + } + } + + public class Foo1 : IFoo + { + } + + public class Foo2 : IFoo + { + } + + public class Foo3 : IFoo + { + } + + public class Baz + { + } + + public class Gui + { + } + + public class Bar : IBar + { + public Foo Foo + { + get + { + return null; + } + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/CheatSheet.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/CheatSheet.cs.meta new file mode 100644 index 0000000..c862367 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/CheatSheet.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1d2fc6db101e75248ab98ad463a99ffa +timeCreated: 1528895686 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/DefaultGameObjectParentInstaller.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/DefaultGameObjectParentInstaller.cs new file mode 100644 index 0000000..3be76fa --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/DefaultGameObjectParentInstaller.cs @@ -0,0 +1,53 @@ +#if !NOT_UNITY3D + +using System; +using UnityEngine; + +namespace Zenject +{ + public class DefaultGameObjectParentInstaller : Installer + { + readonly string _name; + + public DefaultGameObjectParentInstaller(string name) + { + _name = name; + } + + public override void InstallBindings() + { +#if !ZEN_TESTS_OUTSIDE_UNITY + var defaultParent = new GameObject(_name); + + defaultParent.transform.SetParent( + Container.InheritedDefaultParent, false); + + Container.DefaultParent = defaultParent.transform; + + Container.Bind() + .To().AsCached().WithArguments(defaultParent); + + // Always destroy the default parent last so that the non-monobehaviours get a chance + // to clean it up if they want to first + Container.BindDisposableExecutionOrder(int.MinValue); +#endif + } + + class DefaultParentObjectDestroyer : IDisposable + { + readonly GameObject _gameObject; + + public DefaultParentObjectDestroyer(GameObject gameObject) + { + _gameObject = gameObject; + } + + public void Dispose() + { + GameObject.Destroy(_gameObject); + } + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/DefaultGameObjectParentInstaller.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/DefaultGameObjectParentInstaller.cs.meta new file mode 100644 index 0000000..527de7f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/DefaultGameObjectParentInstaller.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: dd79d0a4f0b28314cbd6701ff5ab9062 +timeCreated: 1538629352 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/DisposeBlock.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/DisposeBlock.cs new file mode 100644 index 0000000..3b4c534 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/DisposeBlock.cs @@ -0,0 +1,186 @@ +using System; +using System.Collections.Generic; +using ModestTree; + +namespace Zenject +{ + [NoReflectionBaking] + public class DisposeBlock : IDisposable + { + static readonly StaticMemoryPool _pool = + new StaticMemoryPool(OnSpawned, OnDespawned); + + List _disposables; + List _objectPoolPairs; + + static void OnSpawned(DisposeBlock that) + { + Assert.IsNull(that._disposables); + Assert.IsNull(that._objectPoolPairs); + } + + static void OnDespawned(DisposeBlock that) + { + if (that._disposables != null) + { + // Dispose in reverse order since usually that makes the most sense + for (int i = that._disposables.Count - 1; i >= 0; i--) + { + that._disposables[i].Dispose(); + } + ListPool.Instance.Despawn(that._disposables); + that._disposables = null; + } + + if (that._objectPoolPairs != null) + { + // Dispose in reverse order since usually that makes the most sense + for (int i = that._objectPoolPairs.Count - 1; i >= 0; i--) + { + var pair = that._objectPoolPairs[i]; + pair.Pool.Despawn(pair.Object); + } + ListPool.Instance.Despawn(that._objectPoolPairs); + that._objectPoolPairs = null; + } + } + + void LazyInitializeDisposableList() + { + if (_disposables == null) + { + _disposables = ListPool.Instance.Spawn(); + } + } + + public void AddRange(IList disposables) + where T : IDisposable + { + LazyInitializeDisposableList(); + for (int i = 0; i < disposables.Count; i++) + { + _disposables.Add(disposables[i]); + } + } + + public void Add(IDisposable disposable) + { + LazyInitializeDisposableList(); + Assert.That(!_disposables.Contains(disposable)); + _disposables.Add(disposable); + } + + public void Remove(IDisposable disposable) + { + Assert.IsNotNull(_disposables); + _disposables.RemoveWithConfirm(disposable); + } + + void StoreSpawnedObject(T obj, IDespawnableMemoryPool pool) + { + if (typeof(T).DerivesFrom()) + { + Add((IDisposable)obj); + } + else + { + // This allocation is ok because it's a struct + var pair = new SpawnedObjectPoolPair + { + Pool = pool, + Object = obj + }; + + if (_objectPoolPairs == null) + { + _objectPoolPairs = ListPool.Instance.Spawn(); + } + _objectPoolPairs.Add(pair); + } + } + + public T Spawn(IMemoryPool pool) + { + var obj = pool.Spawn(); + StoreSpawnedObject(obj, pool); + return obj; + } + + public TValue Spawn(IMemoryPool pool, TParam1 p1) + { + var obj = pool.Spawn(p1); + StoreSpawnedObject(obj, pool); + return obj; + } + + public TValue Spawn(IMemoryPool pool, TParam1 p1, TParam2 p2) + { + var obj = pool.Spawn(p1, p2); + StoreSpawnedObject(obj, pool); + return obj; + } + + public TValue Spawn(IMemoryPool pool, TParam1 p1, TParam2 p2, TParam3 p3) + { + var obj = pool.Spawn(p1, p2, p3); + StoreSpawnedObject(obj, pool); + return obj; + } + + public TValue Spawn(IMemoryPool pool, TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4) + { + var obj = pool.Spawn(p1, p2, p3, p4); + StoreSpawnedObject(obj, pool); + return obj; + } + + public TValue Spawn(IMemoryPool pool, TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5) + { + var obj = pool.Spawn(p1, p2, p3, p4, p5); + StoreSpawnedObject(obj, pool); + return obj; + } + + public TValue Spawn(IMemoryPool pool, TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6) + { + var obj = pool.Spawn(p1, p2, p3, p4, p5, p6); + StoreSpawnedObject(obj, pool); + return obj; + } + + public TValue Spawn(IMemoryPool pool, TParam1 p1, TParam2 p2, TParam3 p3, TParam4 p4, TParam5 p5, TParam6 p6, TParam7 p7) + { + var obj = pool.Spawn(p1, p2, p3, p4, p5, p6, p7); + StoreSpawnedObject(obj, pool); + return obj; + } + + public List SpawnList(IEnumerable elements) + { + var list = SpawnList(); + list.AddRange(elements); + return list; + } + + public List SpawnList() + { + return Spawn(ListPool.Instance); + } + + public static DisposeBlock Spawn() + { + return _pool.Spawn(); + } + + public void Dispose() + { + _pool.Despawn(this); + } + + struct SpawnedObjectPoolPair + { + public IMemoryPool Pool; + public object Object; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/DisposeBlock.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/DisposeBlock.cs.meta new file mode 100644 index 0000000..867cdc4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/DisposeBlock.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 031fb76cf466ade4baf3269c39c146bd +timeCreated: 1519832826 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ExecutionOrderInstaller.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ExecutionOrderInstaller.cs new file mode 100644 index 0000000..c298dc5 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ExecutionOrderInstaller.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; + +namespace Zenject +{ + public class ExecutionOrderInstaller : Installer, ExecutionOrderInstaller> + { + List _typeOrder; + + public ExecutionOrderInstaller(List typeOrder) + { + _typeOrder = typeOrder; + } + + public override void InstallBindings() + { + // All tickables without explicit priorities assigned are given order of zero, + // so put all of these before that (ie. negative) + int order = -1 * _typeOrder.Count; + + foreach (var type in _typeOrder) + { + Container.BindExecutionOrder(type, order); + order++; + } + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ExecutionOrderInstaller.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ExecutionOrderInstaller.cs.meta new file mode 100644 index 0000000..26b6078 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ExecutionOrderInstaller.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cad41a65c3c0b0f46a659557b2d716e0 +timeCreated: 1461708053 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ProfileBlock.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ProfileBlock.cs new file mode 100644 index 0000000..ed5ba3a --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ProfileBlock.cs @@ -0,0 +1,210 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using ModestTree; +#if UNITY_EDITOR +using UnityEngine.Profiling; +using System.Threading; +#endif + +namespace Zenject +{ + [NoReflectionBaking] + public class ProfileBlock : IDisposable + { +#if UNITY_EDITOR + static int _blockCount; + static ProfileBlock _instance = new ProfileBlock(); + static Dictionary _nameCache = new Dictionary(); + + ProfileBlock() + { + } + + public static Thread UnityMainThread + { + get; set; + } + + public static Regex ProfilePattern + { + get; + set; + } + + static int GetHashCode(object p1, object p2) + { + unchecked // Overflow is fine, just wrap + { + int hash = 17; + hash = hash * 29 + p1.GetHashCode(); + hash = hash * 29 + p2.GetHashCode(); + return hash; + } + } + + static int GetHashCode(object p1, object p2, object p3) + { + unchecked // Overflow is fine, just wrap + { + int hash = 17; + hash = hash * 29 + p1.GetHashCode(); + hash = hash * 29 + p2.GetHashCode(); + hash = hash * 29 + p3.GetHashCode(); + return hash; + } + } + + public static ProfileBlock Start(string sampleNameFormat, object obj1, object obj2) + { +#if ZEN_TESTS_OUTSIDE_UNITY + return null; +#else + if (UnityMainThread == null + || !UnityMainThread.Equals(Thread.CurrentThread)) + { + return null; + } + + if (!Profiler.enabled) + { + return null; + } + + // We need to ensure that we do not have per-frame allocations in ProfileBlock + // to avoid infecting the test too much, so use a cache of formatted strings given + // the input values + // This only works if the input values do not change per frame + var hash = GetHashCode(sampleNameFormat, obj1, obj2); + + string formatString; + + if (!_nameCache.TryGetValue(hash, out formatString)) + { + formatString = string.Format(sampleNameFormat, obj1, obj2); + _nameCache.Add(hash, formatString); + } + + return StartInternal(formatString); +#endif + } + + public static ProfileBlock Start(string sampleNameFormat, object obj) + { +#if ZEN_TESTS_OUTSIDE_UNITY + return null; +#else + if (UnityMainThread == null + || !UnityMainThread.Equals(Thread.CurrentThread)) + { + return null; + } + + if (!Profiler.enabled) + { + return null; + } + + // We need to ensure that we do not have per-frame allocations in ProfileBlock + // to avoid infecting the test too much, so use a cache of formatted strings given + // the input values + // This only works if the input values do not change per frame + var hash = GetHashCode(sampleNameFormat, obj); + + string formatString; + + if (!_nameCache.TryGetValue(hash, out formatString)) + { + formatString = string.Format(sampleNameFormat, obj); + _nameCache.Add(hash, formatString); + } + + return StartInternal(formatString); +#endif + } + + public static ProfileBlock Start(string sampleName) + { +#if ZEN_TESTS_OUTSIDE_UNITY + return null; +#else + if (UnityMainThread == null + || !UnityMainThread.Equals(Thread.CurrentThread)) + { + return null; + } + + if (!Profiler.enabled) + { + return null; + } + + return StartInternal(sampleName); +#endif + } + + static ProfileBlock StartInternal(string sampleName) + { + Assert.That(Profiler.enabled); + + if (ProfilePattern == null || ProfilePattern.Match(sampleName).Success) + { + Profiler.BeginSample(sampleName); + _blockCount++; + return _instance; + } + + return null; + } + + public void Dispose() + { + _blockCount--; + Assert.That(_blockCount >= 0); + Profiler.EndSample(); + } + +#else + ProfileBlock(string sampleName, bool rootBlock) + { + } + + ProfileBlock(string sampleName) + : this(sampleName, false) + { + } + + public static Regex ProfilePattern + { + get; + set; + } + + public static ProfileBlock Start() + { + return null; + } + + public static ProfileBlock Start(string sampleNameFormat, object obj1, object obj2) + { + return null; + } + + // Remove the call completely for builds + public static ProfileBlock Start(string sampleNameFormat, object obj) + { + return null; + } + + // Remove the call completely for builds + public static ProfileBlock Start(string sampleName) + { + return null; + } + + public void Dispose() + { + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ProfileBlock.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ProfileBlock.cs.meta new file mode 100644 index 0000000..f5a5ba6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ProfileBlock.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 952433523e6a6e445adc4ac7e2086e7d +timeCreated: 1485104137 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ProfileTimers.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ProfileTimers.cs new file mode 100644 index 0000000..ccd79ea --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ProfileTimers.cs @@ -0,0 +1,168 @@ +#if ZEN_INTERNAL_PROFILING + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using ModestTree; + +namespace Zenject +{ + // Similar to ProfileBlock except used for measuring speed of zenject specifically + // And does not use unity's profiler + public static class ProfileTimers + { + static Dictionary _timers = new Dictionary(); + + public static void ResetAll() + { + foreach (var timer in _timers.Values) + { + timer.Reset(); + } + } + + public static string FormatResults() + { + var result = new StringBuilder(); + + // Uncomment if you only want to see zenject related info + //var timers = _timers.Where(x => x.Key != "User Code"); + var timers = _timers; + + var total = timers.Select(x => x.Value.TotalMilliseconds).Sum(); + + result.Append("Total time tracked: {0:0.00} ms. Details:".Fmt(total)); + + foreach (var pair in timers.OrderByDescending(x => x.Value.TotalMilliseconds)) + { + var time = pair.Value.TotalMilliseconds; + var percent = 100.0 * (time / total); + var name = pair.Key; + + result.Append("\n {0:00.0}% ({1:00000}x) ({2:0000} ms) {3}".Fmt(percent, pair.Value.CallCount, time, name)); + } + + return result.ToString(); + } + + public static double GetTimerElapsedMilliseconds(string name) + { + return _timers[name].TotalMilliseconds; + } + + public static IDisposable CreateTimedBlock(string name) + { + TimerInfo timer; + + if (!_timers.TryGetValue(name, out timer)) + { + timer = new TimerInfo(); + _timers.Add(name, timer); + } + + timer.CallCount++; + + if (timer.IsRunning) + { + return null; + } + + return TimedBlock.Pool.Spawn(timer); + } + + class TimedBlock : IDisposable + { + public static StaticMemoryPool Pool = + new StaticMemoryPool(OnSpawned, OnDespawned); + + readonly List _pausedTimers = new List(); + + TimerInfo _exclusiveTimer; + + static void OnSpawned( + TimerInfo exclusiveTimer, TimedBlock instance) + { + Assert.That(instance._pausedTimers.Count == 0); + + instance._exclusiveTimer = exclusiveTimer; + + foreach (var timer in _timers.Values) + { + if (exclusiveTimer == timer) + { + Assert.That(!timer.IsRunning); + timer.Resume(); + } + else if (timer.IsRunning) + { + timer.Pause(); + instance._pausedTimers.Add(timer); + } + } + } + + static void OnDespawned(TimedBlock instance) + { + Assert.That(instance._exclusiveTimer.IsRunning); + instance._exclusiveTimer.Pause(); + + foreach (var timer in instance._pausedTimers) + { + Assert.That(!timer.IsRunning); + timer.Resume(); + } + + instance._pausedTimers.Clear(); + } + + public void Dispose() + { + Pool.Despawn(this); + } + } + + public class TimerInfo + { + readonly Stopwatch _timer; + + public TimerInfo() + { + _timer = new Stopwatch(); + } + + public int CallCount + { + get; set; + } + + public double TotalMilliseconds + { + get { return _timer.Elapsed.TotalMilliseconds; } + } + + public bool IsRunning + { + get { return _timer.IsRunning; } + } + + public void Reset() + { + _timer.Reset(); + } + + public void Resume() + { + _timer.Start(); + } + + public void Pause() + { + _timer.Stop(); + } + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ProfileTimers.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ProfileTimers.cs.meta new file mode 100644 index 0000000..80dc719 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ProfileTimers.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 81cad1ee2d8c20942a68a4228e09ff1d +timeCreated: 1537522729 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionInfoTypeInfoConverter.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionInfoTypeInfoConverter.cs new file mode 100644 index 0000000..6038b97 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionInfoTypeInfoConverter.cs @@ -0,0 +1,272 @@ +//#define ZEN_DO_NOT_USE_COMPILED_EXPRESSIONS + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; +using ModestTree; +#if !NOT_UNITY3D +using UnityEngine; +#endif + +namespace Zenject.Internal +{ + public static class ReflectionInfoTypeInfoConverter + { + public static InjectTypeInfo.InjectMethodInfo ConvertMethod( + ReflectionTypeInfo.InjectMethodInfo injectMethod) + { + var methodInfo = injectMethod.MethodInfo; + var action = TryCreateActionForMethod(methodInfo); + + if (action == null) + { + action = (obj, args) => methodInfo.Invoke(obj, args); + } + + return new InjectTypeInfo.InjectMethodInfo( + action, + injectMethod.Parameters.Select(x => x.InjectableInfo).ToArray(), + methodInfo.Name); + } + + public static InjectTypeInfo.InjectConstructorInfo ConvertConstructor( + ReflectionTypeInfo.InjectConstructorInfo injectConstructor, Type type) + { + return new InjectTypeInfo.InjectConstructorInfo( + TryCreateFactoryMethod(type, injectConstructor), + injectConstructor.Parameters.Select(x => x.InjectableInfo).ToArray()); + } + + public static InjectTypeInfo.InjectMemberInfo ConvertField( + Type parentType, ReflectionTypeInfo.InjectFieldInfo injectField) + { + return new InjectTypeInfo.InjectMemberInfo( + GetSetter(parentType, injectField.FieldInfo), injectField.InjectableInfo); + } + + public static InjectTypeInfo.InjectMemberInfo ConvertProperty( + Type parentType, ReflectionTypeInfo.InjectPropertyInfo injectProperty) + { + return new InjectTypeInfo.InjectMemberInfo( + GetSetter(parentType, injectProperty.PropertyInfo), injectProperty.InjectableInfo); + } + + static ZenFactoryMethod TryCreateFactoryMethod( + Type type, ReflectionTypeInfo.InjectConstructorInfo reflectionInfo) + { +#if !NOT_UNITY3D + if (type.DerivesFromOrEqual()) + { + return null; + } +#endif + + if (type.IsAbstract()) + { + Assert.That(reflectionInfo.Parameters.IsEmpty()); + return null; + } + + var constructor = reflectionInfo.ConstructorInfo; + + var factoryMethod = TryCreateFactoryMethodCompiledLambdaExpression(type, constructor); + + if (factoryMethod == null) + { + if (constructor == null) + { + // No choice in this case except to use the slow Activator.CreateInstance + // as far as I know + // This should be rare though and only seems to occur when instantiating + // structs on platforms that don't support lambda expressions + // Non-structs should always have a default constructor + factoryMethod = args => + { + Assert.That(args.Length == 0); + return Activator.CreateInstance(type, new object[0]); + }; + } + else + { + factoryMethod = constructor.Invoke; + } + } + + return factoryMethod; + } + + static ZenFactoryMethod TryCreateFactoryMethodCompiledLambdaExpression( + Type type, ConstructorInfo constructor) + { +#if NET_4_6 && !ENABLE_IL2CPP && !ZEN_DO_NOT_USE_COMPILED_EXPRESSIONS + + if (type.ContainsGenericParameters) + { + return null; + } + + ParameterExpression param = Expression.Parameter(typeof(object[])); + + if (constructor == null) + { + return Expression.Lambda( + Expression.Convert( + Expression.New(type), typeof(object)), param).Compile(); + } + + ParameterInfo[] par = constructor.GetParameters(); + Expression[] args = new Expression[par.Length]; + + for (int i = 0; i != par.Length; ++i) + { + args[i] = Expression.Convert( + Expression.ArrayIndex( + param, Expression.Constant(i)), par[i].ParameterType); + } + + return Expression.Lambda( + Expression.Convert( + Expression.New(constructor, args), typeof(object)), param).Compile(); +#else + return null; +#endif + } + + static ZenInjectMethod TryCreateActionForMethod(MethodInfo methodInfo) + { +#if NET_4_6 && !ENABLE_IL2CPP && !ZEN_DO_NOT_USE_COMPILED_EXPRESSIONS + + if (methodInfo.DeclaringType.ContainsGenericParameters) + { + return null; + } + + ParameterInfo[] par = methodInfo.GetParameters(); + + if (par.Any(x => x.ParameterType.ContainsGenericParameters)) + { + return null; + } + + Expression[] args = new Expression[par.Length]; + ParameterExpression argsParam = Expression.Parameter(typeof(object[])); + ParameterExpression instanceParam = Expression.Parameter(typeof(object)); + + for (int i = 0; i != par.Length; ++i) + { + args[i] = Expression.Convert( + Expression.ArrayIndex( + argsParam, Expression.Constant(i)), par[i].ParameterType); + } + + return Expression.Lambda( + Expression.Call( + Expression.Convert(instanceParam, methodInfo.DeclaringType), methodInfo, args), + instanceParam, argsParam).Compile(); +#else + return null; +#endif + } + +#if !(UNITY_WSA && ENABLE_DOTNET) || UNITY_EDITOR + static IEnumerable GetAllFields(Type t, BindingFlags flags) + { + if (t == null) + { + return Enumerable.Empty(); + } + + return t.GetFields(flags).Concat(GetAllFields(t.BaseType, flags)).Distinct(); + } + + static ZenMemberSetterMethod GetOnlyPropertySetter( + Type parentType, + string propertyName) + { + Assert.That(parentType != null); + Assert.That(!string.IsNullOrEmpty(propertyName)); + + var allFields = GetAllFields( + parentType, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy).ToList(); + + var writeableFields = allFields.Where(f => f.Name == string.Format("<" + propertyName + ">k__BackingField", propertyName)).ToList(); + + if (!writeableFields.Any()) + { + throw new ZenjectException(string.Format( + "Can't find backing field for get only property {0} on {1}.\r\n{2}", + propertyName, parentType.FullName, string.Join(";", allFields.Select(f => f.Name).ToArray()))); + } + + return (injectable, value) => writeableFields.ForEach(f => f.SetValue(injectable, value)); + } +#endif + + static ZenMemberSetterMethod GetSetter(Type parentType, MemberInfo memInfo) + { + var setterMethod = TryGetSetterAsCompiledExpression(parentType, memInfo); + + if (setterMethod != null) + { + return setterMethod; + } + + var fieldInfo = memInfo as FieldInfo; + var propInfo = memInfo as PropertyInfo; + + if (fieldInfo != null) + { + return ((injectable, value) => fieldInfo.SetValue(injectable, value)); + } + + Assert.IsNotNull(propInfo); + +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return ((object injectable, object value) => propInfo.SetValue(injectable, value, null)); +#else + if (propInfo.CanWrite) + { + return ((injectable, value) => propInfo.SetValue(injectable, value, null)); + } + + return GetOnlyPropertySetter(parentType, propInfo.Name); +#endif + } + + static ZenMemberSetterMethod TryGetSetterAsCompiledExpression(Type parentType, MemberInfo memInfo) + { +#if NET_4_6 && !ENABLE_IL2CPP && !ZEN_DO_NOT_USE_COMPILED_EXPRESSIONS + + if (parentType.ContainsGenericParameters) + { + return null; + } + + var fieldInfo = memInfo as FieldInfo; + var propInfo = memInfo as PropertyInfo; + + // It seems that for readonly fields, we have to use the slower approach below + // As discussed here: https://www.productiverage.com/trying-to-set-a-readonly-autoproperty-value-externally-plus-a-little-benchmarkdotnet + // We have to skip value types because those can only be set by reference using an lambda expression + if (!parentType.IsValueType() && (fieldInfo == null || !fieldInfo.IsInitOnly) && (propInfo == null || propInfo.CanWrite)) + { + Type memberType = fieldInfo != null + ? fieldInfo.FieldType : propInfo.PropertyType; + + var typeParam = Expression.Parameter(typeof(object)); + var valueParam = Expression.Parameter(typeof(object)); + + return Expression.Lambda( + Expression.Assign( + Expression.MakeMemberAccess(Expression.Convert(typeParam, parentType), memInfo), + Expression.Convert(valueParam, memberType)), + typeParam, valueParam).Compile(); + } +#endif + + return null; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionInfoTypeInfoConverter.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionInfoTypeInfoConverter.cs.meta new file mode 100644 index 0000000..cf6605d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionInfoTypeInfoConverter.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: e36c348f078bc444fa1e5b22aca27bad +timeCreated: 1536916212 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionTypeInfo.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionTypeInfo.cs new file mode 100644 index 0000000..98ccac4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionTypeInfo.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace Zenject.Internal +{ + [NoReflectionBaking] + public class ReflectionTypeInfo + { + public readonly Type Type; + public readonly Type BaseType; + public readonly List InjectProperties; + public readonly List InjectFields; + public readonly InjectConstructorInfo InjectConstructor; + public readonly List InjectMethods; + + public ReflectionTypeInfo( + Type type, + Type baseType, + InjectConstructorInfo injectConstructor, + List injectMethods, + List injectFields, + List injectProperties) + { + Type = type; + BaseType = baseType; + InjectFields = injectFields; + InjectConstructor = injectConstructor; + InjectMethods = injectMethods; + InjectProperties = injectProperties; + } + + [NoReflectionBaking] + public class InjectFieldInfo + { + public readonly FieldInfo FieldInfo; + public readonly InjectableInfo InjectableInfo; + + public InjectFieldInfo( + FieldInfo fieldInfo, + InjectableInfo injectableInfo) + { + InjectableInfo = injectableInfo; + FieldInfo = fieldInfo; + } + } + + [NoReflectionBaking] + public class InjectParameterInfo + { + public readonly ParameterInfo ParameterInfo; + public readonly InjectableInfo InjectableInfo; + + public InjectParameterInfo( + ParameterInfo parameterInfo, + InjectableInfo injectableInfo) + { + InjectableInfo = injectableInfo; + ParameterInfo = parameterInfo; + } + } + + [NoReflectionBaking] + public class InjectPropertyInfo + { + public readonly PropertyInfo PropertyInfo; + public readonly InjectableInfo InjectableInfo; + + public InjectPropertyInfo( + PropertyInfo propertyInfo, + InjectableInfo injectableInfo) + { + InjectableInfo = injectableInfo; + PropertyInfo = propertyInfo; + } + } + + [NoReflectionBaking] + public class InjectMethodInfo + { + public readonly MethodInfo MethodInfo; + public readonly List Parameters; + + public InjectMethodInfo( + MethodInfo methodInfo, + List parameters) + { + MethodInfo = methodInfo; + Parameters = parameters; + } + } + + [NoReflectionBaking] + public class InjectConstructorInfo + { + public readonly ConstructorInfo ConstructorInfo; + public readonly List Parameters; + + public InjectConstructorInfo( + ConstructorInfo constructorInfo, + List parameters) + { + ConstructorInfo = constructorInfo; + Parameters = parameters; + } + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionTypeInfo.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionTypeInfo.cs.meta new file mode 100644 index 0000000..d1ba881 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionTypeInfo.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 5490313f008f146458b6228165838735 +timeCreated: 1536916212 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionUtil.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionUtil.cs new file mode 100644 index 0000000..d8c2fc2 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionUtil.cs @@ -0,0 +1,166 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +namespace ModestTree +{ + public static class ReflectionUtil + { + public static Array CreateArray(Type elementType, List instances) + { + var array = Array.CreateInstance(elementType, instances.Count); + + for (int i = 0; i < instances.Count; i++) + { + var instance = instances[i]; + + if (instance != null) + { + Assert.That(instance.GetType().DerivesFromOrEqual(elementType), + "Wrong type when creating array, expected something assignable from '"+ elementType +"', but found '" + instance.GetType() + "'"); + } + + array.SetValue(instance, i); + } + + return array; + } + + public static IList CreateGenericList(Type elementType, List instances) + { + var genericType = typeof(List<>).MakeGenericType(elementType); + + var list = (IList)Activator.CreateInstance(genericType); + + for (int i = 0; i < instances.Count; i++) + { + var instance = instances[i]; + + if (instance != null) + { + Assert.That(instance.GetType().DerivesFromOrEqual(elementType), + "Wrong type when creating generic list, expected something assignable from '"+ elementType +"', but found '" + instance.GetType() + "'"); + } + + list.Add(instance); + } + + return list; + } + + public static string ToDebugString(this MethodInfo method) + { + return "{0}.{1}".Fmt(method.DeclaringType.PrettyName(), method.Name); + } + + public static string ToDebugString(this Action action) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return action.ToString(); +#else + return action.Method.ToDebugString(); +#endif + } + + public static string ToDebugString(this Action action) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return action.ToString(); +#else + return action.Method.ToDebugString(); +#endif + } + + public static string ToDebugString(this Action action) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return action.ToString(); +#else + return action.Method.ToDebugString(); +#endif + } + + public static string ToDebugString(this Action action) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return action.ToString(); +#else + return action.Method.ToDebugString(); +#endif + } + + public static string ToDebugString(this Action action) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return action.ToString(); +#else + return action.Method.ToDebugString(); +#endif + } + + public static string ToDebugString(this +#if NET_4_6 + Action action) +#else + ModestTree.Util.Action action) +#endif + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return action.ToString(); +#else + return action.Method.ToDebugString(); +#endif + } + + public static string ToDebugString(this +#if NET_4_6 + Action action) +#else + ModestTree.Util.Action action) +#endif + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return action.ToString(); +#else + return action.Method.ToDebugString(); +#endif + } + + public static string ToDebugString(this Func func) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return func.ToString(); +#else + return func.Method.ToDebugString(); +#endif + } + + public static string ToDebugString(this Func func) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return func.ToString(); +#else + return func.Method.ToDebugString(); +#endif + } + + public static string ToDebugString(this Func func) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return func.ToString(); +#else + return func.Method.ToDebugString(); +#endif + } + + public static string ToDebugString(this Func func) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return func.ToString(); +#else + return func.Method.ToDebugString(); +#endif + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionUtil.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionUtil.cs.meta new file mode 100644 index 0000000..40bcda5 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ReflectionUtil.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7c74b10dac7e87e4095f8e3157eb040d +timeCreated: 1520399530 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/TypeAnalyzer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/TypeAnalyzer.cs new file mode 100644 index 0000000..c4c4094 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/TypeAnalyzer.cs @@ -0,0 +1,249 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using ModestTree; +using Zenject.Internal; + +namespace Zenject +{ + public delegate InjectTypeInfo ZenTypeInfoGetter(); + + public enum ReflectionBakingCoverageModes + { + FallbackToDirectReflection, + NoCheckAssumeFullCoverage, + FallbackToDirectReflectionWithWarning + } + + public static class TypeAnalyzer + { + static Dictionary _typeInfo = new Dictionary(); + + // We store this separately from InjectTypeInfo because this flag is needed for contract + // types whereas InjectTypeInfo is only needed for types that are instantiated, and + // we want to minimize the types that generate InjectTypeInfo for + static Dictionary _allowDuringValidation = new Dictionary(); + + // Use double underscores for generated methods since this is also what the C# compiler does + // for things like anonymous methods + public const string ReflectionBakingGetInjectInfoMethodName = "__zenCreateInjectTypeInfo"; + public const string ReflectionBakingFactoryMethodName = "__zenCreate"; + public const string ReflectionBakingInjectMethodPrefix = "__zenInjectMethod"; + public const string ReflectionBakingFieldSetterPrefix = "__zenFieldSetter"; + public const string ReflectionBakingPropertySetterPrefix = "__zenPropertySetter"; + + public static ReflectionBakingCoverageModes ReflectionBakingCoverageMode + { + get; set; + } + + public static bool ShouldAllowDuringValidation() + { + return ShouldAllowDuringValidation(typeof(T)); + } + + public static bool ShouldAllowDuringValidation(Type type) + { + bool shouldAllow; + + if (!_allowDuringValidation.TryGetValue(type, out shouldAllow)) + { + shouldAllow = ShouldAllowDuringValidationInternal(type); + _allowDuringValidation.Add(type, shouldAllow); + } + + return shouldAllow; + } + + static bool ShouldAllowDuringValidationInternal(Type type) + { + // During validation, do not instantiate or inject anything except for + // Installers, IValidatable's, or types marked with attribute ZenjectAllowDuringValidation + // You would typically use ZenjectAllowDuringValidation attribute for data that you + // inject into factories + + if (type.DerivesFrom() || type.DerivesFrom()) + { + return true; + } + +#if !NOT_UNITY3D + if (type.DerivesFrom()) + { + return true; + } +#endif + +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + return type.GetTypeInfo().GetCustomAttribute() != null; +#else + return type.HasAttribute(); +#endif + } + + public static bool HasInfo() + { + return HasInfo(typeof(T)); + } + + public static bool HasInfo(Type type) + { + return TryGetInfo(type) != null; + } + + public static InjectTypeInfo GetInfo() + { + return GetInfo(typeof(T)); + } + + public static InjectTypeInfo GetInfo(Type type) + { + var info = TryGetInfo(type); + Assert.IsNotNull(info, "Unable to get type info for type '{0}'", type); + return info; + } + + public static InjectTypeInfo TryGetInfo() + { + return TryGetInfo(typeof(T)); + } + + public static InjectTypeInfo TryGetInfo(Type type) + { + InjectTypeInfo info; + +#if ZEN_MULTITHREADING + lock (_typeInfo) +#endif + { + if (_typeInfo.TryGetValue(type, out info)) + { + return info; + } + } + +#if UNITY_EDITOR + using (ProfileBlock.Start("Zenject Reflection")) +#endif + { + info = GetInfoInternal(type); + } + + if (info != null) + { + Assert.IsEqual(info.Type, type); + Assert.IsNull(info.BaseTypeInfo); + + var baseType = type.BaseType(); + + if (baseType != null && !ShouldSkipTypeAnalysis(baseType)) + { + info.BaseTypeInfo = TryGetInfo(baseType); + } + } + +#if ZEN_MULTITHREADING + lock (_typeInfo) +#endif + { + _typeInfo[type] = info; + } + + return info; + } + + static InjectTypeInfo GetInfoInternal(Type type) + { + if (ShouldSkipTypeAnalysis(type)) + { + return null; + } + +#if ZEN_INTERNAL_PROFILING + // Make sure that the static constructor logic doesn't inflate our profile measurements + using (ProfileTimers.CreateTimedBlock("User Code")) + { + RuntimeHelpers.RunClassConstructor(type.TypeHandle); + } +#endif + +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("Type Analysis - Calling Baked Reflection Getter")) +#endif + { + var getInfoMethod = type.GetMethod( + ReflectionBakingGetInjectInfoMethodName, + BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); + + if (getInfoMethod != null) + { +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + var infoGetter = (ZenTypeInfoGetter)getInfoMethod.CreateDelegate( + typeof(ZenTypeInfoGetter), null); +#else + var infoGetter = ((ZenTypeInfoGetter)Delegate.CreateDelegate( + typeof(ZenTypeInfoGetter), getInfoMethod)); +#endif + + return infoGetter(); + } + } + + if (ReflectionBakingCoverageMode == ReflectionBakingCoverageModes.NoCheckAssumeFullCoverage) + { + // If we are confident that the reflection baking supplies all the injection information, + // then we can avoid the costs of doing reflection on types that were not covered + // by the baking + return null; + } + +#if !(UNITY_WSA && ENABLE_DOTNET) || UNITY_EDITOR + if (ReflectionBakingCoverageMode == ReflectionBakingCoverageModes.FallbackToDirectReflectionWithWarning) + { + Log.Warn("No reflection baking information found for type '{0}' - using more costly direct reflection instead", type); + } +#endif + +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("Type Analysis - Direct Reflection")) +#endif + { + return CreateTypeInfoFromReflection(type); + } + } + + public static bool ShouldSkipTypeAnalysis(Type type) + { + return type == null || type.IsEnum() || type.IsArray || type.IsInterface() + || type.ContainsGenericParameters() || IsStaticType(type) + || type == typeof(object); + } + + static bool IsStaticType(Type type) + { + // Apparently this is unique to static classes + return type.IsAbstract() && type.IsSealed(); + } + + static InjectTypeInfo CreateTypeInfoFromReflection(Type type) + { + var reflectionInfo = ReflectionTypeAnalyzer.GetReflectionInfo(type); + + var injectConstructor = ReflectionInfoTypeInfoConverter.ConvertConstructor( + reflectionInfo.InjectConstructor, type); + + var injectMethods = reflectionInfo.InjectMethods.Select( + ReflectionInfoTypeInfoConverter.ConvertMethod).ToArray(); + + var memberInfos = reflectionInfo.InjectFields.Select( + x => ReflectionInfoTypeInfoConverter.ConvertField(type, x)).Concat( + reflectionInfo.InjectProperties.Select( + x => ReflectionInfoTypeInfoConverter.ConvertProperty(type, x))).ToArray(); + + return new InjectTypeInfo( + type, injectConstructor, injectMethods, memberInfos); + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/TypeAnalyzer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/TypeAnalyzer.cs.meta new file mode 100644 index 0000000..8d7a628 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/TypeAnalyzer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7359cd850f5a96d47ad4606d14dac326 +timeCreated: 1461708051 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/UnityUtil.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/UnityUtil.cs new file mode 100644 index 0000000..e262b21 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/UnityUtil.cs @@ -0,0 +1,139 @@ +#if !NOT_UNITY3D + +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace ModestTree.Util +{ + public static class UnityUtil + { + public static IEnumerable AllScenes + { + get + { + for (int i = 0; i < SceneManager.sceneCount; i++) + { + yield return SceneManager.GetSceneAt(i); + } + } + } + + public static IEnumerable AllLoadedScenes + { + get { return AllScenes.Where(scene => scene.isLoaded); } + } + + public static bool IsAltKeyDown + { + get { return Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt); } + } + + public static bool IsControlKeyDown + { + get { return Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl); } + } + + public static bool IsShiftKeyDown + { + get { return Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift); } + } + + public static bool WasShiftKeyJustPressed + { + get { return Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift); } + } + + public static bool WasAltKeyJustPressed + { + get { return Input.GetKeyDown(KeyCode.LeftAlt) || Input.GetKeyDown(KeyCode.RightAlt); } + } + + public static int GetDepthLevel(Transform transform) + { + if (transform == null) + { + return 0; + } + + return 1 + GetDepthLevel(transform.parent); + } + + public static GameObject GetRootParentOrSelf(GameObject gameObject) + { + return GetParentsAndSelf(gameObject.transform).Select(x => x.gameObject).LastOrDefault(); + } + + public static IEnumerable GetParents(Transform transform) + { + if (transform == null) + { + yield break; + } + + foreach (var ancestor in GetParentsAndSelf(transform.parent)) + { + yield return ancestor; + } + } + + public static IEnumerable GetParentsAndSelf(Transform transform) + { + if (transform == null) + { + yield break; + } + + yield return transform; + + foreach (var ancestor in GetParentsAndSelf(transform.parent)) + { + yield return ancestor; + } + } + + public static IEnumerable GetComponentsInChildrenTopDown(GameObject gameObject, bool includeInactive) + { + return gameObject.GetComponentsInChildren(includeInactive) + .OrderBy(x => + x == null ? int.MinValue : GetDepthLevel(x.transform)); + } + + public static IEnumerable GetComponentsInChildrenBottomUp(GameObject gameObject, bool includeInactive) + { + return gameObject.GetComponentsInChildren(includeInactive) + .OrderByDescending(x => + x == null ? int.MinValue : GetDepthLevel(x.transform)); + } + + public static IEnumerable GetDirectChildrenAndSelf(GameObject obj) + { + yield return obj; + + foreach (Transform child in obj.transform) + { + yield return child.gameObject; + } + } + + public static IEnumerable GetDirectChildren(GameObject obj) + { + foreach (Transform child in obj.transform) + { + yield return child.gameObject; + } + } + + public static IEnumerable GetAllGameObjects() + { + return GameObject.FindObjectsOfType().Select(x => x.gameObject); + } + + public static List GetAllRootGameObjects() + { + return GetAllGameObjects().Where(x => x.transform.parent == null).ToList(); + } + } +} +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/UnityUtil.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/UnityUtil.cs.meta new file mode 100644 index 0000000..9b1a2fe --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/UnityUtil.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 136cacfad8fe5404aad05dda29a777e4 +timeCreated: 1461708048 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ValidationUtil.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ValidationUtil.cs new file mode 100644 index 0000000..9cbe5df --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ValidationUtil.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; + +namespace Zenject +{ + public static class ValidationUtil + { + // This method can be used during validation for cases where we need to pass arguments + public static List CreateDefaultArgs(params Type[] argTypes) + { + return argTypes.Select(x => new TypeValuePair(x, x.GetDefaultValue())).ToList(); + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ValidationUtil.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ValidationUtil.cs.meta new file mode 100644 index 0000000..81acfd4 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ValidationUtil.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 018820e0bcd9a4049a305127c0cf1407 +timeCreated: 1461708048 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenAutoInjecter.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenAutoInjecter.cs new file mode 100644 index 0000000..7756c5d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenAutoInjecter.cs @@ -0,0 +1,73 @@ +using ModestTree; +using UnityEngine; + +namespace Zenject +{ + public class ZenAutoInjecter : MonoBehaviour + { + [SerializeField] + ContainerSources _containerSource = ContainerSources.SearchHierarchy; + + bool _hasInjected; + + public ContainerSources ContainerSource + { + get { return _containerSource; } + set { _containerSource = value; } + } + + // Make sure they don't cause injection to happen twice + [Inject] + public void Construct() + { + if (!_hasInjected) + { + throw Assert.CreateException( + "ZenAutoInjecter was injected! Do not use ZenAutoInjecter for objects that are instantiated through zenject or which exist in the initial scene hierarchy"); + } + } + + public void Awake() + { + _hasInjected = true; + LookupContainer().InjectGameObject(gameObject); + } + + DiContainer LookupContainer() + { + if (_containerSource == ContainerSources.ProjectContext) + { + return ProjectContext.Instance.Container; + } + + if (_containerSource == ContainerSources.SceneContext) + { + return GetContainerForCurrentScene(); + } + + Assert.IsEqual(_containerSource, ContainerSources.SearchHierarchy); + + var parentContext = transform.GetComponentInParent(); + + if (parentContext != null) + { + return parentContext.Container; + } + + return GetContainerForCurrentScene(); + } + + DiContainer GetContainerForCurrentScene() + { + return ProjectContext.Instance.Container.Resolve() + .GetContainerForScene(gameObject.scene); + } + + public enum ContainerSources + { + SceneContext, + ProjectContext, + SearchHierarchy + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenAutoInjecter.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenAutoInjecter.cs.meta new file mode 100644 index 0000000..5e7f5e6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenAutoInjecter.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 717a02054ef2699498e6bd4234fd7995 +timeCreated: 1510660712 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenPools.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenPools.cs new file mode 100644 index 0000000..a162e1d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenPools.cs @@ -0,0 +1,200 @@ +using System; +using System.Collections.Generic; + +namespace Zenject.Internal +{ + public static class ZenPools + { +#if ZEN_INTERNAL_NO_POOLS + public static InjectContext SpawnInjectContext(DiContainer container, Type memberType) + { + return new InjectContext(container, memberType); + } + + public static void DespawnInjectContext(InjectContext context) + { + } + + public static List SpawnList() + { + return new List(); + } + + public static void DespawnList(List list) + { + } + + public static void DespawnArray(T[] arr) + { + } + + public static T[] SpawnArray(int length) + { + return new T[length]; + } + + public static HashSet SpawnHashSet() + { + return new HashSet(); + } + + public static Dictionary SpawnDictionary() + { + return new Dictionary(); + } + + public static void DespawnDictionary(Dictionary dictionary) + { + } + + public static void DespawnHashSet(HashSet set) + { + } + + public static LookupId SpawnLookupId(IProvider provider, BindingId bindingId) + { + return new LookupId(provider, bindingId); + } + + public static void DespawnLookupId(LookupId lookupId) + { + } + + public static BindInfo SpawnBindInfo() + { + return new BindInfo(); + } + + public static void DespawnBindInfo(BindInfo bindInfo) + { + } + + public static BindStatement SpawnStatement() + { + return new BindStatement(); + } + + public static void DespawnStatement(BindStatement statement) + { + } +#else + static readonly StaticMemoryPool _contextPool = new StaticMemoryPool(); + static readonly StaticMemoryPool _lookupIdPool = new StaticMemoryPool(); + static readonly StaticMemoryPool _bindInfoPool = new StaticMemoryPool(); + static readonly StaticMemoryPool _bindStatementPool = new StaticMemoryPool(); + + public static HashSet SpawnHashSet() + { + return HashSetPool.Instance.Spawn(); + } + + public static Dictionary SpawnDictionary() + { + return DictionaryPool.Instance.Spawn(); + } + + public static BindStatement SpawnStatement() + { + return _bindStatementPool.Spawn(); + } + + public static void DespawnStatement(BindStatement statement) + { + statement.Reset(); + _bindStatementPool.Despawn(statement); + } + + public static BindInfo SpawnBindInfo() + { + return _bindInfoPool.Spawn(); + } + + public static void DespawnBindInfo(BindInfo bindInfo) + { + bindInfo.Reset(); + _bindInfoPool.Despawn(bindInfo); + } + + public static void DespawnDictionary(Dictionary dictionary) + { + DictionaryPool.Instance.Despawn(dictionary); + } + + public static void DespawnHashSet(HashSet set) + { + HashSetPool.Instance.Despawn(set); + } + + public static LookupId SpawnLookupId(IProvider provider, BindingId bindingId) + { + var lookupId = _lookupIdPool.Spawn(); + + lookupId.Provider = provider; + lookupId.BindingId = bindingId; + + return lookupId; + } + + public static void DespawnLookupId(LookupId lookupId) + { + lookupId.Reset(); + _lookupIdPool.Despawn(lookupId); + } + + public static List SpawnList() + { + return ListPool.Instance.Spawn(); + } + + public static void DespawnList(List list) + { + ListPool.Instance.Despawn(list); + } + + public static void DespawnArray(T[] arr) + { + ArrayPool.GetPool(arr.Length).Despawn(arr); + } + + public static T[] SpawnArray(int length) + { + return ArrayPool.GetPool(length).Spawn(); + } + + public static InjectContext SpawnInjectContext(DiContainer container, Type memberType) + { + var context = _contextPool.Spawn(); + + context.Container = container; + context.MemberType = memberType; + + return context; + } + + public static void DespawnInjectContext(InjectContext context) + { + context.Reset(); + _contextPool.Despawn(context); + } +#endif + + public static InjectContext SpawnInjectContext( + DiContainer container, InjectableInfo injectableInfo, InjectContext currentContext, + object targetInstance, Type targetType, object concreteIdentifier) + { + var context = SpawnInjectContext(container, injectableInfo.MemberType); + + context.ObjectType = targetType; + context.ParentContext = currentContext; + context.ObjectInstance = targetInstance; + context.Identifier = injectableInfo.Identifier; + context.MemberName = injectableInfo.MemberName; + context.Optional = injectableInfo.Optional; + context.SourceType = injectableInfo.SourceType; + context.FallBackValue = injectableInfo.DefaultValue; + context.ConcreteIdentifier = concreteIdentifier; + + return context; + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenPools.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenPools.cs.meta new file mode 100644 index 0000000..464ec3d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenPools.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 14ff296505fe79448b0c79ec09977477 +timeCreated: 1535860932 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenReflectionTypeAnalyzer.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenReflectionTypeAnalyzer.cs new file mode 100644 index 0000000..57c5430 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenReflectionTypeAnalyzer.cs @@ -0,0 +1,261 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using ModestTree; +#if !NOT_UNITY3D +using UnityEngine; +#endif + +namespace Zenject.Internal +{ + public static class ReflectionTypeAnalyzer + { + static readonly HashSet _injectAttributeTypes; + + static ReflectionTypeAnalyzer() + { + _injectAttributeTypes = new HashSet(); + _injectAttributeTypes.Add(typeof(InjectAttributeBase)); + } + + public static void AddCustomInjectAttribute() + where T : Attribute + { + AddCustomInjectAttribute(typeof(T)); + } + + public static void AddCustomInjectAttribute(Type type) + { + Assert.That(type.DerivesFrom()); + _injectAttributeTypes.Add(type); + } + + public static ReflectionTypeInfo GetReflectionInfo(Type type) + { + Assert.That(!type.IsEnum(), "Tried to analyze enum type '{0}'. This is not supported", type); + Assert.That(!type.IsArray, "Tried to analyze array type '{0}'. This is not supported", type); + + var baseType = type.BaseType(); + + if (baseType == typeof(object)) + { + baseType = null; + } + + return new ReflectionTypeInfo( + type, baseType, GetConstructorInfo(type), GetMethodInfos(type), + GetFieldInfos(type), GetPropertyInfos(type)); + } + + static List GetPropertyInfos(Type type) + { + return type.DeclaredInstanceProperties() + .Where(x => _injectAttributeTypes.Any(a => x.HasAttribute(a))) + .Select(x => new ReflectionTypeInfo.InjectPropertyInfo( + x, GetInjectableInfoForMember(type, x))).ToList(); + } + + static List GetFieldInfos(Type type) + { + return type.DeclaredInstanceFields() + .Where(x => _injectAttributeTypes.Any(a => x.HasAttribute(a))) + .Select(x => new ReflectionTypeInfo.InjectFieldInfo( + x, GetInjectableInfoForMember(type, x))) + .ToList(); + } + + static List GetMethodInfos(Type type) + { + var injectMethodInfos = new List(); + + // Note that unlike with fields and properties we use GetCustomAttributes + // This is so that we can ignore inherited attributes, which is necessary + // otherwise a base class method marked with [Inject] would cause all overridden + // derived methods to be added as well + var methodInfos = type.DeclaredInstanceMethods() + .Where(x => _injectAttributeTypes.Any(a => x.GetCustomAttributes(a, false).Any())).ToList(); + + for (int i = 0; i < methodInfos.Count; i++) + { + var methodInfo = methodInfos[i]; + var injectAttr = methodInfo.AllAttributes().SingleOrDefault(); + + if (injectAttr != null) + { + Assert.That(!injectAttr.Optional && injectAttr.Id == null && injectAttr.Source == InjectSources.Any, + "Parameters of InjectAttribute do not apply to constructors and methodInfos"); + } + + var injectParamInfos = methodInfo.GetParameters() + .Select(x => CreateInjectableInfoForParam(type, x)).ToList(); + + injectMethodInfos.Add( + new ReflectionTypeInfo.InjectMethodInfo(methodInfo, injectParamInfos)); + } + + return injectMethodInfos; + } + + static ReflectionTypeInfo.InjectConstructorInfo GetConstructorInfo(Type type) + { + var args = new List(); + + var constructor = TryGetInjectConstructor(type); + + if (constructor != null) + { + args.AddRange(constructor.GetParameters().Select( + x => CreateInjectableInfoForParam(type, x))); + } + + return new ReflectionTypeInfo.InjectConstructorInfo(constructor, args); + } + + static ReflectionTypeInfo.InjectParameterInfo CreateInjectableInfoForParam( + Type parentType, ParameterInfo paramInfo) + { + var injectAttributes = paramInfo.AllAttributes().ToList(); + + Assert.That(injectAttributes.Count <= 1, + "Found multiple 'Inject' attributes on type parameter '{0}' of type '{1}'. Parameter should only have one", paramInfo.Name, parentType); + + var injectAttr = injectAttributes.SingleOrDefault(); + + object identifier = null; + bool isOptional = false; + InjectSources sourceType = InjectSources.Any; + + if (injectAttr != null) + { + identifier = injectAttr.Id; + isOptional = injectAttr.Optional; + sourceType = injectAttr.Source; + } + + bool isOptionalWithADefaultValue = (paramInfo.Attributes & ParameterAttributes.HasDefault) == ParameterAttributes.HasDefault; + + return new ReflectionTypeInfo.InjectParameterInfo( + paramInfo, + new InjectableInfo( + isOptionalWithADefaultValue || isOptional, + identifier, + paramInfo.Name, + paramInfo.ParameterType, + isOptionalWithADefaultValue ? paramInfo.DefaultValue : null, + sourceType)); + } + + static InjectableInfo GetInjectableInfoForMember(Type parentType, MemberInfo memInfo) + { + var injectAttributes = memInfo.AllAttributes().ToList(); + + Assert.That(injectAttributes.Count <= 1, + "Found multiple 'Inject' attributes on type field '{0}' of type '{1}'. Field should only container one Inject attribute", memInfo.Name, parentType); + + var injectAttr = injectAttributes.SingleOrDefault(); + + object identifier = null; + bool isOptional = false; + InjectSources sourceType = InjectSources.Any; + + if (injectAttr != null) + { + identifier = injectAttr.Id; + isOptional = injectAttr.Optional; + sourceType = injectAttr.Source; + } + + Type memberType = memInfo is FieldInfo + ? ((FieldInfo)memInfo).FieldType : ((PropertyInfo)memInfo).PropertyType; + + return new InjectableInfo( + isOptional, + identifier, + memInfo.Name, + memberType, + null, + sourceType); + } + + static ConstructorInfo TryGetInjectConstructor(Type type) + { +#if !NOT_UNITY3D + if (type.DerivesFromOrEqual()) + { + return null; + } +#endif + + if (type.IsAbstract()) + { + return null; + } + + var constructors = type.Constructors(); + +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + // WP8 generates a dummy constructor with signature (internal Classname(UIntPtr dummy)) + // So just ignore that + constructors = constructors.Where(c => !IsWp8GeneratedConstructor(c)).ToArray(); +#endif + + if (constructors.IsEmpty()) + { + return null; + } + + if (constructors.HasMoreThan(1)) + { + var explicitConstructor = (from c in constructors where _injectAttributeTypes.Any(a => c.HasAttribute(a)) select c).SingleOrDefault(); + + if (explicitConstructor != null) + { + return explicitConstructor; + } + + // If there is only one public constructor then use that + // This makes decent sense but is also necessary on WSA sometimes since the WSA generated + // constructor can sometimes be private with zero parameters + var singlePublicConstructor = constructors.Where(x => x.IsPublic).OnlyOrDefault(); + + if (singlePublicConstructor != null) + { + return singlePublicConstructor; + } + + // Choose the one with the least amount of arguments + // This might result in some non obvious errors like null reference exceptions + // but is probably the best trade-off since it allows zenject to be more compatible + // with libraries that don't depend on zenject at all + // Discussion here - https://github.com/svermeulen/Zenject/issues/416 + return constructors.OrderBy(x => x.GetParameters().Count()).First(); + } + + return constructors[0]; + } + +#if UNITY_WSA && ENABLE_DOTNET && !UNITY_EDITOR + static bool IsWp8GeneratedConstructor(ConstructorInfo c) + { + ParameterInfo[] args = c.GetParameters(); + + if (args.Length == 1) + { + return args[0].ParameterType == typeof(UIntPtr) + && (string.IsNullOrEmpty(args[0].Name) || args[0].Name == "dummy"); + } + + if (args.Length == 2) + { + return args[0].ParameterType == typeof(UIntPtr) + && args[1].ParameterType == typeof(Int64*) + && (string.IsNullOrEmpty(args[0].Name) || args[0].Name == "dummy") + && (string.IsNullOrEmpty(args[1].Name) || args[1].Name == "dummy"); + } + + return false; + } +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenReflectionTypeAnalyzer.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenReflectionTypeAnalyzer.cs.meta new file mode 100644 index 0000000..c73305b --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenReflectionTypeAnalyzer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 046b222c5a2e0994cb5c424ed912f808 +timeCreated: 1536916211 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenUtilInternal.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenUtilInternal.cs new file mode 100644 index 0000000..174d2a8 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenUtilInternal.cs @@ -0,0 +1,272 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ModestTree; +using ModestTree.Util; +#if !NOT_UNITY3D +using UnityEngine.SceneManagement; +using UnityEngine; +#endif + +namespace Zenject.Internal +{ + public static class ZenUtilInternal + { +#if UNITY_EDITOR + static GameObject _disabledIndestructibleGameObject; +#endif + + // Due to the way that Unity overrides the Equals operator, + // normal null checks such as (x == null) do not always work as + // expected + // In those cases you can use this function which will also + // work with non-unity objects + public static bool IsNull(System.Object obj) + { + return obj == null || obj.Equals(null); + } + +#if UNITY_EDITOR + // This can be useful if you are running code outside unity + // since in that case you have to make sure to avoid calling anything + // inside Unity DLLs + public static bool IsOutsideUnity() + { + return AppDomain.CurrentDomain.FriendlyName != "Unity Child Domain"; + } +#endif + + public static bool AreFunctionsEqual(Delegate left, Delegate right) + { + return left.Target == right.Target && left.Method() == right.Method(); + } + + // Taken from here: + // http://stackoverflow.com/questions/28937324/in-c-how-could-i-get-a-classs-inheritance-distance-to-base-class/28937542#28937542 + public static int GetInheritanceDelta(Type derived, Type parent) + { + Assert.That(derived.DerivesFromOrEqual(parent)); + + if (parent.IsInterface()) + { + // Not sure if we can calculate this so just return 1 + return 1; + } + + if (derived == parent) + { + return 0; + } + + int distance = 1; + + Type child = derived; + + while ((child = child.BaseType()) != parent) + { + distance++; + } + + return distance; + } + +#if !NOT_UNITY3D + public static IEnumerable GetAllSceneContexts() + { + foreach (var scene in UnityUtil.AllLoadedScenes) + { + var contexts = scene.GetRootGameObjects() + .SelectMany(root => root.GetComponentsInChildren()).ToList(); + + if (contexts.IsEmpty()) + { + continue; + } + + Assert.That(contexts.Count == 1, + "Found multiple scene contexts in scene '{0}'", scene.name); + + yield return contexts[0]; + } + } + + public static void AddStateMachineBehaviourAutoInjectersInScene(Scene scene) + { + foreach (var rootObj in GetRootGameObjects(scene)) + { + if (rootObj != null) + { + AddStateMachineBehaviourAutoInjectersUnderGameObject(rootObj); + } + } + } + + // Call this before calling GetInjectableMonoBehavioursUnderGameObject to ensure that the StateMachineBehaviour's + // also get injected properly + // The StateMachineBehaviour's cannot be retrieved until after the Start() method so we + // need to use ZenjectStateMachineBehaviourAutoInjecter to do the injection at that + // time for us + public static void AddStateMachineBehaviourAutoInjectersUnderGameObject(GameObject root) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("Searching Hierarchy")) +#endif + { + var animators = root.GetComponentsInChildren(true); + + foreach (var animator in animators) + { + if (animator.gameObject.GetComponent() == null) + { + animator.gameObject.AddComponent(); + } + } + } + } + + public static void GetInjectableMonoBehavioursInScene( + Scene scene, List monoBehaviours) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("Searching Hierarchy")) +#endif + { + foreach (var rootObj in GetRootGameObjects(scene)) + { + if (rootObj != null) + { + GetInjectableMonoBehavioursUnderGameObjectInternal(rootObj, monoBehaviours); + } + } + } + } + + // NOTE: This method will not return components that are within a GameObjectContext + // It returns monobehaviours in a bottom-up order + public static void GetInjectableMonoBehavioursUnderGameObject( + GameObject gameObject, List injectableComponents) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("Searching Hierarchy")) +#endif + { + GetInjectableMonoBehavioursUnderGameObjectInternal(gameObject, injectableComponents); + } + } + + static void GetInjectableMonoBehavioursUnderGameObjectInternal( + GameObject gameObject, List injectableComponents) + { + if (gameObject == null) + { + return; + } + + var monoBehaviours = gameObject.GetComponents(); + + for (int i = 0; i < monoBehaviours.Length; i++) + { + var monoBehaviour = monoBehaviours[i]; + + // Can be null for broken component references + if (monoBehaviour != null + && monoBehaviour.GetType().DerivesFromOrEqual()) + { + // Need to make sure we don't inject on any MonoBehaviour's that are below a GameObjectContext + // Since that is the responsibility of the GameObjectContext + // BUT we do want to inject on the GameObjectContext itself + injectableComponents.Add(monoBehaviour); + return; + } + } + + // Recurse first so it adds components bottom up though it shouldn't really matter much + // because it should always inject in the dependency order + for (int i = 0; i < gameObject.transform.childCount; i++) + { + var child = gameObject.transform.GetChild(i); + + if (child != null) + { + GetInjectableMonoBehavioursUnderGameObjectInternal(child.gameObject, injectableComponents); + } + } + + for (int i = 0; i < monoBehaviours.Length; i++) + { + var monoBehaviour = monoBehaviours[i]; + + // Can be null for broken component references + if (monoBehaviour != null + && IsInjectableMonoBehaviourType(monoBehaviour.GetType())) + { + injectableComponents.Add(monoBehaviour); + } + } + } + + public static bool IsInjectableMonoBehaviourType(Type type) + { + // Do not inject on installers since these are always injected before they are installed + return type != null && !type.DerivesFrom() && TypeAnalyzer.HasInfo(type); + } + + public static IEnumerable GetRootGameObjects(Scene scene) + { +#if ZEN_INTERNAL_PROFILING + using (ProfileTimers.CreateTimedBlock("Searching Hierarchy")) +#endif + { + if (scene.isLoaded) + { + return scene.GetRootGameObjects() + .Where(x => x.GetComponent() == null); + } + + // Note: We can't use scene.GetRootObjects() here because that apparently fails with an exception + // about the scene not being loaded yet when executed in Awake + // We also can't use GameObject.FindObjectsOfType() because that does not include inactive game objects + // So we use Resources.FindObjectsOfTypeAll, even though that may include prefabs. However, our assumption here + // is that prefabs do not have their "scene" property set correctly so this should work + // + // It's important here that we only inject into root objects that are part of our scene, to properly support + // multi-scene editing features of Unity 5.x + // + // Also, even with older Unity versions, if there is an object that is marked with DontDestroyOnLoad, then it will + // be injected multiple times when another scene is loaded + // + // We also make sure not to inject into the project root objects which are injected by ProjectContext. + return Resources.FindObjectsOfTypeAll() + .Where(x => x.transform.parent == null + && x.GetComponent() == null + && x.scene == scene); + } + } + +#if UNITY_EDITOR + // Returns a Transform in the DontDestroyOnLoad scene (or, if we're not in play mode, within the current active scene) + // whose GameObject is inactive, and whose hide flags are set to HideAndDontSave. We can instantiate prefabs in here + // without any of their Awake() methods firing. + public static Transform GetOrCreateInactivePrefabParent() + { + if(_disabledIndestructibleGameObject == null || (!Application.isPlaying && _disabledIndestructibleGameObject.scene != SceneManager.GetActiveScene())) + { + var go = new GameObject("ZenUtilInternal_PrefabParent"); + go.hideFlags = HideFlags.HideAndDontSave; + go.SetActive(false); + + if(Application.isPlaying) + { + UnityEngine.Object.DontDestroyOnLoad(go); + } + + _disabledIndestructibleGameObject = go; + } + + return _disabledIndestructibleGameObject.transform; + } +#endif + +#endif + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenUtilInternal.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenUtilInternal.cs.meta new file mode 100644 index 0000000..c986b1e --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenUtilInternal.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 401238e59d733ab48aaea1a582241b29 +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectException.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectException.cs new file mode 100644 index 0000000..f0ee200 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectException.cs @@ -0,0 +1,21 @@ +using System; +using System.Diagnostics; + +namespace Zenject +{ + [DebuggerStepThrough] + [NoReflectionBaking] + public class ZenjectException : Exception + { + public ZenjectException(string message) + : base(message) + { + } + + public ZenjectException( + string message, Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectException.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectException.cs.meta new file mode 100644 index 0000000..359e602 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectException.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 60bbf1e064ae9674185f3f301957c914 +timeCreated: 1461708050 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectSceneLoader.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectSceneLoader.cs new file mode 100644 index 0000000..87980f3 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectSceneLoader.cs @@ -0,0 +1,151 @@ +#if !NOT_UNITY3D + +using System; +using ModestTree; +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace Zenject +{ + public enum LoadSceneRelationship + { + // This will use the ProjectContext container as parent for the new scene + // This is similar to just running the new scene normally + None, + // This will use current scene as parent for the new scene + // This will allow the new scene to refer to dependencies in the current scene + Child, + // This will use the parent of the current scene as the parent for the next scene + // In most cases this will be the same as None + Sibling + } + + public class ZenjectSceneLoader + { + readonly ProjectKernel _projectKernel; + readonly DiContainer _sceneContainer; + + public ZenjectSceneLoader( + [InjectOptional] + SceneContext sceneRoot, + ProjectKernel projectKernel) + { + _projectKernel = projectKernel; + _sceneContainer = sceneRoot == null ? null : sceneRoot.Container; + } + + public void LoadScene( + string sceneName, + LoadSceneMode loadMode = LoadSceneMode.Single, + Action extraBindings = null, + LoadSceneRelationship containerMode = LoadSceneRelationship.None, + Action extraBindingsLate = null) + { + PrepareForLoadScene(loadMode, extraBindings, extraBindingsLate, containerMode); + + Assert.That(Application.CanStreamedLevelBeLoaded(sceneName), + "Unable to load scene '{0}'", sceneName); + + SceneManager.LoadScene(sceneName, loadMode); + + // It would be nice here to actually verify that the new scene has a SceneContext + // if we have extra binding hooks, or LoadSceneRelationship != None, but + // we can't do that in this case since the scene isn't loaded until the next frame + } + + public AsyncOperation LoadSceneAsync( + string sceneName, + LoadSceneMode loadMode = LoadSceneMode.Single, + Action extraBindings = null, + LoadSceneRelationship containerMode = LoadSceneRelationship.None, + Action extraBindingsLate = null) + { + PrepareForLoadScene(loadMode, extraBindings, extraBindingsLate, containerMode); + + Assert.That(Application.CanStreamedLevelBeLoaded(sceneName), + "Unable to load scene '{0}'", sceneName); + + return SceneManager.LoadSceneAsync(sceneName, loadMode); + } + + void PrepareForLoadScene( + LoadSceneMode loadMode, + Action extraBindings, + Action extraBindingsLate, + LoadSceneRelationship containerMode) + { + if (loadMode == LoadSceneMode.Single) + { + Assert.IsEqual(containerMode, LoadSceneRelationship.None); + + // Here we explicitly unload all existing scenes rather than relying on Unity to + // do this for us. The reason we do this is to ensure a deterministic destruction + // order for everything in the scene and in the container. + // See comment at ProjectKernel.OnApplicationQuit for more details + _projectKernel.ForceUnloadAllScenes(); + } + + if (containerMode == LoadSceneRelationship.None) + { + SceneContext.ParentContainers = null; + } + else if (containerMode == LoadSceneRelationship.Child) + { + if (_sceneContainer == null) + { + SceneContext.ParentContainers = null; + } + else + { + SceneContext.ParentContainers = new[] { _sceneContainer }; + } + } + else + { + Assert.IsNotNull(_sceneContainer, + "Cannot use LoadSceneRelationship.Sibling when loading scenes from ProjectContext"); + Assert.IsEqual(containerMode, LoadSceneRelationship.Sibling); + SceneContext.ParentContainers = _sceneContainer.ParentContainers; + } + + SceneContext.ExtraBindingsInstallMethod = extraBindings; + SceneContext.ExtraBindingsLateInstallMethod = extraBindingsLate; + } + + public void LoadScene( + int sceneIndex, + LoadSceneMode loadMode = LoadSceneMode.Single, + Action extraBindings = null, + LoadSceneRelationship containerMode = LoadSceneRelationship.None, + Action extraBindingsLate = null) + { + PrepareForLoadScene(loadMode, extraBindings, extraBindingsLate, containerMode); + + Assert.That(Application.CanStreamedLevelBeLoaded(sceneIndex), + "Unable to load scene '{0}'", sceneIndex); + + SceneManager.LoadScene(sceneIndex, loadMode); + + // It would be nice here to actually verify that the new scene has a SceneContext + // if we have extra binding hooks, or LoadSceneRelationship != None, but + // we can't do that in this case since the scene isn't loaded until the next frame + } + + public AsyncOperation LoadSceneAsync( + int sceneIndex, + LoadSceneMode loadMode = LoadSceneMode.Single, + Action extraBindings = null, + LoadSceneRelationship containerMode = LoadSceneRelationship.None, + Action extraBindingsLate = null) + { + PrepareForLoadScene(loadMode, extraBindings, extraBindingsLate, containerMode); + + Assert.That(Application.CanStreamedLevelBeLoaded(sceneIndex), + "Unable to load scene '{0}'", sceneIndex); + + return SceneManager.LoadSceneAsync(sceneIndex, loadMode); + } + } +} + +#endif diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectSceneLoader.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectSceneLoader.cs.meta new file mode 100644 index 0000000..dabe691 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectSceneLoader.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 097ddf2608210fe44a9d215a1721d857 +timeCreated: 1461708048 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectStateMachineBehaviourAutoInjecter.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectStateMachineBehaviourAutoInjecter.cs new file mode 100644 index 0000000..05f8a65 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectStateMachineBehaviourAutoInjecter.cs @@ -0,0 +1,40 @@ +using ModestTree; +using UnityEngine; + +namespace Zenject +{ + public class ZenjectStateMachineBehaviourAutoInjecter : MonoBehaviour + { + DiContainer _container; + Animator _animator; + + [Inject] + public void Construct(DiContainer container) + { + _container = container; + _animator = GetComponent(); + Assert.IsNotNull(_animator); + } + + // The unity docs (https://unity3d.com/learn/tutorials/modules/beginner/5-pre-order-beta/state-machine-behaviours) + // mention that StateMachineBehaviour's should only be retrieved in the Start method + // which is why we do it here + public void Start() + { + // Animator can be null when users create GameObjects directly so in that case + // Just don't bother attempting to inject the behaviour classes + if (_animator != null) + { + var behaviours = _animator.GetBehaviours(); + + if (behaviours != null) + { + foreach (var behaviour in behaviours) + { + _container.Inject(behaviour); + } + } + } + } + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectStateMachineBehaviourAutoInjecter.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectStateMachineBehaviourAutoInjecter.cs.meta new file mode 100644 index 0000000..40571d7 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Util/ZenjectStateMachineBehaviourAutoInjecter.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 486c69818dffcd14f96ce64502516bbb +timeCreated: 1527941118 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: -9991 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation.meta new file mode 100644 index 0000000..1c49dc5 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 577ec212adf31e04bbd46b24f633f1e3 +folderAsset: yes +timeCreated: 1459463884 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation/IValidatable.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation/IValidatable.cs new file mode 100644 index 0000000..ba8f4a6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation/IValidatable.cs @@ -0,0 +1,7 @@ +namespace Zenject +{ + public interface IValidatable + { + void Validate(); + } +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation/IValidatable.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation/IValidatable.cs.meta new file mode 100644 index 0000000..030e251 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation/IValidatable.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5d2a7156fffca9b439f7734d94ccf336 +timeCreated: 1461708050 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation/ValidationMarker.cs b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation/ValidationMarker.cs new file mode 100644 index 0000000..e199a65 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation/ValidationMarker.cs @@ -0,0 +1,33 @@ +using System; + +namespace Zenject +{ + [NoReflectionBaking] + public class ValidationMarker + { + public ValidationMarker( + Type markedType, bool instantiateFailed) + { + MarkedType = markedType; + InstantiateFailed = instantiateFailed; + } + + public ValidationMarker(Type markedType) + : this(markedType, false) + { + } + + public bool InstantiateFailed + { + get; + private set; + } + + public Type MarkedType + { + get; + private set; + } + } +} + diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation/ValidationMarker.cs.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation/ValidationMarker.cs.meta new file mode 100644 index 0000000..b65bd19 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Validation/ValidationMarker.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 27e4cef6504bc0243b1893240d22b72d +timeCreated: 1461708049 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Zenject.csproj.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Zenject.csproj.meta new file mode 100644 index 0000000..eff454d --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Source/Zenject.csproj.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8645273165cb7f54290d6eaa1e10ab37 +timeCreated: 1461878212 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Version.txt b/UnityActionUpdaterService/Assets/Plugins/Zenject/Version.txt new file mode 100644 index 0000000..deeb3d6 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Version.txt @@ -0,0 +1 @@ +9.2.0 diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/Version.txt.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/Version.txt.meta new file mode 100644 index 0000000..104e888 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/Version.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4917e73af158b1e4782b175c0568afcf +timeCreated: 1452175972 +licenseType: Store +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/package.json b/UnityActionUpdaterService/Assets/Plugins/Zenject/package.json new file mode 100644 index 0000000..36bea62 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/package.json @@ -0,0 +1,8 @@ + +{ + "name": "com.mathijsbakker.extenject", + "displayName": "Extenject", + "version": "9.2.0", + "description": "Dependency Injection Framework for Unity3D", + "unity": "2019.3" +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/package.json.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/package.json.meta new file mode 100644 index 0000000..da96800 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/package.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: b5ee7f1788474bd44a48b0a201461151 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/zenject.asmdef b/UnityActionUpdaterService/Assets/Plugins/Zenject/zenject.asmdef new file mode 100644 index 0000000..def0954 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/zenject.asmdef @@ -0,0 +1,3 @@ +{ + "name": "Zenject" +} diff --git a/UnityActionUpdaterService/Assets/Plugins/Zenject/zenject.asmdef.meta b/UnityActionUpdaterService/Assets/Plugins/Zenject/zenject.asmdef.meta new file mode 100644 index 0000000..46f04de --- /dev/null +++ b/UnityActionUpdaterService/Assets/Plugins/Zenject/zenject.asmdef.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0d8beb7f090555447a6cf5ce9e54dbb4 +timeCreated: 1531030458 +licenseType: Store +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Resources.meta b/UnityActionUpdaterService/Assets/Resources.meta new file mode 100644 index 0000000..094535f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b89714c5b945e1b4cba211b2ab272e80 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Assets/Resources/ProjectContext.prefab b/UnityActionUpdaterService/Assets/Resources/ProjectContext.prefab new file mode 100644 index 0000000..e15fc35 --- /dev/null +++ b/UnityActionUpdaterService/Assets/Resources/ProjectContext.prefab @@ -0,0 +1,89 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2852676154417311453 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3610626289738869952} + - component: {fileID: 1943409333942081146} + - component: {fileID: -4354688342791186411} + - component: {fileID: 4225630340514570631} + m_Layer: 0 + m_Name: ProjectContext + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3610626289738869952 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2852676154417311453} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1943409333942081146 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2852676154417311453} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a4e6589720da476459dc6dd71624b071, type: 3} + m_Name: + m_EditorClassIdentifier: + _scriptableObjectInstallers: [] + _monoInstallers: + - {fileID: -4354688342791186411} + _installerPrefabs: [] + _parentNewObjectsUnderContext: 1 + _editorReflectionBakingCoverageMode: 0 + _buildsReflectionBakingCoverageMode: 0 + _settings: + _ensureDeterministicDestructionOrderOnApplicationQuit: 0 + _displayWarningWhenResolvingDuringInstall: 1 + _validationRootResolveMethod: 0 + _validationErrorResponse: 0 + _signalSettings: + _defaultSyncMode: 0 + _missingHandlerDefaultResponse: 2 + _requireStrictUnsubscribe: 0 + _defaultAsyncTickPriority: 1 +--- !u!114 &-4354688342791186411 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2852676154417311453} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8a5b6d620b74e5299d770435fc5cd30, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &4225630340514570631 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2852676154417311453} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 64fe7a25dc404739b3df57dbe5447840, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/UnityActionUpdaterService/Assets/Resources/ProjectContext.prefab.meta b/UnityActionUpdaterService/Assets/Resources/ProjectContext.prefab.meta new file mode 100644 index 0000000..148693f --- /dev/null +++ b/UnityActionUpdaterService/Assets/Resources/ProjectContext.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bcb33965c7a25894382bcbe90b7e4cb7 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityActionUpdaterService/Packages/manifest.json b/UnityActionUpdaterService/Packages/manifest.json new file mode 100644 index 0000000..9b1952f --- /dev/null +++ b/UnityActionUpdaterService/Packages/manifest.json @@ -0,0 +1,41 @@ +{ + "dependencies": { + "com.unity.collab-proxy": "2.2.0", + "com.unity.feature.development": "1.0.1", + "com.unity.textmeshpro": "3.0.6", + "com.unity.timeline": "1.7.5", + "com.unity.ugui": "1.0.0", + "com.unity.visualscripting": "1.9.0", + "com.unity.modules.ai": "1.0.0", + "com.unity.modules.androidjni": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.cloth": "1.0.0", + "com.unity.modules.director": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.physics2d": "1.0.0", + "com.unity.modules.screencapture": "1.0.0", + "com.unity.modules.terrain": "1.0.0", + "com.unity.modules.terrainphysics": "1.0.0", + "com.unity.modules.tilemap": "1.0.0", + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.uielements": "1.0.0", + "com.unity.modules.umbra": "1.0.0", + "com.unity.modules.unityanalytics": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.unitywebrequesttexture": "1.0.0", + "com.unity.modules.unitywebrequestwww": "1.0.0", + "com.unity.modules.vehicles": "1.0.0", + "com.unity.modules.video": "1.0.0", + "com.unity.modules.vr": "1.0.0", + "com.unity.modules.wind": "1.0.0", + "com.unity.modules.xr": "1.0.0" + } +} diff --git a/UnityActionUpdaterService/Packages/packages-lock.json b/UnityActionUpdaterService/Packages/packages-lock.json new file mode 100644 index 0000000..3952ede --- /dev/null +++ b/UnityActionUpdaterService/Packages/packages-lock.json @@ -0,0 +1,382 @@ +{ + "dependencies": { + "com.unity.collab-proxy": { + "version": "2.2.0", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.editorcoroutines": { + "version": "1.0.0", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.ext.nunit": { + "version": "1.0.6", + "depth": 2, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.feature.development": { + "version": "1.0.1", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.ide.visualstudio": "2.0.18", + "com.unity.ide.rider": "3.0.24", + "com.unity.ide.vscode": "1.2.5", + "com.unity.editorcoroutines": "1.0.0", + "com.unity.performance.profile-analyzer": "1.2.2", + "com.unity.test-framework": "1.1.33", + "com.unity.testtools.codecoverage": "1.2.4" + } + }, + "com.unity.ide.rider": { + "version": "3.0.24", + "depth": 1, + "source": "registry", + "dependencies": { + "com.unity.ext.nunit": "1.0.6" + }, + "url": "https://packages.unity.com" + }, + "com.unity.ide.visualstudio": { + "version": "2.0.18", + "depth": 1, + "source": "registry", + "dependencies": { + "com.unity.test-framework": "1.1.9" + }, + "url": "https://packages.unity.com" + }, + "com.unity.ide.vscode": { + "version": "1.2.5", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.performance.profile-analyzer": { + "version": "1.2.2", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.settings-manager": { + "version": "2.0.1", + "depth": 2, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.test-framework": { + "version": "1.1.33", + "depth": 1, + "source": "registry", + "dependencies": { + "com.unity.ext.nunit": "1.0.6", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.testtools.codecoverage": { + "version": "1.2.4", + "depth": 1, + "source": "registry", + "dependencies": { + "com.unity.test-framework": "1.0.16", + "com.unity.settings-manager": "1.0.1" + }, + "url": "https://packages.unity.com" + }, + "com.unity.textmeshpro": { + "version": "3.0.6", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ugui": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.timeline": { + "version": "1.7.5", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.modules.director": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.ugui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.imgui": "1.0.0" + } + }, + "com.unity.visualscripting": { + "version": "1.9.0", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ugui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.modules.ai": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.androidjni": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.animation": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.assetbundle": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.audio": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.cloth": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0" + } + }, + "com.unity.modules.director": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.animation": "1.0.0" + } + }, + "com.unity.modules.imageconversion": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.imgui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.jsonserialize": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.particlesystem": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.physics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.physics2d": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.screencapture": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.subsystems": { + "version": "1.0.0", + "depth": 1, + "source": "builtin", + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.terrain": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.terrainphysics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.terrain": "1.0.0" + } + }, + "com.unity.modules.tilemap": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics2d": "1.0.0" + } + }, + "com.unity.modules.ui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.uielements": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.umbra": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.unityanalytics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.unitywebrequest": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.unitywebrequestassetbundle": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0" + } + }, + "com.unity.modules.unitywebrequestaudio": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.audio": "1.0.0" + } + }, + "com.unity.modules.unitywebrequesttexture": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.unitywebrequestwww": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.vehicles": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0" + } + }, + "com.unity.modules.video": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0" + } + }, + "com.unity.modules.vr": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.xr": "1.0.0" + } + }, + "com.unity.modules.wind": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.xr": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.subsystems": "1.0.0" + } + } + } +} diff --git a/UnityActionUpdaterService/ProjectSettings/AudioManager.asset b/UnityActionUpdaterService/ProjectSettings/AudioManager.asset new file mode 100644 index 0000000..07ebfb0 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/AudioManager.asset @@ -0,0 +1,19 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!11 &1 +AudioManager: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Volume: 1 + Rolloff Scale: 1 + Doppler Factor: 1 + Default Speaker Mode: 2 + m_SampleRate: 0 + m_DSPBufferSize: 1024 + m_VirtualVoiceCount: 512 + m_RealVoiceCount: 32 + m_SpatializerPlugin: + m_AmbisonicDecoderPlugin: + m_DisableAudio: 0 + m_VirtualizeEffects: 1 + m_RequestedDSPBufferSize: 1024 diff --git a/UnityActionUpdaterService/ProjectSettings/ClusterInputManager.asset b/UnityActionUpdaterService/ProjectSettings/ClusterInputManager.asset new file mode 100644 index 0000000..e7886b2 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/ClusterInputManager.asset @@ -0,0 +1,6 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!236 &1 +ClusterInputManager: + m_ObjectHideFlags: 0 + m_Inputs: [] diff --git a/UnityActionUpdaterService/ProjectSettings/DynamicsManager.asset b/UnityActionUpdaterService/ProjectSettings/DynamicsManager.asset new file mode 100644 index 0000000..cdc1f3e --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/DynamicsManager.asset @@ -0,0 +1,34 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!55 &1 +PhysicsManager: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_Gravity: {x: 0, y: -9.81, z: 0} + m_DefaultMaterial: {fileID: 0} + m_BounceThreshold: 2 + m_SleepThreshold: 0.005 + m_DefaultContactOffset: 0.01 + m_DefaultSolverIterations: 6 + m_DefaultSolverVelocityIterations: 1 + m_QueriesHitBackfaces: 0 + m_QueriesHitTriggers: 1 + m_EnableAdaptiveForce: 0 + m_ClothInterCollisionDistance: 0 + m_ClothInterCollisionStiffness: 0 + m_ContactsGeneration: 1 + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + m_AutoSimulation: 1 + m_AutoSyncTransforms: 0 + m_ReuseCollisionCallbacks: 1 + m_ClothInterCollisionSettingsToggle: 0 + m_ContactPairsMode: 0 + m_BroadphaseType: 0 + m_WorldBounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 250, y: 250, z: 250} + m_WorldSubdivisions: 8 + m_FrictionType: 0 + m_EnableEnhancedDeterminism: 0 + m_EnableUnifiedHeightmaps: 1 + m_DefaultMaxAngluarSpeed: 7 diff --git a/UnityActionUpdaterService/ProjectSettings/EditorBuildSettings.asset b/UnityActionUpdaterService/ProjectSettings/EditorBuildSettings.asset new file mode 100644 index 0000000..55cbfc9 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/EditorBuildSettings.asset @@ -0,0 +1,11 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1045 &1 +EditorBuildSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Scenes: + - enabled: 1 + path: Assets/Internal/Scenes/SampleScene.unity + guid: 9fc0d4010bbf28b4594072e72b8655ab + m_configObjects: {} diff --git a/UnityActionUpdaterService/ProjectSettings/EditorSettings.asset b/UnityActionUpdaterService/ProjectSettings/EditorSettings.asset new file mode 100644 index 0000000..3f6fb2f --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/EditorSettings.asset @@ -0,0 +1,47 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!159 &1 +EditorSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_SerializationMode: 2 + m_LineEndingsForNewScripts: 0 + m_DefaultBehaviorMode: 0 + m_PrefabRegularEnvironment: {fileID: 0} + m_PrefabUIEnvironment: {fileID: 0} + m_SpritePackerMode: 0 + m_SpritePackerCacheSize: 10 + m_SpritePackerPaddingPower: 1 + m_Bc7TextureCompressor: 0 + m_EtcTextureCompressorBehavior: 1 + m_EtcTextureFastCompressor: 1 + m_EtcTextureNormalCompressor: 2 + m_EtcTextureBestCompressor: 4 + m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref + m_ProjectGenerationRootNamespace: RimuruDev + m_EnableTextureStreamingInEditMode: 1 + m_EnableTextureStreamingInPlayMode: 1 + m_EnableEditorAsyncCPUTextureLoading: 0 + m_AsyncShaderCompilation: 1 + m_PrefabModeAllowAutoSave: 1 + m_EnterPlayModeOptionsEnabled: 0 + m_EnterPlayModeOptions: 3 + m_GameObjectNamingDigits: 1 + m_GameObjectNamingScheme: 2 + m_AssetNamingUsesSpace: 0 + m_InspectorUseIMGUIDefaultInspector: 0 + m_UseLegacyProbeSampleCount: 0 + m_SerializeInlineMappingsOnOneLine: 1 + m_DisableCookiesInLightmapper: 0 + m_AssetPipelineMode: 1 + m_RefreshImportMode: 0 + m_CacheServerMode: 0 + m_CacheServerEndpoint: + m_CacheServerNamespacePrefix: default + m_CacheServerEnableDownload: 1 + m_CacheServerEnableUpload: 1 + m_CacheServerEnableAuth: 0 + m_CacheServerEnableTls: 0 + m_CacheServerValidationMode: 2 + m_CacheServerDownloadBatchSize: 128 + m_EnableEnlightenBakedGI: 0 diff --git a/UnityActionUpdaterService/ProjectSettings/GraphicsSettings.asset b/UnityActionUpdaterService/ProjectSettings/GraphicsSettings.asset new file mode 100644 index 0000000..43369e3 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/GraphicsSettings.asset @@ -0,0 +1,63 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!30 &1 +GraphicsSettings: + m_ObjectHideFlags: 0 + serializedVersion: 13 + m_Deferred: + m_Mode: 1 + m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} + m_DeferredReflections: + m_Mode: 1 + m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} + m_ScreenSpaceShadows: + m_Mode: 1 + m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} + m_LegacyDeferred: + m_Mode: 1 + m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} + m_DepthNormals: + m_Mode: 1 + m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} + m_MotionVectors: + m_Mode: 1 + m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} + m_LightHalo: + m_Mode: 1 + m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} + m_LensFlare: + m_Mode: 1 + m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} + m_AlwaysIncludedShaders: + - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} + m_PreloadedShaders: [] + m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, + type: 0} + m_CustomRenderPipeline: {fileID: 0} + m_TransparencySortMode: 0 + m_TransparencySortAxis: {x: 0, y: 0, z: 1} + m_DefaultRenderingPath: 1 + m_DefaultMobileRenderingPath: 1 + m_TierSettings: [] + m_LightmapStripping: 0 + m_FogStripping: 0 + m_InstancingStripping: 0 + m_LightmapKeepPlain: 1 + m_LightmapKeepDirCombined: 1 + m_LightmapKeepDynamicPlain: 1 + m_LightmapKeepDynamicDirCombined: 1 + m_LightmapKeepShadowMask: 1 + m_LightmapKeepSubtractive: 1 + m_FogKeepLinear: 1 + m_FogKeepExp: 1 + m_FogKeepExp2: 1 + m_AlbedoSwatchInfos: [] + m_LightsUseLinearIntensity: 0 + m_LightsUseColorTemperature: 0 + m_LogWhenShaderIsCompiled: 0 + m_AllowEnlightenSupportForUpgradedProject: 0 diff --git a/UnityActionUpdaterService/ProjectSettings/InputManager.asset b/UnityActionUpdaterService/ProjectSettings/InputManager.asset new file mode 100644 index 0000000..17c8f53 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/InputManager.asset @@ -0,0 +1,295 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: 0.001 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: 0.001 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left shift + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0.19 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0.19 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Submit + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: return + altNegativeButton: + altPositiveButton: joystick button 0 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Submit + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: enter + altNegativeButton: + altPositiveButton: space + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Cancel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: escape + altNegativeButton: + altPositiveButton: joystick button 1 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 diff --git a/UnityActionUpdaterService/ProjectSettings/MemorySettings.asset b/UnityActionUpdaterService/ProjectSettings/MemorySettings.asset new file mode 100644 index 0000000..5b5face --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/MemorySettings.asset @@ -0,0 +1,35 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!387306366 &1 +MemorySettings: + m_ObjectHideFlags: 0 + m_EditorMemorySettings: + m_MainAllocatorBlockSize: -1 + m_ThreadAllocatorBlockSize: -1 + m_MainGfxBlockSize: -1 + m_ThreadGfxBlockSize: -1 + m_CacheBlockSize: -1 + m_TypetreeBlockSize: -1 + m_ProfilerBlockSize: -1 + m_ProfilerEditorBlockSize: -1 + m_BucketAllocatorGranularity: -1 + m_BucketAllocatorBucketsCount: -1 + m_BucketAllocatorBlockSize: -1 + m_BucketAllocatorBlockCount: -1 + m_ProfilerBucketAllocatorGranularity: -1 + m_ProfilerBucketAllocatorBucketsCount: -1 + m_ProfilerBucketAllocatorBlockSize: -1 + m_ProfilerBucketAllocatorBlockCount: -1 + m_TempAllocatorSizeMain: -1 + m_JobTempAllocatorBlockSize: -1 + m_BackgroundJobTempAllocatorBlockSize: -1 + m_JobTempAllocatorReducedBlockSize: -1 + m_TempAllocatorSizeGIBakingWorker: -1 + m_TempAllocatorSizeNavMeshWorker: -1 + m_TempAllocatorSizeAudioWorker: -1 + m_TempAllocatorSizeCloudWorker: -1 + m_TempAllocatorSizeGfx: -1 + m_TempAllocatorSizeJobWorker: -1 + m_TempAllocatorSizeBackgroundWorker: -1 + m_TempAllocatorSizePreloadManager: -1 + m_PlatformMemorySettings: {} diff --git a/UnityActionUpdaterService/ProjectSettings/NavMeshAreas.asset b/UnityActionUpdaterService/ProjectSettings/NavMeshAreas.asset new file mode 100644 index 0000000..3b0b7c3 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/NavMeshAreas.asset @@ -0,0 +1,91 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!126 &1 +NavMeshProjectSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + areas: + - name: Walkable + cost: 1 + - name: Not Walkable + cost: 1 + - name: Jump + cost: 2 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + m_LastAgentTypeID: -887442657 + m_Settings: + - serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.75 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_SettingNames: + - Humanoid diff --git a/UnityActionUpdaterService/ProjectSettings/PackageManagerSettings.asset b/UnityActionUpdaterService/ProjectSettings/PackageManagerSettings.asset new file mode 100644 index 0000000..112a053 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/PackageManagerSettings.asset @@ -0,0 +1,35 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &1 +MonoBehaviour: + m_ObjectHideFlags: 61 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} + m_Name: + m_EditorClassIdentifier: + m_EnablePreReleasePackages: 0 + m_EnablePackageDependencies: 0 + m_AdvancedSettingsExpanded: 1 + m_ScopedRegistriesSettingsExpanded: 1 + m_SeeAllPackageVersions: 0 + oneTimeWarningShown: 0 + m_Registries: + - m_Id: main + m_Name: + m_Url: https://packages.unity.com + m_Scopes: [] + m_IsDefault: 1 + m_Capabilities: 7 + m_UserSelectedRegistryName: + m_UserAddingNewScopedRegistry: 0 + m_RegistryInfoDraft: + m_Modified: 0 + m_ErrorMessage: + m_UserModificationsInstanceId: -830 + m_OriginalInstanceId: -832 + m_LoadAssets: 0 diff --git a/UnityActionUpdaterService/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json b/UnityActionUpdaterService/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json new file mode 100644 index 0000000..3c7b4c1 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json @@ -0,0 +1,5 @@ +{ + "m_Dictionary": { + "m_DictionaryValues": [] + } +} \ No newline at end of file diff --git a/UnityActionUpdaterService/ProjectSettings/Physics2DSettings.asset b/UnityActionUpdaterService/ProjectSettings/Physics2DSettings.asset new file mode 100644 index 0000000..47880b1 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/Physics2DSettings.asset @@ -0,0 +1,56 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!19 &1 +Physics2DSettings: + m_ObjectHideFlags: 0 + serializedVersion: 4 + m_Gravity: {x: 0, y: -9.81} + m_DefaultMaterial: {fileID: 0} + m_VelocityIterations: 8 + m_PositionIterations: 3 + m_VelocityThreshold: 1 + m_MaxLinearCorrection: 0.2 + m_MaxAngularCorrection: 8 + m_MaxTranslationSpeed: 100 + m_MaxRotationSpeed: 360 + m_BaumgarteScale: 0.2 + m_BaumgarteTimeOfImpactScale: 0.75 + m_TimeToSleep: 0.5 + m_LinearSleepTolerance: 0.01 + m_AngularSleepTolerance: 2 + m_DefaultContactOffset: 0.01 + m_JobOptions: + serializedVersion: 2 + useMultithreading: 0 + useConsistencySorting: 0 + m_InterpolationPosesPerJob: 100 + m_NewContactsPerJob: 30 + m_CollideContactsPerJob: 100 + m_ClearFlagsPerJob: 200 + m_ClearBodyForcesPerJob: 200 + m_SyncDiscreteFixturesPerJob: 50 + m_SyncContinuousFixturesPerJob: 50 + m_FindNearestContactsPerJob: 100 + m_UpdateTriggerContactsPerJob: 100 + m_IslandSolverCostThreshold: 100 + m_IslandSolverBodyCostScale: 1 + m_IslandSolverContactCostScale: 10 + m_IslandSolverJointCostScale: 10 + m_IslandSolverBodiesPerJob: 50 + m_IslandSolverContactsPerJob: 50 + m_AutoSimulation: 1 + m_QueriesHitTriggers: 1 + m_QueriesStartInColliders: 1 + m_CallbacksOnDisable: 1 + m_ReuseCollisionCallbacks: 1 + m_AutoSyncTransforms: 0 + m_AlwaysShowColliders: 0 + m_ShowColliderSleep: 1 + m_ShowColliderContacts: 0 + m_ShowColliderAABB: 0 + m_ContactArrowScale: 0.2 + m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} + m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} + m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} + m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/UnityActionUpdaterService/ProjectSettings/PresetManager.asset b/UnityActionUpdaterService/ProjectSettings/PresetManager.asset new file mode 100644 index 0000000..67a94da --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/PresetManager.asset @@ -0,0 +1,7 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1386491679 &1 +PresetManager: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_DefaultPresets: {} diff --git a/UnityActionUpdaterService/ProjectSettings/ProjectSettings.asset b/UnityActionUpdaterService/ProjectSettings/ProjectSettings.asset new file mode 100644 index 0000000..9485193 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/ProjectSettings.asset @@ -0,0 +1,952 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!129 &1 +PlayerSettings: + m_ObjectHideFlags: 0 + serializedVersion: 26 + productGUID: 522f644efaeff99408d9f7d746b1981b + AndroidProfiler: 0 + AndroidFilterTouchesWhenObscured: 0 + AndroidEnableSustainedPerformanceMode: 0 + defaultScreenOrientation: 4 + targetDevice: 2 + useOnDemandResources: 0 + accelerometerFrequency: 60 + companyName: RimuruDev + productName: UnityActionUpdaterService + defaultCursor: {fileID: 0} + cursorHotspot: {x: 0, y: 0} + m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} + m_ShowUnitySplashScreen: 1 + m_ShowUnitySplashLogo: 1 + m_SplashScreenOverlayOpacity: 1 + m_SplashScreenAnimation: 1 + m_SplashScreenLogoStyle: 1 + m_SplashScreenDrawMode: 0 + m_SplashScreenBackgroundAnimationZoom: 1 + m_SplashScreenLogoAnimationZoom: 1 + m_SplashScreenBackgroundLandscapeAspect: 1 + m_SplashScreenBackgroundPortraitAspect: 1 + m_SplashScreenBackgroundLandscapeUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenBackgroundPortraitUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenLogos: [] + m_VirtualRealitySplashScreen: {fileID: 0} + m_HolographicTrackingLossScreen: {fileID: 0} + defaultScreenWidth: 1920 + defaultScreenHeight: 1080 + defaultScreenWidthWeb: 960 + defaultScreenHeightWeb: 600 + m_StereoRenderingPath: 0 + m_ActiveColorSpace: 0 + m_SpriteBatchVertexThreshold: 300 + m_MTRendering: 1 + mipStripping: 0 + numberOfMipsStripped: 0 + numberOfMipsStrippedPerMipmapLimitGroup: {} + m_StackTraceTypes: 010000000100000001000000010000000100000001000000 + iosShowActivityIndicatorOnLoading: -1 + androidShowActivityIndicatorOnLoading: -1 + iosUseCustomAppBackgroundBehavior: 0 + allowedAutorotateToPortrait: 1 + allowedAutorotateToPortraitUpsideDown: 1 + allowedAutorotateToLandscapeRight: 1 + allowedAutorotateToLandscapeLeft: 1 + useOSAutorotation: 1 + use32BitDisplayBuffer: 1 + preserveFramebufferAlpha: 0 + disableDepthAndStencilBuffers: 0 + androidStartInFullscreen: 1 + androidRenderOutsideSafeArea: 1 + androidUseSwappy: 1 + androidBlitType: 0 + androidResizableWindow: 0 + androidDefaultWindowWidth: 1920 + androidDefaultWindowHeight: 1080 + androidMinimumWindowWidth: 400 + androidMinimumWindowHeight: 300 + androidFullscreenMode: 1 + defaultIsNativeResolution: 1 + macRetinaSupport: 1 + runInBackground: 1 + captureSingleScreen: 0 + muteOtherAudioSources: 0 + Prepare IOS For Recording: 0 + Force IOS Speakers When Recording: 0 + deferSystemGesturesMode: 0 + hideHomeButton: 0 + submitAnalytics: 1 + usePlayerLog: 1 + dedicatedServerOptimizations: 0 + bakeCollisionMeshes: 0 + forceSingleInstance: 0 + useFlipModelSwapchain: 1 + resizableWindow: 0 + useMacAppStoreValidation: 0 + macAppStoreCategory: public.app-category.games + gpuSkinning: 1 + xboxPIXTextureCapture: 0 + xboxEnableAvatar: 0 + xboxEnableKinect: 0 + xboxEnableKinectAutoTracking: 0 + xboxEnableFitness: 0 + visibleInBackground: 1 + allowFullscreenSwitch: 1 + fullscreenMode: 1 + xboxSpeechDB: 0 + xboxEnableHeadOrientation: 0 + xboxEnableGuest: 0 + xboxEnablePIXSampling: 0 + metalFramebufferOnly: 0 + xboxOneResolution: 0 + xboxOneSResolution: 0 + xboxOneXResolution: 3 + xboxOneMonoLoggingLevel: 0 + xboxOneLoggingLevel: 1 + xboxOneDisableEsram: 0 + xboxOneEnableTypeOptimization: 0 + xboxOnePresentImmediateThreshold: 0 + switchQueueCommandMemory: 0 + switchQueueControlMemory: 16384 + switchQueueComputeMemory: 262144 + switchNVNShaderPoolsGranularity: 33554432 + switchNVNDefaultPoolsGranularity: 16777216 + switchNVNOtherPoolsGranularity: 16777216 + switchGpuScratchPoolGranularity: 2097152 + switchAllowGpuScratchShrinking: 0 + switchNVNMaxPublicTextureIDCount: 0 + switchNVNMaxPublicSamplerIDCount: 0 + switchNVNGraphicsFirmwareMemory: 32 + switchMaxWorkerMultiple: 8 + stadiaPresentMode: 0 + stadiaTargetFramerate: 0 + vulkanNumSwapchainBuffers: 3 + vulkanEnableSetSRGBWrite: 0 + vulkanEnablePreTransform: 1 + vulkanEnableLateAcquireNextImage: 0 + vulkanEnableCommandBufferRecycling: 1 + loadStoreDebugModeEnabled: 0 + bundleVersion: 1.0.0.0 + preloadedAssets: [] + metroInputSource: 0 + wsaTransparentSwapchain: 0 + m_HolographicPauseOnTrackingLoss: 1 + xboxOneDisableKinectGpuReservation: 1 + xboxOneEnable7thCore: 1 + vrSettings: + enable360StereoCapture: 0 + isWsaHolographicRemotingEnabled: 0 + enableFrameTimingStats: 0 + enableOpenGLProfilerGPURecorders: 0 + useHDRDisplay: 0 + hdrBitDepth: 0 + m_ColorGamuts: 00000000 + targetPixelDensity: 30 + resolutionScalingMode: 0 + resetResolutionOnWindowResize: 0 + androidSupportedAspectRatio: 1 + androidMaxAspectRatio: 2.1 + applicationIdentifier: + Standalone: com.RimuruDev.UnityActionUpdaterService + buildNumber: + Standalone: 0 + VisionOS: 0 + iPhone: 0 + tvOS: 0 + overrideDefaultApplicationIdentifier: 1 + AndroidBundleVersionCode: 1 + AndroidMinSdkVersion: 22 + AndroidTargetSdkVersion: 0 + AndroidPreferredInstallLocation: 1 + aotOptions: + stripEngineCode: 1 + iPhoneStrippingLevel: 0 + iPhoneScriptCallOptimization: 0 + ForceInternetPermission: 0 + ForceSDCardPermission: 0 + CreateWallpaper: 0 + APKExpansionFiles: 0 + keepLoadedShadersAlive: 0 + StripUnusedMeshComponents: 1 + strictShaderVariantMatching: 0 + VertexChannelCompressionMask: 4054 + iPhoneSdkVersion: 988 + iOSTargetOSVersionString: 12.0 + tvOSSdkVersion: 0 + tvOSRequireExtendedGameController: 0 + tvOSTargetOSVersionString: 12.0 + VisionOSSdkVersion: 0 + VisionOSTargetOSVersionString: 1.0 + uIPrerenderedIcon: 0 + uIRequiresPersistentWiFi: 0 + uIRequiresFullScreen: 1 + uIStatusBarHidden: 1 + uIExitOnSuspend: 0 + uIStatusBarStyle: 0 + appleTVSplashScreen: {fileID: 0} + appleTVSplashScreen2x: {fileID: 0} + tvOSSmallIconLayers: [] + tvOSSmallIconLayers2x: [] + tvOSLargeIconLayers: [] + tvOSLargeIconLayers2x: [] + tvOSTopShelfImageLayers: [] + tvOSTopShelfImageLayers2x: [] + tvOSTopShelfImageWideLayers: [] + tvOSTopShelfImageWideLayers2x: [] + iOSLaunchScreenType: 0 + iOSLaunchScreenPortrait: {fileID: 0} + iOSLaunchScreenLandscape: {fileID: 0} + iOSLaunchScreenBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreenFillPct: 100 + iOSLaunchScreenSize: 100 + iOSLaunchScreenCustomXibPath: + iOSLaunchScreeniPadType: 0 + iOSLaunchScreeniPadImage: {fileID: 0} + iOSLaunchScreeniPadBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreeniPadFillPct: 100 + iOSLaunchScreeniPadSize: 100 + iOSLaunchScreeniPadCustomXibPath: + iOSLaunchScreenCustomStoryboardPath: + iOSLaunchScreeniPadCustomStoryboardPath: + iOSDeviceRequirements: [] + iOSURLSchemes: [] + macOSURLSchemes: [] + iOSBackgroundModes: 0 + iOSMetalForceHardShadows: 0 + metalEditorSupport: 1 + metalAPIValidation: 1 + iOSRenderExtraFrameOnPause: 0 + iosCopyPluginsCodeInsteadOfSymlink: 0 + appleDeveloperTeamID: + iOSManualSigningProvisioningProfileID: + tvOSManualSigningProvisioningProfileID: + VisionOSManualSigningProvisioningProfileID: + iOSManualSigningProvisioningProfileType: 0 + tvOSManualSigningProvisioningProfileType: 0 + VisionOSManualSigningProvisioningProfileType: 0 + appleEnableAutomaticSigning: 0 + iOSRequireARKit: 0 + iOSAutomaticallyDetectAndAddCapabilities: 1 + appleEnableProMotion: 0 + shaderPrecisionModel: 0 + clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea + templatePackageId: com.unity.template.3d@8.1.1 + templateDefaultScene: Assets/Scenes/SampleScene.unity + useCustomMainManifest: 0 + useCustomLauncherManifest: 0 + useCustomMainGradleTemplate: 0 + useCustomLauncherGradleManifest: 0 + useCustomBaseGradleTemplate: 0 + useCustomGradlePropertiesTemplate: 0 + useCustomGradleSettingsTemplate: 0 + useCustomProguardFile: 0 + AndroidTargetArchitectures: 1 + AndroidTargetDevices: 0 + AndroidSplashScreenScale: 0 + androidSplashScreen: {fileID: 0} + AndroidKeystoreName: + AndroidKeyaliasName: + AndroidEnableArmv9SecurityFeatures: 0 + AndroidBuildApkPerCpuArchitecture: 0 + AndroidTVCompatibility: 0 + AndroidIsGame: 1 + AndroidEnableTango: 0 + androidEnableBanner: 1 + androidUseLowAccuracyLocation: 0 + androidUseCustomKeystore: 0 + m_AndroidBanners: + - width: 320 + height: 180 + banner: {fileID: 0} + androidGamepadSupportLevel: 0 + chromeosInputEmulation: 1 + AndroidMinifyRelease: 0 + AndroidMinifyDebug: 0 + AndroidValidateAppBundleSize: 1 + AndroidAppBundleSizeToValidate: 150 + m_BuildTargetIcons: [] + m_BuildTargetPlatformIcons: + - m_BuildTarget: iPhone + m_Icons: + - m_Textures: [] + m_Width: 180 + m_Height: 180 + m_Kind: 0 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 120 + m_Height: 120 + m_Kind: 0 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 167 + m_Height: 167 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 152 + m_Height: 152 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 76 + m_Height: 76 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 120 + m_Height: 120 + m_Kind: 3 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 80 + m_Height: 80 + m_Kind: 3 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 80 + m_Height: 80 + m_Kind: 3 + m_SubKind: iPad + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 3 + m_SubKind: iPad + - m_Textures: [] + m_Width: 87 + m_Height: 87 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 58 + m_Height: 58 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 29 + m_Height: 29 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 58 + m_Height: 58 + m_Kind: 1 + m_SubKind: iPad + - m_Textures: [] + m_Width: 29 + m_Height: 29 + m_Kind: 1 + m_SubKind: iPad + - m_Textures: [] + m_Width: 60 + m_Height: 60 + m_Kind: 2 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 2 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 2 + m_SubKind: iPad + - m_Textures: [] + m_Width: 20 + m_Height: 20 + m_Kind: 2 + m_SubKind: iPad + - m_Textures: [] + m_Width: 1024 + m_Height: 1024 + m_Kind: 4 + m_SubKind: App Store + - m_BuildTarget: Android + m_Icons: + - m_Textures: [] + m_Width: 432 + m_Height: 432 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 324 + m_Height: 324 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 216 + m_Height: 216 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 162 + m_Height: 162 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 108 + m_Height: 108 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 81 + m_Height: 81 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 192 + m_Height: 192 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 144 + m_Height: 144 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 96 + m_Height: 96 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 72 + m_Height: 72 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 48 + m_Height: 48 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 36 + m_Height: 36 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 192 + m_Height: 192 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 144 + m_Height: 144 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 96 + m_Height: 96 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 72 + m_Height: 72 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 48 + m_Height: 48 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 36 + m_Height: 36 + m_Kind: 0 + m_SubKind: + m_BuildTargetBatching: + - m_BuildTarget: Standalone + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: tvOS + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: Android + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: iPhone + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: WebGL + m_StaticBatching: 0 + m_DynamicBatching: 0 + m_BuildTargetShaderSettings: [] + m_BuildTargetGraphicsJobs: + - m_BuildTarget: MacStandaloneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: Switch + m_GraphicsJobs: 1 + - m_BuildTarget: MetroSupport + m_GraphicsJobs: 1 + - m_BuildTarget: AppleTVSupport + m_GraphicsJobs: 0 + - m_BuildTarget: BJMSupport + m_GraphicsJobs: 1 + - m_BuildTarget: LinuxStandaloneSupport + m_GraphicsJobs: 1 + - m_BuildTarget: PS4Player + m_GraphicsJobs: 1 + - m_BuildTarget: iOSSupport + m_GraphicsJobs: 0 + - m_BuildTarget: WindowsStandaloneSupport + m_GraphicsJobs: 1 + - m_BuildTarget: XboxOnePlayer + m_GraphicsJobs: 1 + - m_BuildTarget: LuminSupport + m_GraphicsJobs: 0 + - m_BuildTarget: AndroidPlayer + m_GraphicsJobs: 0 + - m_BuildTarget: WebGLSupport + m_GraphicsJobs: 0 + m_BuildTargetGraphicsJobMode: + - m_BuildTarget: PS4Player + m_GraphicsJobMode: 0 + - m_BuildTarget: XboxOnePlayer + m_GraphicsJobMode: 0 + m_BuildTargetGraphicsAPIs: + - m_BuildTarget: AndroidPlayer + m_APIs: 150000000b000000 + m_Automatic: 1 + - m_BuildTarget: iOSSupport + m_APIs: 10000000 + m_Automatic: 1 + - m_BuildTarget: AppleTVSupport + m_APIs: 10000000 + m_Automatic: 1 + - m_BuildTarget: WebGLSupport + m_APIs: 0b000000 + m_Automatic: 1 + m_BuildTargetVRSettings: + - m_BuildTarget: Standalone + m_Enabled: 0 + m_Devices: + - Oculus + - OpenVR + m_DefaultShaderChunkSizeInMB: 16 + m_DefaultShaderChunkCount: 0 + openGLRequireES31: 0 + openGLRequireES31AEP: 0 + openGLRequireES32: 0 + m_TemplateCustomTags: {} + mobileMTRendering: + Android: 1 + iPhone: 1 + tvOS: 1 + m_BuildTargetGroupLightmapEncodingQuality: + - m_BuildTarget: Android + m_EncodingQuality: 1 + - m_BuildTarget: iPhone + m_EncodingQuality: 1 + - m_BuildTarget: tvOS + m_EncodingQuality: 1 + m_BuildTargetGroupHDRCubemapEncodingQuality: + - m_BuildTarget: Android + m_EncodingQuality: 1 + - m_BuildTarget: iPhone + m_EncodingQuality: 1 + - m_BuildTarget: tvOS + m_EncodingQuality: 1 + m_BuildTargetGroupLightmapSettings: [] + m_BuildTargetGroupLoadStoreDebugModeSettings: [] + m_BuildTargetNormalMapEncoding: + - m_BuildTarget: Android + m_Encoding: 1 + - m_BuildTarget: iPhone + m_Encoding: 1 + - m_BuildTarget: tvOS + m_Encoding: 1 + m_BuildTargetDefaultTextureCompressionFormat: + - m_BuildTarget: Android + m_Format: 3 + playModeTestRunnerEnabled: 0 + runPlayModeTestAsEditModeTest: 0 + actionOnDotNetUnhandledException: 1 + enableInternalProfiler: 0 + logObjCUncaughtExceptions: 1 + enableCrashReportAPI: 0 + cameraUsageDescription: + locationUsageDescription: + microphoneUsageDescription: + bluetoothUsageDescription: + macOSTargetOSVersion: 10.13.0 + switchNMETAOverride: + switchNetLibKey: + switchSocketMemoryPoolSize: 6144 + switchSocketAllocatorPoolSize: 128 + switchSocketConcurrencyLimit: 14 + switchScreenResolutionBehavior: 2 + switchUseCPUProfiler: 0 + switchEnableFileSystemTrace: 0 + switchUseGOLDLinker: 0 + switchLTOSetting: 0 + switchApplicationID: 0x01004b9000490000 + switchNSODependencies: + switchCompilerFlags: + switchTitleNames_0: + switchTitleNames_1: + switchTitleNames_2: + switchTitleNames_3: + switchTitleNames_4: + switchTitleNames_5: + switchTitleNames_6: + switchTitleNames_7: + switchTitleNames_8: + switchTitleNames_9: + switchTitleNames_10: + switchTitleNames_11: + switchTitleNames_12: + switchTitleNames_13: + switchTitleNames_14: + switchTitleNames_15: + switchPublisherNames_0: + switchPublisherNames_1: + switchPublisherNames_2: + switchPublisherNames_3: + switchPublisherNames_4: + switchPublisherNames_5: + switchPublisherNames_6: + switchPublisherNames_7: + switchPublisherNames_8: + switchPublisherNames_9: + switchPublisherNames_10: + switchPublisherNames_11: + switchPublisherNames_12: + switchPublisherNames_13: + switchPublisherNames_14: + switchPublisherNames_15: + switchIcons_0: {fileID: 0} + switchIcons_1: {fileID: 0} + switchIcons_2: {fileID: 0} + switchIcons_3: {fileID: 0} + switchIcons_4: {fileID: 0} + switchIcons_5: {fileID: 0} + switchIcons_6: {fileID: 0} + switchIcons_7: {fileID: 0} + switchIcons_8: {fileID: 0} + switchIcons_9: {fileID: 0} + switchIcons_10: {fileID: 0} + switchIcons_11: {fileID: 0} + switchIcons_12: {fileID: 0} + switchIcons_13: {fileID: 0} + switchIcons_14: {fileID: 0} + switchIcons_15: {fileID: 0} + switchSmallIcons_0: {fileID: 0} + switchSmallIcons_1: {fileID: 0} + switchSmallIcons_2: {fileID: 0} + switchSmallIcons_3: {fileID: 0} + switchSmallIcons_4: {fileID: 0} + switchSmallIcons_5: {fileID: 0} + switchSmallIcons_6: {fileID: 0} + switchSmallIcons_7: {fileID: 0} + switchSmallIcons_8: {fileID: 0} + switchSmallIcons_9: {fileID: 0} + switchSmallIcons_10: {fileID: 0} + switchSmallIcons_11: {fileID: 0} + switchSmallIcons_12: {fileID: 0} + switchSmallIcons_13: {fileID: 0} + switchSmallIcons_14: {fileID: 0} + switchSmallIcons_15: {fileID: 0} + switchManualHTML: + switchAccessibleURLs: + switchLegalInformation: + switchMainThreadStackSize: 1048576 + switchPresenceGroupId: + switchLogoHandling: 0 + switchReleaseVersion: 0 + switchDisplayVersion: 1.0.0 + switchStartupUserAccount: 0 + switchSupportedLanguagesMask: 0 + switchLogoType: 0 + switchApplicationErrorCodeCategory: + switchUserAccountSaveDataSize: 0 + switchUserAccountSaveDataJournalSize: 0 + switchApplicationAttribute: 0 + switchCardSpecSize: -1 + switchCardSpecClock: -1 + switchRatingsMask: 0 + switchRatingsInt_0: 0 + switchRatingsInt_1: 0 + switchRatingsInt_2: 0 + switchRatingsInt_3: 0 + switchRatingsInt_4: 0 + switchRatingsInt_5: 0 + switchRatingsInt_6: 0 + switchRatingsInt_7: 0 + switchRatingsInt_8: 0 + switchRatingsInt_9: 0 + switchRatingsInt_10: 0 + switchRatingsInt_11: 0 + switchRatingsInt_12: 0 + switchLocalCommunicationIds_0: + switchLocalCommunicationIds_1: + switchLocalCommunicationIds_2: + switchLocalCommunicationIds_3: + switchLocalCommunicationIds_4: + switchLocalCommunicationIds_5: + switchLocalCommunicationIds_6: + switchLocalCommunicationIds_7: + switchParentalControl: 0 + switchAllowsScreenshot: 1 + switchAllowsVideoCapturing: 1 + switchAllowsRuntimeAddOnContentInstall: 0 + switchDataLossConfirmation: 0 + switchUserAccountLockEnabled: 0 + switchSystemResourceMemory: 16777216 + switchSupportedNpadStyles: 22 + switchNativeFsCacheSize: 32 + switchIsHoldTypeHorizontal: 0 + switchSupportedNpadCount: 8 + switchEnableTouchScreen: 1 + switchSocketConfigEnabled: 0 + switchTcpInitialSendBufferSize: 32 + switchTcpInitialReceiveBufferSize: 64 + switchTcpAutoSendBufferSizeMax: 256 + switchTcpAutoReceiveBufferSizeMax: 256 + switchUdpSendBufferSize: 9 + switchUdpReceiveBufferSize: 42 + switchSocketBufferEfficiency: 4 + switchSocketInitializeEnabled: 1 + switchNetworkInterfaceManagerInitializeEnabled: 1 + switchPlayerConnectionEnabled: 1 + switchUseNewStyleFilepaths: 1 + switchUseLegacyFmodPriorities: 0 + switchUseMicroSleepForYield: 1 + switchEnableRamDiskSupport: 0 + switchMicroSleepForYieldTime: 25 + switchRamDiskSpaceSize: 12 + ps4NPAgeRating: 12 + ps4NPTitleSecret: + ps4NPTrophyPackPath: + ps4ParentalLevel: 11 + ps4ContentID: ED1633-NPXX51362_00-0000000000000000 + ps4Category: 0 + ps4MasterVersion: 01.00 + ps4AppVersion: 01.00 + ps4AppType: 0 + ps4ParamSfxPath: + ps4VideoOutPixelFormat: 0 + ps4VideoOutInitialWidth: 1920 + ps4VideoOutBaseModeInitialWidth: 1920 + ps4VideoOutReprojectionRate: 60 + ps4PronunciationXMLPath: + ps4PronunciationSIGPath: + ps4BackgroundImagePath: + ps4StartupImagePath: + ps4StartupImagesFolder: + ps4IconImagesFolder: + ps4SaveDataImagePath: + ps4SdkOverride: + ps4BGMPath: + ps4ShareFilePath: + ps4ShareOverlayImagePath: + ps4PrivacyGuardImagePath: + ps4ExtraSceSysFile: + ps4NPtitleDatPath: + ps4RemotePlayKeyAssignment: -1 + ps4RemotePlayKeyMappingDir: + ps4PlayTogetherPlayerCount: 0 + ps4EnterButtonAssignment: 1 + ps4ApplicationParam1: 0 + ps4ApplicationParam2: 0 + ps4ApplicationParam3: 0 + ps4ApplicationParam4: 0 + ps4DownloadDataSize: 0 + ps4GarlicHeapSize: 2048 + ps4ProGarlicHeapSize: 2560 + playerPrefsMaxSize: 32768 + ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ + ps4pnSessions: 1 + ps4pnPresence: 1 + ps4pnFriends: 1 + ps4pnGameCustomData: 1 + playerPrefsSupport: 0 + enableApplicationExit: 0 + resetTempFolder: 1 + restrictedAudioUsageRights: 0 + ps4UseResolutionFallback: 0 + ps4ReprojectionSupport: 0 + ps4UseAudio3dBackend: 0 + ps4UseLowGarlicFragmentationMode: 1 + ps4SocialScreenEnabled: 0 + ps4ScriptOptimizationLevel: 0 + ps4Audio3dVirtualSpeakerCount: 14 + ps4attribCpuUsage: 0 + ps4PatchPkgPath: + ps4PatchLatestPkgPath: + ps4PatchChangeinfoPath: + ps4PatchDayOne: 0 + ps4attribUserManagement: 0 + ps4attribMoveSupport: 0 + ps4attrib3DSupport: 0 + ps4attribShareSupport: 0 + ps4attribExclusiveVR: 0 + ps4disableAutoHideSplash: 0 + ps4videoRecordingFeaturesUsed: 0 + ps4contentSearchFeaturesUsed: 0 + ps4CompatibilityPS5: 0 + ps4AllowPS5Detection: 0 + ps4GPU800MHz: 1 + ps4attribEyeToEyeDistanceSettingVR: 0 + ps4IncludedModules: [] + ps4attribVROutputEnabled: 0 + monoEnv: + splashScreenBackgroundSourceLandscape: {fileID: 0} + splashScreenBackgroundSourcePortrait: {fileID: 0} + blurSplashScreenBackground: 1 + spritePackerPolicy: + webGLMemorySize: 16 + webGLExceptionSupport: 1 + webGLNameFilesAsHashes: 0 + webGLShowDiagnostics: 0 + webGLDataCaching: 1 + webGLDebugSymbols: 0 + webGLEmscriptenArgs: + webGLModulesDirectory: + webGLTemplate: APPLICATION:Default + webGLAnalyzeBuildSize: 0 + webGLUseEmbeddedResources: 0 + webGLCompressionFormat: 1 + webGLWasmArithmeticExceptions: 0 + webGLLinkerTarget: 1 + webGLThreadsSupport: 0 + webGLDecompressionFallback: 0 + webGLInitialMemorySize: 32 + webGLMaximumMemorySize: 2048 + webGLMemoryGrowthMode: 2 + webGLMemoryLinearGrowthStep: 16 + webGLMemoryGeometricGrowthStep: 0.2 + webGLMemoryGeometricGrowthCap: 96 + webGLPowerPreference: 2 + scriptingDefineSymbols: {} + additionalCompilerArguments: {} + platformArchitecture: {} + scriptingBackend: {} + il2cppCompilerConfiguration: {} + il2cppCodeGeneration: {} + managedStrippingLevel: + EmbeddedLinux: 1 + GameCoreScarlett: 1 + GameCoreXboxOne: 1 + Nintendo Switch: 1 + PS4: 1 + PS5: 1 + QNX: 1 + Stadia: 1 + VisionOS: 1 + WebGL: 1 + Windows Store Apps: 1 + XboxOne: 1 + iPhone: 1 + tvOS: 1 + incrementalIl2cppBuild: {} + suppressCommonWarnings: 1 + allowUnsafeCode: 0 + useDeterministicCompilation: 1 + additionalIl2CppArgs: + scriptingRuntimeVersion: 1 + gcIncremental: 1 + gcWBarrierValidation: 0 + apiCompatibilityLevelPerPlatform: {} + m_RenderingPath: 1 + m_MobileRenderingPath: 1 + metroPackageName: UnityActionUpdaterService + metroPackageVersion: 1.0.0.0 + metroCertificatePath: + metroCertificatePassword: + metroCertificateSubject: + metroCertificateIssuer: + metroCertificateNotAfter: 0000000000000000 + metroApplicationDescription: UnityActionUpdaterService + wsaImages: {} + metroTileShortName: UnityActionUpdaterService + metroTileShowName: 0 + metroMediumTileShowName: 0 + metroLargeTileShowName: 0 + metroWideTileShowName: 0 + metroSupportStreamingInstall: 0 + metroLastRequiredScene: 0 + metroDefaultTileSize: 1 + metroTileForegroundText: 2 + metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} + metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, a: 1} + metroSplashScreenUseBackgroundColor: 0 + platformCapabilities: {} + metroTargetDeviceFamilies: {} + metroFTAName: + metroFTAFileTypes: [] + metroProtocolName: + vcxProjDefaultLanguage: + XboxOneProductId: + XboxOneUpdateKey: + XboxOneSandboxId: + XboxOneContentId: + XboxOneTitleId: + XboxOneSCId: + XboxOneGameOsOverridePath: + XboxOnePackagingOverridePath: + XboxOneAppManifestOverridePath: + XboxOneVersion: 1.0.0.0 + XboxOnePackageEncryption: 0 + XboxOnePackageUpdateGranularity: 2 + XboxOneDescription: + XboxOneLanguage: + - enus + XboxOneCapability: [] + XboxOneGameRating: {} + XboxOneIsContentPackage: 0 + XboxOneEnhancedXboxCompatibilityMode: 0 + XboxOneEnableGPUVariability: 1 + XboxOneSockets: {} + XboxOneSplashScreen: {fileID: 0} + XboxOneAllowedProductIds: [] + XboxOnePersistentLocalStorageSize: 0 + XboxOneXTitleMemory: 8 + XboxOneOverrideIdentityName: + XboxOneOverrideIdentityPublisher: + vrEditorSettings: {} + cloudServicesEnabled: + UNet: 1 + luminIcon: + m_Name: + m_ModelFolderPath: + m_PortalFolderPath: + luminCert: + m_CertPath: + m_SignPackage: 1 + luminIsChannelApp: 0 + luminVersion: + m_VersionCode: 1 + m_VersionName: + hmiPlayerDataPath: + hmiForceSRGBBlit: 1 + embeddedLinuxEnableGamepadInput: 1 + hmiLogStartupTiming: 0 + hmiCpuConfiguration: + apiCompatibilityLevel: 6 + activeInputHandler: 0 + windowsGamepadBackendHint: 0 + cloudProjectId: + framebufferDepthMemorylessMode: 0 + qualitySettingsNames: [] + projectName: + organizationId: + cloudEnabled: 0 + legacyClampBlendShapeWeights: 0 + hmiLoadingImage: {fileID: 0} + platformRequiresReadableAssets: 0 + virtualTexturingSupportEnabled: 0 + insecureHttpOption: 0 diff --git a/UnityActionUpdaterService/ProjectSettings/ProjectVersion.txt b/UnityActionUpdaterService/ProjectSettings/ProjectVersion.txt new file mode 100644 index 0000000..88bb9cf --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/ProjectVersion.txt @@ -0,0 +1,2 @@ +m_EditorVersion: 2022.3.10f1 +m_EditorVersionWithRevision: 2022.3.10f1 (ff3792e53c62) diff --git a/UnityActionUpdaterService/ProjectSettings/QualitySettings.asset b/UnityActionUpdaterService/ProjectSettings/QualitySettings.asset new file mode 100644 index 0000000..7b7658d --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/QualitySettings.asset @@ -0,0 +1,232 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!47 &1 +QualitySettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_CurrentQuality: 5 + m_QualitySettings: + - serializedVersion: 2 + name: Very Low + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 15 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 1 + textureQuality: 1 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.3 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 4 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Low + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.4 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 16 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Medium + pixelLightCount: 1 + shadows: 1 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 1 + lodBias: 0.7 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 64 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: High + pixelLightCount: 2 + shadows: 2 + shadowResolution: 1 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 40 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 256 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Very High + pixelLightCount: 3 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 70 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 2 + antiAliasing: 2 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1.5 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 1024 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Ultra + pixelLightCount: 4 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 4 + shadowDistance: 150 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 2 + antiAliasing: 2 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 2 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 4096 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + m_PerPlatformDefaultQuality: + Android: 2 + Lumin: 5 + Nintendo 3DS: 5 + Nintendo Switch: 5 + PS4: 5 + PSP2: 2 + Stadia: 5 + Standalone: 5 + WebGL: 3 + Windows Store Apps: 5 + XboxOne: 5 + iPhone: 2 + tvOS: 2 diff --git a/UnityActionUpdaterService/ProjectSettings/SceneTemplateSettings.json b/UnityActionUpdaterService/ProjectSettings/SceneTemplateSettings.json new file mode 100644 index 0000000..5e97f83 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/SceneTemplateSettings.json @@ -0,0 +1,121 @@ +{ + "templatePinStates": [], + "dependencyTypeInfos": [ + { + "userAdded": false, + "type": "UnityEngine.AnimationClip", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.Animations.AnimatorController", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.AnimatorOverrideController", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.Audio.AudioMixerController", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.ComputeShader", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.Cubemap", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.GameObject", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.LightingDataAsset", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.LightingSettings", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Material", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.MonoScript", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicMaterial", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicsMaterial2D", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.VolumeProfile", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.SceneAsset", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.Shader", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.ShaderVariantCollection", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.Texture", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Texture2D", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Timeline.TimelineAsset", + "defaultInstantiationMode": 0 + } + ], + "defaultDependencyTypeInfo": { + "userAdded": false, + "type": "", + "defaultInstantiationMode": 1 + }, + "newSceneOverride": 0 +} \ No newline at end of file diff --git a/UnityActionUpdaterService/ProjectSettings/TagManager.asset b/UnityActionUpdaterService/ProjectSettings/TagManager.asset new file mode 100644 index 0000000..1c92a78 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/TagManager.asset @@ -0,0 +1,43 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!78 &1 +TagManager: + serializedVersion: 2 + tags: [] + layers: + - Default + - TransparentFX + - Ignore Raycast + - + - Water + - UI + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + m_SortingLayers: + - name: Default + uniqueID: 0 + locked: 0 diff --git a/UnityActionUpdaterService/ProjectSettings/TimeManager.asset b/UnityActionUpdaterService/ProjectSettings/TimeManager.asset new file mode 100644 index 0000000..558a017 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/TimeManager.asset @@ -0,0 +1,9 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!5 &1 +TimeManager: + m_ObjectHideFlags: 0 + Fixed Timestep: 0.02 + Maximum Allowed Timestep: 0.33333334 + m_TimeScale: 1 + Maximum Particle Timestep: 0.03 diff --git a/UnityActionUpdaterService/ProjectSettings/UnityConnectSettings.asset b/UnityActionUpdaterService/ProjectSettings/UnityConnectSettings.asset new file mode 100644 index 0000000..a88bee0 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/UnityConnectSettings.asset @@ -0,0 +1,36 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!310 &1 +UnityConnectSettings: + m_ObjectHideFlags: 0 + serializedVersion: 1 + m_Enabled: 0 + m_TestMode: 0 + m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events + m_EventUrl: https://cdp.cloud.unity3d.com/v1/events + m_ConfigUrl: https://config.uca.cloud.unity3d.com + m_DashboardUrl: https://dashboard.unity3d.com + m_TestInitMode: 0 + CrashReportingSettings: + m_EventUrl: https://perf-events.cloud.unity3d.com + m_Enabled: 0 + m_LogBufferSize: 10 + m_CaptureEditorExceptions: 1 + UnityPurchasingSettings: + m_Enabled: 0 + m_TestMode: 0 + UnityAnalyticsSettings: + m_Enabled: 0 + m_TestMode: 0 + m_InitializeOnStartup: 1 + m_PackageRequiringCoreStatsPresent: 0 + UnityAdsSettings: + m_Enabled: 0 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_IosGameId: + m_AndroidGameId: + m_GameIds: {} + m_GameId: + PerformanceReportingSettings: + m_Enabled: 0 diff --git a/UnityActionUpdaterService/ProjectSettings/VFXManager.asset b/UnityActionUpdaterService/ProjectSettings/VFXManager.asset new file mode 100644 index 0000000..3a95c98 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/VFXManager.asset @@ -0,0 +1,12 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!937362698 &1 +VFXManager: + m_ObjectHideFlags: 0 + m_IndirectShader: {fileID: 0} + m_CopyBufferShader: {fileID: 0} + m_SortShader: {fileID: 0} + m_StripUpdateShader: {fileID: 0} + m_RenderPipeSettingsPath: + m_FixedTimeStep: 0.016666668 + m_MaxDeltaTime: 0.05 diff --git a/UnityActionUpdaterService/ProjectSettings/VersionControlSettings.asset b/UnityActionUpdaterService/ProjectSettings/VersionControlSettings.asset new file mode 100644 index 0000000..dca2881 --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/VersionControlSettings.asset @@ -0,0 +1,8 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!890905787 &1 +VersionControlSettings: + m_ObjectHideFlags: 0 + m_Mode: Visible Meta Files + m_CollabEditorSettings: + inProgressEnabled: 1 diff --git a/UnityActionUpdaterService/ProjectSettings/XRSettings.asset b/UnityActionUpdaterService/ProjectSettings/XRSettings.asset new file mode 100644 index 0000000..482590c --- /dev/null +++ b/UnityActionUpdaterService/ProjectSettings/XRSettings.asset @@ -0,0 +1,10 @@ +{ + "m_SettingKeys": [ + "VR Device Disabled", + "VR Device User Alert" + ], + "m_SettingValues": [ + "False", + "False" + ] +} \ No newline at end of file