A simple C# SDK for interacting with the Salesforce Tooling API using the REST interface.
Перейти к файлу
Wade Wegner fb3cf137d2 Simplified samples 2016-06-14 18:59:59 -07:00
src/Salesforce.Tooling Fixed some tests broken by replace command 2016-06-14 18:28:43 -07:00
.gitignore Initial commit 2016-06-10 12:12:55 -07:00
LICENSE Initial commit 2016-06-10 12:12:55 -07:00
README.md Simplified samples 2016-06-14 18:59:59 -07:00

README.md

Salesforce.CSharp.Tooling

A simple C# SDK for interacting with the Salesforce Tooling API using the REST interface.

Usage

Below you'll find some sample codes for using this library. You can also review the functional tests for cues on usage.

Login

This uses the DeveloperForce.Force library for authentication.

var auth = new AuthenticationClient();
await auth.UsernamePasswordAsync(ConsumerKey, ConsumerSecret, Username, Password, TokenRequestEndpointUrl);

Get all sObjects

var toolingClient = new ToolingClient(auth);
var sObjectsResults = await toolingClient.SObjects<SObjectsModel>();

Get a specific sObject (e.g. ApexClass)

var traceFlagResult = await toolingClient.SObject("ApexClass");

Describe a specific sObject (e.g. ApexClass)

var apexClassDescribeResult = await toolingClient.SObjectDescribe("ApexClass");

Query a specific sObject (e.g. ApexClass)

const string query = "SELECT Id, NamespacePrefix, Name, ApiVersion, Status, IsValid, BodyCrc, Body, LengthWithoutComments, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, SymbolTable, Metadata, FullName FROM ApexClass";

var result = await toolingClient.Query<dynamic>(query);

Create an ApexClass


var apexClass = new Models.ApexClass
{
  Body = "public class TestClass {{\n\n}}",
  Name = "TestClassName"
};

var createApexClassResult = await toolingClient.CreateRecord("ApexClass", apexClass);

Create an ApexClass using MetadataContainer

var metadataContainer = new MetadataContainer
{
    Name = metadataContainerName
};

var createMetadataContainerResult = await toolingClient.CreateRecord("MetadataContainer", metadataContainer);

var apexClassMember = new ApexClassMember
{
  MetadataContainerId = createMetadataContainerResult.Id,
  FullName = "TestClass",
  Body = "public class TestClass {{\n\n}}",
  Metadata = new ApexClassMemberMetadata {apiVersion = "36.0", status = "Active"}
};

var createApexClassMemberResult = await toolingClient.CreateRecord("ApexClassMember", apexClassMember);

var containerAsyncRequest = new ContainerAsyncRequest
{
    MetadataContainerId = createMetadataContainerResult.Id,
    IsCheckOnly = true
};

var containerAsyncRequestResult = await toolingClient.CreateRecord("ContainerAsyncRequest", containerAsyncRequest);