public AccountSchemaModel GetAccountSchema() { var response = HttpContext.Current.Cache[_cacheKey] as AccountSchemaModel; if (response != null) { return(response); } response = new AccountSchemaModel { Properties = new List <AccountSchemaProperty>() }; AddProperties(ref response, "systemSchema", null); AddProperties(ref response, "profileSchema", "profile"); AddProperties(ref response, "dataSchema", "data"); AddProperties(ref response, "subscriptionsSchema", "subscriptions"); AddProperties(ref response, "preferencesSchema", "preferences"); HttpContext.Current.Cache.Insert(_cacheKey, response, null, DateTime.UtcNow.AddMinutes(_cacheMins), Cache.NoSlidingExpiration); return(response); }
private void AddProperties(ref AccountSchemaModel results, string schema, string propertyPrefix) { var schemaData = _apiHelper.GetAccountSchema(_gigyaModuleSettings, schema); if (schemaData == null || schemaData.GetErrorCode() != 0) { return; } var model = JsonConvert.DeserializeObject <ExpandoObject>(schemaData.GetResponseText()); var propertyPath = string.Concat(schema, ".fields"); var fields = DynamicUtils.GetValue <IDictionary <string, object> >(model, propertyPath); if (fields == null || !fields.Any()) { return; } results.Properties.AddRange(fields.Keys.Select(i => new AccountSchemaProperty { Name = !string.IsNullOrEmpty(propertyPrefix) ? string.Join(".", propertyPrefix, i) : i })); }