本文整理汇总了C#中ISerializer.ToJson方法的典型用法代码示例。如果您正苦于以下问题:C# ISerializer.ToJson方法的具体用法?C# ISerializer.ToJson怎么用?C# ISerializer.ToJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISerializer
的用法示例。
在下文中一共展示了ISerializer.ToJson方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TrackedEntity
public TrackedEntity(object id, ISerializer serializer, Type documentType, object document)
{
_serializer = serializer;
Id = id;
DocumentType = documentType;
Document = document;
_json = _serializer.ToJson(document);
}
示例2: QueryFromICollectionContains
static IWhereFragment QueryFromICollectionContains(MethodCallExpression expression, string fieldPath, ISerializer serializer)
{
var constant = expression.Arguments[0] as ConstantExpression;
var kvp = constant.Value; // is kvp<string, unknown>
var kvpType = kvp.GetType();
var key = kvpType.GetProperty("Key").GetValue(kvp);
var value = kvpType.GetProperty("Value").GetValue(kvp);
var dictType = typeof(Dictionary<,>).MakeGenericType(kvpType.GenericTypeArguments[0], kvpType.GenericTypeArguments[1]);
var dict = dictType.GetConstructors()[0].Invoke(null);
dictType.GetMethod("Add").Invoke(dict, new[] { key, value });
var json = serializer.ToJson(dict);
return new CustomizableWhereFragment($"{fieldPath} @> ?", "?", Tuple.Create<object, NpgsqlTypes.NpgsqlDbType?>(json, NpgsqlTypes.NpgsqlDbType.Jsonb));
}
示例3: TrackedEntity
public TrackedEntity(object id, ISerializer serializer, Type documentType, object document, string json)
{
_serializer = serializer;
Id = id;
DocumentType = documentType;
Document = document;
if (json != null && document == null)
{
Document = _serializer.FromJson(documentType, json);
}
else if (document != null)
{
_json = _serializer.ToJson(document);
}
}
示例4: EventParameters
public EventParameters(ISerializer serializer, IEventMigrationHierarchyManager eventMigrationHierarchyManager)
{
_serializer = serializer;
_eventMigrationHierarchyManager = eventMigrationHierarchyManager;
_eventProperties = typeof(IEvent).GetProperties(BindingFlags.Public | BindingFlags.Instance);
Parameters = new[]
{
new EventParameter(COMMANDCONTEXT,OracleDbType.Raw,16),
new EventParameter(NAME,OracleDbType.NVarchar2,512),
new MetaDataEventParameter(LOGICALNAME, OracleDbType.NVarchar2, 512, m => m.LogicalName),
new EventParameter(EVENTSOURCEID,OracleDbType.Raw,16),
new EventParameter(EVENTSOURCE,OracleDbType.NVarchar2,512),
new MetaDataEventParameter(GENERATION, OracleDbType.Int32, m => m.Generation),
new DataEventParameter(GetDataProperties, d => _serializer.ToJson(d,null)),
new EventParameter(CAUSEDBY,OracleDbType.NVarchar2,512),
new EventParameter(ORIGIN,OracleDbType.NVarchar2,512),
new EventParameter(OCCURED,OracleDbType.Date),
new EventParameter(VERSION,OracleDbType.Double),
new IdEventParameter()
};
}