circular-reference

Using print_r and var_dump with circular reference

ぃ、小莉子 提交于 2019-11-27 13:03:20
I'm using the MVC framework Symfony , and it seems a lot of the built-in objects I want to debug have circular references. This makes it impossible to print the variables with print_r() or var_dump() (since they follow circular references ad infinitum or until the process runs out of memory, whichever comes first). Instead of writing my own print_r clone with some intelligence, are there better alternatives out there? I only want to be able to print a variable (object, array or scalar), either to a log file, http header or the web page itself. Edit: to clarify what the problem is, try this

How to avoid circular unit reference?

不打扰是莪最后的温柔 提交于 2019-11-27 11:55:03
问题 Imagine the following two classes of a chess game: TChessBoard = class private FBoard : array [1..8, 1..8] of TChessPiece; ... end; TChessPiece = class abstract public procedure GetMoveTargets (BoardPos : TPoint; Board : TChessBoard; MoveTargetList : TList <TPoint>); ... end; I want the two classes to be defined in two separate units ChessBoard.pas and ChessPiece.pas . How can I avoid the circular unit reference that I run into here (each unit is needed in the other unit's interface section)?

scala: circular reference while creating object?

时光怂恿深爱的人放手 提交于 2019-11-27 06:05:40
问题 I accidentally ran into a situation like this (the example is simplified to isolate the problem): abstract class Element(val other: Element) case object First extends Element(Second) case object Second extends Element(First) object Main { def main(arguments: Array[String]) { val e1 = First val e2 = Second println("e1: "+e1+" e1.other: "+e1.other) println("e2: "+e2+" e2.other: "+e2.other) } } Anyone would like to guess the output? :-) e1: First e1.other: Second e2: Second e2.other: null The

How to restore circular references (e.g. “$id”) from Json.NET-serialized JSON?

 ̄綄美尐妖づ 提交于 2019-11-27 05:23:16
Is there an existing javascript library which will deserialize Json.Net with reference loop handling? { "$id": "1", "AppViewColumns": [ { "$id": "2", "AppView": {"$ref":"1"}, "ColumnID": 1, } ] } this should deserialize to an object with a reference loop between the object in the array and the outer object The answers given almost worked for me, but the latest version of MVC, JSON.Net, and DNX uses "$ref" and "$id", and they may be out of order. So I've modified user2864740's answer. I should note that this code does not handle array references, which are also possible. function

Circular reference causing stack overflow with Automapper

跟風遠走 提交于 2019-11-27 05:03:39
I'm using Automapper to map my NHibernate proxy objects (DTO) to my CSLA business objects I'm using Fluent NHibernate to create the mappings - this is working fine The problem I have is that the Order has a collection of OrderLines and each of these has a reference to Order . public class OrderMapping : ClassMap<OrderDTO> { public OrderMapping() { // Standard properties Id(x => x.OrderId); Map(x => x.OrderDate); Map(x => x.Address); HasMany<OrderLineDTO>(x => x.OrderLines).KeyColumn("OrderId").Inverse(); Table("`Order`"); } } public class OrderDTO { // Standard properties public virtual int

What lifetimes do I use to create Rust structs that reference each other cyclically?

谁都会走 提交于 2019-11-27 01:58:07
I'd like to have struct members that know their parent. This is approximately what I'm trying to do: struct Parent<'me> { children: Vec<Child<'me>>, } struct Child<'me> { parent: &'me Parent<'me>, i: i32, } fn main() { let mut p = Parent { children: vec![] }; let c1 = Child { parent: &p, i: 1 }; p.children.push(c1); } I tried to appease the compiler with lifetimes without completely understanding what I was doing. Here's the error message I'm stuck on: error[E0502]: cannot borrow `p.children` as mutable because `p` is also borrowed as immutable --> src/main.rs:13:5 | 12 | let c1 = Child {

How To Fix Circular Reference Error When Dealing With Json

拥有回忆 提交于 2019-11-27 01:49:51
问题 This question is a part of my original post here Get Data Into Extjs GridPanel Below is my Controller that reads data from sql db and then I am trying to encode the result as JSON and send the data back to my gridview.js public JsonResult writeRecord() //public string writeRecord() { Response.Write("Survey Completed!"); SqlConnection conn = DBTools.GetDBConnection("ApplicationServices2"); string sqlquery = "SELECT Q1, Q2, Q3, Q4, Improvements, Comments FROM myTable"; SqlDataAdapter cmd = new

Json and Java - Circular Reference

可紊 提交于 2019-11-27 01:36:30
I'm having and issue with the Circular reference. I have Rest Webservices which returns objects to the front end, the issue is when I try to return objects that have several references so as the result I get an infinite response, which generate java.lang.IllegalStateException: Cannot call sendError() after the response has been committed The objects are generated automatically by Hibernate Code Generation and I need to have the circular reference in the backend, I've just need to remove it before send the information to the frontend using Jackson. The controller method header is:

How to create a circularly referenced type in TypeScript?

泄露秘密 提交于 2019-11-26 23:00:24
问题 I have the following code: type Document = number | string | Array<Document>; TypeScript complains with the following error: test.ts(7,6): error TS2456: Type alias 'Document' circularly references itself. Clearly circular references are not allowed. However, I still need this kind of structure. What would be a workaround for this? 回答1: The creator of TypeScript explains how to create recursive types here: https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540 The

javascript, circular references and memory leaks

牧云@^-^@ 提交于 2019-11-26 22:40:08
问题 From what I recall of a not too distant past, Javascript interpreters suffered from memory leaking issues when faced with circular references. Is it still the case in the latest browsers? (e.g. Chrome, FF 3.5 etc) 回答1: The vast majority of leaks we talk about with JavaScript are specifically in IE6-7 when you make a reference loop between JavaScript objects and host objects like DOM nodes. In IE6 this is particularly pernicious in that you don't get the memory back when you leave the page; it