diff --git a/GQ_TongXin/Assembly-CSharp-firstpass.csproj b/GQ_TongXin/Assembly-CSharp-firstpass.csproj index 2eba451a5..e2c2a6db1 100644 --- a/GQ_TongXin/Assembly-CSharp-firstpass.csproj +++ b/GQ_TongXin/Assembly-CSharp-firstpass.csproj @@ -310,9 +310,6 @@ Assets\Adam\Plugins\Interop.SpeechLib.dll - - Assets\Packages\AutoMapper.12.0.1\lib\netstandard2.1\AutoMapper.dll - Assets\Adam\Plugins\ICSharpCode.SharpZipLib.dll diff --git a/GQ_TongXin/Assets/NuGet.meta b/GQ_TongXin/Assets/NuGet.meta deleted file mode 100644 index 27037b55e..000000000 --- a/GQ_TongXin/Assets/NuGet.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: dbf134857daf7df428aa31cdd055514f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/NuGet/Editor.meta b/GQ_TongXin/Assets/NuGet/Editor.meta deleted file mode 100644 index 3b6fd6bc4..000000000 --- a/GQ_TongXin/Assets/NuGet/Editor.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: b3fad56c531ac5a4db190a745f589a8e -folderAsset: yes -timeCreated: 1510280304 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/NuGet/Editor/NugetForUnity.dll b/GQ_TongXin/Assets/NuGet/Editor/NugetForUnity.dll deleted file mode 100644 index 053969313..000000000 Binary files a/GQ_TongXin/Assets/NuGet/Editor/NugetForUnity.dll and /dev/null differ diff --git a/GQ_TongXin/Assets/NuGet/Editor/NugetForUnity.dll.meta b/GQ_TongXin/Assets/NuGet/Editor/NugetForUnity.dll.meta deleted file mode 100644 index 833aac7d1..000000000 --- a/GQ_TongXin/Assets/NuGet/Editor/NugetForUnity.dll.meta +++ /dev/null @@ -1,33 +0,0 @@ -fileFormatVersion: 2 -guid: 8dc1be91775c4bb469f6b74cef450eaa -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 1 - settings: - DefaultValueInitialized: true - - first: - Windows Store Apps: WindowsStoreApps - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/NuGet/LICENSE b/GQ_TongXin/Assets/NuGet/LICENSE deleted file mode 100644 index e5e721045..000000000 --- a/GQ_TongXin/Assets/NuGet/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Patrick McCarthy - -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. diff --git a/GQ_TongXin/Assets/NuGet/LICENSE.meta b/GQ_TongXin/Assets/NuGet/LICENSE.meta deleted file mode 100644 index 9de0ac8de..000000000 --- a/GQ_TongXin/Assets/NuGet/LICENSE.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 1d9014b99ad06af428514a5902d29ff3 -timeCreated: 1573248500 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/NuGet/README.pdf b/GQ_TongXin/Assets/NuGet/README.pdf deleted file mode 100644 index e67f9fa59..000000000 --- a/GQ_TongXin/Assets/NuGet/README.pdf +++ /dev/null @@ -1,110 +0,0 @@ -What is NuGetForUnity? - -NuGetForUnity is a NuGet client built from scratch to run inside the Unity Editor. NuGet is a package management system -which makes it easy to create packages that are distributed on a server and consumed by users. NuGet supports sematic -versioning for packages as well as dependencies on other packages. -You can learn more about NuGet here: nuget.org -NuGetForUnity provides a visual editor window to see available packages on the server, see installed packages, and see -available package updates. A visual interface is also provided to create and edit .nuspec files in order to define and publish -your own NuGet packages from within Unity. - -How do I install NuGetForUnity? - -Install the provided Unity package into your Unity project. Located here. - -How do I use NuGetForUnity? - -To launch, select NuGet → Manage NuGet Packages - After several seconds (it can take some time to query the server for packages), you should see a window like this: - -The Online tab shows the packages available on the NuGet server. -Enable Show All Versions to list all old versions of a package (doesn't work with nuget.org). -Disable Show All Versions to only show the latest version of a package. -Enable Show Prelease to list prerelease versions of packages (alpha, beta, release candidate, etc). -Disable Show Prerelease to only show stable releases. -Type a search term in the Search box to filter what is displayed. -Press the Refresh button to refresh the window with the latest query settings. (Useful after pushing a new package to the -server and wanting to see it without closing and reopening the window.) -The name of the package, the version of the package (in square brakets), and a description are displayed. -Click the View License to open the license in a web browser. -Click the Install to install the package. Note: If the package is already installed an Uninstall button will be displayed which lets -you uninstall the package. -The Installed tabs shows the packages already installed in the current Unity project. - Click the Uninstall button to uninstall the package. -The Updates tab shows the packages currently installed that have updates available on the server. - The version in brackets on the left is the new version number. The version in brackets in the Update button is the currently -installed version. - -Click the Update button to uninstall the current package and install the new package. - -How does NuGetForUnity work? - -NuGetForUnity loads the NuGet.config file in the Unity project (automatically created if there isn't already one) in order to -determine the server it should pull packages down from and push packages up to. By default, this server is set to the -nuget.org package source. - -The default NuGet.config file: - - - - - - - - - - - - - - - - - - - -You can change this to any other NuGet server (such as NuGet.Server or ProGet - see below). The NuGet → Reload -NuGet.config menu item is useful if you are editing the NuGet.config file. - See more information about NuGet.config files here: https://docs.nuget.org/consume/nuget-config-settings - -NuGetForUnity installs packages into the local repository path defined in the NuGet.config file ( repositoryPath ). By default, -this is set to the Assets/Packages folder. In the NuGet.config file, this can either be a full path, or it can be a relative path -based on the project's Assets folder. Note: You'll probably want your Packages folder to be ignored by your version control -software to prevent NuGet packages from being versioned in your repository. -When a package is installed, the packages.config file in the project is automatically updated with the specific package -information, as well as all of the dependencies that are also installed. This allows for the packages to be restored from scratch -at any point. The Restore operation is automatically run every time the project is opened or the code is recompiled in the -project. It can be run manually by selecting the NuGet → Restore Packages menu item. - -Note: Depending on the size and number of packages you need to isntalled, the Restore operation could take a long time, -so please be patient. If it appears the Unity isn't launching or responding, wait a few more minutes before attempting to kill -the process. -If you are interested in the process NuGetForUnity follows or you are trying to debug an issue, you can force NuGetForUnity -to use verbose logging to output an increased amount of data to the Unity console. Add the line to the element in the NuGet.config file. You can disable verbose logging by either setting the -value to false or completely deleting the line. -The .nupkg files downloaded from the NuGet server are cached locally in the current user's Application Data folder. -( C:\Users\[username]\AppData\Local\NuGet\Cache ). Packages previously installed are installed via the cache folder instead of -downloading it from the server again. - -How do I create my own NuGet packages from within Unity? - -First, you'll need to create a .nuspec file that defines your package. In your Project window, right click where you want the -.nuspec file to go and select NuGet → Create Nuspec File. - Select the new .nuspec file and you should see something like this: - -Input the appropriate information for your package (ID, Version, Author, Description, etc). Be sure to include whatever -dependencies are required by your package. -Press the Pack button to pack your package into a .nupkg file that is saved in the C:\Users\ -[username]\AppData\Local\NuGet\Cache folder. -Press the Push button to push your package up to the server. Be sure to set the correct API Key that give you permission to -push to the server (if you server is configured to use one). - -How do I create my own NuGet server to host NuGet -packages? - -You can use NuGet.Server, NuGet Gallery, ProGet, etc to create your own NuGet server. -Alternatively, you can use a "local feed" which is just a folder on your hard-drive or a network share. -Be sure to set the proper URL/path in the NuGet.config file and you should be good to go! - Read more information here: http://docs.nuget.org/create/hosting-your-own-nuget-feeds - diff --git a/GQ_TongXin/Assets/NuGet/README.pdf.meta b/GQ_TongXin/Assets/NuGet/README.pdf.meta deleted file mode 100644 index e95001a02..000000000 --- a/GQ_TongXin/Assets/NuGet/README.pdf.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 83c5d2001771f15429a88d67e81366d6 -timeCreated: 1517876157 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/NuGet/Resources.meta b/GQ_TongXin/Assets/NuGet/Resources.meta deleted file mode 100644 index 49a5e3b4f..000000000 --- a/GQ_TongXin/Assets/NuGet/Resources.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 1738075a39a390447b7a620ca6962142 -folderAsset: yes -timeCreated: 1510280362 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/NuGet/Resources/defaultIcon.png b/GQ_TongXin/Assets/NuGet/Resources/defaultIcon.png deleted file mode 100644 index a16cc1989..000000000 Binary files a/GQ_TongXin/Assets/NuGet/Resources/defaultIcon.png and /dev/null differ diff --git a/GQ_TongXin/Assets/NuGet/Resources/defaultIcon.png.meta b/GQ_TongXin/Assets/NuGet/Resources/defaultIcon.png.meta deleted file mode 100644 index d23111aba..000000000 --- a/GQ_TongXin/Assets/NuGet/Resources/defaultIcon.png.meta +++ /dev/null @@ -1,88 +0,0 @@ -fileFormatVersion: 2 -guid: eec19781926cd2248b7c9abfde8db555 -TextureImporter: - fileIDToRecycleName: {} - externalObjects: {} - serializedVersion: 9 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - sRGBTexture: 1 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - streamingMipmaps: 0 - streamingMipmapsPriority: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: -1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: -1 - mipBias: -100 - wrapU: 1 - wrapV: 1 - wrapW: 1 - nPOTScale: 0 - lightmap: 0 - compressionQuality: 50 - spriteMode: 1 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 - alphaUsage: 1 - alphaIsTransparency: 1 - spriteTessellationDetail: -1 - textureType: 8 - textureShape: 1 - singleChannelComponent: 0 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - platformSettings: - - serializedVersion: 2 - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - bones: [] - spriteID: 215e43cda847e6d44af8b40376eeed8a - vertices: [] - indices: - edges: [] - weights: [] - spritePackingTag: - pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1.meta b/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1.meta deleted file mode 100644 index 7313003a3..000000000 --- a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8ac4ba33e51537741aab4e936235035c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/.signature.p7s b/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/.signature.p7s deleted file mode 100644 index d1614866a..000000000 Binary files a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/.signature.p7s and /dev/null differ diff --git a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/AutoMapper.12.0.1.nupkg b/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/AutoMapper.12.0.1.nupkg deleted file mode 100644 index aa7541f82..000000000 Binary files a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/AutoMapper.12.0.1.nupkg and /dev/null differ diff --git a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/AutoMapper.12.0.1.nupkg.meta b/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/AutoMapper.12.0.1.nupkg.meta deleted file mode 100644 index f43a29ec6..000000000 --- a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/AutoMapper.12.0.1.nupkg.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: f5bc329c4e62b2c4c9070d24a2b67a41 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/README.md b/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/README.md deleted file mode 100644 index 9b288ebad..000000000 --- a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/README.md +++ /dev/null @@ -1,75 +0,0 @@ -![AutoMapper](https://camo.githubusercontent.com/603a9fdf1c6578e4df423ecdb784cb5d634e016850c10ba0798970fd48c55d41/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6175746f6d61707065722f6c6f676f2e706e67) - -[![CI](https://github.com/automapper/automapper/workflows/CI/badge.svg)](https://github.com/AutoMapper/AutoMapper/actions?query=workflow%3ACI) -[![NuGet](http://img.shields.io/nuget/vpre/AutoMapper.svg?label=NuGet)](https://www.nuget.org/packages/AutoMapper/) -[![MyGet (dev)](https://img.shields.io/myget/automapperdev/vpre/AutoMapper.svg?label=MyGet)](https://myget.org/feed/automapperdev/package/nuget/AutoMapper) - -### What is AutoMapper? - -AutoMapper is a simple little library built to solve a deceptively complex problem - getting rid of code that mapped one object to another. This type of code is rather dreary and boring to write, so why not invent a tool to do it for us? - -This is the main repository for AutoMapper, but there's more: - -* [Microsoft DI Extensions](https://github.com/AutoMapper/AutoMapper.Extensions.Microsoft.DependencyInjection) -* [Collection Extensions](https://github.com/AutoMapper/AutoMapper.Collection) -* [Expression Mapping](https://github.com/AutoMapper/AutoMapper.Extensions.ExpressionMapping) -* [EF6 Extensions](https://github.com/AutoMapper/AutoMapper.EF6) -* [IDataReader/Record Extensions](https://github.com/AutoMapper/AutoMapper.Data) -* [Enum Extensions](https://github.com/AutoMapper/AutoMapper.Extensions.EnumMapping) - -### How do I get started? - -First, configure AutoMapper to know what types you want to map, in the startup of your application: - -```csharp -var configuration = new MapperConfiguration(cfg => -{ - cfg.CreateMap(); - cfg.CreateMap(); -}); -// only during development, validate your mappings; remove it before release -#if DEBUG -configuration.AssertConfigurationIsValid(); -#endif -// use DI (http://docs.automapper.org/en/latest/Dependency-injection.html) or create the mapper yourself -var mapper = configuration.CreateMapper(); -``` -Then in your application code, execute the mappings: - -```csharp -var fooDto = mapper.Map(foo); -var barDto = mapper.Map(bar); -``` - -Check out the [getting started guide](https://automapper.readthedocs.io/en/latest/Getting-started.html). When you're done there, the [wiki](https://automapper.readthedocs.io/en/latest/) goes in to the nitty-gritty details. If you have questions, you can post them to [Stack Overflow](https://stackoverflow.com/questions/tagged/automapper) or in our [Gitter](https://gitter.im/AutoMapper/AutoMapper). - -### Where can I get it? - -First, [install NuGet](http://docs.nuget.org/docs/start-here/installing-nuget). Then, install [AutoMapper](https://www.nuget.org/packages/AutoMapper/) from the package manager console: - -``` -PM> Install-Package AutoMapper -``` -Or from the .NET CLI as: -``` -dotnet add package AutoMapper -``` - -### Do you have an issue? - -First check if it's already fixed by trying the [MyGet build](https://automapper.readthedocs.io/en/latest/The-MyGet-build.html). - -You might want to know exactly what [your mapping does](https://automapper.readthedocs.io/en/latest/Understanding-your-mapping.html) at runtime. - -If you're still running into problems, file an issue above. - -### License, etc. - -This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. -For more information see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct). - -AutoMapper is Copyright © 2009 [Jimmy Bogard](https://jimmybogard.com) and other contributors under the [MIT license](LICENSE.txt). - -### .NET Foundation - -This project is supported by the [.NET Foundation](https://dotnetfoundation.org). diff --git a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/README.md.meta b/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/README.md.meta deleted file mode 100644 index f007e1bef..000000000 --- a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/README.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 2623992dedb8e904d9304fed457f1185 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/icon.png b/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/icon.png deleted file mode 100644 index 56b96cabf..000000000 Binary files a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/icon.png and /dev/null differ diff --git a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/icon.png.meta b/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/icon.png.meta deleted file mode 100644 index 8dc2ec701..000000000 --- a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/icon.png.meta +++ /dev/null @@ -1,98 +0,0 @@ -fileFormatVersion: 2 -guid: a8100efd47f79b84b92592319e59764f -TextureImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 11 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - sRGBTexture: 1 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - streamingMipmaps: 0 - streamingMipmapsPriority: 0 - vTOnly: 0 - ignoreMasterTextureLimit: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: 1 - aniso: 1 - mipBias: 0 - wrapU: 0 - wrapV: 0 - wrapW: 0 - nPOTScale: 1 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 - alphaUsage: 1 - alphaIsTransparency: 0 - spriteTessellationDetail: -1 - textureType: 0 - textureShape: 1 - singleChannelComponent: 0 - flipbookRows: 1 - flipbookColumns: 1 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - ignorePngGamma: 0 - applyGammaDecoding: 0 - platformSettings: - - serializedVersion: 3 - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - bones: [] - spriteID: - internalID: 0 - vertices: [] - indices: - edges: [] - weights: [] - secondaryTextures: [] - nameFileIdTable: {} - spritePackingTag: - pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib.meta b/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib.meta deleted file mode 100644 index b6cd520d5..000000000 --- a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 311c404e58c1e2f49b0a29f2e6bd8d7f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1.meta b/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1.meta deleted file mode 100644 index d33ba4bf6..000000000 --- a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 35ee67e92be19cb4ca8e2c2da6507ddb -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1/AutoMapper.dll b/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1/AutoMapper.dll deleted file mode 100644 index b33d3d0f0..000000000 Binary files a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1/AutoMapper.dll and /dev/null differ diff --git a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1/AutoMapper.dll.meta b/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1/AutoMapper.dll.meta deleted file mode 100644 index f9edaa1a6..000000000 --- a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1/AutoMapper.dll.meta +++ /dev/null @@ -1,23 +0,0 @@ -fileFormatVersion: 2 -guid: 67ea87c5c77cdbf439ff12f600ab45ba -labels: -- NuGetForUnity -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - Any: - second: - enabled: 1 - settings: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1/AutoMapper.xml b/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1/AutoMapper.xml deleted file mode 100644 index df7b1e550..000000000 --- a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1/AutoMapper.xml +++ /dev/null @@ -1,1824 +0,0 @@ - - - - AutoMapper - - - - - Wraps mapping exceptions. Check exception.ToString() for the full error message. - - - - - Auto map to this destination type from the specified source type. - Discovered during scanning assembly scanning for configuration when calling - - - - - If set to true, construct the destination object using the service locator. - - - - - For self-referential types, limit recurse depth. - - - - - If set to true, preserve object identity. Useful for circular references. - - - - - If set to true, disable constructor validation. - - - - - If set to true, include this configuration in all derived types' maps. - - - - - Skip normal member mapping and convert using a instantiated during mapping. - - - - - If set to true, proxy will be created. - - - - - Ignore this member for configuration validation and skip during mapping. - - - Must be used in combination with - - - - - Do not precompute the execution plan for this member, just map it at runtime. - Simplifies the execution plan by not inlining. - - - Must be used in combination with - - - - - Supply a custom mapping order instead of what the .NET runtime returns - - - Must be used in combination with - - - - - Substitute a custom value when the source member resolves as null - - - Must be used in combination with - - - - - Value to use if source value is null - - - - - Specify the source member to map from. Can only reference a member on the type - - - Must be used in combination with - - - - - Use the destination value instead of mapping from the source value or creating a new instance - - - Must be used in combination with - - - - - Specify a value converter type to convert from the matching source member to the destination member - Use with to specify a separate source member to supply to the value converter - - - Must be used in combination with - - - - - type - - - - - Map destination member using a custom value resolver. - Use with to specify an type. - - - Must be used in combination with - - - - - or type - - - - - Specify the source member(s) to map from. - - Property name referencing the source member to map against. Or a dot separated member path. - - - - Ignore this member for LINQ projections unless explicitly expanded during projection - - - - - Map constructor parameter from member expression - - Member type - Member expression - - - - Map constructor parameter from custom func that has access to - - Not used for LINQ projection (ProjectTo) - Custom func - - - - Member configuration options - - Source type for this member - Destination type for this map - Type for this member - - - - Specify the source member to map from. Can only reference a member on the type - Any null reference exceptions in this expression will be ignored (similar to flattening behavior) - - Member type of the source member to use - Expression referencing the source member to map against - - - - Ignore this member for configuration validation and skip during mapping - - - - - Source member configuration options - - - - - Ignore this member when validating source members, MemberList.Source. - Does not affect validation for the default case, MemberList.Destination. - - - - - Contains member configuration relating to source members - - - - - Mapping configuration options for non-generic maps - - - - - Add extra configuration to the current map by also mapping the specified child objects to the destination object. - The maps from the child types to the destination need to be created explicitly. - - the names of child object properties to map to the destination - - - - - Create a type mapping from the destination to the source type, with validation disabled. - This allows for two-way mapping. - - Itself - - - - Customize configuration for all members - - Callback for member options - - - - Customize individual members - - Name of the member - Callback for configuring member - Itself - - - - Mapping configuration options - - Source type - Destination type - - - - Customize configuration for a path inside the destination object. - - Expression to the destination sub object - Callback for member options - Itself - - - - Customize configuration for individual member - - Expression to the top-level destination member. This must be a member on the TDestination type - Callback for member options - Itself - - - - Customize configuration for individual member. Used when the name isn't known at compile-time - - Destination member name - Callback for member options - Itself - - - - Customize configuration for all members - - Callback for member options - - - - Include this configuration in derived types' maps - - Derived source type - Derived destination type - Itself - - - - Include the base type map's configuration in this map - - Base source type - Base destination type - Itself - - - - Customize configuration for an individual source member - - Expression to source member. Must be a member of the type - Callback for member configuration options - Itself - - - - Create a type mapping from the destination to the source type, with validation disabled. - This allows for two-way mapping. - - Itself - - - - Override the destination type mapping for looking up configuration and instantiation - - Destination type to use - - - - Apply a transformation function after any resolved destination member value with the given type - - Value type to match and transform - Transformation expression - Itself - - - - Add extra configuration to the current map by also mapping the specified child objects to the destination object. - The maps from the child types to the destination need to be created explicitly. - - the child objects to map to the destination - - - - - Customize configuration for individual member - - Expression to the top-level destination member. This must be a member on the TDestination type - Callback for member options - Itself - - - - Common mapping configuration options between generic and non-generic mapping configuration - - Source type - Destination type - Concrete return type for fluent interface - - - - For self-referential types, limit recurse depth. - Enables PreserveReferences. - - Number of levels to limit to - Itself - - - - Value transformers, typically configured through explicit or extension methods. - - - - - Specify which member list to validate - - Member list to validate - Itself - - - - Supply a custom instantiation expression for the destination type - - Expression to create the destination type given the source object - Itself - - - - Customize configuration for individual constructor parameter - - Constructor parameter name - Options - Itself - - - - Skip member mapping and use a custom expression to convert to the destination type - - Callback to convert from source type to destination type - - - - Common mapping configuration options between generic and non-generic mapping configuration - - Source type - Destination type - Concrete return type for fluent interface - - - - Disable constructor validation. During mapping this map is used against an existing destination object and never constructed itself. - - Itself - - - - Construct the destination object using the service locator - - Itself - - - - Preserve object identity. Useful for circular references. - - Itself - - - - Execute a custom function to the source and/or destination types before member mapping - - Not used for LINQ projection (ProjectTo) - Callback for the source/destination types - Itself - - - - Execute a custom function to the source and/or destination types before member mapping - - Not used for LINQ projection (ProjectTo) - Callback for the source/destination types - Itself - - - - Execute a custom mapping action before member mapping - - Not used for LINQ projection (ProjectTo) - Mapping action type instantiated during mapping - Itself - - - - Execute a custom function to the source and/or destination types after member mapping - - Not used for LINQ projection (ProjectTo) - Callback for the source/destination types - Itself - - - - Execute a custom function to the source and/or destination types after member mapping - - Not used for LINQ projection (ProjectTo) - Callback for the source/destination types - Itself - - - - Execute a custom mapping action after member mapping - - Not used for LINQ projection (ProjectTo) - Mapping action type instantiated during mapping - Itself - - - - Include this configuration in all derived types' maps. Works by scanning all type maps for matches during configuration. - - Itself - - - - Include this configuration in derived types' maps - - Derived source type - Derived destination type - Itself - - - - Include the base type map's configuration in this map - - Base source type - Base destination type - - - - - Customize configuration for an individual source member. Member name not known until runtime - - Expression to source member. Must be a member of the type - Callback for member configuration options - Itself - - - - Ignores all properties that have either a private or protected setter, forcing the mapper to respect encapsulation (note: order matters, so place this before explicit configuration of any properties with an inaccessible setter) - - Itself - - - - When using ReverseMap, ignores all properties that have either a private or protected setter, keeping the reverse mapping consistent with the forward mapping (note: properties with an inaccessible setter may still be mapped unless IgnoreAllPropertiesWithAnInaccessibleSetter is also used) - - Itself - - - - Supply a custom instantiation function for the destination type, based on the entire resolution context - - Not used for LINQ projection (ProjectTo) - Callback to create the destination type given the current resolution context - Itself - - - - Override the destination type mapping for looking up configuration and instantiation - - - - - - Create at runtime a proxy type implementing the destination interface. - - Itself - - - - Skip normal member mapping and convert using a instantiated during mapping - Use this method if you need to specify the converter type at runtime - - Type converter type - - - - Skip member mapping and use a custom function to convert to the destination type - - Not used for LINQ projection (ProjectTo) - Callback to convert from source type to destination type, including destination object - - - - Skip member mapping and use a custom function to convert to the destination type - - Not used for LINQ projection (ProjectTo) - Callback to convert from source type to destination type, with source, destination and context - - - - Skip member mapping and use a custom type converter instance to convert to the destination type - - Not used for LINQ projection (ProjectTo) - Type converter instance - - - - Skip member mapping and use a custom type converter instance to convert to the destination type - - Not used for LINQ projection (ProjectTo) - Type converter type - - - - Custom mapping action - - Source type - Destination type - - - - Implementors can modify both the source and destination objects - - Source object - Destination object - Resolution context - - - - Converts source type to destination type instead of normal member mapping - - Source type - Destination type - - - - Performs conversion from source to destination type - - Source object - Destination object - Resolution context - Destination object - - - - Options for a single map operation - - - - - Construct services using this callback. Use this for child/nested containers - - - - - - Add context items to be accessed at map time inside an or - - - - - Execute a custom function to the source and/or destination types before member mapping - - Callback for the source/destination types - - - - Execute a custom function to the source and/or destination types after member mapping - - Callback for the source/destination types - - - - Execute a custom function to the source and/or destination types before member mapping - - Callback for the source/destination types - - - - Execute a custom function to the source and/or destination types after member mapping - - Callback for the source/destination types - - - - Member configuration options - - Source type for this member - Type for this member - Destination type for this map - - - - Do not precompute the execution plan for this member, just map it at runtime. - Simplifies the execution plan by not inlining. - - - - - Map destination member using a custom value resolver - - Not used for LINQ projection (ProjectTo) - Value resolver type - - - - Map destination member using a custom member value resolver supplied with a source member - - Not used for LINQ projection (ProjectTo) - Value resolver type - Source member to supply - - - - Map destination member using a custom member value resolver supplied from a source member name - - Not used for LINQ projection (ProjectTo) - Value resolver type - Source member to supply - Source member name - - - - Map destination member using a custom value resolver instance - - Not used for LINQ projection (ProjectTo) - Value resolver instance to use - - - - Map destination member using a custom value resolver instance - - Not used for LINQ projection (ProjectTo) - Value resolver instance to use - Source member to supply to value resolver - - - - Map destination member using a custom function. Access both the source and destination object. - - Not used for LINQ projection (ProjectTo) - Function to map to destination member - - - - Map destination member using a custom function. Access the source, destination object, and destination member. - - Not used for LINQ projection (ProjectTo) - Function to map to destination member - - - - Map destination member using a custom function. Access the source, destination object, destination member, and context. - - Not used for LINQ projection (ProjectTo) - Function to map to destination member - - - - Specify the source member(s) to map from. - - Property name referencing the source member to map against. Or a dot separated member path. - - - - Supply a custom mapping order instead of what the .NET runtime returns - - Mapping order value - - - - Reset UseDestinationValue. - - - - - Use the destination value instead of mapping from the source value or creating a new instance - - - - - Conditionally map this member against the source, destination, source and destination members - - Condition to evaluate using the source object - - - - Conditionally map this member - - Condition to evaluate using the source object - - - - Conditionally map this member - - Condition to evaluate using the source object - - - - Conditionally map this member - - Condition to evaluate using the source object - - - - Conditionally map this member - - Condition to evaluate using the source object - - - - Conditionally map this member, evaluated before accessing the source value - - Condition to evaluate using the source object - - - - Conditionally map this member, evaluated before accessing the source value - - Condition to evaluate using the current resolution context - - - - Conditionally map this member, evaluated before accessing the source value - - Condition to evaluate using the source object and the current resolution context - - - - Conditionally map this member, evaluated before accessing the source value - - Condition to evaluate using the source object, the destination object, and the current resolution context - - - - The destination member being configured. - - - - - Specify a value converter to convert from the matching source member to the destination member - - - Value converters are similar to type converters, but scoped to a single member. Value resolvers receive the enclosed source/destination objects as parameters. - Value converters do not. This makes it possible to reuse value converters across multiple members and multiple maps. - - Value converter type - Source member type - - - - Specify a value converter to convert from the specified source member to the destination member - - - Value converters are similar to type converters, but scoped to a single member. Value resolvers receive the enclosed source/destination objects as parameters. - Value converters do not. This makes it possible to reuse value converters across multiple members and multiple maps. - - Value converter type - Source member type - Source member to supply to the value converter - - - - Specify a value converter to convert from the specified source member name to the destination member - - - Value converters are similar to type converters, but scoped to a single member. Value resolvers receive the enclosed source/destination objects as parameters. - Value converters do not. This makes it possible to reuse value converters across multiple members and multiple maps. - - Value converter type - Source member type - Source member name to supply to the value converter - - - - Specify a value converter instance to convert from the matching source member to the destination member - - - Value converters are similar to type converters, but scoped to a single member. Value resolvers receive the enclosed source/destination objects as parameters. - Value converters do not. This makes it possible to reuse value converters across multiple members and multiple maps. - - Source member type - Value converter instance - - - - Specify a value converter instance from the specified source member to the destination member - - - Value converters are similar to type converters, but scoped to a single member. Value resolvers receive the enclosed source/destination objects as parameters. - Value converters do not. This makes it possible to reuse value converters across multiple members and multiple maps. - - Source member type - Value converter instance - Source member to supply to the value converter - - - - Specify a value converter instance to convert from the specified source member name to the destination member - - - Value converters are similar to type converters, but scoped to a single member. Value resolvers receive the enclosed source/destination objects as parameters. - Value converters do not. This makes it possible to reuse value converters across multiple members and multiple maps. - - Source member type - Value converter instance - Source member name to supply to the value converter - - - - Configuration options for an individual member - - - - - Map destination member using a custom value resolver. Used when the value resolver is not known at compile-time - - Not used for LINQ projection (ProjectTo) - Value resolver type - - - - Map destination member using a custom value resolver. Used when the value resolver is not known at compile-time - - Not used for LINQ projection (ProjectTo) - Value resolver type - Member to supply to value resolver - - - - Map destination member using a custom value resolver instance - - Not used for LINQ projection (ProjectTo) - Value resolver instance to use - Source member to supply to value resolver - - - - Specify a value converter type to convert from the matching source member to the destination member - - - Value converters are similar to type converters, but scoped to a single member. Value resolvers receive the enclosed source/destination objects as parameters. - Value converters do not. This makes it possible to reuse value converters across multiple members and multiple maps. - - Value converter type - - - - Specify a value converter type to convert from the specified source member name to the destination member - - - Value converters are similar to type converters, but scoped to a single member. Value resolvers receive the enclosed source/destination objects as parameters. - Value converters do not. This makes it possible to reuse value converters across multiple members and multiple maps. - - Value converter type - Source member name to supply to the value converter - - - - Specify a value converter instance to convert from the specified source member name to the destination member - - - Value converters are similar to type converters, but scoped to a single member. Value resolvers receive the enclosed source/destination objects as parameters. - Value converters do not. This makes it possible to reuse value converters across multiple members and multiple maps. - - Source member type - Destination member type - Value converter instance - Source member name to supply to the value converter - - - - Member configuration options - - Source type for this member - Type for this member - Destination type for this map - - - - Substitute a custom value when the source member resolves as null - - Value to use - - - - Map destination member using a custom expression. Used in LINQ projection (ProjectTo). - - Member type of the source member to use - Map expression - - - - Ignore this member for configuration validation and skip during mapping - - - - - Allow this member to be null. Overrides AllowNullDestinationValues/AllowNullCollection. - - - - - Don't allow this member to be null. Overrides AllowNullDestinationValues/AllowNullCollection. - - - - - Ignore this member for LINQ projections unless explicitly expanded during projection - - - - - Apply a transformation function after any resolved destination member value with the given type - - Transformation expression - - - - Converts a source member value to a destination member value - - Source member type - Destination member type - - - - Perform conversion from source member value to destination member value - - Source member object - Resolution context - Destination member value - - - - Extension point to provide custom resolution for a destination value - - - - - Implementors use source object to provide a destination object. - - Source object - Destination object, if exists - Destination member - The context of the mapping - Result, typically build from the source resolution result - - - - Extension point to provide custom resolution for a destination value - - - - - Implementors use source object to provide a destination object. - - Source object - Destination object, if exists - Source member - Destination member - The context of the mapping - Result, typically build from the source resolution result - - - - Defines a naming convention strategy - - - - - Configuration for profile-specific maps - - - - - Disable constructor mapping. Use this if you don't intend to have AutoMapper try to map to constructors - - - - - Creates a mapping configuration from the type to the type - - Source type - Destination type - Mapping expression for more configuration options - - - - Creates a mapping configuration from the type to the type. - Specify the member list to validate against during configuration validation. - - Source type - Destination type - Member list to validate - Mapping expression for more configuration options - - - - Creates a projection configuration from the type to the type - - Source type - Destination type - Mapping expression for more configuration options - - - - Creates a projection configuration from the type to the type. - Specify the member list to validate against during configuration validation. - - Source type - Destination type - Member list to validate - Mapping expression for more configuration options - - - - Create a mapping configuration from the source type to the destination type. - Use this method when the source and destination type are known at runtime and not compile time. - - Source type - Destination type - Mapping expression for more configuration options - - - - Creates a mapping configuration from the source type to the destination type. - Specify the member list to validate against during configuration validation. - - Source type - Destination type - Member list to validate - Mapping expression for more configuration options - - - - Clear the list of recognized prefixes. - - - - - Recognize a list of prefixes to be removed from source member names when matching - - List of prefixes - - - - Recognize a list of postfixes to be removed from source member names when matching - - List of postfixes - - - - Provide a new value for a part of a members name - - Original member value - New member value - - - - Recognize a list of prefixes to be removed from destination member names when matching - - List of prefixes - - - - Recognize a list of postfixes to be removed from destination member names when matching - - List of postfixes - - - - Add a property name to globally ignore. Matches against the beginning of the property names. - - Property name to match against - - - - Allow null destination values. If false, destination objects will be created for deep object graphs. Default true. - - - - - Allow null destination collections. If true, null source collections result in null destination collections. Default false. - - - - - Naming convention for source members - - - - - Naming convention for destination members - - - - - Include extension methods against source members for matching destination members to. Default source extension methods from - - Static type that contains extension methods - - - - Value transformers. Modify the list directly or use - - - - - Member list to check for configuration validation - - - - - Check that all destination members are mapped - - - - - Check that all source members are mapped - - - - - Check neither source nor destination members, skipping validation - - - - - Dry run all configured type maps and throw for each problem - - - - - Create a mapper instance based on this configuration. Mapper instances are lightweight and can be created as needed. - - The mapper instance - - - - Create a mapper instance with the specified service constructor to be used for resolvers and type converters. - - Service factory to create services - The mapper instance - - - - Builds the execution plan used to map the source to destination. - Useful to understand what exactly is happening during mapping. - See the wiki for details. - - the runtime type of the source object - the runtime type of the destination object - the execution plan - - - - Compile all underlying mapping expressions to cached delegates. - Use if you want AutoMapper to compile all mappings up front instead of deferring expression compilation for each first map. - - - - - Add an existing profile - - Profile to add - - - - Add an existing profile type. Profile will be instantiated and added to the configuration. - - Profile type - - - - Add an existing profile type. Profile will be instantiated and added to the configuration. - - Profile type - - - - Add profiles contained in an IEnumerable - - IEnumerable of Profile - - - - Add mapping definitions contained in assemblies. - Looks for definitions and classes decorated with - - Assemblies containing mapping definitions - - - - Add mapping definitions contained in assemblies. - Looks for definitions and classes decorated with - - Assemblies containing mapping definitions - - - - Add mapping definitions contained in assemblies. - Looks for definitions and classes decorated with - - Assembly names to load and scan containing mapping definitions - - - - Add mapping definitions contained in assemblies. - Looks for definitions and classes decorated with - - Assembly names to load and scan containing mapping definitions - - - - Add mapping definitions contained in assemblies. - Looks for definitions and classes decorated with - - Types from assemblies containing mapping definitions - - - - Add mapping definitions contained in assemblies. - Looks for definitions and classes decorated with - - Types from assemblies containing mapping definitions - - - - Supply a factory method callback for creating resolvers and type converters - - Factory method - - - - Create a named profile with the supplied configuration - - Profile name, must be unique - Profile configuration - - - - Add an action to be called when validating the configuration. - - the validation callback - - - - Allow the same map to exist in different profiles. - The default is to throw an exception, true means the maps are merged. - - - - - How many levels deep should AutoMapper try to inline the execution plan for child classes. - See the docs for details. - - - - - How many levels deep should recursive queries be expanded. - Must be zero for EF6. Can be greater than zero for EF Core. - - - - - Source extension methods included for search - - - - - Specify which properties should be mapped. - By default only public properties are mapped. - - - - - Specify which fields should be mapped. - By default only public fields are mapped. - - - - - Specify which methods, of those that are eligible (public, parameterless, and non-static or extension methods), should be mapped. - By default all eligible methods are mapped. - - - - - Specify which constructors should be considered for the destination objects. - By default all constructors are considered. - - - - - Provides a named configuration for maps. Naming conventions become scoped per profile. - - - - - Gets the feature of type . - - The type of the feature. - The feature or null if feature not exists. - - - - Add or update the feature. Existing feature of the same type will be replaced. - - The feature. - - - - Get the features collection. - - - - - Object mappers - - - - - Add an action to be called when validating the configuration. - - the validation callback - - - - Allow the same map to exist in different profiles. - The default is to throw an exception, true means the maps are merged. - - - - - How many levels deep should AutoMapper try to inline the execution plan for child classes. - See the docs for details. - - - - - How many levels deep should recursive queries be expanded. - Must be zero for EF6. Can be greater than zero for EF Core. - - - - - Get all configured type maps created - - All configured type maps - - - - Find the for the configured source and destination type - - Configured source type - Configured destination type - Type map configuration - - - - Find the for the configured type pair - - Type pair - Type map configuration - - - - Find the for the configured source and destination type - - Source type - Destination type - Type map configuration - - - - Resolve the for the configured source and destination type, checking parent types - - Configured source type - Configured destination type - Type map configuration - - - - Resolve the for the configured type pair, checking parent types - - Type pair - Type map configuration - - - - Dry run single type map - - Type map to check - - - - Dry run all type maps in given profile - - Profile name of type maps to test - - - - Dry run all type maps in given profile - - Profile type - - - - Get all configured mappers - - List of mappers - - - - Gets the features collection. - - The feature collection. - - - - Find a matching object mapper. - - the types to match - the matching mapper or null - - - - Builds the execution plan used to map the source to destination. - Useful to understand what exactly is happening during mapping. - See the wiki for details. - - The source/destination map request - the execution plan - - - - Allows to enable null-value propagation for query mapping. - Some providers (such as EntityFrameworkQueryVisitor) do not work with this feature enabled! - - - - - Factory method to create formatters, resolvers and type converters - - - - - Allows to enable null-value propagation for query mapping. - Some providers (such as EntityFrameworkQueryVisitor) do not work with this feature enabled! - - - - - Disable method mapping. Use this if you don't intend to have AutoMapper try to map from methods. - - - - - Disable fields mapping. Use this if you don't intend to have AutoMapper try to map from/to fields. - - - - - Specify common configuration for all type maps. - - configuration callback - - - - Customize configuration for all members across all maps - - Condition - Callback for member options. Use the property map for conditional maps. - - - - Contains cached reflection information for easy retrieval - - - - - Mapping execution strategy, as a chain of responsibility - - - - - When true, the mapping engine will use this mapper as the strategy - - Resolution context - Is match - - - - Builds a mapping expression equivalent to the base Map method - - - - - Source parameter - Destination parameter - - Map expression - - - - Base class for simple object mappers that don't want to use expressions. - - type of the source - type of the destination - - - - When true, the mapping engine will use this mapper as the strategy - - Resolution context - Is match - - - - Performs conversion from source to destination type - - Source object - Destination object - The compile time type of the source object - The compile time type of the destination object - Resolution context - Destination object - - - - Execute a mapping from the source object to a new destination object. - The source type is inferred from the source object. - - Destination type to create - Source object to map from - Mapped destination object - - - - Execute a mapping from the source object to a new destination object. - - Source type to use, regardless of the runtime type - Destination type to create - Source object to map from - Mapped destination object - - - - Execute a mapping from the source object to the existing destination object. - - Source type to use - Destination type - Source object to map from - Destination object to map into - The mapped destination object, same instance as the object - - - - Execute a mapping from the source object to a new destination object with explicit objects - - Source object to map from - Source type to use - Destination type to create - Mapped destination object - - - - Execute a mapping from the source object to existing destination object with explicit objects - - Source object to map from - Destination object to map into - Source type to use - Destination type to use - Mapped destination object, same instance as the object - - - - Execute a mapping from the source object to a new destination object with supplied mapping options. - - Destination type to create - Source object to map from - Mapping options - Mapped destination object - - - - Execute a mapping from the source object to a new destination object with supplied mapping options. - - Source type to use - Destination type to create - Source object to map from - Mapping options - Mapped destination object - - - - Execute a mapping from the source object to the existing destination object with supplied mapping options. - - Source type to use - Destination type - Source object to map from - Destination object to map into - Mapping options - The mapped destination object, same instance as the object - - - - Execute a mapping from the source object to a new destination object with explicit objects and supplied mapping options. - - Source object to map from - Source type to use - Destination type to create - Mapping options - Mapped destination object - - - - Execute a mapping from the source object to existing destination object with supplied mapping options and explicit objects - - Source object to map from - Destination object to map into - Source type to use - Destination type to use - Mapping options - Mapped destination object, same instance as the object - - - - Configuration provider for performing maps - - - - - Project the input queryable. - - Projections are only calculated once and cached - Destination type - Queryable source - Optional parameter object for parameterized mapping expressions - Explicit members to expand - Queryable result, use queryable extension methods to project and execute result - - - - Project the input queryable. - - Destination type to map to - Queryable source - Optional parameter object for parameterized mapping expressions - Explicit members to expand - Queryable result, use queryable extension methods to project and execute result - - - - Project the input queryable. - - Queryable source - Destination type to map to - Optional parameter object for parameterized mapping expressions - Explicit members to expand - Queryable result, use queryable extension methods to project and execute result - - - - The base class for member maps (property, constructor and path maps). - - - - - Apply a transformation function after any resolved destination member value with the given type - - Value type to match and transform - Value transformer list - Transformation expression - - - - Queryable extensions for AutoMapper - - - - - Extension method to project from a queryable using the provided mapping engine - - Projections are only calculated once and cached - Destination type - Queryable source - Mapper configuration - Optional parameter object for parameterized mapping expressions - Explicit members to expand - Expression to project into - - - - Extension method to project from a queryable using the provided mapping engine - - Projections are only calculated once and cached - Destination type - Queryable source - Mapper configuration - Explicit members to expand - Expression to project into - - - - Projects the source type to the destination type given the mapping configuration - - Destination type to map to - Queryable source - Mapper configuration - Optional parameter object for parameterized mapping expressions - Explicit members to expand - Queryable result, use queryable extension methods to project and execute result - - - - Extension method to project from a queryable using the provided mapping engine - - Projections are only calculated once and cached - Queryable source - Destination type - Mapper configuration - Expression to project into - - - - Projects the source type to the destination type given the mapping configuration - - Queryable source - Destination type to map to - Mapper configuration - Optional parameter object for parameterized mapping expressions - Explicit members to expand - Queryable result, use queryable extension methods to project and execute result - - - - Expression visitor for making member access null-safe. - - - NullSafeQueryRewriter is copied from the NeinLinq project, licensed under the MIT license. - Copyright (c) 2014-2018 Axel Heer. - See https://github.com/axelheer/nein-linq/blob/master/src/NeinLinq/NullsafeQueryRewriter.cs - - - - - - - - - - - Context information regarding resolution of a destination value - - - - - The items passed in the options of the Map call. - - - - - The items passed in the options of the Map call. Returns false when no context was passed. - - - - - Current mapper - - - - - Instance cache for resolving circular references - - - - - Instance cache for resolving keeping track of depth - - - - - Main configuration object holding all mapping configuration for a source and destination type - - - - diff --git a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1/AutoMapper.xml.meta b/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1/AutoMapper.xml.meta deleted file mode 100644 index b5a10b23e..000000000 --- a/GQ_TongXin/Assets/Packages/AutoMapper.12.0.1/lib/netstandard2.1/AutoMapper.xml.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 1777d27f495eb7e4c810e03a88823eae -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0.meta b/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0.meta deleted file mode 100644 index 50d41d906..000000000 --- a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f2f45a901a877f34d8af1dc431be9abf -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/.signature.p7s b/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/.signature.p7s deleted file mode 100644 index cc2d4f3ef..000000000 Binary files a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/.signature.p7s and /dev/null differ diff --git a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/SimpleJson.0.38.0.nupkg b/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/SimpleJson.0.38.0.nupkg deleted file mode 100644 index fab60309a..000000000 Binary files a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/SimpleJson.0.38.0.nupkg and /dev/null differ diff --git a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/SimpleJson.psm1 b/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/SimpleJson.psm1 deleted file mode 100644 index 954f84c5a..000000000 --- a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/SimpleJson.psm1 +++ /dev/null @@ -1,2202 +0,0 @@ -# SimpleJson https://github.com/facebook-csharp-sdk/simple-json -# License: MIT License -# Version: 0.38.0 - -function ConvertFrom-Json -{ - param( - [Switch] $AsPSObject, - [Parameter(Mandatory=$true,ValueFromPipeline=$true)][String]$json - ) - - $obj= [SimpleJson.SimpleJson]::DeserializeObject($json) - - if($AsPSObject) - { - $obj = ConvertJsonObjectToPsObject($obj) - } - - return $obj -} - -function ConvertTo-Json -{ - param( - [object][Parameter(Mandatory=$true,ValueFromPipeline=$true)] $obj - ) - - return [SimpleJson.SimpleJson]::SerializeObject($obj) -} - -function ConvertJsonObjectToPsObject -{ - param( - [Object] $obj - ) - - if($obj -eq $null) - { - return $null - } - if($obj -is [System.Collections.Generic.IDictionary[string,object]]) - { - $hash = @{} - foreach($kvp in $obj) - { - $hash[$kvp.Key] = ConvertJsonObjectToPsObject($kvp.Value) - } - - return $hash - } - if($obj -is [system.collections.generic.list[object]]) - { - $arr = New-Object object[] $obj.Count - - for ( $i = 0; $i -lt $obj.count; $i++ ) - { - $arr[$i] = ConvertJsonObjectToPsObject($obj[$i]) - } - - return $arr - } - - return $obj -} - -$source = @" - -#define SIMPLE_JSON_DATACONTRACT -#define SIMPLE_JSON_REFLECTIONEMIT - -//----------------------------------------------------------------------- -// -// Copyright (c) 2011, The Outercurve Foundation. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.opensource.org/licenses/mit-license.php -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) -// https://github.com/facebook-csharp-sdk/simple-json -//----------------------------------------------------------------------- - -// VERSION: 0.38.0 - -// NOTE: uncomment the following line to make SimpleJson class internal. -//#define SIMPLE_JSON_INTERNAL - -// NOTE: uncomment the following line to make JsonArray and JsonObject class internal. -//#define SIMPLE_JSON_OBJARRAYINTERNAL - -// NOTE: uncomment the following line to enable dynamic support. -//#define SIMPLE_JSON_DYNAMIC - -// NOTE: uncomment the following line to enable DataContract support. -//#define SIMPLE_JSON_DATACONTRACT - -// NOTE: uncomment the following line to enable IReadOnlyCollection and IReadOnlyList support. -//#define SIMPLE_JSON_READONLY_COLLECTIONS - -// NOTE: uncomment the following line to disable linq expressions/compiled lambda (better performance) instead of method.invoke(). -// define if you are using .net framework <= 3.0 or < WP7.5 -//#define SIMPLE_JSON_NO_LINQ_EXPRESSION - -// NOTE: uncomment the following line if you are compiling under Window Metro style application/library. -// usually already defined in properties -//#define NETFX_CORE; - -// If you are targetting WinStore, WP8 and NET4.5+ PCL make sure to #define SIMPLE_JSON_TYPEINFO; - -// original json parsing code from http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html - -#if NETFX_CORE -#define SIMPLE_JSON_TYPEINFO -#endif - -using System; -using System.CodeDom.Compiler; -using System.Collections; -using System.Collections.Generic; -#if !SIMPLE_JSON_NO_LINQ_EXPRESSION -using System.Linq.Expressions; -#endif -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -#if SIMPLE_JSON_DYNAMIC -using System.Dynamic; -#endif -using System.Globalization; -using System.Reflection; -using System.Runtime.Serialization; -using System.Text; -using SimpleJson.Reflection; - -// ReSharper disable LoopCanBeConvertedToQuery -// ReSharper disable RedundantExplicitArrayCreation -// ReSharper disable SuggestUseVarKeywordEvident -namespace SimpleJson -{ - /// - /// Represents the json array. - /// - [GeneratedCode("simple-json", "1.0.0")] - [EditorBrowsable(EditorBrowsableState.Never)] - [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] -#if SIMPLE_JSON_OBJARRAYINTERNAL - internal -#else - public -#endif - class JsonArray : List - { - /// - /// Initializes a new instance of the class. - /// - public JsonArray() { } - - /// - /// Initializes a new instance of the class. - /// - /// The capacity of the json array. - public JsonArray(int capacity) : base(capacity) { } - - /// - /// The json representation of the array. - /// - /// The json representation of the array. - public override string ToString() - { - return SimpleJson.SerializeObject(this) ?? string.Empty; - } - } - - /// - /// Represents the json object. - /// - [GeneratedCode("simple-json", "1.0.0")] - [EditorBrowsable(EditorBrowsableState.Never)] - [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] -#if SIMPLE_JSON_OBJARRAYINTERNAL - internal -#else - public -#endif - class JsonObject : -#if SIMPLE_JSON_DYNAMIC - DynamicObject, -#endif - IDictionary - { - /// - /// The internal member dictionary. - /// - private readonly Dictionary _members; - - /// - /// Initializes a new instance of . - /// - public JsonObject() - { - _members = new Dictionary(); - } - - /// - /// Initializes a new instance of . - /// - /// The implementation to use when comparing keys, or null to use the default for the type of the key. - public JsonObject(IEqualityComparer comparer) - { - _members = new Dictionary(comparer); - } - - /// - /// Gets the at the specified index. - /// - /// - public object this[int index] - { - get { return GetAtIndex(_members, index); } - } - - internal static object GetAtIndex(IDictionary obj, int index) - { - if (obj == null) - throw new ArgumentNullException("obj"); - if (index >= obj.Count) - throw new ArgumentOutOfRangeException("index"); - int i = 0; - foreach (KeyValuePair o in obj) - if (i++ == index) return o.Value; - return null; - } - - /// - /// Adds the specified key. - /// - /// The key. - /// The value. - public void Add(string key, object value) - { - _members.Add(key, value); - } - - /// - /// Determines whether the specified key contains key. - /// - /// The key. - /// - /// true if the specified key contains key; otherwise, false. - /// - public bool ContainsKey(string key) - { - return _members.ContainsKey(key); - } - - /// - /// Gets the keys. - /// - /// The keys. - public ICollection Keys - { - get { return _members.Keys; } - } - - /// - /// Removes the specified key. - /// - /// The key. - /// - public bool Remove(string key) - { - return _members.Remove(key); - } - - /// - /// Tries the get value. - /// - /// The key. - /// The value. - /// - public bool TryGetValue(string key, out object value) - { - return _members.TryGetValue(key, out value); - } - - /// - /// Gets the values. - /// - /// The values. - public ICollection Values - { - get { return _members.Values; } - } - - /// - /// Gets or sets the with the specified key. - /// - /// - public object this[string key] - { - get { return _members[key]; } - set { _members[key] = value; } - } - - /// - /// Adds the specified item. - /// - /// The item. - public void Add(KeyValuePair item) - { - _members.Add(item.Key, item.Value); - } - - /// - /// Clears this instance. - /// - public void Clear() - { - _members.Clear(); - } - - /// - /// Determines whether [contains] [the specified item]. - /// - /// The item. - /// - /// true if [contains] [the specified item]; otherwise, false. - /// - public bool Contains(KeyValuePair item) - { - return _members.ContainsKey(item.Key) && _members[item.Key] == item.Value; - } - - /// - /// Copies to. - /// - /// The array. - /// Index of the array. - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - if (array == null) throw new ArgumentNullException("array"); - int num = Count; - foreach (KeyValuePair kvp in this) - { - array[arrayIndex++] = kvp; - if (--num <= 0) - return; - } - } - - /// - /// Gets the count. - /// - /// The count. - public int Count - { - get { return _members.Count; } - } - - /// - /// Gets a value indicating whether this instance is read only. - /// - /// - /// true if this instance is read only; otherwise, false. - /// - public bool IsReadOnly - { - get { return false; } - } - - /// - /// Removes the specified item. - /// - /// The item. - /// - public bool Remove(KeyValuePair item) - { - return _members.Remove(item.Key); - } - - /// - /// Gets the enumerator. - /// - /// - public IEnumerator> GetEnumerator() - { - return _members.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// - /// An object that can be used to iterate through the collection. - /// - IEnumerator IEnumerable.GetEnumerator() - { - return _members.GetEnumerator(); - } - - /// - /// Returns a json that represents the current . - /// - /// - /// A json that represents the current . - /// - public override string ToString() - { - return SimpleJson.SerializeObject(this); - } - -#if SIMPLE_JSON_DYNAMIC - /// - /// Provides implementation for type conversion operations. Classes derived from the class can override this method to specify dynamic behavior for operations that convert an object from one type to another. - /// - /// Provides information about the conversion operation. The binder.Type property provides the type to which the object must be converted. For example, for the statement (String)sampleObject in C# (CType(sampleObject, Type) in Visual Basic), where sampleObject is an instance of the class derived from the class, binder.Type returns the type. The binder.Explicit property provides information about the kind of conversion that occurs. It returns true for explicit conversion and false for implicit conversion. - /// The result of the type conversion operation. - /// - /// Alwasy returns true. - /// - public override bool TryConvert(ConvertBinder binder, out object result) - { - // - if (binder == null) - throw new ArgumentNullException("binder"); - // - Type targetType = binder.Type; - - if ((targetType == typeof(IEnumerable)) || - (targetType == typeof(IEnumerable>)) || - (targetType == typeof(IDictionary)) || - (targetType == typeof(IDictionary))) - { - result = this; - return true; - } - - return base.TryConvert(binder, out result); - } - - /// - /// Provides the implementation for operations that delete an object member. This method is not intended for use in C# or Visual Basic. - /// - /// Provides information about the deletion. - /// - /// Alwasy returns true. - /// - public override bool TryDeleteMember(DeleteMemberBinder binder) - { - // - if (binder == null) - throw new ArgumentNullException("binder"); - // - return _members.Remove(binder.Name); - } - - /// - /// Provides the implementation for operations that get a value by index. Classes derived from the class can override this method to specify dynamic behavior for indexing operations. - /// - /// Provides information about the operation. - /// The indexes that are used in the operation. For example, for the sampleObject[3] operation in C# (sampleObject(3) in Visual Basic), where sampleObject is derived from the DynamicObject class, is equal to 3. - /// The result of the index operation. - /// - /// Alwasy returns true. - /// - public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result) - { - if (indexes == null) throw new ArgumentNullException("indexes"); - if (indexes.Length == 1) - { - result = ((IDictionary)this)[(string)indexes[0]]; - return true; - } - result = null; - return true; - } - - /// - /// Provides the implementation for operations that get member values. Classes derived from the class can override this method to specify dynamic behavior for operations such as getting a value for a property. - /// - /// Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive. - /// The result of the get operation. For example, if the method is called for a property, you can assign the property value to . - /// - /// Alwasy returns true. - /// - public override bool TryGetMember(GetMemberBinder binder, out object result) - { - object value; - if (_members.TryGetValue(binder.Name, out value)) - { - result = value; - return true; - } - result = null; - return true; - } - - /// - /// Provides the implementation for operations that set a value by index. Classes derived from the class can override this method to specify dynamic behavior for operations that access objects by a specified index. - /// - /// Provides information about the operation. - /// The indexes that are used in the operation. For example, for the sampleObject[3] = 10 operation in C# (sampleObject(3) = 10 in Visual Basic), where sampleObject is derived from the class, is equal to 3. - /// The value to set to the object that has the specified index. For example, for the sampleObject[3] = 10 operation in C# (sampleObject(3) = 10 in Visual Basic), where sampleObject is derived from the class, is equal to 10. - /// - /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown. - /// - public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value) - { - if (indexes == null) throw new ArgumentNullException("indexes"); - if (indexes.Length == 1) - { - ((IDictionary)this)[(string)indexes[0]] = value; - return true; - } - return base.TrySetIndex(binder, indexes, value); - } - - /// - /// Provides the implementation for operations that set member values. Classes derived from the class can override this method to specify dynamic behavior for operations such as setting a value for a property. - /// - /// Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member to which the value is being assigned. For example, for the statement sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive. - /// The value to set to the member. For example, for sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the class, the is "Test". - /// - /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.) - /// - public override bool TrySetMember(SetMemberBinder binder, object value) - { - // - if (binder == null) - throw new ArgumentNullException("binder"); - // - _members[binder.Name] = value; - return true; - } - - /// - /// Returns the enumeration of all dynamic member names. - /// - /// - /// A sequence that contains dynamic member names. - /// - public override IEnumerable GetDynamicMemberNames() - { - foreach (var key in Keys) - yield return key; - } -#endif - } -} - -namespace SimpleJson -{ - /// - /// This class encodes and decodes JSON strings. - /// Spec. details, see http://www.json.org/ - /// - /// JSON uses Arrays and Objects. These correspond here to the datatypes JsonArray(IList<object>) and JsonObject(IDictionary<string,object>). - /// All numbers are parsed to doubles. - /// - [GeneratedCode("simple-json", "1.0.0")] -#if SIMPLE_JSON_INTERNAL - internal -#else - public -#endif - static class SimpleJson - { - private const int TOKEN_NONE = 0; - private const int TOKEN_CURLY_OPEN = 1; - private const int TOKEN_CURLY_CLOSE = 2; - private const int TOKEN_SQUARED_OPEN = 3; - private const int TOKEN_SQUARED_CLOSE = 4; - private const int TOKEN_COLON = 5; - private const int TOKEN_COMMA = 6; - private const int TOKEN_STRING = 7; - private const int TOKEN_NUMBER = 8; - private const int TOKEN_TRUE = 9; - private const int TOKEN_FALSE = 10; - private const int TOKEN_NULL = 11; - private const int BUILDER_CAPACITY = 2000; - - private static readonly char[] EscapeTable; - private static readonly char[] EscapeCharacters = new char[] { '"', '\\', '\b', '\f', '\n', '\r', '\t' }; - private static readonly string EscapeCharactersString = new string(EscapeCharacters); - - static SimpleJson() - { - EscapeTable = new char[93]; - EscapeTable['"'] = '"'; - EscapeTable['\\'] = '\\'; - EscapeTable['\b'] = 'b'; - EscapeTable['\f'] = 'f'; - EscapeTable['\n'] = 'n'; - EscapeTable['\r'] = 'r'; - EscapeTable['\t'] = 't'; - } - - /// - /// Parses the string json into a value - /// - /// A JSON string. - /// An IList<object>, a IDictionary<string,object>, a double, a string, null, true, or false - public static object DeserializeObject(string json) - { - object obj; - if (TryDeserializeObject(json, out obj)) - return obj; - throw new SerializationException("Invalid JSON string"); - } - - /// - /// Try parsing the json string into a value. - /// - /// - /// A JSON string. - /// - /// - /// The object. - /// - /// - /// Returns true if successfull otherwise false. - /// - [SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")] - public static bool TryDeserializeObject(string json, out object obj) - { - bool success = true; - if (json != null) - { - char[] charArray = json.ToCharArray(); - int index = 0; - obj = ParseValue(charArray, ref index, ref success); - } - else - obj = null; - - return success; - } - - public static object DeserializeObject(string json, Type type, IJsonSerializerStrategy jsonSerializerStrategy) - { - object jsonObject = DeserializeObject(json); - return type == null || jsonObject != null && ReflectionUtils.IsAssignableFrom(jsonObject.GetType(), type) - ? jsonObject - : (jsonSerializerStrategy ?? CurrentJsonSerializerStrategy).DeserializeObject(jsonObject, type); - } - - public static object DeserializeObject(string json, Type type) - { - return DeserializeObject(json, type, null); - } - - public static T DeserializeObject(string json, IJsonSerializerStrategy jsonSerializerStrategy) - { - return (T)DeserializeObject(json, typeof(T), jsonSerializerStrategy); - } - - public static T DeserializeObject(string json) - { - return (T)DeserializeObject(json, typeof(T), null); - } - - /// - /// Converts a IDictionary<string,object> / IList<object> object into a JSON string - /// - /// A IDictionary<string,object> / IList<object> - /// Serializer strategy to use - /// A JSON encoded string, or null if object 'json' is not serializable - public static string SerializeObject(object json, IJsonSerializerStrategy jsonSerializerStrategy) - { - StringBuilder builder = new StringBuilder(BUILDER_CAPACITY); - bool success = SerializeValue(jsonSerializerStrategy, json, builder); - return (success ? builder.ToString() : null); - } - - public static string SerializeObject(object json) - { - return SerializeObject(json, CurrentJsonSerializerStrategy); - } - - public static string EscapeToJavascriptString(string jsonString) - { - if (string.IsNullOrEmpty(jsonString)) - return jsonString; - - StringBuilder sb = new StringBuilder(); - char c; - - for (int i = 0; i < jsonString.Length; ) - { - c = jsonString[i++]; - - if (c == '\\') - { - int remainingLength = jsonString.Length - i; - if (remainingLength >= 2) - { - char lookahead = jsonString[i]; - if (lookahead == '\\') - { - sb.Append('\\'); - ++i; - } - else if (lookahead == '"') - { - sb.Append("\""); - ++i; - } - else if (lookahead == 't') - { - sb.Append('\t'); - ++i; - } - else if (lookahead == 'b') - { - sb.Append('\b'); - ++i; - } - else if (lookahead == 'n') - { - sb.Append('\n'); - ++i; - } - else if (lookahead == 'r') - { - sb.Append('\r'); - ++i; - } - } - } - else - { - sb.Append(c); - } - } - return sb.ToString(); - } - - static IDictionary ParseObject(char[] json, ref int index, ref bool success) - { - IDictionary table = new JsonObject(); - int token; - - // { - NextToken(json, ref index); - - bool done = false; - while (!done) - { - token = LookAhead(json, index); - if (token == TOKEN_NONE) - { - success = false; - return null; - } - else if (token == TOKEN_COMMA) - NextToken(json, ref index); - else if (token == TOKEN_CURLY_CLOSE) - { - NextToken(json, ref index); - return table; - } - else - { - // name - string name = ParseString(json, ref index, ref success); - if (!success) - { - success = false; - return null; - } - // : - token = NextToken(json, ref index); - if (token != TOKEN_COLON) - { - success = false; - return null; - } - // value - object value = ParseValue(json, ref index, ref success); - if (!success) - { - success = false; - return null; - } - table[name] = value; - } - } - return table; - } - - static JsonArray ParseArray(char[] json, ref int index, ref bool success) - { - JsonArray array = new JsonArray(); - - // [ - NextToken(json, ref index); - - bool done = false; - while (!done) - { - int token = LookAhead(json, index); - if (token == TOKEN_NONE) - { - success = false; - return null; - } - else if (token == TOKEN_COMMA) - NextToken(json, ref index); - else if (token == TOKEN_SQUARED_CLOSE) - { - NextToken(json, ref index); - break; - } - else - { - object value = ParseValue(json, ref index, ref success); - if (!success) - return null; - array.Add(value); - } - } - return array; - } - - static object ParseValue(char[] json, ref int index, ref bool success) - { - switch (LookAhead(json, index)) - { - case TOKEN_STRING: - return ParseString(json, ref index, ref success); - case TOKEN_NUMBER: - return ParseNumber(json, ref index, ref success); - case TOKEN_CURLY_OPEN: - return ParseObject(json, ref index, ref success); - case TOKEN_SQUARED_OPEN: - return ParseArray(json, ref index, ref success); - case TOKEN_TRUE: - NextToken(json, ref index); - return true; - case TOKEN_FALSE: - NextToken(json, ref index); - return false; - case TOKEN_NULL: - NextToken(json, ref index); - return null; - case TOKEN_NONE: - break; - } - success = false; - return null; - } - - static string ParseString(char[] json, ref int index, ref bool success) - { - StringBuilder s = new StringBuilder(BUILDER_CAPACITY); - char c; - - EatWhitespace(json, ref index); - - // " - c = json[index++]; - bool complete = false; - while (!complete) - { - if (index == json.Length) - break; - - c = json[index++]; - if (c == '"') - { - complete = true; - break; - } - else if (c == '\\') - { - if (index == json.Length) - break; - c = json[index++]; - if (c == '"') - s.Append('"'); - else if (c == '\\') - s.Append('\\'); - else if (c == '/') - s.Append('/'); - else if (c == 'b') - s.Append('\b'); - else if (c == 'f') - s.Append('\f'); - else if (c == 'n') - s.Append('\n'); - else if (c == 'r') - s.Append('\r'); - else if (c == 't') - s.Append('\t'); - else if (c == 'u') - { - int remainingLength = json.Length - index; - if (remainingLength >= 4) - { - // parse the 32 bit hex into an integer codepoint - uint codePoint; - if (!(success = UInt32.TryParse(new string(json, index, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codePoint))) - return ""; - - // convert the integer codepoint to a unicode char and add to string - if (0xD800 <= codePoint && codePoint <= 0xDBFF) // if high surrogate - { - index += 4; // skip 4 chars - remainingLength = json.Length - index; - if (remainingLength >= 6) - { - uint lowCodePoint; - if (new string(json, index, 2) == "\\u" && UInt32.TryParse(new string(json, index + 2, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out lowCodePoint)) - { - if (0xDC00 <= lowCodePoint && lowCodePoint <= 0xDFFF) // if low surrogate - { - s.Append((char)codePoint); - s.Append((char)lowCodePoint); - index += 6; // skip 6 chars - continue; - } - } - } - success = false; // invalid surrogate pair - return ""; - } - s.Append(ConvertFromUtf32((int)codePoint)); - // skip 4 chars - index += 4; - } - else - break; - } - } - else - s.Append(c); - } - if (!complete) - { - success = false; - return null; - } - return s.ToString(); - } - - private static string ConvertFromUtf32(int utf32) - { - // http://www.java2s.com/Open-Source/CSharp/2.6.4-mono-.net-core/System/System/Char.cs.htm - if (utf32 < 0 || utf32 > 0x10FFFF) - throw new ArgumentOutOfRangeException("utf32", "The argument must be from 0 to 0x10FFFF."); - if (0xD800 <= utf32 && utf32 <= 0xDFFF) - throw new ArgumentOutOfRangeException("utf32", "The argument must not be in surrogate pair range."); - if (utf32 < 0x10000) - return new string((char)utf32, 1); - utf32 -= 0x10000; - return new string(new char[] { (char)((utf32 >> 10) + 0xD800), (char)(utf32 % 0x0400 + 0xDC00) }); - } - - static object ParseNumber(char[] json, ref int index, ref bool success) - { - EatWhitespace(json, ref index); - int lastIndex = GetLastIndexOfNumber(json, index); - int charLength = (lastIndex - index) + 1; - object returnNumber; - string str = new string(json, index, charLength); - if (str.IndexOf(".", StringComparison.OrdinalIgnoreCase) != -1 || str.IndexOf("e", StringComparison.OrdinalIgnoreCase) != -1) - { - double number; - success = double.TryParse(new string(json, index, charLength), NumberStyles.Any, CultureInfo.InvariantCulture, out number); - returnNumber = number; - } - else - { - long number; - success = long.TryParse(new string(json, index, charLength), NumberStyles.Any, CultureInfo.InvariantCulture, out number); - returnNumber = number; - } - index = lastIndex + 1; - return returnNumber; - } - - static int GetLastIndexOfNumber(char[] json, int index) - { - int lastIndex; - for (lastIndex = index; lastIndex < json.Length; lastIndex++) - if ("0123456789+-.eE".IndexOf(json[lastIndex]) == -1) break; - return lastIndex - 1; - } - - static void EatWhitespace(char[] json, ref int index) - { - for (; index < json.Length; index++) - if (" \t\n\r\b\f".IndexOf(json[index]) == -1) break; - } - - static int LookAhead(char[] json, int index) - { - int saveIndex = index; - return NextToken(json, ref saveIndex); - } - - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - static int NextToken(char[] json, ref int index) - { - EatWhitespace(json, ref index); - if (index == json.Length) - return TOKEN_NONE; - char c = json[index]; - index++; - switch (c) - { - case '{': - return TOKEN_CURLY_OPEN; - case '}': - return TOKEN_CURLY_CLOSE; - case '[': - return TOKEN_SQUARED_OPEN; - case ']': - return TOKEN_SQUARED_CLOSE; - case ',': - return TOKEN_COMMA; - case '"': - return TOKEN_STRING; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '-': - return TOKEN_NUMBER; - case ':': - return TOKEN_COLON; - } - index--; - int remainingLength = json.Length - index; - // false - if (remainingLength >= 5) - { - if (json[index] == 'f' && json[index + 1] == 'a' && json[index + 2] == 'l' && json[index + 3] == 's' && json[index + 4] == 'e') - { - index += 5; - return TOKEN_FALSE; - } - } - // true - if (remainingLength >= 4) - { - if (json[index] == 't' && json[index + 1] == 'r' && json[index + 2] == 'u' && json[index + 3] == 'e') - { - index += 4; - return TOKEN_TRUE; - } - } - // null - if (remainingLength >= 4) - { - if (json[index] == 'n' && json[index + 1] == 'u' && json[index + 2] == 'l' && json[index + 3] == 'l') - { - index += 4; - return TOKEN_NULL; - } - } - return TOKEN_NONE; - } - - static bool SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, object value, StringBuilder builder) - { - bool success = true; - string stringValue = value as string; - if (stringValue != null) - success = SerializeString(stringValue, builder); - else - { - IDictionary dict = value as IDictionary; - if (dict != null) - { - success = SerializeObject(jsonSerializerStrategy, dict.Keys, dict.Values, builder); - } - else - { - IDictionary stringDictionary = value as IDictionary; - if (stringDictionary != null) - { - success = SerializeObject(jsonSerializerStrategy, stringDictionary.Keys, stringDictionary.Values, builder); - } - else - { - IEnumerable enumerableValue = value as IEnumerable; - if (enumerableValue != null) - success = SerializeArray(jsonSerializerStrategy, enumerableValue, builder); - else if (IsNumeric(value)) - success = SerializeNumber(value, builder); - else if (value is bool) - builder.Append((bool)value ? "true" : "false"); - else if (value == null) - builder.Append("null"); - else - { - object serializedObject; - success = jsonSerializerStrategy.TrySerializeNonPrimitiveObject(value, out serializedObject); - if (success) - SerializeValue(jsonSerializerStrategy, serializedObject, builder); - } - } - } - } - return success; - } - - static bool SerializeObject(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable keys, IEnumerable values, StringBuilder builder) - { - builder.Append("{"); - IEnumerator ke = keys.GetEnumerator(); - IEnumerator ve = values.GetEnumerator(); - bool first = true; - while (ke.MoveNext() && ve.MoveNext()) - { - object key = ke.Current; - object value = ve.Current; - if (!first) - builder.Append(","); - string stringKey = key as string; - if (stringKey != null) - SerializeString(stringKey, builder); - else - if (!SerializeValue(jsonSerializerStrategy, value, builder)) return false; - builder.Append(":"); - if (!SerializeValue(jsonSerializerStrategy, value, builder)) - return false; - first = false; - } - builder.Append("}"); - return true; - } - - static bool SerializeArray(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable anArray, StringBuilder builder) - { - builder.Append("["); - bool first = true; - foreach (object value in anArray) - { - if (!first) - builder.Append(","); - if (!SerializeValue(jsonSerializerStrategy, value, builder)) - return false; - first = false; - } - builder.Append("]"); - return true; - } - - static bool SerializeString(string aString, StringBuilder builder) - { - // Happy path if there's nothing to be escaped. IndexOfAny is highly optimized (and unmanaged) - if (aString.IndexOfAny(EscapeCharacters) == -1) - { - builder.Append('"'); - builder.Append(aString); - builder.Append('"'); - - return true; - } - - builder.Append('"'); - int safeCharacterCount = 0; - char[] charArray = aString.ToCharArray(); - - for (int i = 0; i < charArray.Length; i++) - { - char c = charArray[i]; - - // Non ascii characters are fine, buffer them up and send them to the builder - // in larger chunks if possible. The escape table is a 1:1 translation table - // with \0 [default(char)] denoting a safe character. - if (c >= EscapeTable.Length || EscapeTable[c] == default(char)) - { - safeCharacterCount++; - } - else - { - if (safeCharacterCount > 0) - { - builder.Append(charArray, i - safeCharacterCount, safeCharacterCount); - safeCharacterCount = 0; - } - - builder.Append('\\'); - builder.Append(EscapeTable[c]); - } - } - - if (safeCharacterCount > 0) - { - builder.Append(charArray, charArray.Length - safeCharacterCount, safeCharacterCount); - } - - builder.Append('"'); - return true; - } - - static bool SerializeNumber(object number, StringBuilder builder) - { - if (number is long) - builder.Append(((long)number).ToString(CultureInfo.InvariantCulture)); - else if (number is ulong) - builder.Append(((ulong)number).ToString(CultureInfo.InvariantCulture)); - else if (number is int) - builder.Append(((int)number).ToString(CultureInfo.InvariantCulture)); - else if (number is uint) - builder.Append(((uint)number).ToString(CultureInfo.InvariantCulture)); - else if (number is decimal) - builder.Append(((decimal)number).ToString(CultureInfo.InvariantCulture)); - else if (number is float) - builder.Append(((float)number).ToString(CultureInfo.InvariantCulture)); - else - builder.Append(Convert.ToDouble(number, CultureInfo.InvariantCulture).ToString("r", CultureInfo.InvariantCulture)); - return true; - } - - /// - /// Determines if a given object is numeric in any way - /// (can be integer, double, null, etc). - /// - static bool IsNumeric(object value) - { - if (value is sbyte) return true; - if (value is byte) return true; - if (value is short) return true; - if (value is ushort) return true; - if (value is int) return true; - if (value is uint) return true; - if (value is long) return true; - if (value is ulong) return true; - if (value is float) return true; - if (value is double) return true; - if (value is decimal) return true; - return false; - } - - private static IJsonSerializerStrategy _currentJsonSerializerStrategy; - public static IJsonSerializerStrategy CurrentJsonSerializerStrategy - { - get - { - return _currentJsonSerializerStrategy ?? - (_currentJsonSerializerStrategy = -#if SIMPLE_JSON_DATACONTRACT - DataContractJsonSerializerStrategy -#else - PocoJsonSerializerStrategy -#endif -); - } - set - { - _currentJsonSerializerStrategy = value; - } - } - - private static PocoJsonSerializerStrategy _pocoJsonSerializerStrategy; - [EditorBrowsable(EditorBrowsableState.Advanced)] - public static PocoJsonSerializerStrategy PocoJsonSerializerStrategy - { - get - { - return _pocoJsonSerializerStrategy ?? (_pocoJsonSerializerStrategy = new PocoJsonSerializerStrategy()); - } - } - -#if SIMPLE_JSON_DATACONTRACT - - private static DataContractJsonSerializerStrategy _dataContractJsonSerializerStrategy; - [System.ComponentModel.EditorBrowsable(EditorBrowsableState.Advanced)] - public static DataContractJsonSerializerStrategy DataContractJsonSerializerStrategy - { - get - { - return _dataContractJsonSerializerStrategy ?? (_dataContractJsonSerializerStrategy = new DataContractJsonSerializerStrategy()); - } - } - -#endif - } - - [GeneratedCode("simple-json", "1.0.0")] -#if SIMPLE_JSON_INTERNAL - internal -#else - public -#endif - interface IJsonSerializerStrategy - { - [SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")] - bool TrySerializeNonPrimitiveObject(object input, out object output); - object DeserializeObject(object value, Type type); - } - - [GeneratedCode("simple-json", "1.0.0")] -#if SIMPLE_JSON_INTERNAL - internal -#else - public -#endif - class PocoJsonSerializerStrategy : IJsonSerializerStrategy - { - internal IDictionary ConstructorCache; - internal IDictionary> GetCache; - internal IDictionary>> SetCache; - - internal static readonly Type[] EmptyTypes = new Type[0]; - internal static readonly Type[] ArrayConstructorParameterTypes = new Type[] { typeof(int) }; - - private static readonly string[] Iso8601Format = new string[] - { - @"yyyy-MM-dd\THH:mm:ss.FFFFFFF\Z", - @"yyyy-MM-dd\THH:mm:ss\Z", - @"yyyy-MM-dd\THH:mm:ssK" - }; - - public PocoJsonSerializerStrategy() - { - ConstructorCache = new ReflectionUtils.ThreadSafeDictionary(ContructorDelegateFactory); - GetCache = new ReflectionUtils.ThreadSafeDictionary>(GetterValueFactory); - SetCache = new ReflectionUtils.ThreadSafeDictionary>>(SetterValueFactory); - } - - protected virtual string MapClrMemberNameToJsonFieldName(string clrPropertyName) - { - return clrPropertyName; - } - - internal virtual ReflectionUtils.ConstructorDelegate ContructorDelegateFactory(Type key) - { - return ReflectionUtils.GetContructor(key, key.IsArray ? ArrayConstructorParameterTypes : EmptyTypes); - } - - internal virtual IDictionary GetterValueFactory(Type type) - { - IDictionary result = new Dictionary(); - foreach (PropertyInfo propertyInfo in ReflectionUtils.GetProperties(type)) - { - if (propertyInfo.CanRead) - { - MethodInfo getMethod = ReflectionUtils.GetGetterMethodInfo(propertyInfo); - if (getMethod.IsStatic || !getMethod.IsPublic) - continue; - result[MapClrMemberNameToJsonFieldName(propertyInfo.Name)] = ReflectionUtils.GetGetMethod(propertyInfo); - } - } - foreach (FieldInfo fieldInfo in ReflectionUtils.GetFields(type)) - { - if (fieldInfo.IsStatic || !fieldInfo.IsPublic) - continue; - result[MapClrMemberNameToJsonFieldName(fieldInfo.Name)] = ReflectionUtils.GetGetMethod(fieldInfo); - } - return result; - } - - internal virtual IDictionary> SetterValueFactory(Type type) - { - IDictionary> result = new Dictionary>(); - foreach (PropertyInfo propertyInfo in ReflectionUtils.GetProperties(type)) - { - if (propertyInfo.CanWrite) - { - MethodInfo setMethod = ReflectionUtils.GetSetterMethodInfo(propertyInfo); - if (setMethod.IsStatic || !setMethod.IsPublic) - continue; - result[MapClrMemberNameToJsonFieldName(propertyInfo.Name)] = new KeyValuePair(propertyInfo.PropertyType, ReflectionUtils.GetSetMethod(propertyInfo)); - } - } - foreach (FieldInfo fieldInfo in ReflectionUtils.GetFields(type)) - { - if (fieldInfo.IsInitOnly || fieldInfo.IsStatic || !fieldInfo.IsPublic) - continue; - result[MapClrMemberNameToJsonFieldName(fieldInfo.Name)] = new KeyValuePair(fieldInfo.FieldType, ReflectionUtils.GetSetMethod(fieldInfo)); - } - return result; - } - - public virtual bool TrySerializeNonPrimitiveObject(object input, out object output) - { - return TrySerializeKnownTypes(input, out output) || TrySerializeUnknownTypes(input, out output); - } - - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - public virtual object DeserializeObject(object value, Type type) - { - if (type == null) throw new ArgumentNullException("type"); - string str = value as string; - - if (type == typeof (Guid) && string.IsNullOrEmpty(str)) - return default(Guid); - - if (value == null) - return null; - - object obj = null; - - if (str != null) - { - if (str.Length != 0) // We know it can't be null now. - { - if (type == typeof(DateTime) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(DateTime))) - return DateTime.ParseExact(str, Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal); - if (type == typeof(DateTimeOffset) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(DateTimeOffset))) - return DateTimeOffset.ParseExact(str, Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal); - if (type == typeof(Guid) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid))) - return new Guid(str); - if (type == typeof(Uri)) - { - bool isValid = Uri.IsWellFormedUriString(str, UriKind.RelativeOrAbsolute); - - Uri result; - if (isValid && Uri.TryCreate(str, UriKind.RelativeOrAbsolute, out result)) - return result; - - return null; - } - - if (type == typeof(string)) - return str; - - return Convert.ChangeType(str, type, CultureInfo.InvariantCulture); - } - else - { - if (type == typeof(Guid)) - obj = default(Guid); - else if (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid)) - obj = null; - else - obj = str; - } - // Empty string case - if (!ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid)) - return str; - } - else if (value is bool) - return value; - - bool valueIsLong = value is long; - bool valueIsDouble = value is double; - if ((valueIsLong && type == typeof(long)) || (valueIsDouble && type == typeof(double))) - return value; - if ((valueIsDouble && type != typeof(double)) || (valueIsLong && type != typeof(long))) - { - obj = type == typeof(int) || type == typeof(long) || type == typeof(double) || type == typeof(float) || type == typeof(bool) || type == typeof(decimal) || type == typeof(byte) || type == typeof(short) - ? Convert.ChangeType(value, type, CultureInfo.InvariantCulture) - : value; - } - else - { - IDictionary objects = value as IDictionary; - if (objects != null) - { - IDictionary jsonObject = objects; - - if (ReflectionUtils.IsTypeDictionary(type)) - { - // if dictionary then - Type[] types = ReflectionUtils.GetGenericTypeArguments(type); - Type keyType = types[0]; - Type valueType = types[1]; - - Type genericType = typeof(Dictionary<,>).MakeGenericType(keyType, valueType); - - IDictionary dict = (IDictionary)ConstructorCache[genericType](); - - foreach (KeyValuePair kvp in jsonObject) - dict.Add(kvp.Key, DeserializeObject(kvp.Value, valueType)); - - obj = dict; - } - else - { - if (type == typeof(object)) - obj = value; - else - { - obj = ConstructorCache[type](); - foreach (KeyValuePair> setter in SetCache[type]) - { - object jsonValue; - if (jsonObject.TryGetValue(setter.Key, out jsonValue)) - { - jsonValue = DeserializeObject(jsonValue, setter.Value.Key); - setter.Value.Value(obj, jsonValue); - } - } - } - } - } - else - { - IList valueAsList = value as IList; - if (valueAsList != null) - { - IList jsonObject = valueAsList; - IList list = null; - - if (type.IsArray) - { - list = (IList)ConstructorCache[type](jsonObject.Count); - int i = 0; - foreach (object o in jsonObject) - list[i++] = DeserializeObject(o, type.GetElementType()); - } - else if (ReflectionUtils.IsTypeGenericeCollectionInterface(type) || ReflectionUtils.IsAssignableFrom(typeof(IList), type)) - { - Type innerType = ReflectionUtils.GetGenericListElementType(type); - list = (IList)(ConstructorCache[type] ?? ConstructorCache[typeof(List<>).MakeGenericType(innerType)])(jsonObject.Count); - foreach (object o in jsonObject) - list.Add(DeserializeObject(o, innerType)); - } - obj = list; - } - } - return obj; - } - if (ReflectionUtils.IsNullableType(type)) - return ReflectionUtils.ToNullableType(obj, type); - return obj; - } - - protected virtual object SerializeEnum(Enum p) - { - return Convert.ToDouble(p, CultureInfo.InvariantCulture); - } - - [SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")] - protected virtual bool TrySerializeKnownTypes(object input, out object output) - { - bool returnValue = true; - if (input is DateTime) - output = ((DateTime)input).ToUniversalTime().ToString(Iso8601Format[0], CultureInfo.InvariantCulture); - else if (input is DateTimeOffset) - output = ((DateTimeOffset)input).ToUniversalTime().ToString(Iso8601Format[0], CultureInfo.InvariantCulture); - else if (input is Guid) - output = ((Guid)input).ToString("D"); - else if (input is Uri) - output = input.ToString(); - else - { - Enum inputEnum = input as Enum; - if (inputEnum != null) - output = SerializeEnum(inputEnum); - else - { - returnValue = false; - output = null; - } - } - return returnValue; - } - [SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")] - protected virtual bool TrySerializeUnknownTypes(object input, out object output) - { - if (input == null) throw new ArgumentNullException("input"); - output = null; - Type type = input.GetType(); - if (type.FullName == null) - return false; - IDictionary obj = new JsonObject(); - IDictionary getters = GetCache[type]; - foreach (KeyValuePair getter in getters) - { - if (getter.Value != null) - obj.Add(MapClrMemberNameToJsonFieldName(getter.Key), getter.Value(input)); - } - output = obj; - return true; - } - } - -#if SIMPLE_JSON_DATACONTRACT - [GeneratedCode("simple-json", "1.0.0")] -#if SIMPLE_JSON_INTERNAL - internal -#else - public -#endif - class DataContractJsonSerializerStrategy : PocoJsonSerializerStrategy - { - public DataContractJsonSerializerStrategy() - { - GetCache = new ReflectionUtils.ThreadSafeDictionary>(GetterValueFactory); - SetCache = new ReflectionUtils.ThreadSafeDictionary>>(SetterValueFactory); - } - - internal override IDictionary GetterValueFactory(Type type) - { - bool hasDataContract = ReflectionUtils.GetAttribute(type, typeof(DataContractAttribute)) != null; - if (!hasDataContract) - return base.GetterValueFactory(type); - string jsonKey; - IDictionary result = new Dictionary(); - foreach (PropertyInfo propertyInfo in ReflectionUtils.GetProperties(type)) - { - if (propertyInfo.CanRead) - { - MethodInfo getMethod = ReflectionUtils.GetGetterMethodInfo(propertyInfo); - if (!getMethod.IsStatic && CanAdd(propertyInfo, out jsonKey)) - result[jsonKey] = ReflectionUtils.GetGetMethod(propertyInfo); - } - } - foreach (FieldInfo fieldInfo in ReflectionUtils.GetFields(type)) - { - if (!fieldInfo.IsStatic && CanAdd(fieldInfo, out jsonKey)) - result[jsonKey] = ReflectionUtils.GetGetMethod(fieldInfo); - } - return result; - } - - internal override IDictionary> SetterValueFactory(Type type) - { - bool hasDataContract = ReflectionUtils.GetAttribute(type, typeof(DataContractAttribute)) != null; - if (!hasDataContract) - return base.SetterValueFactory(type); - string jsonKey; - IDictionary> result = new Dictionary>(); - foreach (PropertyInfo propertyInfo in ReflectionUtils.GetProperties(type)) - { - if (propertyInfo.CanWrite) - { - MethodInfo setMethod = ReflectionUtils.GetSetterMethodInfo(propertyInfo); - if (!setMethod.IsStatic && CanAdd(propertyInfo, out jsonKey)) - result[jsonKey] = new KeyValuePair(propertyInfo.PropertyType, ReflectionUtils.GetSetMethod(propertyInfo)); - } - } - foreach (FieldInfo fieldInfo in ReflectionUtils.GetFields(type)) - { - if (!fieldInfo.IsInitOnly && !fieldInfo.IsStatic && CanAdd(fieldInfo, out jsonKey)) - result[jsonKey] = new KeyValuePair(fieldInfo.FieldType, ReflectionUtils.GetSetMethod(fieldInfo)); - } - // todo implement sorting for DATACONTRACT. - return result; - } - - private static bool CanAdd(MemberInfo info, out string jsonKey) - { - jsonKey = null; - if (ReflectionUtils.GetAttribute(info, typeof(IgnoreDataMemberAttribute)) != null) - return false; - DataMemberAttribute dataMemberAttribute = (DataMemberAttribute)ReflectionUtils.GetAttribute(info, typeof(DataMemberAttribute)); - if (dataMemberAttribute == null) - return false; - jsonKey = string.IsNullOrEmpty(dataMemberAttribute.Name) ? info.Name : dataMemberAttribute.Name; - return true; - } - } - -#endif - - namespace Reflection - { - // This class is meant to be copied into other libraries. So we want to exclude it from Code Analysis rules - // that might be in place in the target project. - [GeneratedCode("reflection-utils", "1.0.0")] -#if SIMPLE_JSON_REFLECTION_UTILS_PUBLIC - public -#else - internal -#endif - class ReflectionUtils - { - private static readonly object[] EmptyObjects = new object[] { }; - - public delegate object GetDelegate(object source); - public delegate void SetDelegate(object source, object value); - public delegate object ConstructorDelegate(params object[] args); - - public delegate TValue ThreadSafeDictionaryValueFactory(TKey key); - -#if SIMPLE_JSON_TYPEINFO - public static TypeInfo GetTypeInfo(Type type) - { - return type.GetTypeInfo(); - } -#else - public static Type GetTypeInfo(Type type) - { - return type; - } -#endif - - public static Attribute GetAttribute(MemberInfo info, Type type) - { -#if SIMPLE_JSON_TYPEINFO - if (info == null || type == null || !info.IsDefined(type)) - return null; - return info.GetCustomAttribute(type); -#else - if (info == null || type == null || !Attribute.IsDefined(info, type)) - return null; - return Attribute.GetCustomAttribute(info, type); -#endif - } - - public static Type GetGenericListElementType(Type type) - { - IEnumerable interfaces; -#if SIMPLE_JSON_TYPEINFO - interfaces = type.GetTypeInfo().ImplementedInterfaces; -#else - interfaces = type.GetInterfaces(); -#endif - foreach (Type implementedInterface in interfaces) - { - if (IsTypeGeneric(implementedInterface) && - implementedInterface.GetGenericTypeDefinition() == typeof (IList<>)) - { - return GetGenericTypeArguments(implementedInterface)[0]; - } - } - return GetGenericTypeArguments(type)[0]; - } - - public static Attribute GetAttribute(Type objectType, Type attributeType) - { - -#if SIMPLE_JSON_TYPEINFO - if (objectType == null || attributeType == null || !objectType.GetTypeInfo().IsDefined(attributeType)) - return null; - return objectType.GetTypeInfo().GetCustomAttribute(attributeType); -#else - if (objectType == null || attributeType == null || !Attribute.IsDefined(objectType, attributeType)) - return null; - return Attribute.GetCustomAttribute(objectType, attributeType); -#endif - } - - public static Type[] GetGenericTypeArguments(Type type) - { -#if SIMPLE_JSON_TYPEINFO - return type.GetTypeInfo().GenericTypeArguments; -#else - return type.GetGenericArguments(); -#endif - } - - public static bool IsTypeGeneric(Type type) - { - return GetTypeInfo(type).IsGenericType; - } - - public static bool IsTypeGenericeCollectionInterface(Type type) - { - if (!IsTypeGeneric(type)) - return false; - - Type genericDefinition = type.GetGenericTypeDefinition(); - - return (genericDefinition == typeof(IList<>) - || genericDefinition == typeof(ICollection<>) - || genericDefinition == typeof(IEnumerable<>) -#if SIMPLE_JSON_READONLY_COLLECTIONS - || genericDefinition == typeof(IReadOnlyCollection<>) - || genericDefinition == typeof(IReadOnlyList<>) -#endif - ); - } - - public static bool IsAssignableFrom(Type type1, Type type2) - { - return GetTypeInfo(type1).IsAssignableFrom(GetTypeInfo(type2)); - } - - public static bool IsTypeDictionary(Type type) - { -#if SIMPLE_JSON_TYPEINFO - if (typeof(IDictionary<,>).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) - return true; -#else - if (typeof(System.Collections.IDictionary).IsAssignableFrom(type)) - return true; -#endif - if (!GetTypeInfo(type).IsGenericType) - return false; - - Type genericDefinition = type.GetGenericTypeDefinition(); - return genericDefinition == typeof(IDictionary<,>); - } - - public static bool IsNullableType(Type type) - { - return GetTypeInfo(type).IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>); - } - - public static object ToNullableType(object obj, Type nullableType) - { - return obj == null ? null : Convert.ChangeType(obj, Nullable.GetUnderlyingType(nullableType), CultureInfo.InvariantCulture); - } - - public static bool IsValueType(Type type) - { - return GetTypeInfo(type).IsValueType; - } - - public static IEnumerable GetConstructors(Type type) - { -#if SIMPLE_JSON_TYPEINFO - return type.GetTypeInfo().DeclaredConstructors; -#else - return type.GetConstructors(); -#endif - } - - public static ConstructorInfo GetConstructorInfo(Type type, params Type[] argsType) - { - IEnumerable constructorInfos = GetConstructors(type); - int i; - bool matches; - foreach (ConstructorInfo constructorInfo in constructorInfos) - { - ParameterInfo[] parameters = constructorInfo.GetParameters(); - if (argsType.Length != parameters.Length) - continue; - - i = 0; - matches = true; - foreach (ParameterInfo parameterInfo in constructorInfo.GetParameters()) - { - if (parameterInfo.ParameterType != argsType[i]) - { - matches = false; - break; - } - } - - if (matches) - return constructorInfo; - } - - return null; - } - - public static IEnumerable GetProperties(Type type) - { -#if SIMPLE_JSON_TYPEINFO - return type.GetRuntimeProperties(); -#else - return type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); -#endif - } - - public static IEnumerable GetFields(Type type) - { -#if SIMPLE_JSON_TYPEINFO - return type.GetRuntimeFields(); -#else - return type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); -#endif - } - - public static MethodInfo GetGetterMethodInfo(PropertyInfo propertyInfo) - { -#if SIMPLE_JSON_TYPEINFO - return propertyInfo.GetMethod; -#else - return propertyInfo.GetGetMethod(true); -#endif - } - - public static MethodInfo GetSetterMethodInfo(PropertyInfo propertyInfo) - { -#if SIMPLE_JSON_TYPEINFO - return propertyInfo.SetMethod; -#else - return propertyInfo.GetSetMethod(true); -#endif - } - - public static ConstructorDelegate GetContructor(ConstructorInfo constructorInfo) - { -#if SIMPLE_JSON_NO_LINQ_EXPRESSION - return GetConstructorByReflection(constructorInfo); -#else - return GetConstructorByExpression(constructorInfo); -#endif - } - - public static ConstructorDelegate GetContructor(Type type, params Type[] argsType) - { -#if SIMPLE_JSON_NO_LINQ_EXPRESSION - return GetConstructorByReflection(type, argsType); -#else - return GetConstructorByExpression(type, argsType); -#endif - } - - public static ConstructorDelegate GetConstructorByReflection(ConstructorInfo constructorInfo) - { - return delegate(object[] args) { return constructorInfo.Invoke(args); }; - } - - public static ConstructorDelegate GetConstructorByReflection(Type type, params Type[] argsType) - { - ConstructorInfo constructorInfo = GetConstructorInfo(type, argsType); - return constructorInfo == null ? null : GetConstructorByReflection(constructorInfo); - } - -#if !SIMPLE_JSON_NO_LINQ_EXPRESSION - - public static ConstructorDelegate GetConstructorByExpression(ConstructorInfo constructorInfo) - { - ParameterInfo[] paramsInfo = constructorInfo.GetParameters(); - ParameterExpression param = Expression.Parameter(typeof(object[]), "args"); - Expression[] argsExp = new Expression[paramsInfo.Length]; - for (int i = 0; i < paramsInfo.Length; i++) - { - Expression index = Expression.Constant(i); - Type paramType = paramsInfo[i].ParameterType; - Expression paramAccessorExp = Expression.ArrayIndex(param, index); - Expression paramCastExp = Expression.Convert(paramAccessorExp, paramType); - argsExp[i] = paramCastExp; - } - NewExpression newExp = Expression.New(constructorInfo, argsExp); - Expression> lambda = Expression.Lambda>(newExp, param); - Func compiledLambda = lambda.Compile(); - return delegate(object[] args) { return compiledLambda(args); }; - } - - public static ConstructorDelegate GetConstructorByExpression(Type type, params Type[] argsType) - { - ConstructorInfo constructorInfo = GetConstructorInfo(type, argsType); - return constructorInfo == null ? null : GetConstructorByExpression(constructorInfo); - } - -#endif - - public static GetDelegate GetGetMethod(PropertyInfo propertyInfo) - { -#if SIMPLE_JSON_NO_LINQ_EXPRESSION - return GetGetMethodByReflection(propertyInfo); -#else - return GetGetMethodByExpression(propertyInfo); -#endif - } - - public static GetDelegate GetGetMethod(FieldInfo fieldInfo) - { -#if SIMPLE_JSON_NO_LINQ_EXPRESSION - return GetGetMethodByReflection(fieldInfo); -#else - return GetGetMethodByExpression(fieldInfo); -#endif - } - - public static GetDelegate GetGetMethodByReflection(PropertyInfo propertyInfo) - { - MethodInfo methodInfo = GetGetterMethodInfo(propertyInfo); - return delegate(object source) { return methodInfo.Invoke(source, EmptyObjects); }; - } - - public static GetDelegate GetGetMethodByReflection(FieldInfo fieldInfo) - { - return delegate(object source) { return fieldInfo.GetValue(source); }; - } - -#if !SIMPLE_JSON_NO_LINQ_EXPRESSION - - public static GetDelegate GetGetMethodByExpression(PropertyInfo propertyInfo) - { - MethodInfo getMethodInfo = GetGetterMethodInfo(propertyInfo); - ParameterExpression instance = Expression.Parameter(typeof(object), "instance"); - UnaryExpression instanceCast = (!IsValueType(propertyInfo.DeclaringType)) ? Expression.TypeAs(instance, propertyInfo.DeclaringType) : Expression.Convert(instance, propertyInfo.DeclaringType); - Func compiled = Expression.Lambda>(Expression.TypeAs(Expression.Call(instanceCast, getMethodInfo), typeof(object)), instance).Compile(); - return delegate(object source) { return compiled(source); }; - } - - public static GetDelegate GetGetMethodByExpression(FieldInfo fieldInfo) - { - ParameterExpression instance = Expression.Parameter(typeof(object), "instance"); - MemberExpression member = Expression.Field(Expression.Convert(instance, fieldInfo.DeclaringType), fieldInfo); - GetDelegate compiled = Expression.Lambda(Expression.Convert(member, typeof(object)), instance).Compile(); - return delegate(object source) { return compiled(source); }; - } - -#endif - - public static SetDelegate GetSetMethod(PropertyInfo propertyInfo) - { -#if SIMPLE_JSON_NO_LINQ_EXPRESSION - return GetSetMethodByReflection(propertyInfo); -#else - return GetSetMethodByExpression(propertyInfo); -#endif - } - - public static SetDelegate GetSetMethod(FieldInfo fieldInfo) - { -#if SIMPLE_JSON_NO_LINQ_EXPRESSION - return GetSetMethodByReflection(fieldInfo); -#else - return GetSetMethodByExpression(fieldInfo); -#endif - } - - public static SetDelegate GetSetMethodByReflection(PropertyInfo propertyInfo) - { - MethodInfo methodInfo = GetSetterMethodInfo(propertyInfo); - return delegate(object source, object value) { methodInfo.Invoke(source, new object[] { value }); }; - } - - public static SetDelegate GetSetMethodByReflection(FieldInfo fieldInfo) - { - return delegate(object source, object value) { fieldInfo.SetValue(source, value); }; - } - -#if !SIMPLE_JSON_NO_LINQ_EXPRESSION - - public static SetDelegate GetSetMethodByExpression(PropertyInfo propertyInfo) - { - MethodInfo setMethodInfo = GetSetterMethodInfo(propertyInfo); - ParameterExpression instance = Expression.Parameter(typeof(object), "instance"); - ParameterExpression value = Expression.Parameter(typeof(object), "value"); - UnaryExpression instanceCast = (!IsValueType(propertyInfo.DeclaringType)) ? Expression.TypeAs(instance, propertyInfo.DeclaringType) : Expression.Convert(instance, propertyInfo.DeclaringType); - UnaryExpression valueCast = (!IsValueType(propertyInfo.PropertyType)) ? Expression.TypeAs(value, propertyInfo.PropertyType) : Expression.Convert(value, propertyInfo.PropertyType); - Action compiled = Expression.Lambda>(Expression.Call(instanceCast, setMethodInfo, valueCast), new ParameterExpression[] { instance, value }).Compile(); - return delegate(object source, object val) { compiled(source, val); }; - } - - public static SetDelegate GetSetMethodByExpression(FieldInfo fieldInfo) - { - ParameterExpression instance = Expression.Parameter(typeof(object), "instance"); - ParameterExpression value = Expression.Parameter(typeof(object), "value"); - Action compiled = Expression.Lambda>( - Assign(Expression.Field(Expression.Convert(instance, fieldInfo.DeclaringType), fieldInfo), Expression.Convert(value, fieldInfo.FieldType)), instance, value).Compile(); - return delegate(object source, object val) { compiled(source, val); }; - } - - public static BinaryExpression Assign(Expression left, Expression right) - { -#if SIMPLE_JSON_TYPEINFO - return Expression.Assign(left, right); -#else - MethodInfo assign = typeof(Assigner<>).MakeGenericType(left.Type).GetMethod("Assign"); - BinaryExpression assignExpr = Expression.Add(left, right, assign); - return assignExpr; -#endif - } - - private static class Assigner - { - public static T Assign(ref T left, T right) - { - return (left = right); - } - } - -#endif - - public sealed class ThreadSafeDictionary : IDictionary - { - private readonly object _lock = new object(); - private readonly ThreadSafeDictionaryValueFactory _valueFactory; - private Dictionary _dictionary; - - public ThreadSafeDictionary(ThreadSafeDictionaryValueFactory valueFactory) - { - _valueFactory = valueFactory; - } - - private TValue Get(TKey key) - { - if (_dictionary == null) - return AddValue(key); - TValue value; - if (!_dictionary.TryGetValue(key, out value)) - return AddValue(key); - return value; - } - - private TValue AddValue(TKey key) - { - TValue value = _valueFactory(key); - lock (_lock) - { - if (_dictionary == null) - { - _dictionary = new Dictionary(); - _dictionary[key] = value; - } - else - { - TValue val; - if (_dictionary.TryGetValue(key, out val)) - return val; - Dictionary dict = new Dictionary(_dictionary); - dict[key] = value; - _dictionary = dict; - } - } - return value; - } - - public void Add(TKey key, TValue value) - { - throw new NotImplementedException(); - } - - public bool ContainsKey(TKey key) - { - return _dictionary.ContainsKey(key); - } - - public ICollection Keys - { - get { return _dictionary.Keys; } - } - - public bool Remove(TKey key) - { - throw new NotImplementedException(); - } - - public bool TryGetValue(TKey key, out TValue value) - { - value = this[key]; - return true; - } - - public ICollection Values - { - get { return _dictionary.Values; } - } - - public TValue this[TKey key] - { - get { return Get(key); } - set { throw new NotImplementedException(); } - } - - public void Add(KeyValuePair item) - { - throw new NotImplementedException(); - } - - public void Clear() - { - throw new NotImplementedException(); - } - - public bool Contains(KeyValuePair item) - { - throw new NotImplementedException(); - } - - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - throw new NotImplementedException(); - } - - public int Count - { - get { return _dictionary.Count; } - } - - public bool IsReadOnly - { - get { throw new NotImplementedException(); } - } - - public bool Remove(KeyValuePair item) - { - throw new NotImplementedException(); - } - - public IEnumerator> GetEnumerator() - { - return _dictionary.GetEnumerator(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return _dictionary.GetEnumerator(); - } - } - - } - } -} -// ReSharper restore LoopCanBeConvertedToQuery -// ReSharper restore RedundantExplicitArrayCreation -// ReSharper restore SuggestUseVarKeywordEvident - -"@ -Export-ModuleMember ConvertFrom-Json -Export-ModuleMember ConvertTo-Json -Add-Type -ReferencedAssemblies System.Runtime.Serialization -TypeDefinition $source -Language CSharp \ No newline at end of file diff --git a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/SimpleJson.psm1.meta b/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/SimpleJson.psm1.meta deleted file mode 100644 index 36d4eb85f..000000000 --- a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/SimpleJson.psm1.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 1d41f4959e2e98647938b30050873ab7 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/content.meta b/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/content.meta deleted file mode 100644 index eba473467..000000000 --- a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/content.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4b90f445dcdc3d8438d24cc7e5c3b9f7 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/content/SimpleJson.cs.pp b/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/content/SimpleJson.cs.pp deleted file mode 100644 index 5168470e3..000000000 --- a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/content/SimpleJson.cs.pp +++ /dev/null @@ -1,2127 +0,0 @@ -//----------------------------------------------------------------------- -// -// Copyright (c) 2011, The Outercurve Foundation. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.opensource.org/licenses/mit-license.php -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) -// https://github.com/facebook-csharp-sdk/simple-json -//----------------------------------------------------------------------- - -// VERSION: 0.38.0 - -// NOTE: uncomment the following line to make SimpleJson class internal. -//#define SIMPLE_JSON_INTERNAL - -// NOTE: uncomment the following line to make JsonArray and JsonObject class internal. -//#define SIMPLE_JSON_OBJARRAYINTERNAL - -// NOTE: uncomment the following line to enable dynamic support. -//#define SIMPLE_JSON_DYNAMIC - -// NOTE: uncomment the following line to enable DataContract support. -//#define SIMPLE_JSON_DATACONTRACT - -// NOTE: uncomment the following line to enable IReadOnlyCollection and IReadOnlyList support. -//#define SIMPLE_JSON_READONLY_COLLECTIONS - -// NOTE: uncomment the following line to disable linq expressions/compiled lambda (better performance) instead of method.invoke(). -// define if you are using .net framework <= 3.0 or < WP7.5 -//#define SIMPLE_JSON_NO_LINQ_EXPRESSION - -// NOTE: uncomment the following line if you are compiling under Window Metro style application/library. -// usually already defined in properties -//#define NETFX_CORE; - -// If you are targetting WinStore, WP8 and NET4.5+ PCL make sure to #define SIMPLE_JSON_TYPEINFO; - -// original json parsing code from http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html - -#if NETFX_CORE -#define SIMPLE_JSON_TYPEINFO -#endif - -using System; -using System.CodeDom.Compiler; -using System.Collections; -using System.Collections.Generic; -#if !SIMPLE_JSON_NO_LINQ_EXPRESSION -using System.Linq.Expressions; -#endif -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -#if SIMPLE_JSON_DYNAMIC -using System.Dynamic; -#endif -using System.Globalization; -using System.Reflection; -using System.Runtime.Serialization; -using System.Text; -using $rootnamespace$.Reflection; - -// ReSharper disable LoopCanBeConvertedToQuery -// ReSharper disable RedundantExplicitArrayCreation -// ReSharper disable SuggestUseVarKeywordEvident -namespace $rootnamespace$ -{ - /// - /// Represents the json array. - /// - [GeneratedCode("simple-json", "1.0.0")] - [EditorBrowsable(EditorBrowsableState.Never)] - [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] -#if SIMPLE_JSON_OBJARRAYINTERNAL - internal -#else - public -#endif - class JsonArray : List - { - /// - /// Initializes a new instance of the class. - /// - public JsonArray() { } - - /// - /// Initializes a new instance of the class. - /// - /// The capacity of the json array. - public JsonArray(int capacity) : base(capacity) { } - - /// - /// The json representation of the array. - /// - /// The json representation of the array. - public override string ToString() - { - return SimpleJson.SerializeObject(this) ?? string.Empty; - } - } - - /// - /// Represents the json object. - /// - [GeneratedCode("simple-json", "1.0.0")] - [EditorBrowsable(EditorBrowsableState.Never)] - [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] -#if SIMPLE_JSON_OBJARRAYINTERNAL - internal -#else - public -#endif - class JsonObject : -#if SIMPLE_JSON_DYNAMIC - DynamicObject, -#endif - IDictionary - { - /// - /// The internal member dictionary. - /// - private readonly Dictionary _members; - - /// - /// Initializes a new instance of . - /// - public JsonObject() - { - _members = new Dictionary(); - } - - /// - /// Initializes a new instance of . - /// - /// The implementation to use when comparing keys, or null to use the default for the type of the key. - public JsonObject(IEqualityComparer comparer) - { - _members = new Dictionary(comparer); - } - - /// - /// Gets the at the specified index. - /// - /// - public object this[int index] - { - get { return GetAtIndex(_members, index); } - } - - internal static object GetAtIndex(IDictionary obj, int index) - { - if (obj == null) - throw new ArgumentNullException("obj"); - if (index >= obj.Count) - throw new ArgumentOutOfRangeException("index"); - int i = 0; - foreach (KeyValuePair o in obj) - if (i++ == index) return o.Value; - return null; - } - - /// - /// Adds the specified key. - /// - /// The key. - /// The value. - public void Add(string key, object value) - { - _members.Add(key, value); - } - - /// - /// Determines whether the specified key contains key. - /// - /// The key. - /// - /// true if the specified key contains key; otherwise, false. - /// - public bool ContainsKey(string key) - { - return _members.ContainsKey(key); - } - - /// - /// Gets the keys. - /// - /// The keys. - public ICollection Keys - { - get { return _members.Keys; } - } - - /// - /// Removes the specified key. - /// - /// The key. - /// - public bool Remove(string key) - { - return _members.Remove(key); - } - - /// - /// Tries the get value. - /// - /// The key. - /// The value. - /// - public bool TryGetValue(string key, out object value) - { - return _members.TryGetValue(key, out value); - } - - /// - /// Gets the values. - /// - /// The values. - public ICollection Values - { - get { return _members.Values; } - } - - /// - /// Gets or sets the with the specified key. - /// - /// - public object this[string key] - { - get { return _members[key]; } - set { _members[key] = value; } - } - - /// - /// Adds the specified item. - /// - /// The item. - public void Add(KeyValuePair item) - { - _members.Add(item.Key, item.Value); - } - - /// - /// Clears this instance. - /// - public void Clear() - { - _members.Clear(); - } - - /// - /// Determines whether [contains] [the specified item]. - /// - /// The item. - /// - /// true if [contains] [the specified item]; otherwise, false. - /// - public bool Contains(KeyValuePair item) - { - return _members.ContainsKey(item.Key) && _members[item.Key] == item.Value; - } - - /// - /// Copies to. - /// - /// The array. - /// Index of the array. - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - if (array == null) throw new ArgumentNullException("array"); - int num = Count; - foreach (KeyValuePair kvp in this) - { - array[arrayIndex++] = kvp; - if (--num <= 0) - return; - } - } - - /// - /// Gets the count. - /// - /// The count. - public int Count - { - get { return _members.Count; } - } - - /// - /// Gets a value indicating whether this instance is read only. - /// - /// - /// true if this instance is read only; otherwise, false. - /// - public bool IsReadOnly - { - get { return false; } - } - - /// - /// Removes the specified item. - /// - /// The item. - /// - public bool Remove(KeyValuePair item) - { - return _members.Remove(item.Key); - } - - /// - /// Gets the enumerator. - /// - /// - public IEnumerator> GetEnumerator() - { - return _members.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// - /// An object that can be used to iterate through the collection. - /// - IEnumerator IEnumerable.GetEnumerator() - { - return _members.GetEnumerator(); - } - - /// - /// Returns a json that represents the current . - /// - /// - /// A json that represents the current . - /// - public override string ToString() - { - return SimpleJson.SerializeObject(this); - } - -#if SIMPLE_JSON_DYNAMIC - /// - /// Provides implementation for type conversion operations. Classes derived from the class can override this method to specify dynamic behavior for operations that convert an object from one type to another. - /// - /// Provides information about the conversion operation. The binder.Type property provides the type to which the object must be converted. For example, for the statement (String)sampleObject in C# (CType(sampleObject, Type) in Visual Basic), where sampleObject is an instance of the class derived from the class, binder.Type returns the type. The binder.Explicit property provides information about the kind of conversion that occurs. It returns true for explicit conversion and false for implicit conversion. - /// The result of the type conversion operation. - /// - /// Alwasy returns true. - /// - public override bool TryConvert(ConvertBinder binder, out object result) - { - // - if (binder == null) - throw new ArgumentNullException("binder"); - // - Type targetType = binder.Type; - - if ((targetType == typeof(IEnumerable)) || - (targetType == typeof(IEnumerable>)) || - (targetType == typeof(IDictionary)) || - (targetType == typeof(IDictionary))) - { - result = this; - return true; - } - - return base.TryConvert(binder, out result); - } - - /// - /// Provides the implementation for operations that delete an object member. This method is not intended for use in C# or Visual Basic. - /// - /// Provides information about the deletion. - /// - /// Alwasy returns true. - /// - public override bool TryDeleteMember(DeleteMemberBinder binder) - { - // - if (binder == null) - throw new ArgumentNullException("binder"); - // - return _members.Remove(binder.Name); - } - - /// - /// Provides the implementation for operations that get a value by index. Classes derived from the class can override this method to specify dynamic behavior for indexing operations. - /// - /// Provides information about the operation. - /// The indexes that are used in the operation. For example, for the sampleObject[3] operation in C# (sampleObject(3) in Visual Basic), where sampleObject is derived from the DynamicObject class, is equal to 3. - /// The result of the index operation. - /// - /// Alwasy returns true. - /// - public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result) - { - if (indexes == null) throw new ArgumentNullException("indexes"); - if (indexes.Length == 1) - { - result = ((IDictionary)this)[(string)indexes[0]]; - return true; - } - result = null; - return true; - } - - /// - /// Provides the implementation for operations that get member values. Classes derived from the class can override this method to specify dynamic behavior for operations such as getting a value for a property. - /// - /// Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive. - /// The result of the get operation. For example, if the method is called for a property, you can assign the property value to . - /// - /// Alwasy returns true. - /// - public override bool TryGetMember(GetMemberBinder binder, out object result) - { - object value; - if (_members.TryGetValue(binder.Name, out value)) - { - result = value; - return true; - } - result = null; - return true; - } - - /// - /// Provides the implementation for operations that set a value by index. Classes derived from the class can override this method to specify dynamic behavior for operations that access objects by a specified index. - /// - /// Provides information about the operation. - /// The indexes that are used in the operation. For example, for the sampleObject[3] = 10 operation in C# (sampleObject(3) = 10 in Visual Basic), where sampleObject is derived from the class, is equal to 3. - /// The value to set to the object that has the specified index. For example, for the sampleObject[3] = 10 operation in C# (sampleObject(3) = 10 in Visual Basic), where sampleObject is derived from the class, is equal to 10. - /// - /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown. - /// - public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value) - { - if (indexes == null) throw new ArgumentNullException("indexes"); - if (indexes.Length == 1) - { - ((IDictionary)this)[(string)indexes[0]] = value; - return true; - } - return base.TrySetIndex(binder, indexes, value); - } - - /// - /// Provides the implementation for operations that set member values. Classes derived from the class can override this method to specify dynamic behavior for operations such as setting a value for a property. - /// - /// Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member to which the value is being assigned. For example, for the statement sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive. - /// The value to set to the member. For example, for sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the class, the is "Test". - /// - /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.) - /// - public override bool TrySetMember(SetMemberBinder binder, object value) - { - // - if (binder == null) - throw new ArgumentNullException("binder"); - // - _members[binder.Name] = value; - return true; - } - - /// - /// Returns the enumeration of all dynamic member names. - /// - /// - /// A sequence that contains dynamic member names. - /// - public override IEnumerable GetDynamicMemberNames() - { - foreach (var key in Keys) - yield return key; - } -#endif - } -} - -namespace $rootnamespace$ -{ - /// - /// This class encodes and decodes JSON strings. - /// Spec. details, see http://www.json.org/ - /// - /// JSON uses Arrays and Objects. These correspond here to the datatypes JsonArray(IList<object>) and JsonObject(IDictionary<string,object>). - /// All numbers are parsed to doubles. - /// - [GeneratedCode("simple-json", "1.0.0")] -#if SIMPLE_JSON_INTERNAL - internal -#else - public -#endif - static class SimpleJson - { - private const int TOKEN_NONE = 0; - private const int TOKEN_CURLY_OPEN = 1; - private const int TOKEN_CURLY_CLOSE = 2; - private const int TOKEN_SQUARED_OPEN = 3; - private const int TOKEN_SQUARED_CLOSE = 4; - private const int TOKEN_COLON = 5; - private const int TOKEN_COMMA = 6; - private const int TOKEN_STRING = 7; - private const int TOKEN_NUMBER = 8; - private const int TOKEN_TRUE = 9; - private const int TOKEN_FALSE = 10; - private const int TOKEN_NULL = 11; - private const int BUILDER_CAPACITY = 2000; - - private static readonly char[] EscapeTable; - private static readonly char[] EscapeCharacters = new char[] { '"', '\\', '\b', '\f', '\n', '\r', '\t' }; - private static readonly string EscapeCharactersString = new string(EscapeCharacters); - - static SimpleJson() - { - EscapeTable = new char[93]; - EscapeTable['"'] = '"'; - EscapeTable['\\'] = '\\'; - EscapeTable['\b'] = 'b'; - EscapeTable['\f'] = 'f'; - EscapeTable['\n'] = 'n'; - EscapeTable['\r'] = 'r'; - EscapeTable['\t'] = 't'; - } - - /// - /// Parses the string json into a value - /// - /// A JSON string. - /// An IList<object>, a IDictionary<string,object>, a double, a string, null, true, or false - public static object DeserializeObject(string json) - { - object obj; - if (TryDeserializeObject(json, out obj)) - return obj; - throw new SerializationException("Invalid JSON string"); - } - - /// - /// Try parsing the json string into a value. - /// - /// - /// A JSON string. - /// - /// - /// The object. - /// - /// - /// Returns true if successfull otherwise false. - /// - [SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")] - public static bool TryDeserializeObject(string json, out object obj) - { - bool success = true; - if (json != null) - { - char[] charArray = json.ToCharArray(); - int index = 0; - obj = ParseValue(charArray, ref index, ref success); - } - else - obj = null; - - return success; - } - - public static object DeserializeObject(string json, Type type, IJsonSerializerStrategy jsonSerializerStrategy) - { - object jsonObject = DeserializeObject(json); - return type == null || jsonObject != null && ReflectionUtils.IsAssignableFrom(jsonObject.GetType(), type) - ? jsonObject - : (jsonSerializerStrategy ?? CurrentJsonSerializerStrategy).DeserializeObject(jsonObject, type); - } - - public static object DeserializeObject(string json, Type type) - { - return DeserializeObject(json, type, null); - } - - public static T DeserializeObject(string json, IJsonSerializerStrategy jsonSerializerStrategy) - { - return (T)DeserializeObject(json, typeof(T), jsonSerializerStrategy); - } - - public static T DeserializeObject(string json) - { - return (T)DeserializeObject(json, typeof(T), null); - } - - /// - /// Converts a IDictionary<string,object> / IList<object> object into a JSON string - /// - /// A IDictionary<string,object> / IList<object> - /// Serializer strategy to use - /// A JSON encoded string, or null if object 'json' is not serializable - public static string SerializeObject(object json, IJsonSerializerStrategy jsonSerializerStrategy) - { - StringBuilder builder = new StringBuilder(BUILDER_CAPACITY); - bool success = SerializeValue(jsonSerializerStrategy, json, builder); - return (success ? builder.ToString() : null); - } - - public static string SerializeObject(object json) - { - return SerializeObject(json, CurrentJsonSerializerStrategy); - } - - public static string EscapeToJavascriptString(string jsonString) - { - if (string.IsNullOrEmpty(jsonString)) - return jsonString; - - StringBuilder sb = new StringBuilder(); - char c; - - for (int i = 0; i < jsonString.Length; ) - { - c = jsonString[i++]; - - if (c == '\\') - { - int remainingLength = jsonString.Length - i; - if (remainingLength >= 2) - { - char lookahead = jsonString[i]; - if (lookahead == '\\') - { - sb.Append('\\'); - ++i; - } - else if (lookahead == '"') - { - sb.Append("\""); - ++i; - } - else if (lookahead == 't') - { - sb.Append('\t'); - ++i; - } - else if (lookahead == 'b') - { - sb.Append('\b'); - ++i; - } - else if (lookahead == 'n') - { - sb.Append('\n'); - ++i; - } - else if (lookahead == 'r') - { - sb.Append('\r'); - ++i; - } - } - } - else - { - sb.Append(c); - } - } - return sb.ToString(); - } - - static IDictionary ParseObject(char[] json, ref int index, ref bool success) - { - IDictionary table = new JsonObject(); - int token; - - // { - NextToken(json, ref index); - - bool done = false; - while (!done) - { - token = LookAhead(json, index); - if (token == TOKEN_NONE) - { - success = false; - return null; - } - else if (token == TOKEN_COMMA) - NextToken(json, ref index); - else if (token == TOKEN_CURLY_CLOSE) - { - NextToken(json, ref index); - return table; - } - else - { - // name - string name = ParseString(json, ref index, ref success); - if (!success) - { - success = false; - return null; - } - // : - token = NextToken(json, ref index); - if (token != TOKEN_COLON) - { - success = false; - return null; - } - // value - object value = ParseValue(json, ref index, ref success); - if (!success) - { - success = false; - return null; - } - table[name] = value; - } - } - return table; - } - - static JsonArray ParseArray(char[] json, ref int index, ref bool success) - { - JsonArray array = new JsonArray(); - - // [ - NextToken(json, ref index); - - bool done = false; - while (!done) - { - int token = LookAhead(json, index); - if (token == TOKEN_NONE) - { - success = false; - return null; - } - else if (token == TOKEN_COMMA) - NextToken(json, ref index); - else if (token == TOKEN_SQUARED_CLOSE) - { - NextToken(json, ref index); - break; - } - else - { - object value = ParseValue(json, ref index, ref success); - if (!success) - return null; - array.Add(value); - } - } - return array; - } - - static object ParseValue(char[] json, ref int index, ref bool success) - { - switch (LookAhead(json, index)) - { - case TOKEN_STRING: - return ParseString(json, ref index, ref success); - case TOKEN_NUMBER: - return ParseNumber(json, ref index, ref success); - case TOKEN_CURLY_OPEN: - return ParseObject(json, ref index, ref success); - case TOKEN_SQUARED_OPEN: - return ParseArray(json, ref index, ref success); - case TOKEN_TRUE: - NextToken(json, ref index); - return true; - case TOKEN_FALSE: - NextToken(json, ref index); - return false; - case TOKEN_NULL: - NextToken(json, ref index); - return null; - case TOKEN_NONE: - break; - } - success = false; - return null; - } - - static string ParseString(char[] json, ref int index, ref bool success) - { - StringBuilder s = new StringBuilder(BUILDER_CAPACITY); - char c; - - EatWhitespace(json, ref index); - - // " - c = json[index++]; - bool complete = false; - while (!complete) - { - if (index == json.Length) - break; - - c = json[index++]; - if (c == '"') - { - complete = true; - break; - } - else if (c == '\\') - { - if (index == json.Length) - break; - c = json[index++]; - if (c == '"') - s.Append('"'); - else if (c == '\\') - s.Append('\\'); - else if (c == '/') - s.Append('/'); - else if (c == 'b') - s.Append('\b'); - else if (c == 'f') - s.Append('\f'); - else if (c == 'n') - s.Append('\n'); - else if (c == 'r') - s.Append('\r'); - else if (c == 't') - s.Append('\t'); - else if (c == 'u') - { - int remainingLength = json.Length - index; - if (remainingLength >= 4) - { - // parse the 32 bit hex into an integer codepoint - uint codePoint; - if (!(success = UInt32.TryParse(new string(json, index, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codePoint))) - return ""; - - // convert the integer codepoint to a unicode char and add to string - if (0xD800 <= codePoint && codePoint <= 0xDBFF) // if high surrogate - { - index += 4; // skip 4 chars - remainingLength = json.Length - index; - if (remainingLength >= 6) - { - uint lowCodePoint; - if (new string(json, index, 2) == "\\u" && UInt32.TryParse(new string(json, index + 2, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out lowCodePoint)) - { - if (0xDC00 <= lowCodePoint && lowCodePoint <= 0xDFFF) // if low surrogate - { - s.Append((char)codePoint); - s.Append((char)lowCodePoint); - index += 6; // skip 6 chars - continue; - } - } - } - success = false; // invalid surrogate pair - return ""; - } - s.Append(ConvertFromUtf32((int)codePoint)); - // skip 4 chars - index += 4; - } - else - break; - } - } - else - s.Append(c); - } - if (!complete) - { - success = false; - return null; - } - return s.ToString(); - } - - private static string ConvertFromUtf32(int utf32) - { - // http://www.java2s.com/Open-Source/CSharp/2.6.4-mono-.net-core/System/System/Char.cs.htm - if (utf32 < 0 || utf32 > 0x10FFFF) - throw new ArgumentOutOfRangeException("utf32", "The argument must be from 0 to 0x10FFFF."); - if (0xD800 <= utf32 && utf32 <= 0xDFFF) - throw new ArgumentOutOfRangeException("utf32", "The argument must not be in surrogate pair range."); - if (utf32 < 0x10000) - return new string((char)utf32, 1); - utf32 -= 0x10000; - return new string(new char[] { (char)((utf32 >> 10) + 0xD800), (char)(utf32 % 0x0400 + 0xDC00) }); - } - - static object ParseNumber(char[] json, ref int index, ref bool success) - { - EatWhitespace(json, ref index); - int lastIndex = GetLastIndexOfNumber(json, index); - int charLength = (lastIndex - index) + 1; - object returnNumber; - string str = new string(json, index, charLength); - if (str.IndexOf(".", StringComparison.OrdinalIgnoreCase) != -1 || str.IndexOf("e", StringComparison.OrdinalIgnoreCase) != -1) - { - double number; - success = double.TryParse(new string(json, index, charLength), NumberStyles.Any, CultureInfo.InvariantCulture, out number); - returnNumber = number; - } - else - { - long number; - success = long.TryParse(new string(json, index, charLength), NumberStyles.Any, CultureInfo.InvariantCulture, out number); - returnNumber = number; - } - index = lastIndex + 1; - return returnNumber; - } - - static int GetLastIndexOfNumber(char[] json, int index) - { - int lastIndex; - for (lastIndex = index; lastIndex < json.Length; lastIndex++) - if ("0123456789+-.eE".IndexOf(json[lastIndex]) == -1) break; - return lastIndex - 1; - } - - static void EatWhitespace(char[] json, ref int index) - { - for (; index < json.Length; index++) - if (" \t\n\r\b\f".IndexOf(json[index]) == -1) break; - } - - static int LookAhead(char[] json, int index) - { - int saveIndex = index; - return NextToken(json, ref saveIndex); - } - - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - static int NextToken(char[] json, ref int index) - { - EatWhitespace(json, ref index); - if (index == json.Length) - return TOKEN_NONE; - char c = json[index]; - index++; - switch (c) - { - case '{': - return TOKEN_CURLY_OPEN; - case '}': - return TOKEN_CURLY_CLOSE; - case '[': - return TOKEN_SQUARED_OPEN; - case ']': - return TOKEN_SQUARED_CLOSE; - case ',': - return TOKEN_COMMA; - case '"': - return TOKEN_STRING; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '-': - return TOKEN_NUMBER; - case ':': - return TOKEN_COLON; - } - index--; - int remainingLength = json.Length - index; - // false - if (remainingLength >= 5) - { - if (json[index] == 'f' && json[index + 1] == 'a' && json[index + 2] == 'l' && json[index + 3] == 's' && json[index + 4] == 'e') - { - index += 5; - return TOKEN_FALSE; - } - } - // true - if (remainingLength >= 4) - { - if (json[index] == 't' && json[index + 1] == 'r' && json[index + 2] == 'u' && json[index + 3] == 'e') - { - index += 4; - return TOKEN_TRUE; - } - } - // null - if (remainingLength >= 4) - { - if (json[index] == 'n' && json[index + 1] == 'u' && json[index + 2] == 'l' && json[index + 3] == 'l') - { - index += 4; - return TOKEN_NULL; - } - } - return TOKEN_NONE; - } - - static bool SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, object value, StringBuilder builder) - { - bool success = true; - string stringValue = value as string; - if (stringValue != null) - success = SerializeString(stringValue, builder); - else - { - IDictionary dict = value as IDictionary; - if (dict != null) - { - success = SerializeObject(jsonSerializerStrategy, dict.Keys, dict.Values, builder); - } - else - { - IDictionary stringDictionary = value as IDictionary; - if (stringDictionary != null) - { - success = SerializeObject(jsonSerializerStrategy, stringDictionary.Keys, stringDictionary.Values, builder); - } - else - { - IEnumerable enumerableValue = value as IEnumerable; - if (enumerableValue != null) - success = SerializeArray(jsonSerializerStrategy, enumerableValue, builder); - else if (IsNumeric(value)) - success = SerializeNumber(value, builder); - else if (value is bool) - builder.Append((bool)value ? "true" : "false"); - else if (value == null) - builder.Append("null"); - else - { - object serializedObject; - success = jsonSerializerStrategy.TrySerializeNonPrimitiveObject(value, out serializedObject); - if (success) - SerializeValue(jsonSerializerStrategy, serializedObject, builder); - } - } - } - } - return success; - } - - static bool SerializeObject(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable keys, IEnumerable values, StringBuilder builder) - { - builder.Append("{"); - IEnumerator ke = keys.GetEnumerator(); - IEnumerator ve = values.GetEnumerator(); - bool first = true; - while (ke.MoveNext() && ve.MoveNext()) - { - object key = ke.Current; - object value = ve.Current; - if (!first) - builder.Append(","); - string stringKey = key as string; - if (stringKey != null) - SerializeString(stringKey, builder); - else - if (!SerializeValue(jsonSerializerStrategy, value, builder)) return false; - builder.Append(":"); - if (!SerializeValue(jsonSerializerStrategy, value, builder)) - return false; - first = false; - } - builder.Append("}"); - return true; - } - - static bool SerializeArray(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable anArray, StringBuilder builder) - { - builder.Append("["); - bool first = true; - foreach (object value in anArray) - { - if (!first) - builder.Append(","); - if (!SerializeValue(jsonSerializerStrategy, value, builder)) - return false; - first = false; - } - builder.Append("]"); - return true; - } - - static bool SerializeString(string aString, StringBuilder builder) - { - // Happy path if there's nothing to be escaped. IndexOfAny is highly optimized (and unmanaged) - if (aString.IndexOfAny(EscapeCharacters) == -1) - { - builder.Append('"'); - builder.Append(aString); - builder.Append('"'); - - return true; - } - - builder.Append('"'); - int safeCharacterCount = 0; - char[] charArray = aString.ToCharArray(); - - for (int i = 0; i < charArray.Length; i++) - { - char c = charArray[i]; - - // Non ascii characters are fine, buffer them up and send them to the builder - // in larger chunks if possible. The escape table is a 1:1 translation table - // with \0 [default(char)] denoting a safe character. - if (c >= EscapeTable.Length || EscapeTable[c] == default(char)) - { - safeCharacterCount++; - } - else - { - if (safeCharacterCount > 0) - { - builder.Append(charArray, i - safeCharacterCount, safeCharacterCount); - safeCharacterCount = 0; - } - - builder.Append('\\'); - builder.Append(EscapeTable[c]); - } - } - - if (safeCharacterCount > 0) - { - builder.Append(charArray, charArray.Length - safeCharacterCount, safeCharacterCount); - } - - builder.Append('"'); - return true; - } - - static bool SerializeNumber(object number, StringBuilder builder) - { - if (number is long) - builder.Append(((long)number).ToString(CultureInfo.InvariantCulture)); - else if (number is ulong) - builder.Append(((ulong)number).ToString(CultureInfo.InvariantCulture)); - else if (number is int) - builder.Append(((int)number).ToString(CultureInfo.InvariantCulture)); - else if (number is uint) - builder.Append(((uint)number).ToString(CultureInfo.InvariantCulture)); - else if (number is decimal) - builder.Append(((decimal)number).ToString(CultureInfo.InvariantCulture)); - else if (number is float) - builder.Append(((float)number).ToString(CultureInfo.InvariantCulture)); - else - builder.Append(Convert.ToDouble(number, CultureInfo.InvariantCulture).ToString("r", CultureInfo.InvariantCulture)); - return true; - } - - /// - /// Determines if a given object is numeric in any way - /// (can be integer, double, null, etc). - /// - static bool IsNumeric(object value) - { - if (value is sbyte) return true; - if (value is byte) return true; - if (value is short) return true; - if (value is ushort) return true; - if (value is int) return true; - if (value is uint) return true; - if (value is long) return true; - if (value is ulong) return true; - if (value is float) return true; - if (value is double) return true; - if (value is decimal) return true; - return false; - } - - private static IJsonSerializerStrategy _currentJsonSerializerStrategy; - public static IJsonSerializerStrategy CurrentJsonSerializerStrategy - { - get - { - return _currentJsonSerializerStrategy ?? - (_currentJsonSerializerStrategy = -#if SIMPLE_JSON_DATACONTRACT - DataContractJsonSerializerStrategy -#else - PocoJsonSerializerStrategy -#endif -); - } - set - { - _currentJsonSerializerStrategy = value; - } - } - - private static PocoJsonSerializerStrategy _pocoJsonSerializerStrategy; - [EditorBrowsable(EditorBrowsableState.Advanced)] - public static PocoJsonSerializerStrategy PocoJsonSerializerStrategy - { - get - { - return _pocoJsonSerializerStrategy ?? (_pocoJsonSerializerStrategy = new PocoJsonSerializerStrategy()); - } - } - -#if SIMPLE_JSON_DATACONTRACT - - private static DataContractJsonSerializerStrategy _dataContractJsonSerializerStrategy; - [System.ComponentModel.EditorBrowsable(EditorBrowsableState.Advanced)] - public static DataContractJsonSerializerStrategy DataContractJsonSerializerStrategy - { - get - { - return _dataContractJsonSerializerStrategy ?? (_dataContractJsonSerializerStrategy = new DataContractJsonSerializerStrategy()); - } - } - -#endif - } - - [GeneratedCode("simple-json", "1.0.0")] -#if SIMPLE_JSON_INTERNAL - internal -#else - public -#endif - interface IJsonSerializerStrategy - { - [SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")] - bool TrySerializeNonPrimitiveObject(object input, out object output); - object DeserializeObject(object value, Type type); - } - - [GeneratedCode("simple-json", "1.0.0")] -#if SIMPLE_JSON_INTERNAL - internal -#else - public -#endif - class PocoJsonSerializerStrategy : IJsonSerializerStrategy - { - internal IDictionary ConstructorCache; - internal IDictionary> GetCache; - internal IDictionary>> SetCache; - - internal static readonly Type[] EmptyTypes = new Type[0]; - internal static readonly Type[] ArrayConstructorParameterTypes = new Type[] { typeof(int) }; - - private static readonly string[] Iso8601Format = new string[] - { - @"yyyy-MM-dd\THH:mm:ss.FFFFFFF\Z", - @"yyyy-MM-dd\THH:mm:ss\Z", - @"yyyy-MM-dd\THH:mm:ssK" - }; - - public PocoJsonSerializerStrategy() - { - ConstructorCache = new ReflectionUtils.ThreadSafeDictionary(ContructorDelegateFactory); - GetCache = new ReflectionUtils.ThreadSafeDictionary>(GetterValueFactory); - SetCache = new ReflectionUtils.ThreadSafeDictionary>>(SetterValueFactory); - } - - protected virtual string MapClrMemberNameToJsonFieldName(string clrPropertyName) - { - return clrPropertyName; - } - - internal virtual ReflectionUtils.ConstructorDelegate ContructorDelegateFactory(Type key) - { - return ReflectionUtils.GetContructor(key, key.IsArray ? ArrayConstructorParameterTypes : EmptyTypes); - } - - internal virtual IDictionary GetterValueFactory(Type type) - { - IDictionary result = new Dictionary(); - foreach (PropertyInfo propertyInfo in ReflectionUtils.GetProperties(type)) - { - if (propertyInfo.CanRead) - { - MethodInfo getMethod = ReflectionUtils.GetGetterMethodInfo(propertyInfo); - if (getMethod.IsStatic || !getMethod.IsPublic) - continue; - result[MapClrMemberNameToJsonFieldName(propertyInfo.Name)] = ReflectionUtils.GetGetMethod(propertyInfo); - } - } - foreach (FieldInfo fieldInfo in ReflectionUtils.GetFields(type)) - { - if (fieldInfo.IsStatic || !fieldInfo.IsPublic) - continue; - result[MapClrMemberNameToJsonFieldName(fieldInfo.Name)] = ReflectionUtils.GetGetMethod(fieldInfo); - } - return result; - } - - internal virtual IDictionary> SetterValueFactory(Type type) - { - IDictionary> result = new Dictionary>(); - foreach (PropertyInfo propertyInfo in ReflectionUtils.GetProperties(type)) - { - if (propertyInfo.CanWrite) - { - MethodInfo setMethod = ReflectionUtils.GetSetterMethodInfo(propertyInfo); - if (setMethod.IsStatic || !setMethod.IsPublic) - continue; - result[MapClrMemberNameToJsonFieldName(propertyInfo.Name)] = new KeyValuePair(propertyInfo.PropertyType, ReflectionUtils.GetSetMethod(propertyInfo)); - } - } - foreach (FieldInfo fieldInfo in ReflectionUtils.GetFields(type)) - { - if (fieldInfo.IsInitOnly || fieldInfo.IsStatic || !fieldInfo.IsPublic) - continue; - result[MapClrMemberNameToJsonFieldName(fieldInfo.Name)] = new KeyValuePair(fieldInfo.FieldType, ReflectionUtils.GetSetMethod(fieldInfo)); - } - return result; - } - - public virtual bool TrySerializeNonPrimitiveObject(object input, out object output) - { - return TrySerializeKnownTypes(input, out output) || TrySerializeUnknownTypes(input, out output); - } - - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - public virtual object DeserializeObject(object value, Type type) - { - if (type == null) throw new ArgumentNullException("type"); - string str = value as string; - - if (type == typeof (Guid) && string.IsNullOrEmpty(str)) - return default(Guid); - - if (value == null) - return null; - - object obj = null; - - if (str != null) - { - if (str.Length != 0) // We know it can't be null now. - { - if (type == typeof(DateTime) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(DateTime))) - return DateTime.ParseExact(str, Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal); - if (type == typeof(DateTimeOffset) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(DateTimeOffset))) - return DateTimeOffset.ParseExact(str, Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal); - if (type == typeof(Guid) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid))) - return new Guid(str); - if (type == typeof(Uri)) - { - bool isValid = Uri.IsWellFormedUriString(str, UriKind.RelativeOrAbsolute); - - Uri result; - if (isValid && Uri.TryCreate(str, UriKind.RelativeOrAbsolute, out result)) - return result; - - return null; - } - - if (type == typeof(string)) - return str; - - return Convert.ChangeType(str, type, CultureInfo.InvariantCulture); - } - else - { - if (type == typeof(Guid)) - obj = default(Guid); - else if (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid)) - obj = null; - else - obj = str; - } - // Empty string case - if (!ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid)) - return str; - } - else if (value is bool) - return value; - - bool valueIsLong = value is long; - bool valueIsDouble = value is double; - if ((valueIsLong && type == typeof(long)) || (valueIsDouble && type == typeof(double))) - return value; - if ((valueIsDouble && type != typeof(double)) || (valueIsLong && type != typeof(long))) - { - obj = type == typeof(int) || type == typeof(long) || type == typeof(double) || type == typeof(float) || type == typeof(bool) || type == typeof(decimal) || type == typeof(byte) || type == typeof(short) - ? Convert.ChangeType(value, type, CultureInfo.InvariantCulture) - : value; - } - else - { - IDictionary objects = value as IDictionary; - if (objects != null) - { - IDictionary jsonObject = objects; - - if (ReflectionUtils.IsTypeDictionary(type)) - { - // if dictionary then - Type[] types = ReflectionUtils.GetGenericTypeArguments(type); - Type keyType = types[0]; - Type valueType = types[1]; - - Type genericType = typeof(Dictionary<,>).MakeGenericType(keyType, valueType); - - IDictionary dict = (IDictionary)ConstructorCache[genericType](); - - foreach (KeyValuePair kvp in jsonObject) - dict.Add(kvp.Key, DeserializeObject(kvp.Value, valueType)); - - obj = dict; - } - else - { - if (type == typeof(object)) - obj = value; - else - { - obj = ConstructorCache[type](); - foreach (KeyValuePair> setter in SetCache[type]) - { - object jsonValue; - if (jsonObject.TryGetValue(setter.Key, out jsonValue)) - { - jsonValue = DeserializeObject(jsonValue, setter.Value.Key); - setter.Value.Value(obj, jsonValue); - } - } - } - } - } - else - { - IList valueAsList = value as IList; - if (valueAsList != null) - { - IList jsonObject = valueAsList; - IList list = null; - - if (type.IsArray) - { - list = (IList)ConstructorCache[type](jsonObject.Count); - int i = 0; - foreach (object o in jsonObject) - list[i++] = DeserializeObject(o, type.GetElementType()); - } - else if (ReflectionUtils.IsTypeGenericeCollectionInterface(type) || ReflectionUtils.IsAssignableFrom(typeof(IList), type)) - { - Type innerType = ReflectionUtils.GetGenericListElementType(type); - list = (IList)(ConstructorCache[type] ?? ConstructorCache[typeof(List<>).MakeGenericType(innerType)])(jsonObject.Count); - foreach (object o in jsonObject) - list.Add(DeserializeObject(o, innerType)); - } - obj = list; - } - } - return obj; - } - if (ReflectionUtils.IsNullableType(type)) - return ReflectionUtils.ToNullableType(obj, type); - return obj; - } - - protected virtual object SerializeEnum(Enum p) - { - return Convert.ToDouble(p, CultureInfo.InvariantCulture); - } - - [SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")] - protected virtual bool TrySerializeKnownTypes(object input, out object output) - { - bool returnValue = true; - if (input is DateTime) - output = ((DateTime)input).ToUniversalTime().ToString(Iso8601Format[0], CultureInfo.InvariantCulture); - else if (input is DateTimeOffset) - output = ((DateTimeOffset)input).ToUniversalTime().ToString(Iso8601Format[0], CultureInfo.InvariantCulture); - else if (input is Guid) - output = ((Guid)input).ToString("D"); - else if (input is Uri) - output = input.ToString(); - else - { - Enum inputEnum = input as Enum; - if (inputEnum != null) - output = SerializeEnum(inputEnum); - else - { - returnValue = false; - output = null; - } - } - return returnValue; - } - [SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")] - protected virtual bool TrySerializeUnknownTypes(object input, out object output) - { - if (input == null) throw new ArgumentNullException("input"); - output = null; - Type type = input.GetType(); - if (type.FullName == null) - return false; - IDictionary obj = new JsonObject(); - IDictionary getters = GetCache[type]; - foreach (KeyValuePair getter in getters) - { - if (getter.Value != null) - obj.Add(MapClrMemberNameToJsonFieldName(getter.Key), getter.Value(input)); - } - output = obj; - return true; - } - } - -#if SIMPLE_JSON_DATACONTRACT - [GeneratedCode("simple-json", "1.0.0")] -#if SIMPLE_JSON_INTERNAL - internal -#else - public -#endif - class DataContractJsonSerializerStrategy : PocoJsonSerializerStrategy - { - public DataContractJsonSerializerStrategy() - { - GetCache = new ReflectionUtils.ThreadSafeDictionary>(GetterValueFactory); - SetCache = new ReflectionUtils.ThreadSafeDictionary>>(SetterValueFactory); - } - - internal override IDictionary GetterValueFactory(Type type) - { - bool hasDataContract = ReflectionUtils.GetAttribute(type, typeof(DataContractAttribute)) != null; - if (!hasDataContract) - return base.GetterValueFactory(type); - string jsonKey; - IDictionary result = new Dictionary(); - foreach (PropertyInfo propertyInfo in ReflectionUtils.GetProperties(type)) - { - if (propertyInfo.CanRead) - { - MethodInfo getMethod = ReflectionUtils.GetGetterMethodInfo(propertyInfo); - if (!getMethod.IsStatic && CanAdd(propertyInfo, out jsonKey)) - result[jsonKey] = ReflectionUtils.GetGetMethod(propertyInfo); - } - } - foreach (FieldInfo fieldInfo in ReflectionUtils.GetFields(type)) - { - if (!fieldInfo.IsStatic && CanAdd(fieldInfo, out jsonKey)) - result[jsonKey] = ReflectionUtils.GetGetMethod(fieldInfo); - } - return result; - } - - internal override IDictionary> SetterValueFactory(Type type) - { - bool hasDataContract = ReflectionUtils.GetAttribute(type, typeof(DataContractAttribute)) != null; - if (!hasDataContract) - return base.SetterValueFactory(type); - string jsonKey; - IDictionary> result = new Dictionary>(); - foreach (PropertyInfo propertyInfo in ReflectionUtils.GetProperties(type)) - { - if (propertyInfo.CanWrite) - { - MethodInfo setMethod = ReflectionUtils.GetSetterMethodInfo(propertyInfo); - if (!setMethod.IsStatic && CanAdd(propertyInfo, out jsonKey)) - result[jsonKey] = new KeyValuePair(propertyInfo.PropertyType, ReflectionUtils.GetSetMethod(propertyInfo)); - } - } - foreach (FieldInfo fieldInfo in ReflectionUtils.GetFields(type)) - { - if (!fieldInfo.IsInitOnly && !fieldInfo.IsStatic && CanAdd(fieldInfo, out jsonKey)) - result[jsonKey] = new KeyValuePair(fieldInfo.FieldType, ReflectionUtils.GetSetMethod(fieldInfo)); - } - // todo implement sorting for DATACONTRACT. - return result; - } - - private static bool CanAdd(MemberInfo info, out string jsonKey) - { - jsonKey = null; - if (ReflectionUtils.GetAttribute(info, typeof(IgnoreDataMemberAttribute)) != null) - return false; - DataMemberAttribute dataMemberAttribute = (DataMemberAttribute)ReflectionUtils.GetAttribute(info, typeof(DataMemberAttribute)); - if (dataMemberAttribute == null) - return false; - jsonKey = string.IsNullOrEmpty(dataMemberAttribute.Name) ? info.Name : dataMemberAttribute.Name; - return true; - } - } - -#endif - - namespace Reflection - { - // This class is meant to be copied into other libraries. So we want to exclude it from Code Analysis rules - // that might be in place in the target project. - [GeneratedCode("reflection-utils", "1.0.0")] -#if SIMPLE_JSON_REFLECTION_UTILS_PUBLIC - public -#else - internal -#endif - class ReflectionUtils - { - private static readonly object[] EmptyObjects = new object[] { }; - - public delegate object GetDelegate(object source); - public delegate void SetDelegate(object source, object value); - public delegate object ConstructorDelegate(params object[] args); - - public delegate TValue ThreadSafeDictionaryValueFactory(TKey key); - -#if SIMPLE_JSON_TYPEINFO - public static TypeInfo GetTypeInfo(Type type) - { - return type.GetTypeInfo(); - } -#else - public static Type GetTypeInfo(Type type) - { - return type; - } -#endif - - public static Attribute GetAttribute(MemberInfo info, Type type) - { -#if SIMPLE_JSON_TYPEINFO - if (info == null || type == null || !info.IsDefined(type)) - return null; - return info.GetCustomAttribute(type); -#else - if (info == null || type == null || !Attribute.IsDefined(info, type)) - return null; - return Attribute.GetCustomAttribute(info, type); -#endif - } - - public static Type GetGenericListElementType(Type type) - { - IEnumerable interfaces; -#if SIMPLE_JSON_TYPEINFO - interfaces = type.GetTypeInfo().ImplementedInterfaces; -#else - interfaces = type.GetInterfaces(); -#endif - foreach (Type implementedInterface in interfaces) - { - if (IsTypeGeneric(implementedInterface) && - implementedInterface.GetGenericTypeDefinition() == typeof (IList<>)) - { - return GetGenericTypeArguments(implementedInterface)[0]; - } - } - return GetGenericTypeArguments(type)[0]; - } - - public static Attribute GetAttribute(Type objectType, Type attributeType) - { - -#if SIMPLE_JSON_TYPEINFO - if (objectType == null || attributeType == null || !objectType.GetTypeInfo().IsDefined(attributeType)) - return null; - return objectType.GetTypeInfo().GetCustomAttribute(attributeType); -#else - if (objectType == null || attributeType == null || !Attribute.IsDefined(objectType, attributeType)) - return null; - return Attribute.GetCustomAttribute(objectType, attributeType); -#endif - } - - public static Type[] GetGenericTypeArguments(Type type) - { -#if SIMPLE_JSON_TYPEINFO - return type.GetTypeInfo().GenericTypeArguments; -#else - return type.GetGenericArguments(); -#endif - } - - public static bool IsTypeGeneric(Type type) - { - return GetTypeInfo(type).IsGenericType; - } - - public static bool IsTypeGenericeCollectionInterface(Type type) - { - if (!IsTypeGeneric(type)) - return false; - - Type genericDefinition = type.GetGenericTypeDefinition(); - - return (genericDefinition == typeof(IList<>) - || genericDefinition == typeof(ICollection<>) - || genericDefinition == typeof(IEnumerable<>) -#if SIMPLE_JSON_READONLY_COLLECTIONS - || genericDefinition == typeof(IReadOnlyCollection<>) - || genericDefinition == typeof(IReadOnlyList<>) -#endif - ); - } - - public static bool IsAssignableFrom(Type type1, Type type2) - { - return GetTypeInfo(type1).IsAssignableFrom(GetTypeInfo(type2)); - } - - public static bool IsTypeDictionary(Type type) - { -#if SIMPLE_JSON_TYPEINFO - if (typeof(IDictionary<,>).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) - return true; -#else - if (typeof(System.Collections.IDictionary).IsAssignableFrom(type)) - return true; -#endif - if (!GetTypeInfo(type).IsGenericType) - return false; - - Type genericDefinition = type.GetGenericTypeDefinition(); - return genericDefinition == typeof(IDictionary<,>); - } - - public static bool IsNullableType(Type type) - { - return GetTypeInfo(type).IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>); - } - - public static object ToNullableType(object obj, Type nullableType) - { - return obj == null ? null : Convert.ChangeType(obj, Nullable.GetUnderlyingType(nullableType), CultureInfo.InvariantCulture); - } - - public static bool IsValueType(Type type) - { - return GetTypeInfo(type).IsValueType; - } - - public static IEnumerable GetConstructors(Type type) - { -#if SIMPLE_JSON_TYPEINFO - return type.GetTypeInfo().DeclaredConstructors; -#else - return type.GetConstructors(); -#endif - } - - public static ConstructorInfo GetConstructorInfo(Type type, params Type[] argsType) - { - IEnumerable constructorInfos = GetConstructors(type); - int i; - bool matches; - foreach (ConstructorInfo constructorInfo in constructorInfos) - { - ParameterInfo[] parameters = constructorInfo.GetParameters(); - if (argsType.Length != parameters.Length) - continue; - - i = 0; - matches = true; - foreach (ParameterInfo parameterInfo in constructorInfo.GetParameters()) - { - if (parameterInfo.ParameterType != argsType[i]) - { - matches = false; - break; - } - } - - if (matches) - return constructorInfo; - } - - return null; - } - - public static IEnumerable GetProperties(Type type) - { -#if SIMPLE_JSON_TYPEINFO - return type.GetRuntimeProperties(); -#else - return type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); -#endif - } - - public static IEnumerable GetFields(Type type) - { -#if SIMPLE_JSON_TYPEINFO - return type.GetRuntimeFields(); -#else - return type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); -#endif - } - - public static MethodInfo GetGetterMethodInfo(PropertyInfo propertyInfo) - { -#if SIMPLE_JSON_TYPEINFO - return propertyInfo.GetMethod; -#else - return propertyInfo.GetGetMethod(true); -#endif - } - - public static MethodInfo GetSetterMethodInfo(PropertyInfo propertyInfo) - { -#if SIMPLE_JSON_TYPEINFO - return propertyInfo.SetMethod; -#else - return propertyInfo.GetSetMethod(true); -#endif - } - - public static ConstructorDelegate GetContructor(ConstructorInfo constructorInfo) - { -#if SIMPLE_JSON_NO_LINQ_EXPRESSION - return GetConstructorByReflection(constructorInfo); -#else - return GetConstructorByExpression(constructorInfo); -#endif - } - - public static ConstructorDelegate GetContructor(Type type, params Type[] argsType) - { -#if SIMPLE_JSON_NO_LINQ_EXPRESSION - return GetConstructorByReflection(type, argsType); -#else - return GetConstructorByExpression(type, argsType); -#endif - } - - public static ConstructorDelegate GetConstructorByReflection(ConstructorInfo constructorInfo) - { - return delegate(object[] args) { return constructorInfo.Invoke(args); }; - } - - public static ConstructorDelegate GetConstructorByReflection(Type type, params Type[] argsType) - { - ConstructorInfo constructorInfo = GetConstructorInfo(type, argsType); - return constructorInfo == null ? null : GetConstructorByReflection(constructorInfo); - } - -#if !SIMPLE_JSON_NO_LINQ_EXPRESSION - - public static ConstructorDelegate GetConstructorByExpression(ConstructorInfo constructorInfo) - { - ParameterInfo[] paramsInfo = constructorInfo.GetParameters(); - ParameterExpression param = Expression.Parameter(typeof(object[]), "args"); - Expression[] argsExp = new Expression[paramsInfo.Length]; - for (int i = 0; i < paramsInfo.Length; i++) - { - Expression index = Expression.Constant(i); - Type paramType = paramsInfo[i].ParameterType; - Expression paramAccessorExp = Expression.ArrayIndex(param, index); - Expression paramCastExp = Expression.Convert(paramAccessorExp, paramType); - argsExp[i] = paramCastExp; - } - NewExpression newExp = Expression.New(constructorInfo, argsExp); - Expression> lambda = Expression.Lambda>(newExp, param); - Func compiledLambda = lambda.Compile(); - return delegate(object[] args) { return compiledLambda(args); }; - } - - public static ConstructorDelegate GetConstructorByExpression(Type type, params Type[] argsType) - { - ConstructorInfo constructorInfo = GetConstructorInfo(type, argsType); - return constructorInfo == null ? null : GetConstructorByExpression(constructorInfo); - } - -#endif - - public static GetDelegate GetGetMethod(PropertyInfo propertyInfo) - { -#if SIMPLE_JSON_NO_LINQ_EXPRESSION - return GetGetMethodByReflection(propertyInfo); -#else - return GetGetMethodByExpression(propertyInfo); -#endif - } - - public static GetDelegate GetGetMethod(FieldInfo fieldInfo) - { -#if SIMPLE_JSON_NO_LINQ_EXPRESSION - return GetGetMethodByReflection(fieldInfo); -#else - return GetGetMethodByExpression(fieldInfo); -#endif - } - - public static GetDelegate GetGetMethodByReflection(PropertyInfo propertyInfo) - { - MethodInfo methodInfo = GetGetterMethodInfo(propertyInfo); - return delegate(object source) { return methodInfo.Invoke(source, EmptyObjects); }; - } - - public static GetDelegate GetGetMethodByReflection(FieldInfo fieldInfo) - { - return delegate(object source) { return fieldInfo.GetValue(source); }; - } - -#if !SIMPLE_JSON_NO_LINQ_EXPRESSION - - public static GetDelegate GetGetMethodByExpression(PropertyInfo propertyInfo) - { - MethodInfo getMethodInfo = GetGetterMethodInfo(propertyInfo); - ParameterExpression instance = Expression.Parameter(typeof(object), "instance"); - UnaryExpression instanceCast = (!IsValueType(propertyInfo.DeclaringType)) ? Expression.TypeAs(instance, propertyInfo.DeclaringType) : Expression.Convert(instance, propertyInfo.DeclaringType); - Func compiled = Expression.Lambda>(Expression.TypeAs(Expression.Call(instanceCast, getMethodInfo), typeof(object)), instance).Compile(); - return delegate(object source) { return compiled(source); }; - } - - public static GetDelegate GetGetMethodByExpression(FieldInfo fieldInfo) - { - ParameterExpression instance = Expression.Parameter(typeof(object), "instance"); - MemberExpression member = Expression.Field(Expression.Convert(instance, fieldInfo.DeclaringType), fieldInfo); - GetDelegate compiled = Expression.Lambda(Expression.Convert(member, typeof(object)), instance).Compile(); - return delegate(object source) { return compiled(source); }; - } - -#endif - - public static SetDelegate GetSetMethod(PropertyInfo propertyInfo) - { -#if SIMPLE_JSON_NO_LINQ_EXPRESSION - return GetSetMethodByReflection(propertyInfo); -#else - return GetSetMethodByExpression(propertyInfo); -#endif - } - - public static SetDelegate GetSetMethod(FieldInfo fieldInfo) - { -#if SIMPLE_JSON_NO_LINQ_EXPRESSION - return GetSetMethodByReflection(fieldInfo); -#else - return GetSetMethodByExpression(fieldInfo); -#endif - } - - public static SetDelegate GetSetMethodByReflection(PropertyInfo propertyInfo) - { - MethodInfo methodInfo = GetSetterMethodInfo(propertyInfo); - return delegate(object source, object value) { methodInfo.Invoke(source, new object[] { value }); }; - } - - public static SetDelegate GetSetMethodByReflection(FieldInfo fieldInfo) - { - return delegate(object source, object value) { fieldInfo.SetValue(source, value); }; - } - -#if !SIMPLE_JSON_NO_LINQ_EXPRESSION - - public static SetDelegate GetSetMethodByExpression(PropertyInfo propertyInfo) - { - MethodInfo setMethodInfo = GetSetterMethodInfo(propertyInfo); - ParameterExpression instance = Expression.Parameter(typeof(object), "instance"); - ParameterExpression value = Expression.Parameter(typeof(object), "value"); - UnaryExpression instanceCast = (!IsValueType(propertyInfo.DeclaringType)) ? Expression.TypeAs(instance, propertyInfo.DeclaringType) : Expression.Convert(instance, propertyInfo.DeclaringType); - UnaryExpression valueCast = (!IsValueType(propertyInfo.PropertyType)) ? Expression.TypeAs(value, propertyInfo.PropertyType) : Expression.Convert(value, propertyInfo.PropertyType); - Action compiled = Expression.Lambda>(Expression.Call(instanceCast, setMethodInfo, valueCast), new ParameterExpression[] { instance, value }).Compile(); - return delegate(object source, object val) { compiled(source, val); }; - } - - public static SetDelegate GetSetMethodByExpression(FieldInfo fieldInfo) - { - ParameterExpression instance = Expression.Parameter(typeof(object), "instance"); - ParameterExpression value = Expression.Parameter(typeof(object), "value"); - Action compiled = Expression.Lambda>( - Assign(Expression.Field(Expression.Convert(instance, fieldInfo.DeclaringType), fieldInfo), Expression.Convert(value, fieldInfo.FieldType)), instance, value).Compile(); - return delegate(object source, object val) { compiled(source, val); }; - } - - public static BinaryExpression Assign(Expression left, Expression right) - { -#if SIMPLE_JSON_TYPEINFO - return Expression.Assign(left, right); -#else - MethodInfo assign = typeof(Assigner<>).MakeGenericType(left.Type).GetMethod("Assign"); - BinaryExpression assignExpr = Expression.Add(left, right, assign); - return assignExpr; -#endif - } - - private static class Assigner - { - public static T Assign(ref T left, T right) - { - return (left = right); - } - } - -#endif - - public sealed class ThreadSafeDictionary : IDictionary - { - private readonly object _lock = new object(); - private readonly ThreadSafeDictionaryValueFactory _valueFactory; - private Dictionary _dictionary; - - public ThreadSafeDictionary(ThreadSafeDictionaryValueFactory valueFactory) - { - _valueFactory = valueFactory; - } - - private TValue Get(TKey key) - { - if (_dictionary == null) - return AddValue(key); - TValue value; - if (!_dictionary.TryGetValue(key, out value)) - return AddValue(key); - return value; - } - - private TValue AddValue(TKey key) - { - TValue value = _valueFactory(key); - lock (_lock) - { - if (_dictionary == null) - { - _dictionary = new Dictionary(); - _dictionary[key] = value; - } - else - { - TValue val; - if (_dictionary.TryGetValue(key, out val)) - return val; - Dictionary dict = new Dictionary(_dictionary); - dict[key] = value; - _dictionary = dict; - } - } - return value; - } - - public void Add(TKey key, TValue value) - { - throw new NotImplementedException(); - } - - public bool ContainsKey(TKey key) - { - return _dictionary.ContainsKey(key); - } - - public ICollection Keys - { - get { return _dictionary.Keys; } - } - - public bool Remove(TKey key) - { - throw new NotImplementedException(); - } - - public bool TryGetValue(TKey key, out TValue value) - { - value = this[key]; - return true; - } - - public ICollection Values - { - get { return _dictionary.Values; } - } - - public TValue this[TKey key] - { - get { return Get(key); } - set { throw new NotImplementedException(); } - } - - public void Add(KeyValuePair item) - { - throw new NotImplementedException(); - } - - public void Clear() - { - throw new NotImplementedException(); - } - - public bool Contains(KeyValuePair item) - { - throw new NotImplementedException(); - } - - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - throw new NotImplementedException(); - } - - public int Count - { - get { return _dictionary.Count; } - } - - public bool IsReadOnly - { - get { throw new NotImplementedException(); } - } - - public bool Remove(KeyValuePair item) - { - throw new NotImplementedException(); - } - - public IEnumerator> GetEnumerator() - { - return _dictionary.GetEnumerator(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return _dictionary.GetEnumerator(); - } - } - - } - } -} -// ReSharper restore LoopCanBeConvertedToQuery -// ReSharper restore RedundantExplicitArrayCreation -// ReSharper restore SuggestUseVarKeywordEvident diff --git a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/content/SimpleJson.cs.pp.meta b/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/content/SimpleJson.cs.pp.meta deleted file mode 100644 index 2f4ac709c..000000000 --- a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/content/SimpleJson.cs.pp.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 523f8a50e06bb3b49ae4b47f7881a5ef -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/GQ_TongXin/Assets/Scenes/SampleSceneG.unity b/GQ_TongXin/Assets/Scenes/SampleSceneG.unity index 5aa8a6ffe..aa38cf1f3 100644 --- a/GQ_TongXin/Assets/Scenes/SampleSceneG.unity +++ b/GQ_TongXin/Assets/Scenes/SampleSceneG.unity @@ -195017,11 +195017,11 @@ MonoBehaviour: xlz_sc: xllx_sc: arguments: - token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2OTQ2OTcxMjEsInVzZXJuYW1lIjoiMTgzMTIzNDU2NzgifQ.DU-CMUu87u2EZLScKoV5NIkoxfG013lNs9nrIh-HCZI - heatThresholdValueMax: 38 - heatThresholdValueMin: 26 - humidityThresholdValueMax: 90 - humidityThresholdValueMin: 70 + token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2OTQ4NTAyODksInVzZXJuYW1lIjoiMTgzMTIzNDU2NzgifQ.j0JKoTpsQ3upAbreBLVTMZEsYMfN5WtEI810C7TCjLg + heatThresholdValueMax: + heatThresholdValueMin: + humidityThresholdValueMax: + humidityThresholdValueMin: isLoading: 0 Cabinet_quYu: - {fileID: 0} @@ -213116,8 +213116,8 @@ MonoBehaviour: m_EditorClassIdentifier: is_open: 0 is_rotating: 0 - close_angle: {x: 0, y: 0, z: 0} - open_angle: {x: 0, y: 0, z: -90} + close_angle: {x: 0, y: 0, z: -180} + open_angle: {x: 0, y: 0, z: 90} another_door: {fileID: 0} --- !u!1 &1983618591 GameObject: diff --git a/GQ_TongXin/Assets/Scenes/test.unity b/GQ_TongXin/Assets/Scenes/test.unity new file mode 100644 index 000000000..8859b7834 --- /dev/null +++ b/GQ_TongXin/Assets/Scenes/test.unity @@ -0,0 +1,652 @@ +%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: 0} + m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, 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: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + 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: 2 + 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 + accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &1134598145 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1134598148} + - component: {fileID: 1134598147} + - component: {fileID: 1134598146} + 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 &1134598146 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1134598145} + m_Enabled: 1 +--- !u!20 &1134598147 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1134598145} + 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_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + 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 &1134598148 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1134598145} + 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: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1470320783 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1470320785} + - component: {fileID: 1470320784} + 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 &1470320784 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1470320783} + 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: 4 + 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 &1470320785 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1470320783} + 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: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &1789179022 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1789179026} + - component: {fileID: 1789179025} + - component: {fileID: 1789179024} + - component: {fileID: 1789179023} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!65 &1789179023 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1789179022} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &1789179024 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1789179022} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1789179025 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1789179022} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1789179026 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1789179022} + 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_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &2015993432 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2015993436} + - component: {fileID: 2015993435} + - component: {fileID: 2015993434} + - component: {fileID: 2015993433} + m_Layer: 0 + m_Name: GameManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &2015993433 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2015993432} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 625b10f037a004044958c13bd4a03e4e, type: 3} + m_Name: + m_EditorClassIdentifier: + Jk_URL: + sb_cx: + sb_xz: + sb_sc: + sb_bj: + dk_cx: + dk_xz: + dk_sc: + dk_bj: + hj_cx: + gj_cx: + gzp_cx: + jxp_cx: + xlz_cx: + xlz_xz: + xlz_sc: + xllx_sc: + arguments: + token: + heatThresholdValueMax: + heatThresholdValueMin: + humidityThresholdValueMax: + humidityThresholdValueMin: + isLoading: 0 + Cabinet_quYu: + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + nowDeviceID: + nowDevice: {fileID: 0} + lastDeviceID: + lastDevice: {fileID: 0} + nowCabine: {fileID: 0} + root_AllDevice: + code: + message: + data: [] + serverTime: + Cabinets_go: + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + Cabinets: [] + Racks_go: [] + Racks: [] + MachineSlots_go: [] + MachineSlots: [] + TmsCards_go: [] + TmsCards: [] + root_AllPort: + code: + message: + totalRows: + pageSize: 0 + pageNum: 0 + data: [] + TmsPorts_go: [] + TmsPorts: [] + nowLayerMask: 6 + root_AllENV: + code: + message: + data: [] + serverTime: + ENVs: [] + root_AllAlarm: + code: + message: + data: [] + serverTime: + tmsAlarms: [] + search_box: {fileID: 0} + pop_ups: + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + magnifyState: 0 + isgonging: 0 + editorMenu: {fileID: 0} + stagingPanel: {fileID: 0} + objectToShow: {fileID: 0} + objectToShow_add: {fileID: 0} + roomDoors: [] +--- !u!114 &2015993434 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2015993432} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f9c07789c54a1784784bce5a42fdbe09, type: 3} + m_Name: + m_EditorClassIdentifier: + current_videoNumber: + isVideoPlay: 0 + isWorkPlay: 0 + gameManager: {fileID: 2015993433} + bt: {fileID: 0} +--- !u!114 &2015993435 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2015993432} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 63d5830c029ba6d4eb84a0706081bc10, type: 3} + m_Name: + m_EditorClassIdentifier: + gameObjects: [] + Uwei: + - {fileID: 0} + prefab: {fileID: 0} + port: + deviceId: + conDevice: + conPort: + UI_follow: {fileID: 0} + redactDevice: {fileID: 0} + f_old: {fileID: 0} + f_new: {fileID: 0} + font_old: {fileID: 12800000, guid: 2a077a6e99f4a0e48a49176c2bc40182, type: 3} + font_new: {fileID: 12800000, guid: f945cd23a57e99b46ac65684d5bb3be8, type: 3} + originalObject: {fileID: 0} +--- !u!4 &2015993436 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2015993432} + 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_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/SimpleJson.0.38.0.nupkg.meta b/GQ_TongXin/Assets/Scenes/test.unity.meta similarity index 74% rename from GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/SimpleJson.0.38.0.nupkg.meta rename to GQ_TongXin/Assets/Scenes/test.unity.meta index 14953ef53..cf26bc356 100644 --- a/GQ_TongXin/Assets/Packages/SimpleJson.0.38.0/SimpleJson.0.38.0.nupkg.meta +++ b/GQ_TongXin/Assets/Scenes/test.unity.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 778587e0d32548844ba4b2b8d6aae431 +guid: d81bff3c4034dac4ab07829df3a17ed9 DefaultImporter: externalObjects: {} userData: diff --git a/GQ_TongXin/Assets/Scripts/Camera/CameraMgr.cs b/GQ_TongXin/Assets/Scripts/Camera/CameraMgr.cs index 81636397b..66d1f5aa3 100644 --- a/GQ_TongXin/Assets/Scripts/Camera/CameraMgr.cs +++ b/GQ_TongXin/Assets/Scripts/Camera/CameraMgr.cs @@ -44,9 +44,9 @@ public class CameraMgr : MonoSingleton camera_Rt.SetTarget(viewTarget, _distance); } - public void GotoView(Transform viewTarget, float _distance,Quaternion rotation) + public void GotoView(Transform viewTarget, float _distance, Quaternion rotation, float TargetPos_dis = -1) { - camera_Rt.SetTarget(viewTarget, _distance,rotation); + camera_Rt.SetTarget(viewTarget, _distance, rotation, TargetPos_dis); } [ContextMenu("test")] diff --git a/GQ_TongXin/Assets/Scripts/Camera/CameraRT.cs b/GQ_TongXin/Assets/Scripts/Camera/CameraRT.cs index 42ccb4d60..bc3c4c60c 100644 --- a/GQ_TongXin/Assets/Scripts/Camera/CameraRT.cs +++ b/GQ_TongXin/Assets/Scripts/Camera/CameraRT.cs @@ -362,9 +362,11 @@ public class CameraRT : MonoBehaviour x = _target.eulerAngles.y; } - public void SetTarget(Transform _target, float _distance, Quaternion rotation) + public void SetTarget(Transform _target, float _distance, Quaternion rotation, float TargetPos_dis = -1) { target.position = _target.position; + if (TargetPos_dis == 0) + target.position += (Vector3.up * 2); distance = _distance; cameraTransform.rotation = rotation; diff --git a/GQ_TongXin/Assets/packages.config b/GQ_TongXin/Assets/packages.config index 22830b166..2588dd404 100644 --- a/GQ_TongXin/Assets/packages.config +++ b/GQ_TongXin/Assets/packages.config @@ -1,6 +1,4 @@  - - \ No newline at end of file diff --git a/GQ_TongXin/Assets/script/GameManager.cs b/GQ_TongXin/Assets/script/GameManager.cs index afd7060a4..4b0622896 100644 --- a/GQ_TongXin/Assets/script/GameManager.cs +++ b/GQ_TongXin/Assets/script/GameManager.cs @@ -866,7 +866,7 @@ public class GameManager : MonoBehaviour { if (string.IsNullOrEmpty(jsonResult)) { - return; + callback.Invoke(null); } try { @@ -913,7 +913,7 @@ public class GameManager : MonoBehaviour { if (string.IsNullOrEmpty(jsonResult1)) { - return; + callback.Invoke(null); } try { @@ -955,7 +955,7 @@ public class GameManager : MonoBehaviour { if (string.IsNullOrEmpty(jsonResult2)) { - return; + callback.Invoke(null); } try { @@ -1003,7 +1003,7 @@ public class GameManager : MonoBehaviour { if (string.IsNullOrEmpty(jsonResult3)) { - return; + callback.Invoke(null); } try { @@ -1559,7 +1559,7 @@ public class GameManager : MonoBehaviour for (int i = 0; i < roomDoors.Count; i++) { - if(!roomDoors[i].is_open) + if (!roomDoors[i].is_open) roomDoors[i].DoorOpen(true); } } @@ -1854,7 +1854,15 @@ public class GameManager : MonoBehaviour if (ct != null) { Jk_URL = new webURL(ct); - StartCoroutine(Initialize()); + StartCoroutine(Initialize((x) => + { + if (string.IsNullOrEmpty(x)) + { + SecondConfirmPanel.DeleteConform(null, "进入场景失败"); + Debug.Log("接口获取数据失败(手动-初始化失败)"); + LoadScene(); + } + })); } else { @@ -1926,29 +1934,42 @@ public class GameManager : MonoBehaviour string filePath = Application.streamingAssetsPath + "/dz.txt"; UnityWebRequest www = UnityWebRequest.Get(filePath); + DownloadHandlerBuffer dH = new DownloadHandlerBuffer(); + www.downloadHandler = dH; + //www.timeout = 15; yield return www.SendWebRequest(); if (www.result == UnityWebRequest.Result.Success) { + // 等待一帧 + yield return null; + + // 检查请求是否已完成 + while (!www.isDone) + { + yield return null; + } string fileContent = www.downloadHandler.text; - Debug.Log("获取穿透成功" /*+ fileContent + "Token:" + Inst.arguments.token*/); if (string.IsNullOrEmpty(fileContent)) { callback(null); - yield break; } - callback(fileContent); + else + { + Debug.Log("获取穿透成功"); + callback(fileContent); + } } else { + Debug.LogError("获取穿透失败: " + www.error); callback(null); - Debug.LogError("Error: " + www.error); } } // 获取接口信息 - public IEnumerator Initialize(Action callback = null) + public IEnumerator Initialize(Action callback) { yield return null; //Debug.Log("@@10"); @@ -1995,7 +2016,10 @@ public class GameManager : MonoBehaviour })); } else + { callback.Invoke(null); + //callback?.Invoke("1"); + } })); //Debug.Log("@@13");//??? @@ -2034,7 +2058,7 @@ public class GameManager : MonoBehaviour Debug.Log("@@9"); //三维场景加载时显示地图 Application.ExternalCall("OnSceneLoaded", "三维加载完成"); - Debug.Log("@@10"); + Debug.Log("@@10 三维加载完成"); isLoading = true; if (CabinetUIManager.Instance.current_menu == Menu.M_数字孪生_线缆连接_配置) diff --git a/GQ_TongXin/Assets/script/JSON/CombineJSON.cs b/GQ_TongXin/Assets/script/JSON/CombineJSON.cs index a817d752f..93da444cc 100644 --- a/GQ_TongXin/Assets/script/JSON/CombineJSON.cs +++ b/GQ_TongXin/Assets/script/JSON/CombineJSON.cs @@ -4,6 +4,7 @@ using System.Collections; using System.Collections.Generic; using System.Net.Http; using System.Net.Http.Headers; +using System.Text; using System.Threading.Tasks; using UnityEngine; using UnityEngine.Networking; @@ -150,33 +151,49 @@ public static class CombineJSON /// public static IEnumerator GetJson_POST(string apiUrl, string token, Action callback) { - using (UnityWebRequest request = UnityWebRequest.Post(apiUrl, "")) + //using (UnityWebRequest request = UnityWebRequest.Post(apiUrl, "")) + UnityWebRequest request = new UnityWebRequest(apiUrl, "POST"); { request.SetRequestHeader("X-Token", token); - + request.SetRequestHeader("Content-Type", "application/json"); + DownloadHandlerBuffer dH = new DownloadHandlerBuffer(); + request.downloadHandler = dH; + //request.timeout = 15; yield return request.SendWebRequest(); if (!request.isNetworkError && !request.isHttpError) { - if (request.downloadHandler != null) + // 等待一帧 + yield return null; + + // 检查请求是否已完成 + while (!request.isDone) + { + yield return null; + } + //if (request.downloadHandler.text != null) + if (!string.IsNullOrEmpty(request.downloadHandler.text)) + //byte[] responseData = request.downloadHandler.data; + //if (responseData != null && responseData.Length > 0) { string responseText = request.downloadHandler.text; //Debug.Log(responseText); + //string responseText = Encoding.UTF8.GetString(responseData); callback(responseText); } else { - Debug.Log(apiUrl + " request.downloadHandler为null"); + Debug.Log(apiUrl + " request.downloadHandler.text为null"); callback.Invoke(null); } } else { - Debug.Log(apiUrl + " 请求POST接口失败: " + request.error); + Debug.Log(apiUrl + " 请求POST接口失败: " + request.error + "\nURL: " + apiUrl + "\nrequest.downloadHandler:" + request.downloadHandler.text); callback.Invoke(null); } } - } + } /// @@ -189,32 +206,47 @@ public static class CombineJSON /// public static IEnumerator UpdateJson_POST(string apiUrl, string token, string newData, Action callback) { - using (UnityWebRequest request = new UnityWebRequest(apiUrl, "POST")) + //using (UnityWebRequest request = new UnityWebRequest(apiUrl, "POST")) + UnityWebRequest request = new UnityWebRequest(apiUrl, "POST"); { request.SetRequestHeader("X-Token", token); request.SetRequestHeader("Content-Type", "application/json"); byte[] bodyRaw = System.Text.Encoding.UTF8.GetBytes(newData); + DownloadHandlerBuffer dH = new DownloadHandlerBuffer(); request.uploadHandler = new UploadHandlerRaw(bodyRaw); request.downloadHandler = new DownloadHandlerBuffer(); - + request.downloadHandler = dH; + //request.timeout = 15; yield return request.SendWebRequest(); if (request.result == UnityWebRequest.Result.Success) { - if (request.downloadHandler != null) + // 等待一帧 + yield return null; + + // 检查请求是否已完成 + while (!request.isDone) + { + yield return null; + } + //if (request.downloadHandler.text != null) + if (!string.IsNullOrEmpty(request.downloadHandler.text)) + //byte[] responseData = request.downloadHandler.data; + //if (responseData != null && responseData.Length > 0) { string responseText = request.downloadHandler.text; + //string responseText = Encoding.UTF8.GetString(responseData); callback?.Invoke(responseText); } else { - Debug.Log(apiUrl + " request.downloadHandler为空"); + Debug.Log(apiUrl + " request.downloadHandler.text为空"); callback.Invoke(null); } } else { - Debug.Log(apiUrl + " 请求POST接口失败: " + request.error); + Debug.Log(apiUrl + " 请求POST接口失败: " + request.error + "\nURL: " + apiUrl); callback.Invoke(null); } } @@ -233,7 +265,7 @@ public static class CombineJSON if (!request.isNetworkError && !request.isHttpError) { - if (request.downloadHandler != null) + if (request.downloadHandler.text != null) { string jsonResult = request.downloadHandler.text; //Debug.Log(jsonResult); @@ -241,7 +273,7 @@ public static class CombineJSON } else { - Debug.Log("request.downloadHandler为null"); + Debug.Log("request.downloadHandler.text为null"); callback.Invoke(null); } } @@ -255,29 +287,44 @@ public static class CombineJSON public static IEnumerator GetJson_GET(string apiUrl, string token, Action callback) { - using (UnityWebRequest request = UnityWebRequest.Get(apiUrl)) + //using (UnityWebRequest request = UnityWebRequest.Get(apiUrl)) + UnityWebRequest request = UnityWebRequest.Get(apiUrl); { request.SetRequestHeader("X-Token", token); - + DownloadHandlerBuffer dH = new DownloadHandlerBuffer(); + request.downloadHandler = dH; + //request.timeout = 15; yield return request.SendWebRequest(); if (request.result == UnityWebRequest.Result.Success) { - string responseBody = request.downloadHandler.text; - if (request.downloadHandler != null) + // 等待一帧 + yield return null; + + // 检查请求是否已完成 + while (!request.isDone) + { + yield return null; + } + //string responseBody = request.downloadHandler.text; + //if (request.downloadHandler.text != null) + if (!string.IsNullOrEmpty(request.downloadHandler.text)) + // byte[] responseData = request.downloadHandler.data; + //if (responseData != null && responseData.Length > 0) { string responseText = request.downloadHandler.text; + //string responseText = Encoding.UTF8.GetString(responseData); callback?.Invoke(responseText); } else { - Debug.Log(apiUrl + " request.downloadHandler为空"); + Debug.Log(apiUrl + " request.downloadHandler.text为空"); callback.Invoke(null); } } else { - Debug.Log(apiUrl + " 请求POST接口失败: " + request.error); + Debug.Log(apiUrl + " 请求Get接口失败: " + request.error + "\nURL: " + apiUrl); callback.Invoke(null); } } @@ -297,29 +344,44 @@ public static class CombineJSON // yield return null; //} - using (UnityWebRequest request = UnityWebRequest.Post(apiUrl, "")) + //using (UnityWebRequest request = UnityWebRequest.Post(apiUrl, "")) + UnityWebRequest request = new UnityWebRequest(apiUrl, "POST"); { request.SetRequestHeader("X-Token", token); - + request.SetRequestHeader("Content-Type", "application/json"); + DownloadHandlerBuffer dH = new DownloadHandlerBuffer(); + request.downloadHandler = dH; + request.timeout = 15; yield return request.SendWebRequest(); if (!request.isNetworkError && !request.isHttpError) { - if (request.downloadHandler != null) + // 等待一帧 + yield return null; + + // 检查请求是否已完成 + while (!request.isDone) + { + yield return null; + } + //if (request.downloadHandler.text != null) + if (!string.IsNullOrEmpty(request.downloadHandler.text)) + // byte[] responseData = request.downloadHandler.data; + //if (responseData != null && responseData.Length > 0) { string responseText = request.downloadHandler.text; //Debug.Log(responseText); + //string responseText = Encoding.UTF8.GetString(responseData); callback(responseText); } else { - Debug.Log("request.downloadHandler为null"); + Debug.Log("request.downloadHandler.text为null"); } } else { - Debug.Log("请求POST接口失败: " + request.error); - callback.Invoke(null); + Debug.Log("请求POST接口失败: " + request.error + "\nURL: " + apiUrl); } } yield return new WaitForSeconds(looptime); diff --git a/GQ_TongXin/Assets/script/TOOL.cs b/GQ_TongXin/Assets/script/TOOL.cs index 9d10cbb6c..fc839b9c5 100644 --- a/GQ_TongXin/Assets/script/TOOL.cs +++ b/GQ_TongXin/Assets/script/TOOL.cs @@ -1,4 +1,4 @@ -using AutoMapper; +//using AutoMapper; using System; using System.Collections.Generic; using System.Linq; @@ -222,19 +222,19 @@ public class TOOL : MonoBehaviour [ContextMenu("修改机柜")] public void dsadsa() { - var objA = gameObjects[0].GetComponent().deviceList; + //var objA = gameObjects[0].GetComponent().deviceList; - MapperConfiguration config = new MapperConfiguration(cfg => - { - cfg.CreateMap(); - cfg.CreateMap(); - }); + //MapperConfiguration config = new MapperConfiguration(cfg => + //{ + // cfg.CreateMap(); + // cfg.CreateMap(); + //}); - IMapper mapper = config.CreateMapper(); + //IMapper mapper = config.CreateMapper(); - // 转换 ClassA 到 ClassB - redactDevice.mybody = mapper.Map(objA); + //// 转换 ClassA 到 ClassB + //redactDevice.mybody = mapper.Map(objA); } [ContextMenu("xg端口碰撞器")] diff --git a/GQ_TongXin/Assets/script/前端交互/WebInteraction.cs b/GQ_TongXin/Assets/script/前端交互/WebInteraction.cs index 202f0a799..09c3b3dd7 100644 --- a/GQ_TongXin/Assets/script/前端交互/WebInteraction.cs +++ b/GQ_TongXin/Assets/script/前端交互/WebInteraction.cs @@ -51,7 +51,7 @@ public class WebInteraction : MonoBehaviour /// ǰ˵ô˷Token /// /// - public IEnumerator unity_token_value(string jsonData) + public void unity_token_value(string jsonData) { try { @@ -72,11 +72,15 @@ public class WebInteraction : MonoBehaviour } //yield return null; - yield return (StartCoroutine(GameManager.Inst.LoadAddress((ct) => + + StartCoroutine(GameManager.Inst.LoadAddress((ct) => { if (ct != null) { GameManager.Inst.Jk_URL = new webURL(ct); + //Application.ExternalCall("OnSceneLoaded", "ά"); + //Debug.Log("ά"); + //return; StartCoroutine(GameManager.Inst.Initialize((x) => { if (!string.IsNullOrEmpty(x)) @@ -135,13 +139,20 @@ public class WebInteraction : MonoBehaviour gameManager.isgonging = true; } + else + { + SecondConfirmPanel.DeleteConform(null, "볡ʧ"); + Debug.Log("ӿڻȡʧܣʼʧܣ"); + gameManager.LoadScene(); + } })); } else { + SecondConfirmPanel.DeleteConform(null, "ӿڵַ"); Debug.Log("ȡ͸!"); } - }))); + })); } diff --git a/GQ_TongXin/Assets/script/接口/修改/AddDevice.cs b/GQ_TongXin/Assets/script/接口/修改/AddDevice.cs index af9c68f21..01d42c865 100644 --- a/GQ_TongXin/Assets/script/接口/修改/AddDevice.cs +++ b/GQ_TongXin/Assets/script/接口/修改/AddDevice.cs @@ -1,4 +1,4 @@ -using AutoMapper; +//using AutoMapper; using Newtonsoft.Json; using System; using System.Collections; @@ -167,6 +167,11 @@ public class AddDevice : MonoBehaviour GameManager.Inst.lastDeviceID = URlreturn.data; refurbish(); } + else + { + SecondConfirmPanel.DeleteConform(null, "更新场景失败"); + Debug.Log("接口获取数据失败(新增设备-初始化失败)"); + } })); } @@ -217,6 +222,8 @@ public class AddDevice : MonoBehaviour { if (!string.IsNullOrEmpty(x)) callback.Invoke(true); + else + callback.Invoke(false); })); } diff --git a/GQ_TongXin/Assets/script/接口/修改/AddPort.cs b/GQ_TongXin/Assets/script/接口/修改/AddPort.cs index fcea41f9c..444af85ca 100644 --- a/GQ_TongXin/Assets/script/接口/修改/AddPort.cs +++ b/GQ_TongXin/Assets/script/接口/修改/AddPort.cs @@ -1,4 +1,4 @@ -using AutoMapper; +//using AutoMapper; using Newtonsoft.Json; using System; using System.Collections; @@ -234,6 +234,11 @@ public class AddPort : MonoBehaviour GameManager.Inst.lastDeviceID = URlreturn.data; refurbish(); } + else + { + SecondConfirmPanel.DeleteConform(null, "更新场景失败"); + Debug.Log("接口获取数据失败(新增端口-初始化失败)"); + } })); } @@ -277,6 +282,8 @@ public class AddPort : MonoBehaviour { if (!string.IsNullOrEmpty(x)) callback.Invoke(true); + else + callback.Invoke(false); })); diff --git a/GQ_TongXin/Assets/script/接口/修改/DeleteDevice.cs b/GQ_TongXin/Assets/script/接口/修改/DeleteDevice.cs index 1e8138860..9254d492b 100644 --- a/GQ_TongXin/Assets/script/接口/修改/DeleteDevice.cs +++ b/GQ_TongXin/Assets/script/接口/修改/DeleteDevice.cs @@ -27,6 +27,11 @@ public class DeleteDevice : MonoBehaviour { refurbish(); } + else + { + SecondConfirmPanel.DeleteConform(null, "更新场景失败"); + Debug.Log("接口获取数据失败(删除设备-初始化失败)"); + } })); } else @@ -76,6 +81,8 @@ public class DeleteDevice : MonoBehaviour { if (!string.IsNullOrEmpty(x)) callback.Invoke(true); + else + callback.Invoke(false); })); } diff --git a/GQ_TongXin/Assets/script/接口/修改/DeletePort.cs b/GQ_TongXin/Assets/script/接口/修改/DeletePort.cs index 440512f66..dd1f4b2c4 100644 --- a/GQ_TongXin/Assets/script/接口/修改/DeletePort.cs +++ b/GQ_TongXin/Assets/script/接口/修改/DeletePort.cs @@ -27,6 +27,11 @@ public class DeletePort : MonoBehaviour { refurbish(); } + else + { + SecondConfirmPanel.DeleteConform(null, "更新场景失败"); + Debug.Log("接口获取数据失败(删除端口-初始化失败)"); + } })); } else @@ -80,6 +85,8 @@ public class DeletePort : MonoBehaviour { if (!string.IsNullOrEmpty(x)) callback.Invoke(true); + else + callback.Invoke(false); })); } diff --git a/GQ_TongXin/Assets/script/接口/修改/RedactDevice.cs b/GQ_TongXin/Assets/script/接口/修改/RedactDevice.cs index da0520baa..1d201820f 100644 --- a/GQ_TongXin/Assets/script/接口/修改/RedactDevice.cs +++ b/GQ_TongXin/Assets/script/接口/修改/RedactDevice.cs @@ -1,4 +1,4 @@ -using AutoMapper; +//using AutoMapper; using Newtonsoft.Json; using System; using System.Collections; @@ -166,6 +166,11 @@ public class RedactDevice : MonoBehaviour { refurbish(); } + else + { + SecondConfirmPanel.DeleteConform(null, "更新场景失败"); + Debug.Log("接口获取数据失败(编辑设备-初始化失败)"); + } })); } @@ -216,6 +221,8 @@ public class RedactDevice : MonoBehaviour { if (!string.IsNullOrEmpty(x)) callback.Invoke(true); + else + callback.Invoke(false); })); } diff --git a/GQ_TongXin/Assets/script/接口/修改/RedactPort.cs b/GQ_TongXin/Assets/script/接口/修改/RedactPort.cs index ccc12837a..16af10172 100644 --- a/GQ_TongXin/Assets/script/接口/修改/RedactPort.cs +++ b/GQ_TongXin/Assets/script/接口/修改/RedactPort.cs @@ -1,4 +1,4 @@ -using AutoMapper; +//using AutoMapper; using Newtonsoft.Json; using System; using System.Collections; @@ -406,6 +406,11 @@ public class RedactPort : MonoBehaviour { refurbish(); } + else + { + SecondConfirmPanel.DeleteConform(null, "更新场景失败"); + Debug.Log("接口获取数据失败(编辑端口-初始化失败)"); + } })); } else @@ -447,6 +452,8 @@ public class RedactPort : MonoBehaviour { if (!string.IsNullOrEmpty(x)) callback.Invoke(true); + else + callback.Invoke(false); })); } diff --git a/GQ_TongXin/Assets/script/接口/查询/LineQuery.cs b/GQ_TongXin/Assets/script/接口/查询/LineQuery.cs index 7c038a638..d4eafa430 100644 --- a/GQ_TongXin/Assets/script/接口/查询/LineQuery.cs +++ b/GQ_TongXin/Assets/script/接口/查询/LineQuery.cs @@ -273,6 +273,7 @@ public class LineQuery : MonoBehaviour else { SecondConfirmPanel.DeleteConform(null, "³ʧ"); + Debug.Log("ӿڻȡʧܣ½ӿ-ʼʧܣ"); callback.Invoke(null); } })); diff --git a/GQ_TongXin/Assets/script/点击/ClickEvent.cs b/GQ_TongXin/Assets/script/点击/ClickEvent.cs index 28c153949..f291157e1 100644 --- a/GQ_TongXin/Assets/script/点击/ClickEvent.cs +++ b/GQ_TongXin/Assets/script/点击/ClickEvent.cs @@ -834,13 +834,18 @@ public class ClickEvent : MonoBehaviour Vector3 center = renderer.bounds.center; //Vector3 targetPosition = new Vector3(center.x + yiDong_pos.x, center.y + yiDong_pos.y, center.z + yiDong_pos.z); Vector3 targetPosition = new Vector3(center.x, center.y, center.z) + yiDong_pos; + Quaternion targetRotation = Quaternion.Euler(fangDa_rot); Camera.main.transform.DOMove(targetPosition, 1f); Camera.main.transform.DORotateQuaternion(targetRotation, 1f).OnComplete(() => { //ʼתǶ //ExtendedFlycam.Inst.initialRotationEulerAngles = Camera.main.transform.localEulerAngles; - if (cabine.layer != 15) + + //ͷ΢ + if (gameObject.name == "R69" || gameObject.name == "70") + CameraMgr.Instance.GotoView(cabine.transform, 2, targetRotation, 0); + else if (cabine.layer != 15) CameraMgr.Instance.GotoView(cabine.transform, 2, targetRotation); else CameraMgr.Instance.GotoView(cabine.transform.parent, 2, targetRotation); diff --git a/GQ_TongXin/ProjectSettings/ProjectSettings.asset b/GQ_TongXin/ProjectSettings/ProjectSettings.asset index 0fb0eac76..bd53f27d2 100644 --- a/GQ_TongXin/ProjectSettings/ProjectSettings.asset +++ b/GQ_TongXin/ProjectSettings/ProjectSettings.asset @@ -12,7 +12,7 @@ PlayerSettings: targetDevice: 2 useOnDemandResources: 0 accelerometerFrequency: 60 - companyName: DefaultCompany + companyName: GQ_TongXin productName: GQ_TongXin defaultCursor: {fileID: 0} cursorHotspot: {x: 0, y: 0} @@ -162,7 +162,6 @@ PlayerSettings: m_ColorGamuts: 00000000 targetPixelDensity: 30 resolutionScalingMode: 0 - resetResolutionOnWindowResize: 0 androidSupportedAspectRatio: 1 androidMaxAspectRatio: 2.1 applicationIdentifier: {} @@ -690,7 +689,6 @@ PlayerSettings: ps4videoRecordingFeaturesUsed: 0 ps4contentSearchFeaturesUsed: 0 ps4CompatibilityPS5: 0 - ps4AllowPS5Detection: 0 ps4GPU800MHz: 1 ps4attribEyeToEyeDistanceSettingVR: 0 ps4IncludedModules: []