Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Parse SDK for .NET

License

NotificationsYou must be signed in to change notification settings

parse-community/Parse-SDK-dotNET

parse-repository-header-sdk-dotnet


Build StatusCoverageauto-release

.NET VersionNuget

Backers on Open CollectiveSponsors on Open CollectiveForumTwitterChat


This library gives you access to the powerful Parse Server backend from your .NET app. For more information on Parse Platform and its features, visitparseplatform.org.


Compatibility

.NET

Parse .NET SDK is continuously tested with the most recent releases of .NET to ensure compatibility. We follow the.NET Long Term Support plan and only test against versions that are officially supported and have not reached their end-of-life date.

.NET VersionEnd-of-LifeParse .NET SDK Version
Standard 2.0November 2024>=1.0.0 <4.0.0
6.0November 2024>=1.0.0 <5.0.0
7.0May 2024>=1.0.0 <5.0.0
8.0November 2026>=1.0.0
9.0May 2026>=1.0.0

Note

We have removed support forNET Standard 2.0 with Parse .NET SDK 4.0. Xamarin developers should migrate to .NET MAUI to use the latest version of the Parse .NET SDK. Unity developers should use Parse .NET SDK <4.0 until Unity supports .NET and then migrate to the latest version of the Parse .NET SDK.

Using the Code

Make sure you are using the project's root namespace.

usingParse;

TheParseClient class has three constructors, one allowing you to specify your Application ID, Server URI, and .NET Key as well as some configuration items, one for creating clones ofParseClient.Instance ifPublicize was called on an instance previously, and another, accepting anIServerConnectionData implementation instance which exposes the data needed for the SDK to connect to a Parse Server instance, like the first constructor, but with a few extra options. You can create your ownIServerConnectionData implementation or use theServerConnectionData struct.IServerConnectionData allows you to expose a value the SDK should use as the master key, as well as some extra request headers if needed.

ParseClientclient=newParseClient("Your Application ID","The Parse Server Instance Host URI","Your .NET Key");
ParseClientclient=newParseClient(newServerConnectionData{ApplicationID="Your Application ID",ServerURI="The Parse Server Instance Host URI",Key="Your .NET Key",// This is unnecessary if a value for MasterKey is specified.MasterKey="Your Master Key",Headers=newDictionary<string,string>{["X-Extra-Header"]="Some Value"}});

ServerConnectionData is available in theParse.Infrastructure namespace.

The two non-cloningParseClient constructors contain optional parameters for anIServiceHub implementation instance and an array ofIServiceHubMutators. These should only be used when the behavior of the SDK needs to be changed.

To find full usage instructions for the latest stable release, please visit the [Parse docs website][parse-docs-link]. Please note that the latest stable release is quite old and does not reflect the work being done at the moment.

Common Definitions

  • Application ID:Your app'sApplicationId field from your Parse Server.
  • Key:Your app's.NET Key field from your Parse Server.
  • Master Key:Your app'sMaster Key field from your Parse Server. Using this key with the SDK will allow it to bypass any CLPs and object permissions that are set. This also should be compatible with read-only master keys as well.
  • Server URI:The full URL to your web-hosted Parse Server.

Client-Side Use

In your program's entry point, instantiate aParseClient with all the parameters needed to connect to your target Parse Server instance, then callPublicize on it. This will light up the staticParseClient.Instance property with the newly-instantiatedParseClient, so you can perform operations with the SDK.

newParseClient(/* Parameters */).Publicize();

Server-Side Use

The SDK can be set up in a way such that every newParseClient instance can authenticate a different user concurrently. This is enabled by anIServiceHubMutator implementation which adds itself as anIServiceHubCloner implementation to the service hub which, making it so that consecutive calls to the cloningParseClient constructor (the one without parameters) will clone the publicizedParseClient instance, exposed byParseClient.Instance, replacing theIParseCurrentUserController implementation instance with a fresh one with no caching every time. This allows you to configure the original instance, and have the clones retain the general behaviour, while also allowing the differnt users to be signed into the their respective clones and execute requests concurrently, without causing race conditions. To use this feature of the SDK, the firstParseClient instance must be constructued and publicized as follows once, before any otherParseClient instantiations. Any classes that need to be registered must be done so with the original instance.

newParseClient(/* Parameters */,default,newConcurrentUserServiceHubCloner{}).Publicize();

Consecutive instantiations can be done via the cloning constructor for simplicity's sake.

ParseClientclient=newParseClient{};

Basic Demonstration

The following code shows how to use the Parse .NET SDK to create a new user, save and authenticate the user, deauthenticate the user, re-authenticate the user, create an object with permissions that allow only the user to modify it, save the object, update the object, delete the object, and deauthenticate the user once more.

// Instantiate a ParseClient.ParseClientclient=newParseClient(/* Parameters */);// Create a user, save it, and authenticate with it.awaitclient.SignUpAsync(username:"Test",password:"Test");// Get the authenticated user. This is can also be done with a variable that stores the ParseUser instance before the SignUp overload that accepts a ParseUser is called.Console.WriteLine(client.GetCurrentUser().SessionToken);// Deauthenticate the user.awaitclient.LogOutAsync();// Authenticate the user.ParseUseruser=awaitclient.LogInAsync(username:"Test",password:"Test");// Create a new object with permessions that allow only the user to modify it.ParseObjecttestObject=newParseObject("TestClass"){ACL=newParseACL(user)};// Bind the ParseObject to the target ParseClient instance. This is unnecessary if Publicize is called on the client.testObject.Bind(client);// Set some value on the object.testObject.Set("someValue","This is a value.");// See that the ObjectId of an unsaved object is null;Console.WriteLine(testObject.ObjectId);// Save the object to the target Parse Server instance.awaittestObject.SaveAsync();// See that the ObjectId of a saved object is non-null;Console.WriteLine(testObject.ObjectId);// Query the object back down from the server to check that it was actually saved.Console.WriteLine((awaitclient.GetQuery("TestClass").WhereEqualTo("objectId",testObject.ObjectId).FirstAsync()).Get<string>("someValue"));// Mutate some value on the object.testObject.Set("someValue","This is another value.");// Save the object again.awaittestObject.SaveAsync();// Query the object again to see that the change was made.Console.WriteLine((awaitclient.GetQuery("TestClass").WhereEqualTo("objectId",testObject.ObjectId).FirstAsync()).Get<string>("someValue"));// Store the object's objectId so it can be verified that it was deleted later.vartestObjectId=testObject.ObjectId;// Delete the object.awaittestObject.DeleteAsync();// Check that the object was deleted from the server.Console.WriteLine(awaitclient.GetQuery("TestClass").WhereEqualTo("objectId",testObjectId).FirstOrDefaultAsync()==null);// Deauthenticate the user again.awaitclient.LogOutAsync();

Local Builds

You can build the SDK on any system with the MSBuild or .NET Core CLI installed. Results can be found under either theRelease/netstandard2.0 orDebug/netstandard2.0 in thebin folder unless a non-standard build configuration is used.

.NET Core CLI

dotnet build Parse.sln

Sponsor this project

  •  

Packages

No packages published

Contributors26

Languages


[8]ページ先頭

©2009-2025 Movatter.jp