当前位置: 首页>>代码示例>>C#>>正文


C# Dev2JsonSerializer.Deserialize方法代码示例

本文整理汇总了C#中Dev2JsonSerializer.Deserialize方法的典型用法代码示例。如果您正苦于以下问题:C# Dev2JsonSerializer.Deserialize方法的具体用法?C# Dev2JsonSerializer.Deserialize怎么用?C# Dev2JsonSerializer.Deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dev2JsonSerializer的用法示例。


在下文中一共展示了Dev2JsonSerializer.Deserialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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;
            }
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:30,代码来源:GetScheduledResourceHistory.cs

示例2: 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)
        {
            var serializer = new Dev2JsonSerializer();
            try
            {
                var res = new ExecuteMessage { HasError = false };
                if (values == null)
                {
                    throw new ArgumentNullException("values");
                }
                if (!values.ContainsKey("versionInfo"))
                {
// ReSharper disable NotResolvedInText
                    throw new ArgumentNullException("No resourceId was found in the incoming data");
// ReSharper restore NotResolvedInText
                }
               
                var version = serializer.Deserialize<IVersionInfo>(values["versionInfo"]);
                Dev2Logger.Log.Info("Get Version. " + version);
                var result = ServerVersionRepo.GetVersion(version);
                res.Message.Append(result);
                Dev2XamlCleaner dev2XamlCleaner = new Dev2XamlCleaner();
                res.Message = dev2XamlCleaner.StripNaughtyNamespaces(res.Message);


                return serializer.SerializeToBuilder(res);

            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error(e);
                IExplorerRepositoryResult error = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
                return serializer.SerializeToBuilder(error);
            }
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:41,代码来源:GetVersion.cs

示例3: 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);
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:26,代码来源:DeleteItemService.cs

示例4: 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);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:32,代码来源:MoveItemService.cs

示例5: 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());
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:25,代码来源:JsonSerializerTest.cs

示例6: 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);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:25,代码来源:DeleteScheduledResource.cs

示例7: Execute

        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            if(values == null)
            {
                throw new InvalidDataException("Empty values passed.");
            }

            StringBuilder settingsJson;
            values.TryGetValue("Settings", out settingsJson);
            if(settingsJson == null || settingsJson.Length == 0)
            {
                throw new InvalidDataException("Error: Unable to parse values.");
            }
            var serializer = new Dev2JsonSerializer();
            var result = new ExecuteMessage { HasError = false, Message = new StringBuilder() };
            try
            {
                var settings = serializer.Deserialize<Settings>(settingsJson.ToString());
                WriteSecuritySettings(theWorkspace, settings, result);
                WriteLoggingSettings(theWorkspace, settings, result);
            }
            catch (Exception ex)
            {
                Dev2Logger.Log.Error("Error writing settings.", ex);
                result.HasError = true;
                result.Message.AppendLine("Error writing settings.");
            }
            return serializer.SerializeToBuilder(result);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:29,代码来源:SettingsWrite.cs

