1 function Sys$Services$_ProfileService$_flattenProperties(propertyNames, properties, groupName) {
2 var flattenedProperties = {};
3 var val;
4 var key;
5 var count = 0;
6 if (propertyNames && propertyNames.length === 0) {
7 return { value: flattenedProperties, count: 0 };
8 }
9 for (var property in properties) {
10 val = properties[property];
11 key = groupName ? groupName + "." + property : property;
12 if(Sys.Services.ProfileGroup.isInstanceOfType(val)) {
13 var obj = this._flattenProperties(propertyNames, val, key);
14 var groupProperties = obj.value;
15 count += obj.count;
16 for(var subKey in groupProperties) {
17 var subVal = groupProperties[subKey];
18 flattenedProperties[subKey] = subVal;
19 }
20 }
21 else {
22 if(!propertyNames || Array.indexOf(propertyNames, key) !== -1) {
23 flattenedProperties[key] = val;
24 count++;
25 }
26 }
27 }
28 return { value: flattenedProperties, count: count };
29 }