/// <summary> /// Serializes the specified model. /// </summary> /// <param name="model">The model.</param> /// <param name="context">The context.</param> public virtual void Serialize(ModelBase model, TSerializationContext context) { Argument.IsNotNull("model", model); Argument.IsNotNull("context", context); using (var finalContext = GetContext(model, context, SerializationContextMode.Serialization)) { var serializerModifiers = SerializationManager.GetSerializerModifiers(finalContext.ModelType); Log.Debug("Using '{0}' serializer modifiers to deserialize type '{1}'", serializerModifiers.Length, finalContext.ModelType.GetSafeFullName()); var serializingEventArgs = new SerializationEventArgs(finalContext); Serializing.SafeInvoke(this, serializingEventArgs); foreach (var serializerModifier in serializerModifiers) { serializerModifier.OnSerializing(finalContext, model); } BeforeSerialization(finalContext); var members = GetSerializableMembers(model); SerializeMembers(finalContext, members); AfterSerialization(finalContext); foreach (var serializerModifier in serializerModifiers) { serializerModifier.OnSerialized(finalContext, model); } Serialized.SafeInvoke(this, serializingEventArgs); } }
private void getAndVerifyOrderProjections(Serialized client) { Debug.WriteLine("Getting single projections: " + ordersProjections); // Verify count var orderCount = client.GetSingleProjectionCount(ordersProjections); Assert.AreEqual(2, orderCount.Count); // Verify list var orders = client.ListSingleProjections(ordersProjections); Assert.AreEqual(false, orders.HasMore); Assert.AreEqual(2, orders.ProjectionsProperty.Count); // First var order = client.GetSingleProjection(ordersProjections, orderId1); Assert.AreEqual(orderId1, Guid.Parse(order.ProjectionId)); var projectionData = (JObject)order.Data; Assert.AreEqual(12345, projectionData["orderAmount"]); Assert.AreEqual("PAID", projectionData["status"]); // Second order = client.GetSingleProjection(ordersProjections, orderId2); Assert.AreEqual(orderId2, Guid.Parse(order.ProjectionId)); projectionData = (JObject)order.Data; Assert.AreEqual(67890, projectionData["orderAmount"]); Assert.AreEqual("PLACED", projectionData["status"]); }
async public Task SetSerialize(Serialized value) { if (value == null) { return; } if (this.FeatureDataset == null) { IFeatureDataset dataset = PlugInManager.Create(new Guid(value.DatasetGuid)) as IFeatureDataset; if (dataset == null) { throw new Exception("Unable to crete dataset"); } await dataset.SetConnectionString(value.ConnectionString); this.FeatureDataset = dataset; } _selecteFeturesclasses.Serialize = value.FeatureClasses; _tolerance.Serialize = value.NetworkTolerance; await _complexEdges.OnShowWizardPage(); _complexEdges.Serialize = value.ComplexEdges; await _switches.OnShowWizardPage(); _switches.Serialize = value.Nodes; _edgeWeights.Serialize = value.EdgeWeights; var assembly = Assembly.LoadFrom(SystemVariables.ApplicationDirectory + @"\" + value.NetworkCreatorAssembly); _networkCreatorType = (assembly.CreateInstance(value.NetworkCreatorType) as INetworkCreator)?.GetType(); }
public void Save(string file) { //SadConsole.Serializer.Save<Entity>(this, file, new System.Type[] { typeof(List<Frame>) }); Serialized data = new Serialized(this); data.Save(file); }
public void Deserialize(Serialized data) { for (int index = 0; index < data.chunks.Length; index++) { Chunk.Serialized chunkData = data.chunks[index]; Vector2Int coordination = new Vector2Int { x = chunkData.coordinationX, y = chunkData.coordinationY }; Chunk chunk = new Chunk(this, coordination); AddChunk(chunk); chunk.Deserialize(chunkData); OnChunkGenerated(chunk); } player.worldPosition = new Vector3( data.playerPositionX, data.playerPositionY, data.playerPositionZ ); player.viewAngle = data.playerViewAngle; worldCamera.SetCameraTarget(player, true); }
public JsonResult LandRegistryEnquiry(int customerId, string titleNumber, string buildingNumber, string buildingName, string streetName, string cityName, string postCode) { if (!string.IsNullOrEmpty(titleNumber)) { this.m_oServiceClient.Instance.LandRegistryRes(this._context.UserId, customerId, titleNumber); return(Json(new { isTitle = true })); } else { var landregistryXml = this.m_oServiceClient .Instance .LandRegistryEnquiry(this._context.UserId, customerId, buildingNumber, buildingName, streetName, cityName, postCode); var landregistry = Serialized.Deserialize <LandRegistryDataModel>(landregistryXml); return(Json(new { titles = landregistry.Enquery.Titles, rejection = landregistry.Enquery.Rejection, ack = landregistry.Enquery.Acknowledgement, isCache = landregistry.DataSource == LandRegistryDataSource.Cache }, JsonRequestBehavior.AllowGet)); } }
} // CheckHmrc private bool IsSameMarketPlace(int nMpID, byte[] oSecData, MP_MarketplaceType oMp, string sShopID) { VendorInfo vi = Integration.ChannelGrabberConfig.Configuration.Instance.GetVendorInfo(oMp.Name); if (vi == null) { return(false); } try { var am = Serialized.Deserialize <AccountModel>(Encrypted.Decrypt(oSecData)); return(am.Fill().UniqueID() == sShopID); } catch (Exception e) { string sXml = System.Text.Encoding.Default.GetString(oSecData); new SafeILog(this).Warn( e, "Failed to de-serialize security data. Marketplace ID = {0}, Security data: {1}", nMpID, sXml ); return(false); } // try } // IsSameMarketPlace
public void can_deserialize_error_retrying_info() { var xml = "<ErrorRetryingInfo UseLastTimeOut=\"false\" MinorTimeoutInSeconds=\"60\" EnableRetrying=\"true\"><IterationSettings Index=\"1\" CountRequestsExpectError=\"10\" TimeOutAfterRetryingExpiredInMinutes=\"30\" /><IterationSettings Index=\"2\" CountRequestsExpectError=\"5\" TimeOutAfterRetryingExpiredInMinutes=\"0\" /></ErrorRetryingInfo>"; var data = Serialized.Deserialize <ErrorRetryingInfo>(xml); Assert.That(data.Info, Is.Not.Null); }
public void Deserialize() { using (var fs = new FileStream(@"D:\5055375325_report.xml", FileMode.Open)) { var data = Serialized.Deserialize <FileAttachmentDataInfo>(fs); Assert.IsNotNull(data); } }
public void Deserialize2() { using (var fs = new FileStream(@"d:\attach1.xml", FileMode.Open)) { var data = Serialized.Deserialize <FileAttachmentDataInfo>(fs); Assert.IsNotNull(data); } }
public void Serialize() { var attach = new FileAttachmentDataInfo { ActiveInventoryReport = new ActiveInventoryReport { SKUDetails = new List <SKUDetails> { new SKUDetails { ItemID = "2", Price = new Price { currencyID = CurrencyCodeType.USD.ToString(), Value = 20.15 }, Quantity = 25, SKU = "555" }, new SKUDetails { ItemID = "3", Price = new Price { currencyID = CurrencyCodeType.GBP.ToString(), Value = 10 }, Quantity = 1, SKU = "111" } } } }; Serialized.Serialize(@"d:\attach1.xml", attach); }
public ActionResult RefreshYodlee(string displayName = null) { var yodleeAccount = this.yodleeAccountsRepository.Search(this.customer.Id); var yodleeMain = new YodleeMain(); var oEsi = new YodleeServiceInfo(); var yodlees = this.customer.CustomerMarketPlaces .Where(mp => mp.Marketplace.InternalId == oEsi.InternalId) .ToList(); if (yodlees.Count == 0) { return(View(new { error = "Error loading bank accounts" })); } var lu = yodleeMain.LoginUser(yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password)); if (lu == null) { return(View(new { error = "Error logging to yodlee account" })); } MP_CustomerMarketPlace umi = displayName == null ? yodlees[0] : yodlees.FirstOrDefault(y => y.DisplayName == displayName); //TODO Currently refreshes the first one if (umi == null) { return(View(new { error = "Account not found" })); } var callback = Url.Action("RecheckYodleeCallback", "YodleeMarketPlaces", new { Area = "Customer" }, "https") + "/" + umi.Id; string finalUrl = yodleeMain.GetEditAccountUrl(Serialized.Deserialize <YodleeSecurityInfo>(umi.SecurityData).ItemId, callback, yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password)); return(Redirect(finalUrl)); }
public Serialized Serialize() { Serialized data = new Serialized(); data.coordinationX = _coordination.x; data.coordinationY = _coordination.y; List <ushort> tiles = new List <ushort>(); Block blockA = _tiles[0, 0, 0].block; int i = 0; for (int j = 0; j < Length * Height * Length; i++, j++) { Block blockB = _tiles[(j / Length) % Length, j / (Length * Length), j % Length].block; if (blockA != blockB) { tiles.Add((ushort)i); tiles.Add((ushort)Block.GetIDByBlock(blockA)); i = 0; blockA = blockB; } } tiles.Add((ushort)i); tiles.Add((ushort)Block.GetIDByBlock(blockA)); data.tiles = tiles.ToArray(); return(data); }
public static IEnumerable <T> Extract <T>(FileAttachment fileAttach) { var list = new List <T>(); if (fileAttach == null || fileAttach.Data == null) { return(list); } var data = fileAttach.Data; using (var mem = new MemoryStream(data)) { var zip = ZipFile.Read(mem); using (var rezMem = new MemoryStream()) { foreach (ZipEntry entry in zip) { entry.Extract(rezMem); rezMem.Flush(); rezMem.Seek(0, SeekOrigin.Begin); var item = Serialized.Deserialize <T>(rezMem); list.Add(item); } } } return(list); }
/// <summary> /// Serializes the specified model. /// </summary> /// <param name="model">The model.</param> /// <param name="context">The context.</param> protected virtual void Serialize(object model, ISerializationContext <TSerializationContext> context) { Argument.IsNotNull("model", model); Argument.IsNotNull("context", context); var serializerModifiers = SerializationManager.GetSerializerModifiers(context.ModelType); Log.Debug("Using '{0}' serializer modifiers to deserialize type '{1}'", serializerModifiers.Length, context.ModelTypeName); var serializingEventArgs = new SerializationEventArgs(context); Serializing.SafeInvoke(this, serializingEventArgs); foreach (var serializerModifier in serializerModifiers) { serializerModifier.OnSerializing(context, model); } BeforeSerialization(context); var members = GetSerializableMembers(context, model); SerializeMembers(context, members); AfterSerialization(context); foreach (var serializerModifier in serializerModifiers) { serializerModifier.OnSerialized(context, model); } Serialized.SafeInvoke(this, serializingEventArgs); }
public ViewResult YodleeCallback() { Log.InfoFormat("Got to yodlee's callback with params:{0}", HttpContext.Request.Params); foreach (string key in HttpContext.Request.Params.Keys) { if (key == "oauth_error_code") { Log.WarnFormat("Yodlee returned an error. oauth_error_code:{0} oauth_error_problem:{1}", HttpContext.Request.Params["oauth_error_code"], HttpContext.Request.Params["oauth_error_problem"]); if (HttpContext.Request.Params["oauth_error_code"] == "407") { return(View(new { error = "Failure linking account" })); } } } var yodleeAccount = this.yodleeAccountsRepository.Search(this.customer.Id); string decryptedPassword = Encrypted.Decrypt(yodleeAccount.Password); string displayname; long csId; var yodleeMain = new YodleeMain(); var oEsi = new YodleeServiceInfo(); var items = this.customer.CustomerMarketPlaces .Where(mp => mp.Marketplace.InternalId == oEsi.InternalId) .Select(mp => Serialized.Deserialize <YodleeSecurityInfo>(mp.SecurityData).ItemId).ToList(); long itemId = yodleeMain.GetItemId(yodleeAccount.Username, decryptedPassword, items, out displayname, out csId); if (itemId == -1) { return(View(new { error = "Failure linking account" })); } int marketPlaceId = this.mpTypes .GetAll() .First(a => a.InternalId == oEsi.InternalId) .Id; var securityData = new YodleeSecurityInfo { ItemId = itemId, Name = yodleeAccount.Username, Password = yodleeAccount.Password, MarketplaceId = marketPlaceId, CsId = csId }; var yodleeDatabaseMarketPlace = new YodleeDatabaseMarketPlace(); var marketPlace = this.dbHelper.SaveOrUpdateCustomerMarketplace(displayname, yodleeDatabaseMarketPlace, securityData, this.customer); Log.InfoFormat("Added or updated yodlee marketplace: {0}", marketPlace.Id); this.serviceClient.Instance.UpdateMarketplace(this.context.Customer.Id, marketPlace.Id, true, this.context.UserId); return(View(YodleeAccountModel.ToModel(marketPlace, this.yodleeBanksRepository))); }
public ConfigurationService() { Serialized serialized = JsonSerializer.Deserialize <Serialized>(myConfig); token = serialized.token; prefix = serialized.prefix; imgurid = serialized.imgurid; }
public Serialized Serialize() { Serialized data = new Serialized(); data.blockID = Block.GetIDByBlock(block); return(data); }
public void can_serialize_amazon_non_generic() { var data = new AmazonSecurityInfo("A2W2IDM5CJ5O1K", null /*todo*/); var serialized = new Serialized(data); var actual = Serialized.Deserialize <AmazonSecurityInfo>(serialized); Assert.That(actual.MerchantId, Is.EqualTo("A2W2IDM5CJ5O1K")); }
public void can_deserialize_amazon() { //0x3C3F786D6C2076657273696F6E3D22312E30223F3E0D0A3C416D617A6F6E5365637572697479496E666F20786D6C6E733A7873693D22687474703A2F2F7777772E77332E6F72672F323030312F584D4C536368656D612D696E7374616E63652220786D6C6E733A7873643D22687474703A2F2F7777772E77332E6F72672F323030312F584D4C536368656D61223E0D0A20203C4D65726368616E7449643E4132573249444D35434A354F314B3C2F4D65726368616E7449643E0D0A20203C4D61726B6574706C61636549643E0D0A202020203C737472696E673E41314638334738433241524F37503C2F737472696E673E0D0A20203C2F4D61726B6574706C61636549643E0D0A3C2F416D617A6F6E5365637572697479496E666F3E var data = Convert.FromBase64String("PD94bWwgdmVyc2lvbj0iMS4wIj8+DQo8QW1hem9uU2VjdXJpdHlJbmZvIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiPg0KICA8TWVyY2hhbnRJZD5BMlcySURNNUNKNU8xSzwvTWVyY2hhbnRJZD4NCiAgPE1hcmtldHBsYWNlSWQ+DQogICAgPHN0cmluZz5BMUY4M0c4QzJBUk83UDwvc3RyaW5nPg0KICA8L01hcmtldHBsYWNlSWQ+DQo8L0FtYXpvblNlY3VyaXR5SW5mbz4="); var info = Serialized.Deserialize <AmazonSecurityInfo>(data); Assert.That(info.MerchantId, Is.EqualTo("A2W2IDM5CJ5O1K")); }
private void btnLoad_Click(object sender, EventArgs e) { var dlg = new OpenFileDialog(); if (dlg.ShowDialog() == DialogResult.OK) { this.Serialize = JsonConvert.DeserializeObject <Serialized>(System.IO.File.ReadAllText(dlg.FileName)); } }
private void filterOrderProjectionsByReference(Serialized client, string reference) { Debug.WriteLine("Filtering single projections by reference: " + ordersProjections); var orders = client.ListSingleProjections(ordersProjections, reference: reference); Assert.AreEqual(false, orders.HasMore); Assert.AreEqual(1, orders.ProjectionsProperty.Count); }
public void TestScenario() { try { Debug.WriteLine("Running scenario test... " + DateTime.Now); var credentials = new SerializedClientCredentials(accessKey, secretAccessKey); var client = new Serialized(credentials); cleanUpPreviousExecutionResult(client); setUpDefinitions(client); // Verify no feeds exists as no aggregates exists. Assert.AreEqual(0, client.ListFeeds().Feeds.Count); // Store events and verify loading of aggregates. storeAndLoadEvents(client); // Verify one feed exists as one aggregate type (order) now exists. Assert.AreEqual(1, client.ListFeeds().Feeds.Count); readAndVerifyAllFeed(client); readAndVerifyOrderFeed(client); // Projections are created async so we have to wait a while. Thread.Sleep(2000); getAndVerifyOrderProjections(client); getAndVerifyOrderTotalsProjection(client); filterOrderProjectionsByReference(client, "PAID"); // Verify no scheduled reactions exists. Assert.AreEqual(0, client.ListScheduledReactions().ReactionsProperty.Count); // Verify the two OrderPlaced events on orderId1 and orderId2 resulted in successfully triggered reactions (new order notifications). Assert.AreEqual(2, client.ListTriggeredReactions().ReactionsProperty.Count); Debug.WriteLine("Scenario test completed!"); } catch (HttpOperationException hex) { Debug.WriteLine(hex); Debug.WriteLine("Error, code: " + hex.Response.StatusCode); Debug.WriteLine("Request: " + hex.Request.Content); Debug.WriteLine("Response: " + hex.Response.Content); Assert.Fail(); } catch (Exception e) { Debug.WriteLine(e.Message); Assert.Fail(); } }
public static PayPointAccountModel ToModel(MP_CustomerMarketPlace account) { var payPointSecurityInfo = Serialized.Deserialize<PayPointSecurityInfo>(account.SecurityData); return new PayPointAccountModel { id = payPointSecurityInfo.MarketplaceId, mid = payPointSecurityInfo.Mid, vpnPassword = payPointSecurityInfo.VpnPassword, remotePassword = payPointSecurityInfo.RemotePassword }; } // ToModel
/// <summary> /// 保存(序列化)指定路径下的配置文件 /// </summary> /// <param name="t">Config配置</param> public static bool SaveConfig(T t = null) { if (t == null) { t = ConfigInfo; } var result = Serialized <T> .Save(t, FilePath + FileName); return(result); }
public static YodleeAccountModel ToModel(IDatabaseCustomerMarketPlace marketplace, YodleeBanksRepository yodleeBanksRepository) { var securityInfo = Serialized.Deserialize <YodleeSecurityInfo>(marketplace.SecurityData); var yodleeBank = yodleeBanksRepository.Search(securityInfo.CsId); return(new YodleeAccountModel { bankId = yodleeBank.Id, displayName = yodleeBank.Name }); } // ToModel
} // ToModel public static YodleeAccountModel ToModel(MP_CustomerMarketPlace marketplace, YodleeBanksRepository yodleeBanksRepository = null) { var securityInfo = Serialized.Deserialize <YodleeSecurityInfo>(marketplace.SecurityData); var yodleeBank = yodleeBanksRepository != null?yodleeBanksRepository.Search(securityInfo.CsId) : null; return(new YodleeAccountModel { bankId = yodleeBank != null ? yodleeBank.Id : 0, displayName = yodleeBank != null ? yodleeBank.Name : "Uploaded bank" }); } // ToModel
private void getAndVerifyOrderTotalsProjection(Serialized client) { Debug.WriteLine("Getting aggregated projection: " + orderTotalsProjection); var orderTotals = client.GetAggregatedProjection(orderTotalsProjection); Assert.AreEqual(orderTotalsProjection, orderTotals.ProjectionId); var projectionData = (JObject)orderTotals.Data; Assert.AreEqual(80235, projectionData["orderAmount"]); Assert.AreEqual(2, projectionData["orderCount"]); }
} // constructor public override IMarketPlaceSecurityInfo RetrieveCustomerSecurityInfo( int customerMarketPlaceId ) { var account = GetDatabaseCustomerMarketPlace(customerMarketPlaceId); try { return(Serialized.Deserialize <AccountModel>(Encrypted.Decrypt(account.SecurityData))); } catch (Exception e) { throw new ApiException(string.Format("Failed to de-serialise security data for marketplace {0} ({1})", account.DisplayName, account.Id), e); } // try } // RetrieveSecurityInfo
static void Main(string[] args) { XmlSerializer serializer = new XmlSerializer(typeof(Serialized)); Serialized s = new Serialized(); serializer.Serialize(Console.Out, s); Serialized s2 = new Serialized { Value = 10 }; serializer.Serialize(Console.Out, s2); Console.ReadLine(); }