示例8: GetVersions_Execute_ExpectException_NoArgs

 public void GetVersions_Execute_ExpectException_NoArgs()
 {
     //------------Setup for test--------------------------
     var getVersions = new GetVersion();
     Dev2JsonSerializer serialiser = new Dev2JsonSerializer();
     //------------Execute Test---------------------------
     var ax = getVersions.Execute(new Dictionary<string, StringBuilder>(), new Workspace(Guid.NewGuid()));
     Assert.AreEqual(ExecStatus.Fail, serialiser.Deserialize<ExplorerRepositoryResult>(ax).Status);
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:9,代码来源:GetVersionTest.cs

示例9: ReadPermissions

 protected override List<WindowsGroupPermission> ReadPermissions()
 {
     var reader = new SecurityRead();
     var result = reader.Execute(null, null);
     var serializer = new Dev2JsonSerializer();
     SecuritySettingsTO securitySettingsTO = serializer.Deserialize<SecuritySettingsTO>(result);
     TimeOutPeriod = securitySettingsTO.CacheTimeout;
     return securitySettingsTO.WindowsGroupPermissions;
 }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:9,代码来源:ServerSecurityService.cs

示例10: GetVersions_Execute_NullValuesParameter_ErrorResult

 public void GetVersions_Execute_NullValuesParameter_ErrorResult()
 {
     //------------Setup for test--------------------------
     var getVersions = new GetVersions();
     var serializer = new Dev2JsonSerializer();
     //------------Execute Test---------------------------
     StringBuilder jsonResult = getVersions.Execute(null, null);
     IExplorerRepositoryResult result = serializer.Deserialize<IExplorerRepositoryResult>(jsonResult);
     //------------Assert Results-------------------------
     Assert.AreEqual(ExecStatus.Fail, result.Status);
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:11,代码来源:GetVersionsTest.cs

示例11: GetVersions_Execute_NullValuesParameter_ErrorResult

 public void GetVersions_Execute_NullValuesParameter_ErrorResult()
 {
     //------------Setup for test--------------------------
     var getVersions = new GetServerVersion();
     var serializer = new Dev2JsonSerializer();
     //------------Execute Test---------------------------
     StringBuilder jsonResult = getVersions.Execute(null, null);
     var result = serializer.Deserialize<string>(jsonResult);
     //------------Assert Results-------------------------
     Assert.IsNotNull(result);
 }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:11,代码来源:GetServerVersionTest.cs

示例12: MoveItem_Execute_NullValues_ErrorResult

 public void MoveItem_Execute_NullValues_ErrorResult()
 {
     //------------Setup for test--------------------------
     var MoveItemService = new MoveItemService();
     var serializer = new Dev2JsonSerializer();
     //------------Execute Test---------------------------
     StringBuilder jsonResult = MoveItemService.Execute(null, null);
     IExplorerRepositoryResult result = serializer.Deserialize<IExplorerRepositoryResult>(jsonResult);
     //------------Assert Results-------------------------
     Assert.AreEqual(ExecStatus.Fail, result.Status);
 }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:11,代码来源:MoveItemService.cs

示例13: MoveItem_Execute_ItemToRenameNotInValues_ErrorResult

 public void MoveItem_Execute_ItemToRenameNotInValues_ErrorResult()
 {
     //------------Setup for test--------------------------
     var values = new Dictionary<string, StringBuilder> { { "item", new StringBuilder() } };
     var MoveItemService = new MoveItemService();
     var serializer = new Dev2JsonSerializer();
     //------------Execute Test---------------------------
     StringBuilder jsonResult = MoveItemService.Execute(values, null);
     IExplorerRepositoryResult result = serializer.Deserialize<IExplorerRepositoryResult>(jsonResult);
     //------------Assert Results-------------------------
     Assert.AreEqual(ExecStatus.Fail, result.Status);
 }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:12,代码来源:MoveItemService.cs

示例14: Execute

        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var result = new ExecuteMessage { HasError = false };
            StringBuilder tmp;
            values.TryGetValue("Resource", out tmp);
            var serializer = new Dev2JsonSerializer();
            try
            {
                if(tmp != null)
                {

                    var res = serializer.Deserialize<IScheduledResource>(tmp);
                    Dev2Logger.Log.Info("Save Scheduled Resource. Scheduled Resource:" +res);
                    using(var model = SchedulerFactory.CreateModel(GlobalConstants.SchedulerFolderId, SecurityWrapper))
                    {
                        StringBuilder userName;
                        StringBuilder password;

                        values.TryGetValue("UserName", out userName);
                        values.TryGetValue("Password", out password);
                        if(userName == null || password == null)
                        {
                            result.Message.Append("No UserName or password provided");
                            result.HasError = true;
                        }
                        else
                        {
                            StringBuilder previousTask;
                            values.TryGetValue("PreviousResource", out previousTask);

                            model.Save(res, userName.ToString(), password.ToString());
                            if(previousTask != null && !String.IsNullOrEmpty(previousTask.ToString()) && previousTask.ToString() != res.Name)
                            {
                                model.DeleteSchedule(new ScheduledResource(previousTask.ToString(), SchedulerStatus.Disabled, DateTime.MaxValue, null, null));
                            }
                        }
                    }
                }
                else
                {
                    result.Message.Append("No Resource Selected");
                    result.HasError = true;
                }
            }
            catch(Exception e)
            {
                Dev2Logger.Log.Error(e);
                result.Message.Append(string.Format("Error while saving: {0}", e.Message.Remove(e.Message.IndexOf('.'))));
                result.HasError = true;
            }
            return serializer.SerializeToBuilder(result);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:52,代码来源:SaveScheduledResource.cs

示例15: RolbackTo_Execute_InvalidParams

        public void RolbackTo_Execute_InvalidParams()
        {
            //------------Setup for test--------------------------
            var rolbackTo = new RollbackTo();
            var serializer = new Dev2JsonSerializer();
            var ws = new Mock<IWorkspace>();
            //------------Execute Test---------------------------
            var ax = rolbackTo.Execute(new Dictionary<string, StringBuilder>(), ws.Object);

            //------------Assert Results-------------------------
            var des =serializer.Deserialize<ExecuteMessage>(ax);
            Assert.AreEqual(des.HasError,true);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:13,代码来源:RollBackToTest.cs


注:本文中的Dev2JsonSerializer.Deserialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。