public IAccountSettings Convert(ServiceAccount serviceAccount) { GoogleSheetsAccountSettings target = new GoogleSheetsAccountSettings(); target.ID = serviceAccount.ServiceAccountId; target.Name = serviceAccount.ServiceAccountName; target.Source = serviceAccount.Source; target.Tokens = new List<GoogleSheetsAccountToken>(); target.MinUpdateTime = serviceAccount.MinUpdateTime; target.AccountVersion = serviceAccount.AccountVersion; if (serviceAccount.Tokens.Count > 0) { foreach (Token token in serviceAccount.Tokens) { GoogleSheetsAccountToken targetToken = new GoogleSheetsAccountToken(); targetToken = (GoogleSheetsAccountToken)targetToken.Convert(token); target.Tokens.Add(targetToken); } } if (serviceAccount.MappingTemplates.Count > 0) { foreach (Template template in serviceAccount.MappingTemplates) { GoogleSheetsAccountTemplate targetTemplate = new GoogleSheetsAccountTemplate(); targetTemplate = (GoogleSheetsAccountTemplate)targetTemplate.Convert(template); if (target.Templates != null) target.Templates.Add(targetTemplate); } } return target; }
public IAccountTemplate Convert(Template template) { GoogleSheetsAccountTemplate targetTemplate = new GoogleSheetsAccountTemplate(); targetTemplate.TemplateId = template.TemplateId; targetTemplate.TemplateName = template.TemplateName; if (template.Mapping.Count > 0) { targetTemplate.Mapping = (from tok in template.Mapping where tok.Key == "Mapping" select tok.Value).SingleOrDefault(); } return targetTemplate; }