static async Task Main(string[] args) { var appArguments = SetupCommandLineParser(args); Console.WriteLine("Salesforce Object to Poco Generator for Rest API calls."); ForceClient forceClient = null; using (var auth = new Salesforce.Common.AuthenticationClient()) { await auth.UsernamePasswordAsync(appArguments.ConsumerKey, appArguments.ConsumerSecret, appArguments.UserName, appArguments.PasswordAndToken, appArguments.TokenUrl); forceClient = new ForceClient(auth.InstanceUrl, auth.AccessToken, "v50.0"); } // get object description from Salesforce API var describeObjectInfo = await forceClient.DescribeAsync <SalesforceObjectDescribe>(appArguments.ObjectApiName); // generate c# class into string var classStr = ($@" namespace {appArguments.Namespace} {{ public class {appArguments.ObjectApiName} {{ {string.Join("\r\n", describeObjectInfo.Fields.Select(x=> $" public {GetCSharpType(x.SoapType, x.Nillable)} {x.Name} {{get; set;}} " )) } }} }} "); Console.WriteLine(classStr); // write to file if (!string.IsNullOrEmpty(appArguments.FileOutput)) { File.WriteAllText(appArguments.FileOutput, ""); } }
public async Task Object_Describe_IsNotNull() { var accounts = await _client.DescribeAsync <object>("Account"); Assert.IsNotNull(accounts); }
public async Task <string> GetFieldsListAsync(string objectName) { IDictionary <string, object> objectProperties = await _client.DescribeAsync <ExpandoObject>(objectName); objectProperties.TryGetValue("fields", out object fields); List <string> objectDescription = new List <string>(); foreach (dynamic field in fields as IEnumerable) { objectDescription.Add(((ExpandoObject)(field)).FirstOrDefault(x => x.Key == "name").Value.ToString()); } return(string.Join(", ", objectDescription)); }