internal static void ProcessRelatedObjectsCollection <T>(RelatedObjectCollection <T> i_ObjectCollection, SFRefereceResolver i_ReferenceResolver) where T : sObject { if (i_ObjectCollection != null) { foreach (T innerRecord in i_ObjectCollection.records) { i_ReferenceResolver.AddReference(innerRecord); innerRecord.updateReferencesAfterDeserialize(i_ReferenceResolver); } } }
internal static T CreateEmptyReferenceFromId <T>(string i_ObjectId, T i_Property, SFRefereceResolver i_RefereceResolver) where T : sObject { if (i_Property == null) { if (!string.IsNullOrEmpty(i_ObjectId)) { i_Property = (T)Activator.CreateInstance(typeof(T), i_ObjectId); i_RefereceResolver.AddReference(i_Property); } } return(i_Property); }
private void populateServiceParentsList(SFRefereceResolver i_RefereceResolver) { if (ServicesParents == null) { ServicesParents = new Dictionary <string, IServiceAppoinmentParent>(); } if (parents != null) { JsonSerializer serializer = JsonSerializer.Create(DeserializationUtils.SFJsonSerializerSettings); foreach (JObject serviceParent in parents) { JToken attributeType = serviceParent.SelectToken("attributes.type"); if (attributeType != null) { string objectType = attributeType.ToString(); switch (objectType) { case "WorkOrder": WorkOrder workOrder = serviceParent.ToObject <WorkOrder>(serializer); i_RefereceResolver.AddReference(workOrder); ServicesParents.Add(workOrder.Id, workOrder); break; case "WorkOrderLineItem": WorkOrderLineItem workOrderLineItem = serviceParent.ToObject <WorkOrderLineItem>(serializer); i_RefereceResolver.AddReference(workOrderLineItem); ServicesParents.Add(workOrderLineItem.Id, workOrderLineItem); break; } } } parents.Clear(); parents = null; } }
internal static T GetSingleObjectReference <T>(string i_ObjectId, JToken i_ObjectJson, SFRefereceResolver i_ReferenceResolver) where T : sObject { T objectReference; if (!i_ReferenceResolver.TryGetObjectFromId(i_ObjectId, out objectReference)) { if (i_ObjectJson != null && i_ObjectJson.Type == JTokenType.Object) { objectReference = i_ObjectJson.ToObject <T>(JsonSerializer.Create(SFJsonSerializerSettings)); i_ReferenceResolver.AddReference(objectReference); objectReference.updateReferencesAfterDeserialize(i_ReferenceResolver); } } return(objectReference); }