Skip to content

Upgraded to .NET 9 - MAUI #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 2, 2024
Merged

Upgraded to .NET 9 - MAUI #1

merged 2 commits into from
Dec 2, 2024

Conversation

YBTopaz8
Copy link
Owner

@YBTopaz8 YBTopaz8 commented Dec 2, 2024

Added Support for .NET 9 and MAUI
Updated all codes to have the new .NET standards and programming concepts (especially for async)

Tested Support for Live Queries!

You can use this with Live Queries in your .NET 9/MAUI app!

Download the project's source and add to your solution. Build and Run.
Docs from Parse Community
https://github.com/parse-community/Parse-SDK-dotNET

Could be helpful!
Sample static method to convert to Parse Object (so as to do .SaveAsync etc)
You can do the reverse to "de-convert" I have a method but it's mainly for realm classes. Might have one in a Sample project

 public static ParseObject MapToParseObject<T>(T model, string className)
 {
     var parseObject = new ParseObject(className);

     // Get the properties of the class
     var properties = typeof(T).GetProperties();

     foreach (var property in properties)
     {
         try
         {
             var value = property.GetValue(model);

           

             // Handle special types like DateTimeOffset
             if (property.PropertyType == typeof(DateTimeOffset))
             {
                 var val = (DateTimeOffset)value;
                 parseObject[property.Name] = val.Date;
                 continue;
             }

             // Handle string as string (required for Parse compatibility)
             if (property.PropertyType == typeof(string))
             {
                 if(value != null && !string.IsNullOrEmpty(value.ToString()))
                 {
                     parseObject[property.Name] = value.ToString();
                     continue;
                 }
             }

             // Add a fallback check for unsupported complex types
             if (value.GetType().Namespace?.StartsWith("Realms") == true)
             {
                 Debug.WriteLine($"Skipped unsupported Realm type: {property.Name}");
                 continue;
             }

             // For other types, directly set the value
             parseObject[property.Name] = value;
         }
         catch (Exception ex)
         {
             // Log the exception for this particular property, but continue with the next one
             Debug.WriteLine($"Error when mapping property '{property.Name}': {ex.Message}");
         }
     }

     return parseObject;
 }

@YBTopaz8 YBTopaz8 merged commit 5a71f08 into master Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant