/// <summary> /// The AddBlock method adds an instance of a FIX component /// block to the dictionary. If there is already an instance /// of a component block with the same name, an operation is /// not allowed and an ArgumentException is thrown. /// </summary> /// <param name="dxBlock"> /// The FIX component block definition that is to be added. /// </param> public void AddBlock(FixDxBlock dxBlock) { if (_mapBlocksByName.ContainsKey(dxBlock.Name)) { string error = string.Format("Dictionary already contains a block named {0}.", dxBlock.Name); throw new ArgumentException(error); } _mapBlocksByName.Add(dxBlock.Name, dxBlock); _blkElements.Add(dxBlock); }
/// <summary> /// The CloneBlock method is invoked to create a copy of an /// instance of a component block definition. /// </summary> /// <param name="source"> /// The component block to be duplicated. /// </param> /// <returns> /// The resulting clone of the supplied block. /// </returns> private FixDxBlock CloneBlock(FixDxBlock source) { FixDxBlock result = new FixDxBlock(source.Name, source.Category, source.Field); foreach (IFixDxElement dxElement in source.Elements) { result.Elements.Add(CloneElement(dxElement)); } return result; }
/// <summary> /// The PopulateBlocks method populates the blocks section /// of the supplied VFX dictionary with all of the blocks /// that are defined in the supplied XML dictionary. /// </summary> /// <param name="source"> /// The source dictionary for the block elements. /// </param> /// <param name="target"> /// The target dictionary for the converted elements. /// </param> private static void PopulateBlocks(XmlDictionary source, FixDictionary target) { foreach (XmlFixDxBlock src in source.Blocks.Entries) { FixDxBlock dst = new FixDxBlock(src.Name); dst.Type = (FixDxBlockTypes)Enum.Parse(typeof(FixDxBlockTypes), src.Type); dst.Field = src.Field; dst.Category = src.Category; foreach (IFixDxElement element in TranslateElements(src.Elements)) { dst.Elements.Add(element); } target.AddBlock(dst); } }