예제 #1
0
        public void GenerateProperties(IReadOnlyCollection <JsonPropertyInstance> properties, int indentLevel, CodeBuilder classBuilder, JsonFormat jsonFormat)
        {
            var propertyHashFactory = new PropertyHashFactory();
            var propertyHash        = propertyHashFactory.FindBestHash(properties.Select(p => p.JsonName).ToArray(), jsonFormat == JsonFormat.UTF8);

            var hashesQuery =
                from property in properties
                let hash = propertyHash.Hash(property.JsonName)
                           group property by hash into hashGroup
                           orderby hashGroup.Key
                           select hashGroup;

            var hashes      = hashesQuery.ToArray();
            var switchGroup = GetSwitchGroups(hashes);

            GenerateSwitchGroup(switchGroup, classBuilder, indentLevel, propertyHash, jsonFormat);
        }
예제 #2
0
        public void GenerateProperties(IReadOnlyCollection <JsonPropertyInstance> properties, int indentLevel, CodeBuilder classBuilder)
        {
            var propertyHashFactory = new PropertyHashFactory();
            var propertyHash        = propertyHashFactory.FindBestHash(properties.Select(p => p.JsonName).ToArray());

            var hashesQuery =
                from property in properties
                let hash = propertyHash.Hash(property.JsonName)
                           group property by hash into hashGroup
                           orderby hashGroup.Key
                           select hashGroup;

            var hashes       = hashesQuery.ToArray();
            var switchGroups = FindSwitchGroups(hashes);

            foreach (var switchGroup in switchGroups)
            {
                GenerateSwitchGroup(switchGroup, classBuilder, indentLevel, propertyHash);
            }
        }