public void WrapperTargetDefaultWriteTest() { Exception lastException = null; var wrapper = new MyWrapper(); wrapper.WrappedTarget = new MyWrappedTarget(); ((ISupportsInitialize)wrapper).Initialize(); wrapper.WriteLogEvent(LogEventInfo.CreateNullEvent(), ex => lastException = ex); Assert.IsNotNull(lastException); Assert.IsInstanceOfType(lastException, typeof(NotSupportedException)); }
public void WrapperTargetDefaultWriteTest() { Exception lastException = null; var wrapper = new MyWrapper(); wrapper.WrappedTarget = new MyWrappedTarget(); wrapper.Initialize(null); wrapper.WriteAsyncLogEvent(LogEventInfo.CreateNullEvent().WithContinuation(ex => lastException = ex)); Assert.NotNull(lastException); Assert.IsType(typeof(NotSupportedException), lastException); }
public void WrapperTargetFlushTest() { var wrapped = new MyWrappedTarget(); var wrapper = new MyWrapper { WrappedTarget = wrapped, }; wrapper.Flush(ex => { }); Assert.AreEqual(1, wrapped.FlushCount); }
public void WrapperTargetToStringTest() { var wrapper = new MyWrapper { WrappedTarget = new DebugTarget() { Name = "foo" }, }; var wrapper2 = new MyWrapper() { WrappedTarget = wrapper, }; Assert.Equal("MyWrapper(MyWrapper(Debug Target[foo]))", wrapper2.ToString()); }
public void WrapperTargetFlushTest() { var wrapped = new MyWrappedTarget(); var wrapper = new MyWrapper { WrappedTarget = wrapped, }; wrapper.Initialize(null); wrapped.Initialize(null); wrapper.Flush(ex => { }); Assert.Equal(1, wrapped.FlushCount); }
public void CollectInfo() { MyWrapper myWrapper = new MyWrapper(objects); for (int i = 0; i < objects.Count; i++) { objects.Add(null); } for (int i = 0; i < GameManager.childCount; i++) { myWrapper.objects[0].nestedObjects[i].vecPosition = GameManager.transform.GetChild(i).transform.position; } json = JsonUtility.ToJson(myWrapper); File.WriteAllText("C:/save.txt", json); Debug.Log(json); }
static void Main() { var ser = new XmlSerializer(typeof(MyWrapper)); var obj = new MyWrapper { Data = new List <ChildClass> { new ChildA { ChildProp = "abc", AProp = "def" }, new ChildB { ChildProp = "ghi", BProp = "jkl" } } }; ser.Serialize(Console.Out, obj); }
public void WrapperTargetNestedToStringTest() { var wrapper = new MyWrapper { WrappedTarget = new DebugTarget() { Name = "foo" }, }; var wrapper2 = new MyWrapper() { WrappedTarget = wrapper, }; Assert.Equal("MyWrapper_MyWrapper_DebugTarget(Name=foo)", wrapper2.ToString()); }
static void Main(string[] args) { MyWrapper wrapper = new MyWrapper(); wrapper.Add("foo", "bar"); wrapper.Add("fizz", "bang"); // serialize single wrapper instance string json = JsonConvert.SerializeObject(wrapper, Formatting.Indented); Console.WriteLine(json); Console.WriteLine(); // deserialize single wrapper instance wrapper = JsonConvert.DeserializeObject <MyWrapper>(json); foreach (KeyValuePair <string, string> kvp in wrapper) { Console.WriteLine(kvp.Key + "=" + kvp.Value); } Console.WriteLine(); Console.WriteLine("----------\n"); MyWrapper wrapper2 = new MyWrapper(); wrapper2.Add("a", "1"); wrapper2.Add("b", "2"); wrapper2.Add("c", "3"); List <MyWrapper> list = new List <MyWrapper> { wrapper, wrapper2 }; // serialize list of wrappers json = JsonConvert.SerializeObject(list, Formatting.Indented); Console.WriteLine(json); Console.WriteLine(); // deserialize list of wrappers list = JsonConvert.DeserializeObject <List <MyWrapper> >(json); foreach (MyWrapper w in list) { foreach (KeyValuePair <string, string> kvp in w) { Console.WriteLine(kvp.Key + "=" + kvp.Value); } Console.WriteLine(); } }
public CompositeWrapper() { wrappedLogger = new MyWrapper(); }
public UseMyWrapper(MyWrapper wr) { Wr = wr; }
public MyWrapper Clone() { MyWrapper output = new MyWrapper(); output.properties = new Dictionary <string, object>(properties); }
public BatchData(MyWrapper wrapper) { this.wrapper = wrapper; }
public static void Main(string[] args) { var myWrapper = new MyWrapper <int, string, bool>(); }
public void Log_LoggerWrappedAndStackTraceEnabled_UserStackFrameIsCurrentMethod() { LoggingConfiguration config = new LoggingConfiguration(); MyTarget target = new MyTarget(); config.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, target)); LogManager.Configuration = config; MyWrapper wrapper = new MyWrapper(); wrapper.Log("test"); Assert.Equal(MethodBase.GetCurrentMethod(), target.LastEvent.UserStackFrame.GetMethod()); }
IEnumerator WaitForRequest(WWW www) { yield return(www); //Debug.Log(www.text); // check for errors if (www.error == null) { Debug.Log("WWW Ok!: " + www.text); graph = MyWrapper.CreateFromJSON(www.text); //Debug.Log(graph.nodes.Count); nodes = new Dictionary <string, int>(); for (int i = 0; i < graph.nodes.Count; i++) { ProcessNode(graph.nodes[i].id, nodes.Count, false); } for (int i = 0; i < graph.edges.Count; i++) { if (graph.edges[i].style == "graphmeta") { graph.edges.RemoveAt(i); i--; } else { ProcessNode(graph.edges[i].from, nodes.Count, true); ProcessNode(graph.edges[i].to, nodes.Count, true); if (nodes.ContainsKey(graph.edges[i].from) && nodes.ContainsKey(graph.edges[i].to)) { MyNode source = graph.nodes[nodes[graph.edges[i].from]]; MyNode target = graph.nodes[nodes[graph.edges[i].to]]; source.edgeIndicesOut.Add(i); target.edgeIndicesIn.Add(i); source.connectedNodes.Add(nodes[graph.edges[i].to]); target.connectedNodes.Add(nodes[graph.edges[i].from]); } } } identifySubgraphs(); SolveUsingForces(30, 40f, true); List <int> rootIndices = new List <int>(); bool[] visited = new bool[graph.nodes.Count]; float maxConnections = 0; for (int i = 0; i < graph.nodes.Count; i++) { /* * string to = ""; * for(int j=0; j< graph.nodes[i].edgeIndicesIn.Count; j++) * { * to += graph.nodes[nodes[graph.edges[graph.nodes[i].edgeIndicesIn[j]].from]].label+", "; * } * Debug.Log(graph.nodes[i].label + "<-" + to); * * string from = ""; * for (int j = 0; j < graph.nodes[i].edgeIndicesOut.Count; j++) * { * from += graph.nodes[nodes[graph.edges[graph.nodes[i].edgeIndicesOut[j]].to]].label + ", "; * } * Debug.Log(graph.nodes[i].label + "->" + from); * * //*/ if (graph.nodes[i].edgeIndicesIn.Count == 0) { rootIndices.Add(i); } maxConnections = Mathf.Max(graph.nodes[i].connectedNodes.Count, maxConnections); } Debug.Log("#root nodes: " + rootIndices.Count); float maxHeight = 0; for (int i = 0; i < rootIndices.Count; i++) { for (int j = 0; j < graph.nodes.Count; j++) { visited[j] = false; } int curHeight = 1; Stack <int> nodeIndexStack = new Stack <int>(); nodeIndexStack.Push(rootIndices[i]); Stack <int> heightStack = new Stack <int>(); heightStack.Push(curHeight); visited[rootIndices[i]] = true; while (nodeIndexStack.Count > 0) { int curIndex = nodeIndexStack.Pop(); curHeight = heightStack.Pop(); maxHeight = Mathf.Max(curHeight, maxHeight); MyNode curNode = graph.nodes[curIndex]; for (int j = 0; j < curNode.edgeIndicesOut.Count; j++) { int childNodeIndex = nodes[graph.edges[curNode.edgeIndicesOut[j]].to]; graph.nodes[childNodeIndex].height = Mathf.Max(curHeight, graph.nodes[childNodeIndex].height); if (!visited[childNodeIndex]) { visited[childNodeIndex] = true; nodeIndexStack.Push(childNodeIndex); heightStack.Push(curHeight + 1); } } } } sliceWidth = vol / maxHeight; Debug.Log("maxHeight: " + maxHeight); ; for (int i = 0; i < graph.nodes.Count; i++) { var node = graph.nodes[i]; var y = node.height * sliceWidth; /* float x =(maxConnections/10- node.connectedNodes.Count)*20 ; * if (x < -vol) x = 0; * * if (i % 2 == 0) x *= -1;*/ Vector3 pos = new Vector3(node.pos.x, y, node.pos.z); node.pos = pos; node.nodeObject.transform.position = pos; } Vector3[] vertices = new Vector3[4 * graph.edges.Count]; int[] triangles = new int[6 * graph.edges.Count]; line = new GameObject(); MeshRenderer mr = line.AddComponent <MeshRenderer>(); MeshFilter mf = line.AddComponent <MeshFilter>(); Mesh mesh = new Mesh(); for (int i = 0; i < graph.edges.Count; i++) { if (nodes.ContainsKey(graph.edges[i].from) && nodes.ContainsKey(graph.edges[i].to)) { MyNode source = graph.nodes[nodes[graph.edges[i].from]]; MyNode target = graph.nodes[nodes[graph.edges[i].to]]; Vector3 dir = target.pos - source.pos; Vector3 offset = Vector3.Cross(dir, Vector3.up).normalized * 0.5f; vertices[0 + i * 4] = source.pos - offset; vertices[2 + i * 4] = source.pos + offset; vertices[1 + i * 4] = target.pos - offset; vertices[3 + i * 4] = target.pos + offset; triangles[0 + i * 6] = 0 + i * 4; triangles[1 + i * 6] = 1 + i * 4; triangles[2 + i * 6] = 2 + i * 4; triangles[3 + i * 6] = 2 + i * 4; triangles[4 + i * 6] = 3 + i * 4; triangles[5 + i * 6] = 1 + i * 4; } } mesh.vertices = vertices; mesh.triangles = triangles; mr.material = mat; mf.mesh = mesh; line.transform.parent = this.transform; init = true; } else { Debug.Log("WWW Error: " + www.error); } }