private void GetObjectTokens(List <Token <ModelTokenType> > tokens, ICycleDetector detector, DataName typeName, IDictionaryEnumerator enumerator) { tokens.Add(ModelGrammar.TokenObjectBegin(typeName)); while (enumerator.MoveNext()) { tokens.Add(ModelGrammar.TokenProperty(enumerator.Key)); this.GetTokens(tokens, detector, enumerator.Value); } tokens.Add(ModelGrammar.TokenObjectEnd); }
private void GetObjectTokens(List <Token <ModelTokenType> > tokens, ICycleDetector detector, DataName typeName, IEnumerator <KeyValuePair <string, object> > enumerator) { tokens.Add(ModelGrammar.TokenObjectBegin(typeName)); while (enumerator.MoveNext()) { KeyValuePair <string, object> pair = enumerator.Current; tokens.Add(ModelGrammar.TokenProperty(pair.Key)); this.GetTokens(tokens, detector, pair.Value); } tokens.Add(ModelGrammar.TokenObjectEnd); }
private void GetObjectTokens(List <Token <ModelTokenType> > tokens, ICycleDetector detector, Type type, System.Dynamic.DynamicObject value) { DataName typeName = this.GetTypeName(value); tokens.Add(ModelGrammar.TokenObjectBegin(typeName)); foreach (var memberName in value.GetDynamicMemberNames()) { object propertyValue; if (!value.TryGetMember(new DynamicGetter(memberName), out propertyValue)) { continue; } tokens.Add(ModelGrammar.TokenProperty(memberName)); this.GetTokens(tokens, detector, propertyValue); } tokens.Add(ModelGrammar.TokenObjectEnd); }
private void GetObjectTokens(List <Token <ModelTokenType> > tokens, ICycleDetector detector, Type type, object value) { DataName typeName = this.GetTypeName(value); tokens.Add(ModelGrammar.TokenObjectBegin(typeName)); IDictionary <string, MemberMap> maps = this.Settings.Resolver.LoadMaps(type); if (maps == null) { // TODO: verify no other valid situations here tokens.Add(ModelGrammar.TokenObjectEnd); return; } // allow the resolver to optionally sort the members IEnumerable <MemberMap> members = this.Settings.Resolver.SortMembers(maps.Values); foreach (var map in members) { if (map.IsAlternate || map.Getter == null) { continue; } object propertyValue = map.Getter(value); if (map.IsIgnored != null && map.IsIgnored(value, propertyValue)) { continue; } tokens.Add(ModelGrammar.TokenProperty(map.DataName)); this.GetTokens(tokens, detector, propertyValue); } tokens.Add(ModelGrammar.TokenObjectEnd); }