-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔩 Merge pull request #5 from CarterGames/pre-release
📦 0.3.0 Bits
- Loading branch information
Showing
15 changed files
with
218 additions
and
78 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
...ion Database To Unity/Code/Editor/Editors/Drawer/PropertyDrawerNotionSortProperty.cs.meta
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
Carter Games/Notion Database To Unity/Code/Editor/Editors/Sort Property.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...s/Notion Database To Unity/Code/Editor/Editors/Sort Property/SortPropertiesWindow.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
Carter Games/Notion Database To Unity/Code/Runtime/Notion/Notion Database Processing.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...abase To Unity/Code/Runtime/Notion/Notion Database Processing/INotionDatabaseProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2024 Carter Games | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace CarterGames.Standalone.NotionData | ||
{ | ||
/// <summary> | ||
/// Implement to alter the method at which data is parser to an asset from the data downloaded from Notion. | ||
/// </summary> | ||
/// <typeparam name="T">The type to parse to, normally the NotionDataAsset genetic passed argument type.</typeparam> | ||
public interface INotionDatabaseProcessor<T> | ||
{ | ||
List<T> Process(NotionDatabaseQueryResult result); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
... To Unity/Code/Runtime/Notion/Notion Database Processing/INotionDatabaseProcessor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
...o Unity/Code/Runtime/Notion/Notion Database Processing/NotionDatabaseProcessorStandard.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 2024 Carter Games | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
using System.Collections.Generic; | ||
using System.Reflection; | ||
|
||
namespace CarterGames.Standalone.NotionData | ||
{ | ||
/// <summary> | ||
/// The standard data parser from Notion to a NotionDataAsset. Matches the property name for parses the data to each entry. | ||
/// </summary> | ||
/// <typeparam name="T">The type to parse to.</typeparam> | ||
public sealed class NotionDatabaseProcessorStandard<T> : INotionDatabaseProcessor<T> where T : new() | ||
{ | ||
public List<T> Process(NotionDatabaseQueryResult result) | ||
{ | ||
var list = new List<T>(); | ||
|
||
foreach (var row in result.Rows) | ||
{ | ||
var newEntry = new T(); | ||
var newEntryFields = newEntry.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); | ||
|
||
foreach (var field in newEntryFields) | ||
{ | ||
if (row.DataLookup.ContainsKey(field.Name.Trim().ToLower())) | ||
{ | ||
var valueData = row.DataLookup[field.Name.Trim().ToLower()]; | ||
var fieldType = field.FieldType; | ||
|
||
if (fieldType.BaseType.FullName.Contains(typeof(NotionDataWrapper<>).Namespace + ".NotionDataWrapper")) | ||
{ | ||
var instance = valueData.GetValueAs(fieldType); | ||
field.SetValue(newEntry, instance); | ||
|
||
instance.GetType().BaseType.GetMethod("Assign", BindingFlags.NonPublic | BindingFlags.Instance) | ||
?.Invoke(instance, null); | ||
} | ||
else | ||
{ | ||
field.SetValue(newEntry, valueData.GetValueAs(fieldType)); | ||
} | ||
} | ||
} | ||
|
||
list.Add(newEntry); | ||
} | ||
|
||
return list; | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...ty/Code/Runtime/Notion/Notion Database Processing/NotionDatabaseProcessorStandard.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.