本文整理汇总了C#中Dev2JsonSerializer.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# Dev2JsonSerializer.Serialize方法的具体用法?C# Dev2JsonSerializer.Serialize怎么用?C# Dev2JsonSerializer.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dev2JsonSerializer
的用法示例。
在下文中一共展示了Dev2JsonSerializer.Serialize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResourceTypeConvertor_ConvertToJson_EnumAsString_ExpectConvert
public void ResourceTypeConvertor_ConvertToJson_EnumAsString_ExpectConvert()
{
//------------Setup for test--------------------------
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
var data = serializer.Serialize(new ServerExplorerItem("a", Guid.Empty, ResourceType.DbService, null, Permissions.Administrator, "bob"));
//------------Execute Test---------------------------
Assert.IsTrue(data.Contains("DbService"));
//------------Assert Results-------------------------
}
示例2: ResourceTypeConvertor_ConvertToJson_EnumAsString_Deserialise_ExpectConvert_OldServer_IsServer
public void ResourceTypeConvertor_ConvertToJson_EnumAsString_Deserialise_ExpectConvert_OldServer_IsServer()
{
//------------Setup for test--------------------------
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
var data = serializer.Serialize(new ServerExplorerItem("a", Guid.Empty, ResourceType.DbService, null, Permissions.Administrator, "bob"));
//------------Execute Test---------------------------
Assert.IsTrue(data.Contains("DbService"));
data = data.Replace(@"""ResourceType"": ""DbService""", @"""ResourceType"": ""1024""");
var item = (ServerExplorerItem)serializer.Deserialize(data, typeof(ServerExplorerItem));
Assert.AreEqual(ResourceType.Server, item.ResourceType);
//------------Assert Results-------------------------
}
示例3: RemoteDebugItemParser_Parse_WhenValidJsonList_ExpectItems
// ReSharper disable InconsistentNaming
public void RemoteDebugItemParser_Parse_WhenValidJsonList_ExpectItems()
// ReSharper restore InconsistentNaming
{
//------------Setup for test--------------------------
List<IDebugState> items = new List<IDebugState>
{
new DebugState {ActivityType = ActivityType.Workflow, ClientID = Guid.Empty, DisplayName = "DebugState"}
};
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
var data = serializer.Serialize(items);
//------------Execute Test---------------------------
var result = RemoteDebugItemParser.ParseItems(data);
//------------Assert Results-------------------------
Assert.AreEqual(1, result.Count);
Assert.AreEqual("DebugState", result[0].DisplayName);
Assert.AreEqual(ActivityType.Workflow, result[0].ActivityType);
}
示例4: Execute
/// <summary>
/// Executes the service
/// </summary>
/// <param name="values">The values.</param>
/// <param name="theWorkspace">The workspace.</param>
/// <returns></returns>
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
try
{
string directory = null;
StringBuilder result = new StringBuilder();
if(values == null)
{
throw new InvalidDataContractException("No parameter values provided.");
}
StringBuilder tmp;
values.TryGetValue("Directory", out tmp);
if(tmp != null)
{
directory = tmp.ToString();
}
if(String.IsNullOrEmpty(directory))
{
throw new InvalidDataContractException("No value provided for Directory parameter.");
}
Dev2Logger.Log.Info("Get Directories Relative to Server. "+directory);
result.Append("<JSON>");
var explorerItem = ServerExplorerRepo.Load(ResourceType.Folder, string.Empty);
var jsonTreeNode = new JsonTreeNode(explorerItem);
var serializer = new Dev2JsonSerializer();
var directoryInfoAsJson = serializer.Serialize(jsonTreeNode);
result.Append(directoryInfoAsJson);
result.Append("</JSON>");
return result;
}
catch (Exception e)
{
Dev2Logger.Log.Error(e);
throw;
}
}
示例5: SetupConnectionWithCompileMessageList
static Mock<IEnvironmentConnection> SetupConnectionWithCompileMessageList(List<ICompileMessageTO> compileMessageTos, List<string> deps)
{
CompileMessageList compileMessageList = new CompileMessageList { MessageList = compileMessageTos, Dependants = deps };
var jsonSer = new Dev2JsonSerializer();
string serializeObject = jsonSer.Serialize(compileMessageList);
var envConnection = new Mock<IEnvironmentConnection>();
envConnection.Setup(e => e.IsConnected).Returns(true);
envConnection.Setup(c => c.ServerEvents).Returns(new EventPublisher());
envConnection.Setup(connection => connection.ExecuteCommand(It.IsAny<StringBuilder>(), It.IsAny<Guid>())).Returns(new StringBuilder(serializeObject));
return envConnection;
}