本文整理汇总了C#中Dev2JsonSerializer类的典型用法代码示例。如果您正苦于以下问题:C# Dev2JsonSerializer类的具体用法?C# Dev2JsonSerializer怎么用?C# Dev2JsonSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Dev2JsonSerializer类属于命名空间,在下文中一共展示了Dev2JsonSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunOutput
private ExecuteMessage RunOutput(bool expectCorrectInput)
{
var esbMethod = new DeleteScheduledResource();
var factory = new Mock<IServerSchedulerFactory>();
var model = new Mock<IScheduledResourceModel>();
var ws = new Mock<IWorkspace>();
var trigger = new ScheduleTrigger(TaskState.Disabled,
new Dev2DailyTrigger(new TaskServiceConvertorFactory(), new DailyTrigger(21)),
new Dev2TaskService(new TaskServiceConvertorFactory()),
new TaskServiceConvertorFactory());
var res = new ScheduledResource("a", SchedulerStatus.Enabled, DateTime.Now, trigger, "dave");
var security = new Mock<ISecurityWrapper>();
esbMethod.SecurityWrapper = security.Object;
Dictionary<string, StringBuilder> inp = new Dictionary<string, StringBuilder>();
factory.Setup(
a =>
a.CreateModel(GlobalConstants.SchedulerFolderId, It.IsAny<ISecurityWrapper>())).Returns(model.Object);
Dev2JsonSerializer serialiser = new Dev2JsonSerializer();
if(expectCorrectInput)
{
model.Setup(a => a.DeleteSchedule(It.IsAny<ScheduledResource>())).Verifiable();
inp.Add("Resource", serialiser.SerializeToBuilder(res));
}
esbMethod.SchedulerFactory = factory.Object;
var output = esbMethod.Execute(inp, ws.Object);
if(expectCorrectInput)
model.Verify(a => a.DeleteSchedule(It.IsAny<ScheduledResource>()));
return serialiser.Deserialize<ExecuteMessage>(output);
}
示例2: JsonSerializer_Deserializer_WhenUsingStream_ExpectValidObject
public void JsonSerializer_Deserializer_WhenUsingStream_ExpectValidObject()
{
//------------Setup for test--------------------------
var theMessage =
@"Much evil soon high in hope do view. Out may few northward believing attempted. Yet timed being songs marry one defer men our. Although finished blessing do of. Consider speaking me prospect whatever if. Ten nearer rather hunted six parish indeed number. Allowance repulsive sex may contained can set suspected abilities cordially. Do part am he high rest that. So fruit to ready it being views match.
Knowledge nay estimable questions repulsive daughters boy. Solicitude gay way unaffected expression for. His mistress ladyship required off horrible disposed rejoiced. Unpleasing pianoforte unreserved as oh he unpleasant no inquietude insipidity. Advantages can discretion possession add favourable cultivated admiration far. Why rather assure how esteem end hunted nearer and before. By an truth after heard going early given he. Charmed to it excited females whether at examine. Him abilities suffering may are yet dependent.
Why end might ask civil again spoil.";
ExecuteMessage msg = new ExecuteMessage { HasError = false };
msg.SetMessage(theMessage);
StringBuilder buffer = new StringBuilder(JsonConvert.SerializeObject(msg));
//------------Execute Test---------------------------
Dev2JsonSerializer js = new Dev2JsonSerializer();
var result = js.Deserialize<ExecuteMessage>(buffer);
//------------Assert Results-------------------------
Assert.AreEqual(theMessage, result.Message.ToString());
}
示例3: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
var result = new ExecuteMessage { HasError = false };
Dev2Logger.Log.Info("Delete Scheduled Resource Service");
StringBuilder tmp;
values.TryGetValue("Resource", out tmp);
var serializer = new Dev2JsonSerializer();
if (tmp != null)
{
var res = serializer.Deserialize<IScheduledResource>(tmp);
Dev2Logger.Log.Info("Delete Scheduled Resource Service." +res);
using(var model = SchedulerFactory.CreateModel(GlobalConstants.SchedulerFolderId, SecurityWrapper))
{
model.DeleteSchedule(res);
}
}
else
{
Dev2Logger.Log.Info("Delete Scheduled Resource Service. No Resource Selected");
result.Message.Append("No Resource Selected");
result.HasError = true;
}
return serializer.SerializeToBuilder(result);
}
示例4: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
var result = new ExecuteMessage { HasError = false };
Dev2Logger.Log.Info("Find Log Directory");
try
{
var logdir = WorkflowLoggger.GetDirectoryPath(SettingsProvider.Instance.Configuration.Logging);
var cleanedDir = CleanUp(logdir);
result.Message.Append("<JSON>");
result.Message.Append(@"{""PathToSerialize"":""");
result.Message.Append(cleanedDir);
result.Message.Append(@"""}");
result.Message.Append("</JSON>");
}
catch (Exception ex)
{
Dev2Logger.Log.Error(ex);
result.Message.Append(ex.Message);
result.HasError = true;
}
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
return serializer.SerializeToBuilder(result);
}
示例5: DeleteItem
public IExplorerRepositoryResult DeleteItem(IExplorerItem itemToRename, Guid workSpaceId)
{
var controller = CommunicationControllerFactory.CreateController("DeleteItemService");
var serializer = new Dev2JsonSerializer();
controller.AddPayloadArgument("itemToDelete", serializer.SerializeToBuilder(itemToRename).ToString());
return controller.ExecuteCommand<IExplorerRepositoryResult>(Connection, workSpaceId);
}
示例6: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
var serializer = new Dev2JsonSerializer();
try
{
if (values == null)
{
throw new ArgumentNullException("values");
}
if( !values.ContainsKey("resourceId"))
{
// ReSharper disable NotResolvedInText
throw new ArgumentNullException("No resourceId was found in the incoming data");
// ReSharper restore NotResolvedInText
}
var id = Guid.Parse( values["resourceId"].ToString());
Dev2Logger.Log.Info("Get Versions. " + id);
var item = ServerVersionRepo.GetVersions(id);
return serializer.SerializeToBuilder(item);
}
catch (Exception e)
{
Dev2Logger.Log.Error(e);
IExplorerRepositoryResult error = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
return serializer.SerializeToBuilder(error);
}
}
示例7: 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)
{
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
var execMessage = new ExecuteMessage { HasError = false };
if(!values.ContainsKey("resourceId"))
{
Dev2Logger.Log.Info("Delete Version. Invalid Resource Id");
execMessage.HasError = true;
execMessage.Message = new StringBuilder( "No resourceId sent to server");
}
else if(!values.ContainsKey("versionNumber") )
{
Dev2Logger.Log.Info("Delete Version. Invalid Version number");
execMessage.HasError = true;
execMessage.Message = new StringBuilder("No versionNumber sent to server");
}
else
{
try
{
var guid = Guid.Parse(values["resourceId"].ToString());
var version = values["versionNumber"].ToString();
Dev2Logger.Log.Info(String.Format("Delete Version. ResourceId:{0} VersionNumber{1}",guid,version));
var res = ServerVersionRepo.DeleteVersion(guid,version);
execMessage.Message = serializer.SerializeToBuilder(res);
}
catch (Exception e)
{
Dev2Logger.Log.Error(String.Format("Delete Version Error."),e);
execMessage.HasError = true;
execMessage.Message = new StringBuilder( e.Message);
}
}
return serializer.SerializeToBuilder(execMessage);
}
示例8: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
IExplorerRepositoryResult item;
var serializer = new Dev2JsonSerializer();
try
{
if (values == null)
{
throw new ArgumentNullException("values");
}
StringBuilder itemToBeRenamed;
StringBuilder newPath;
if (!values.TryGetValue("itemToMove", out itemToBeRenamed))
{
throw new ArgumentException("itemToMove value not supplied.");
}
if (!values.TryGetValue("newPath", out newPath))
{
throw new ArgumentException("newName value not supplied.");
}
var itemToMove = serializer.Deserialize<ServerExplorerItem>(itemToBeRenamed);
Dev2Logger.Log.Info(String.Format("Move Item. Path:{0} NewPath:{1}", itemToBeRenamed, newPath));
item = ServerExplorerRepo.MoveItem(itemToMove, newPath.ToString(), GlobalConstants.ServerWorkspaceID);
}
catch (Exception e)
{
Dev2Logger.Log.Error(e);
item = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
}
return serializer.SerializeToBuilder(item);
}
示例9: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
string type = null;
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
StringBuilder tmp;
values.TryGetValue("ResourceID", out tmp);
Guid resourceId = Guid.Empty;
if(tmp != null)
{
if(!Guid.TryParse(tmp.ToString(), out resourceId))
{
Dev2Logger.Log.Info("Delete Resource Service. Invalid Parameter Guid:");
var failureResult = new ExecuteMessage { HasError = true };
failureResult.SetMessage("Invalid guid passed for ResourceID");
return serializer.SerializeToBuilder(failureResult);
}
}
values.TryGetValue("ResourceType", out tmp);
if(tmp != null)
{
type = tmp.ToString();
}
Dev2Logger.Log.Info("Delete Resource Service. Resource:" + resourceId);
// BUG 7850 - TWR - 2013.03.11 - ResourceCatalog refactor
var msg = ResourceCatalog.Instance.DeleteResource(theWorkspace.ID, resourceId, type);
var result = new ExecuteMessage { HasError = false };
result.SetMessage(msg.Message);
result.HasError = msg.Status != ExecStatus.Success;
return serializer.SerializeToBuilder(result);
}
示例10: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
try
{
Dev2Logger.Log.Info("Fetch Server Log Started");
var result = new ExecuteMessage { HasError = false };
if (File.Exists(_serverLogPath))
{
var fileStream = File.Open(_serverLogPath, FileMode.Open, FileAccess.Read,FileShare.Read);
using (var streamReader = new StreamReader(fileStream))
{
while(!streamReader.EndOfStream)
{
result.Message.Append(streamReader.ReadLine());
}
}
}
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
return serializer.SerializeToBuilder(result);
}
catch (Exception err)
{
Dev2Logger.Log.Error("Fetch Server Log Error", err);
throw;
}
}
示例11: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
IExplorerRepositoryResult item;
try
{
if(values == null)
{
throw new ArgumentNullException("values");
}
if(theWorkspace == null)
{
throw new ArgumentNullException("theWorkspace");
}
StringBuilder path;
if(!values.TryGetValue("path", out path))
{
throw new ArgumentException("path value not supplied.");
}
StringBuilder newPath;
if(!values.TryGetValue("newPath", out newPath))
{
throw new ArgumentException("newPath value not supplied.");
}
Dev2Logger.Log.Info(String.Format("Reanme Folder. Path:{0} NewPath:{1}",path,newPath));
item = ServerExplorerRepository.Instance.RenameFolder(path.ToString(), newPath.ToString(), theWorkspace.ID);
}
catch(Exception e)
{
Dev2Logger.Log.Error(e);
item = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
}
var serializer = new Dev2JsonSerializer();
return serializer.SerializeToBuilder(item);
}
示例12: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
IExplorerRepositoryResult item;
var serializer = new Dev2JsonSerializer();
try
{
if(values == null)
{
throw new ArgumentNullException("values");
}
StringBuilder itemBeingDeleted;
if(!values.TryGetValue("itemToDelete", out itemBeingDeleted))
{
throw new ArgumentException("itemToDelete value not supplied.");
}
var itemToDelete = serializer.Deserialize<ServerExplorerItem>(itemBeingDeleted);
Dev2Logger.Log.Info("Delete Item Service."+itemToDelete);
item = ServerExplorerRepo.DeleteItem(itemToDelete, GlobalConstants.ServerWorkspaceID);
}
catch(Exception e)
{
Dev2Logger.Log.Error("Delete Item Error" ,e);
item = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
}
return serializer.SerializeToBuilder(item);
}
示例13: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
try
{
string guidCsv = string.Empty;
string type = null;
StringBuilder tmp;
values.TryGetValue("GuidCsv", out tmp);
if(tmp != null)
{
guidCsv = tmp.ToString();
}
values.TryGetValue("ResourceType", out tmp);
if(tmp != null)
{
type = tmp.ToString();
}
Dev2Logger.Log.Info("Find Resource By Id. "+guidCsv);
// BUG 7850 - TWR - 2013.03.11 - ResourceCatalog refactor
var resources = ResourceCatalog.Instance.GetResourceList(theWorkspace.ID, guidCsv, type);
IList<SerializableResource> resourceList = resources.Select(new FindResourceHelper().SerializeResourceForStudio).ToList();
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
return serializer.SerializeToBuilder(resourceList);
}
catch (Exception err)
{
Dev2Logger.Log.Error(err);
throw;
}
}
示例14: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, Workspaces.IWorkspace theWorkspace)
{
try
{
StringBuilder tmp;
values.TryGetValue("Resource", out tmp);
var serializer = new Dev2JsonSerializer();
if (tmp != null)
{
var res = serializer.Deserialize<IScheduledResource>(tmp);
Dev2Logger.Log.Info("Get Scheduled History. " +tmp);
IList<IResourceHistory> resources;
using (var model = SchedulerFactory.CreateModel(GlobalConstants.SchedulerFolderId, SecurityWrapper))
{
resources = model.CreateHistory(res);
}
return serializer.SerializeToBuilder(resources);
}
Dev2Logger.Log.Debug("No resource Provided");
return serializer.SerializeToBuilder(new List<IResourceHistory>());
}
catch (Exception e)
{
Dev2Logger.Log.Error(e);
throw;
}
}
示例15: SharepointServerSourceViewModel
public SharepointServerSourceViewModel(SharepointServerSource serverSource, IEnvironmentModel environment)
{
IsLoading = false;
TestComplete = false;
_environment = environment;
ServerName = "";
AuthenticationType = AuthenticationType.Windows;
IsWindows = true;
SaveCommand = new RelayCommand(o =>
{
serverSource.DialogResult = true;
serverSource.Close();
}, o => TestComplete);
CancelCommand = new RelayCommand(o =>
{
serverSource.DialogResult = false;
serverSource.Close();
});
TestCommand = new RelayCommand(o =>
{
IsLoading = true;
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
var source = CreateSharepointServerSource();
var comsController = new CommunicationController { ServiceName = "TestSharepointServerService" };
comsController.AddPayloadArgument("SharepointServer", serializer.SerializeToBuilder(source));
TestResult = comsController.ExecuteCommand<string>(environment.Connection, GlobalConstants.ServerWorkspaceID);
IsLoading = false;
}, o => !TestComplete);
}