本文整理汇总了C#中Dictionary.AddObject方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.AddObject方法的具体用法?C# Dictionary.AddObject怎么用?C# Dictionary.AddObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dictionary
的用法示例。
在下文中一共展示了Dictionary.AddObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is RangeAggregate))
throw new SerializeTypeException<RangeAggregate>();
RangeAggregate agg = value as RangeAggregate;
Dictionary<string, object> fieldDict = new Dictionary<string, object>();
fieldDict.AddObject(_FIELD, agg.Field);
agg.Script.Serialize(fieldDict);
fieldDict.AddObject(_KEYED, agg.AreRangesKeyed, _KEYED_DEFAULT);
fieldDict.AddObject(_RANGES, agg.Ranges.Select(x => SerializeRangeBucket(x)));
Dictionary<string, object> aggDict = new Dictionary<string, object>();
aggDict.Add(AggregationTypeEnum.Range.ToString(), fieldDict);
Dictionary<string, object> subAggsDict = agg.SerializeSubAggregations();
if (subAggsDict != null)
{
aggDict.Add(BucketAggregationBase._SUB_AGGREGATIONS, subAggsDict);
}
Dictionary<string, object> aggNameDict = new Dictionary<string, object>();
aggNameDict.Add(agg.Name, aggDict);
serializer.Serialize(writer, aggNameDict);
}
示例2: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is FuzzyQueryBase))
throw new SerializeTypeException<FuzzyQueryBase>();
FuzzyQueryBase query = value as FuzzyQueryBase;
Dictionary<string, object> fieldDict = new Dictionary<string, object>();
if (query.Boost == QuerySerializer._BOOST_DEFAULT && query.Fuzziness == null && query.MaximumExpansions == default(int) && query.PrefixLength == default(int))
{
fieldDict.Add(query.Field, query.Value);
}
else
{
Dictionary<string, object> detailDict = new Dictionary<string, object>();
detailDict.Add(_VALUE, query.Value);
detailDict.AddObject(QuerySerializer._BOOST, query.Boost, QuerySerializer._BOOST_DEFAULT);
detailDict.AddObject(_FUZZINESS, query.Fuzziness);
detailDict.AddObject(_PREFIX_LENGTH, query.PrefixLength, _PREFIX_LENGTH_DEFAULT);
detailDict.AddObject(_MAXIMUM_EXPANSIONS, query.MaximumExpansions, _MAXIMUM_EXPANSIONS_DEFAULT);
fieldDict.Add(query.Field, detailDict);
}
Dictionary<string, object> fuzzyDict = new Dictionary<string, object>();
fuzzyDict.Add(QueryTypeEnum.Fuzzy.ToString(), fieldDict);
serializer.Serialize(writer, fuzzyDict);
}
示例3: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is RangeFilterBase))
throw new SerializeTypeException<RangeFilterBase>();
RangeFilterBase filter = value as RangeFilterBase;
Dictionary<string, object> fieldDict = new Dictionary<string, object>();
fieldDict.AddObject(_GREATER_THAN, filter.GreaterThan);
fieldDict.AddObject(_LESS_THAN, filter.LessThan);
fieldDict.AddObject(_GREATER_THAN_OR_EQUAL_TO, filter.GreaterThanOrEqualTo);
fieldDict.AddObject(_LESS_THAN_OR_EQUAL_TO, filter.LessThanOrEqualTo);
Dictionary<string, object> internalDict = new Dictionary<string, object>();
internalDict.Add(filter.Field, fieldDict);
if(filter.ExecutionType != null)
internalDict.AddObject(_EXECUTION, filter.ExecutionType.ToString());
if (filter.ExecutionType != null && filter.ExecutionType == ExecutionTypeEnum.Index)
FilterSerializer.SerializeBaseValues(filter, _INDEX_EXECUTION_CACHE_DEFAULT, internalDict);
else
FilterSerializer.SerializeBaseValues(filter, _CACHE_DEFAULT, fieldDict);
Dictionary<string, object> queryDict = new Dictionary<string, object>();
queryDict.Add(FilterTypeEnum.Range.ToString(), internalDict);
serializer.Serialize(writer, queryDict);
}
示例4: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is HistogramAggregate))
throw new SerializeTypeException<HistogramAggregate>();
HistogramAggregate agg = value as HistogramAggregate;
Dictionary<string, object> fieldDict = new Dictionary<string, object>();
fieldDict.AddObject(_FIELD, agg.Field);
agg.Script.Serialize(fieldDict);
fieldDict.AddObject(_INTERVAL, agg.Interval);
fieldDict.AddObject(_MINIMUM_DOCUMENT_COUNT, agg.MinimumDocumentCount, _MINIMUM_DOCUMENT_COUNT_DEFAULT);
fieldDict.AddObject(_KEYED, agg.AreBucketsKeyed, _KEYED_DEFAULT);
if (!string.IsNullOrWhiteSpace(agg.SortValue))
{
Dictionary<string, object> orderDict = new Dictionary<string, object>();
orderDict.Add(agg.SortValue, agg.SortOrder.ToString());
fieldDict.Add(_ORDER, orderDict);
}
Dictionary<string, object> aggDict = new Dictionary<string, object>();
aggDict.Add(AggregationTypeEnum.Histogram.ToString(), fieldDict);
Dictionary<string, object> subAggsDict = agg.SerializeSubAggregations();
if (subAggsDict != null)
{
aggDict.Add(BucketAggregationBase._SUB_AGGREGATIONS, subAggsDict);
}
Dictionary<string, object> aggNameDict = new Dictionary<string, object>();
aggNameDict.Add(agg.Name, aggDict);
serializer.Serialize(writer, aggNameDict);
}
示例5: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is CompletionSuggester))
throw new SerializeTypeException<CompletionSuggester>();
CompletionSuggester suggestor = value as CompletionSuggester;
Dictionary<string, object> compDict = new Dictionary<string, object>();
compDict.AddObject(SuggestSerializer._FIELD, suggestor.Field);
compDict.AddObject(SuggestSerializer._SIZE, suggestor.Size, SuggestSerializer._SIZE_DEFAULT);
if (suggestor.Fuzzy != null)
{
Dictionary<string, object> fuzzyDict = new Dictionary<string, object>();
fuzzyDict.AddObject(_FUZZINESS, suggestor.Fuzzy.Fuzziness, _FUZZINESS_DEFAULT);
fuzzyDict.AddObject(_IS_UNICODE_AWARE, suggestor.Fuzzy.IsUnicodeAware, _IS_UNICODE_AWARE_DEFAULT);
fuzzyDict.AddObject(_MINIMUM_LENGTH, suggestor.Fuzzy.MinimumLength, _MINIMUM_LENGTH_DEFAULT);
fuzzyDict.AddObject(_PREFIX_LENGTH, suggestor.Fuzzy.PrefixLength, _PREFIX_LENGTH_DEFAULT);
fuzzyDict.AddObject(_TRANSPOSITIONS, suggestor.Fuzzy.Transpositions, _TRANSPOSITIONS_DEFAULT);
compDict.Add(_FUZZY, fuzzyDict);
}
Dictionary<string, object> internalDict = new Dictionary<string, object>();
internalDict.AddObject(SuggestSerializer._TEXT, suggestor.Text);
internalDict.Add(SuggestTypeEnum.Completion.ToString(), compDict);
Dictionary<string, object> suggestDict = new Dictionary<string, object>();
suggestDict.Add(suggestor.SuggestName, internalDict);
serializer.Serialize(writer, suggestDict);
}
示例6: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is CommonGramsTokenFilter))
throw new SerializeTypeException<CommonGramsTokenFilter>();
CommonGramsTokenFilter filter = value as CommonGramsTokenFilter;
Dictionary<string, object> fieldDict = new Dictionary<string, object>();
TokenFilterBase.Serialize(filter, fieldDict);
fieldDict.AddObject(_IGNORE_CASE, filter.IgnoreCase, CommonGramsTokenFilter._IGNORE_CASE_DEFAULT);
fieldDict.AddObject(_QUERY_MODE, filter.QueryMode, CommonGramsTokenFilter._QUERY_MODE_DEFAULT);
if (filter.CommonWords != null && filter.CommonWords.Any(x => !string.IsNullOrWhiteSpace(x)))
{
fieldDict.AddObject(_COMMON_WORDS, filter.CommonWords);
}
else
{
fieldDict.AddObject(_COMMON_WORDS_PATH, filter.CommonWordsPath);
}
Dictionary<string, object> filterDict = new Dictionary<string, object>();
filterDict.Add(filter.Name, fieldDict);
serializer.Serialize(writer, filterDict);
}
示例7: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is GeoHashGridAggregate))
throw new SerializeTypeException<GeoHashGridAggregate>();
GeoHashGridAggregate agg = value as GeoHashGridAggregate;
Dictionary<string, object> fieldDict = new Dictionary<string, object>();
fieldDict.AddObject(_FIELD, agg.Field);
fieldDict.AddObject(_PRECISION, agg.Precision, _PRECISION_DEFAULT);
fieldDict.AddObject(_SIZE, agg.Size, _SIZE_DEFAULT);
fieldDict.AddObject(_SHARD_SIZE, agg.ShardSize, agg.Size);
Dictionary<string, object> aggDict = new Dictionary<string, object>();
aggDict.Add(AggregationTypeEnum.GeoHashGrid.ToString(), fieldDict);
Dictionary<string, object> subAggsDict = agg.SerializeSubAggregations();
if (subAggsDict != null)
{
aggDict.Add(BucketAggregationBase._SUB_AGGREGATIONS, subAggsDict);
}
Dictionary<string, object> aggNameDict = new Dictionary<string, object>();
aggNameDict.Add(agg.Name, aggDict);
serializer.Serialize(writer, aggNameDict);
}
示例8: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is SimpleQueryStringQuery))
throw new SerializeTypeException<SimpleQueryStringQuery>();
SimpleQueryStringQuery query = value as SimpleQueryStringQuery;
Dictionary<string, object> fieldDict = new Dictionary<string, object>();
fieldDict.AddObject(_FIELDS, query.Fields);
fieldDict.Add(_QUERY, query.Query);
fieldDict.AddObject(_ANALYZER, query.Analyzer);
fieldDict.AddObject(_DEFAULT_OPERATOR, query.DefaultOperator.ToString(), _DEFAULT_OPERATOR_DEFAULT.ToString());
if (query.ParsingFeatureFlags != null && query.ParsingFeatureFlags.Any(x => x != null))
{
string defaultValue = string.Join(_FLAG_DELIMITER, _FLAGS_DEFAULT.Select(x => x.ToString()));
string flagsValue = string.Join(_FLAG_DELIMITER, query.ParsingFeatureFlags.Where(x => x != null).Select(x => x.ToString()));
fieldDict.AddObject(_FLAGS, flagsValue, defaultValue);
}
fieldDict.AddObject(QuerySerializer._QUERY_NAME, query.QueryName);
Dictionary<string, object> queryDict = new Dictionary<string,object>();
queryDict.Add(QueryTypeEnum.SimpleQueryString.ToString(), fieldDict);
serializer.Serialize(writer, queryDict);
}
示例9: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is SnowballAnalyzer))
throw new SerializeTypeException<SnowballAnalyzer>();
SnowballAnalyzer analyzer = value as SnowballAnalyzer;
Dictionary<string, object> fieldDict = new Dictionary<string, object>();
AnalyzerBase.Serialize(analyzer, fieldDict);
fieldDict.AddObject(_LANGUAGE, analyzer.Language.ToString(), SnowballAnalyzer._LANGUAGE_DEFAULT.ToString());
if (analyzer.Stopwords != null)
{
if (analyzer.Stopwords == new List<string>() || analyzer.Stopwords.All(x => string.IsNullOrWhiteSpace(x)))
fieldDict.Add(_STOPWORDS, SnowballAnalyzer._EMPTY_STOPWORDS_DEFAULT);
else
fieldDict.Add(_STOPWORDS, analyzer.Stopwords);
}
fieldDict.AddObject(_STOPWORDS_PATH, analyzer.StopwordsPath);
Dictionary<string, object> analyzerDict = new Dictionary<string, object>();
analyzerDict.Add(analyzer.Name, fieldDict);
serializer.Serialize(writer, analyzerDict);
}
示例10: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is GeoDistanceAggregate))
throw new SerializeTypeException<GeoDistanceAggregate>();
GeoDistanceAggregate agg = value as GeoDistanceAggregate;
Dictionary<string, object> fieldDict = new Dictionary<string, object>();
fieldDict.AddObject(_FIELD, agg.Field);
fieldDict.AddObject(_ORIGIN, agg.OriginPoint);
fieldDict.AddObject(_UNIT, agg.Unit.ToString(), _UNIT_DEFAULT.ToString());
fieldDict.AddObject(_DISTANCE_TYPE, agg.DistanceComputeType.ToString(), _DISTANCE_TYPE_DEFAULT.ToString());
fieldDict.AddObject(_RANGES, agg.Ranges.Select(x => SerializeRangeBucket(x)));
Dictionary<string, object> aggDict = new Dictionary<string, object>();
aggDict.Add(AggregationTypeEnum.GeoDistance.ToString(), fieldDict);
Dictionary<string, object> subAggsDict = agg.SerializeSubAggregations();
if (subAggsDict != null)
{
aggDict.Add(BucketAggregationBase._SUB_AGGREGATIONS, subAggsDict);
}
Dictionary<string, object> aggNameDict = new Dictionary<string, object>();
aggNameDict.Add(agg.Name, aggDict);
serializer.Serialize(writer, aggNameDict);
}
示例11: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is ConstantScoreQueryBase))
throw new SerializeTypeException<ConstantScoreQueryBase>();
ConstantScoreQueryBase query = value as ConstantScoreQueryBase;
Dictionary<string, object> constantDict = new Dictionary<string, object>();
Dictionary<string, object> internalDict = new Dictionary<string, object>();
if (value is ConstantScoreQuery)
{
internalDict.Add(_QUERY, query.SearchPiece);
}
else if (value is ConstantScoreFilter)
{
internalDict.Add(_FILTER, query.SearchPiece);
}
else
{
throw new Exception("Serialization value is not a ConstantScoreQuery or ConstantScoreFilter.");
}
internalDict.AddObject(QuerySerializer._BOOST, query.Boost, QuerySerializer._BOOST_DEFAULT);
internalDict.AddObject(QuerySerializer._QUERY_NAME, query.QueryName);
constantDict.Add(_CONSTANT_SCORE, internalDict);
serializer.Serialize(writer, constantDict);
}
示例12: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is PercentilesAggregate))
throw new SerializeTypeException<PercentilesAggregate>();
PercentilesAggregate agg = value as PercentilesAggregate;
Dictionary<string, object> fieldDict = new Dictionary<string, object>();
fieldDict.AddObject(_FIELD, agg.Field);
agg.Script.Serialize(fieldDict);
string defaultPercents = JsonConvert.SerializeObject(PercentilesAggregate._PERCENT_BUCKETS_DEFAULT);
string actualPercents = JsonConvert.SerializeObject(agg.PercentBuckets);
if (actualPercents != defaultPercents)
fieldDict.AddObject(_PERCENTS, agg.PercentBuckets);
fieldDict.AddObject(_COMPRESSION, agg.Compression, PercentilesAggregate._COMPRESSION_DEFAULT);
Dictionary<string, object> aggDict = new Dictionary<string, object>();
aggDict.Add(AggregationTypeEnum.Percentiles.ToString(), fieldDict);
Dictionary<string, object> subAggsDict = agg.SerializeSubAggregations();
if (subAggsDict != null)
{
aggDict.Add(BucketAggregationBase._SUB_AGGREGATIONS, subAggsDict);
}
Dictionary<string, object> aggNameDict = new Dictionary<string, object>();
aggNameDict.Add(agg.Name, aggDict);
serializer.Serialize(writer, aggNameDict);
}
示例13: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is GeoPointProperty))
throw new SerializeTypeException<GeoPointProperty>();
GeoPointProperty prop = value as GeoPointProperty;
Dictionary<string, object> fieldDict = new Dictionary<string, object>();
DocumentPropertyBase.Serialize(prop, fieldDict);
fieldDict.AddObject(_INDEX_LAT_LON, prop.IndexLatLon, GeoPointProperty._INDEX_LAT_LON_DEFAULT);
fieldDict.AddObject(_INDEX_GEO_HASH, prop.IndexGeoHash, GeoPointProperty._INDEX_GEO_HASH_DEFAULT);
fieldDict.AddObject(_INDEX_GEO_HASH_PREFIX, prop.IndexGeoHashPrefix, GeoPointProperty._INDEX_GEO_HASH_PREFIX_DEFAULT);
fieldDict.AddObject(_GEO_HASH_PRECISION, prop.GeoHashPrecision, GeoPointProperty._GEO_HASH_PRECISION_DEFAULT);
fieldDict.AddObject(_VALIDATE, prop.Validate, GeoPointProperty._VALIDATE_DEFAULT);
fieldDict.AddObject(_VALIDATE_LAT, prop.ValidateLatitude, GeoPointProperty._VALIDATE_LAT_DEFAULT);
fieldDict.AddObject(_VALIDATE_LON, prop.ValidateLongitude, GeoPointProperty._VALIDATE_LON_DEFAULT);
fieldDict.AddObject(_NORMALIZE, prop.Normalize, GeoPointProperty._NORMALIZE_DEFAULT);
fieldDict.AddObject(_NORMALIZE_LAT, prop.NormalizeLatitude, GeoPointProperty._NORMALIZE_LAT_DEFAULT);
fieldDict.AddObject(_NORMALIZE_LON, prop.NormalizeLongitude, GeoPointProperty._NORMALIZE_LON_DEFAULT);
if (prop.CompressionPrecision != null && prop.CompressionPrecision.ToString() != GeoPointProperty._COMPRESSION_PRECISION_DEFAULT.ToString())
{
Dictionary<string, object> fieldDataDict = new Dictionary<string, object>();
fieldDataDict.Add(_FORMAT, GeoPointProperty._FIELD_DATA_FORMAT_DEFAULT);
fieldDataDict.Add(_PRECISION, prop.CompressionPrecision);
fieldDict.Add(_FIELD_DATA, fieldDataDict);
}
Dictionary<string, object> propDict = new Dictionary<string, object>();
propDict.Add(prop.Name, fieldDict);
serializer.Serialize(writer, propDict);
}
示例14: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is TermQuery))
throw new SerializeTypeException<TermQuery>();
TermQuery query = value as TermQuery;
Dictionary<string, object> fieldDict = new Dictionary<string, object>();
if (query.Boost != QuerySerializer._BOOST_DEFAULT)
{
Dictionary<string, object> internalDict = new Dictionary<string, object>();
internalDict.Add(_VALUE, query.Value);
internalDict.AddObject(QuerySerializer._BOOST, query.Boost, QuerySerializer._BOOST_DEFAULT);
internalDict.AddObject(QuerySerializer._QUERY_NAME, query.QueryName);
fieldDict.Add(query.Field, internalDict);
}
else
{
fieldDict.Add(query.Field, query.Value);
}
Dictionary<string, object> queryDict = new Dictionary<string, object>();
queryDict.Add(QueryTypeEnum.Term.ToString(), fieldDict);
serializer.Serialize(writer, queryDict);
}
示例15: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!(value is PatternAnalyzer))
throw new SerializeTypeException<PatternAnalyzer>();
PatternAnalyzer analyzer = value as PatternAnalyzer;
Dictionary<string, object> fieldDict = new Dictionary<string, object>();
AnalyzerBase.Serialize(analyzer, fieldDict);
fieldDict.AddObject(_LOWERCASE, analyzer.Lowercase, PatternAnalyzer._LOWERCASE_DEFAULT);
fieldDict.AddObject(_PATTERN, analyzer.Pattern, PatternAnalyzer._REGEX_PATTERN_DEFAULT);
if (analyzer.Flags != null && analyzer.Flags.Any(x => x != null))
{
fieldDict.AddObject(_FLAGS, string.Join(_FLAG_DELIMITER, analyzer.Flags.Where(x => x != null).Select(x => x.ToString())));
}
if (analyzer.Stopwords != null && analyzer.Stopwords.Any(x => !string.IsNullOrWhiteSpace(x)))
{
fieldDict.AddObject(_STOPWORDS, analyzer.Stopwords);
}
Dictionary<string, object> analyzerDict = new Dictionary<string, object>();
analyzerDict.Add(analyzer.Name, fieldDict);
serializer.Serialize(writer, analyzerDict);
}