public static Sorter BuildSorter(DataModel.Search.Sort.ISorter sorter)
 {
     Sorter.Builder builder = Sorter.CreateBuilder();
     if (sorter is DataModel.Search.Sort.FieldSort)
     {
         builder.SetFieldSort(BuildFieldSort((DataModel.Search.Sort.FieldSort)sorter));
     }
     else if (sorter is DataModel.Search.Sort.ScoreSort)
     {
         builder.SetScoreSort(BuildScoreSort((DataModel.Search.Sort.ScoreSort)sorter));
     }
     else if (sorter is DataModel.Search.Sort.GeoDistanceSort)
     {
         builder.SetGeoDistanceSort(BuildGeoDistanceSort((DataModel.Search.Sort.GeoDistanceSort)sorter));
     }
     else if (sorter is DataModel.Search.Sort.PrimaryKeySort)
     {
         builder.SetPkSort(BuilderPrimarykeySort((DataModel.Search.Sort.PrimaryKeySort)sorter));
     }
     else
     {
         throw new ArgumentException("unknown sorter type: " + sorter.ToString());
     }
     return(builder.Build());
 }