Exemplo n.º 1
0
        /// <summary>
        /// Returns a deep clone (a unique object)
        /// </summary>
        public object Clone()
        {
            BeamBlock clone = new BeamBlock();

            foreach (var component in Components)
            {
                if (component is Beam beam)
                {
                    var beamClone = new Beam(beam.EventIDs, component.Depth);
                    clone.Components.Add(beamClone);
                }
                else if (component is BeamHook beamHook)
                {
                    var beamHookClone = new BeamHook(beamHook.EventID, beamHook.BeamHookDirection, beamHook.Depth);
                    clone.Components.Add(beamHookClone);
                }
            }

            return(clone);
        }
Exemplo n.º 2
0
        public BeamBlocks(XmlReader r)
        {
            M.Assert(r.Name == "beams");

            M.ReadToXmlElementTag(r, "beam");

            BeamBlock currentBeamBlock = null;

            int topLevelDepth = r.Depth;

            while (r.Name == "beam" || r.Name == "beam-hook")
            {
                if (r.NodeType != XmlNodeType.EndElement)
                {
                    switch (r.Name)
                    {
                    case "beam":
                    {
                        if (r.Depth == topLevelDepth)
                        {
                            currentBeamBlock = new BeamBlock();
                            Blocks.Add(currentBeamBlock);
                        }
                        currentBeamBlock.Components.Add(new Beam(r, topLevelDepth));
                        break;
                    }

                    case "beam-hook":
                    {
                        currentBeamBlock.Components.Add(new BeamHook(r, topLevelDepth));
                        break;
                    }
                    }
                }
                M.ReadToXmlElementTag(r, "beam", "beam-hook", "beams");
            }
            M.Assert(r.Name == "beams"); // end of beams
        }