protected string BuildModifierItemName(SymbolSet ss, string modNumber, ModifiersTypeModifier m)
        {
            // Constructs a string containing the name of a modifier, where each Label value
            // is seperated by a DomainSeparator (usually a colon).  Builds this for each group
            // of related SymbolSet and modifier.

            //string result = this.BuildModifierItemCategory(ss, modNumber);

            //result = result + _configHelper.DomainSeparator + m.Category.Replace(',', '-') + _configHelper.DomainSeparator + m.Label.Replace(',', '-');

            string result;

            if (m.Category != null && m.Category != "")
            {
                result = ((m.CategoryAlias == "") ? m.Category : m.CategoryAlias) + _configHelper.DomainSeparator + ((m.LabelAlias == "") ? m.Label : m.LabelAlias);
            }
            else
            {
                result = m.LabelAlias == "" ? m.Label : m.LabelAlias;
            }

            result = result.Replace(',', '-');

            return result;
        }
        string IModifierExport.Line(SymbolSet ss, string modNumber, ModifiersTypeModifier m)
        {
            string result = BuildModifierItemName(null, modNumber, m) + ",";

            result = result + BuildModifierCode(null, modNumber, m);

            return result;
        }
        string IEntityExport.Line(LibraryStandardIdentityGroup sig, 
                                  SymbolSet ss, 
                                  EntitySubTypeType eSubType)
        {
            string code = BuildEntityCode(null, null, null, null, eSubType);

            return BuildEntityItemName(null, null, null, null, eSubType) + "," + code;
        }
        public string CodeIt(LibraryStandardIdentityGroup sig, SymbolSet ss, SymbolSetEntity e, SymbolSetEntityEntityType eType, EntitySubTypeType eSubType)
        {
            string code = "";

            if (ss != null); // && (e != null || (e == null && eType == null)))
                code = BuildEntityCode(sig, ss, e, eType, eSubType);

            return code;
        }
        public string NameIt(SymbolSet ss, string modNumber, ModifiersTypeModifier m)
        {
            string name = "";

            if(ss != null && m != null)
                name = BuildModifierItemName(ss, modNumber, m);

            return name;
        }
        public string CodeIt(SymbolSet ss, string modNumber, ModifiersTypeModifier m)
        {
            string code = "";

            if (ss != null && m != null)
                code = BuildModifierCode(ss, modNumber, m);

            return code;
        }
        protected string BuildQuotedModifierCode(SymbolSet ss, string modNumber, ModifiersTypeModifier m)
        {
            // Constructs a quoted string containing the symbol set and modifier codes for a given
            // set of those objects.

            string code = '"' + this.BuildModifierCode(ss, modNumber, m) + '"';

            return code;
        }
        public string NameIt(LibraryStandardIdentityGroup sig, SymbolSet ss, SymbolSetEntity e, SymbolSetEntityEntityType eType, EntitySubTypeType eSubType)
        {
            string name = "";

            if(ss != null && e != null)
                name = BuildEntityItemName(sig, ss, e, eType, eSubType);

            return name;
        }
        protected string BuildModifierItemCategory(SymbolSet ss, string modNumber)
        {
            // Contructs the category information for a given SymbolSet and modifier, including the Label
            // attribute of the SymbolSet and the type of icon being categorized, deperated by the
            // domain separator (usually a colon).

            string result = ss.Label.Replace(',', '-') + _configHelper.DomainSeparator;

            result = result + "Modifier " + modNumber;

            return result;
        }
        string IEntityExport.Line(LibraryStandardIdentityGroup sig, SymbolSet ss, SymbolSetEntity e, SymbolSetEntityEntityType eType, EntitySubTypeType eSubType)
        {
            GeometryType geoType = GeometryType.POINT;
            IconType icoType = IconType.MAIN;

            string result = Convert.ToString(ss.SymbolSetCode.DigitOne) + Convert.ToString(ss.SymbolSetCode.DigitTwo);
            
            string code = BuildEntityCode(sig, ss, e, eType, eSubType);

            // Remove the first two characters as this output does not require the symbol set code, and exclude any trailing underbar digit
            // Note that these code will not be unique, with the substring operation in place.

            code = code.Substring(2,6);
            
            result = result + ",";

            result = result + e.Label.Replace(',', '-');
            geoType = e.GeometryType;
            icoType = e.Icon;

            result = result + ",";

            if (eType != null)
            {
                result = result + eType.Label.Replace(',', '-');
                geoType = eType.GeometryType;
                icoType = eType.Icon;
            }

            result = result + ",";

            if (eSubType != null)
            {
                result = result + eSubType.Label.Replace(',', '-');
                geoType = eSubType.GeometryType;
                icoType = eSubType.Icon;
            }

            if (sig != null)
            {
                result = result + "," + sig.Label;
            }
            else
            {
                result = result + ",";
            }

            result = result + "," + code + "," + _geometryList[(int)geoType];

            result = result + "," + Convert.ToString(icoType) + "," + BuildEntityItemName(sig, ss, e, eType, eSubType); 

            return result;
        }
        protected string BuildEntityCode(LibraryStandardIdentityGroup sig,
                                         SymbolSet ss,
                                         SymbolSetEntity e,
                                         SymbolSetEntityEntityType eType,
                                         EntitySubTypeType eSubType)
        {
            // Constructs a string containing the symbol set and entity codes for a given
            // set of those objects.

            string code = "";

            if (ss != null)
            {
                code = code + Convert.ToString(ss.SymbolSetCode.DigitOne) + Convert.ToString(ss.SymbolSetCode.DigitTwo);
            }

            if (e == null && eType == null && eSubType != null)
            {
                // Deal with the special entity sub types as a special case

                code = code + eSubType.EntityCode + eSubType.EntityTypeCode + Convert.ToString(eSubType.EntitySubTypeCode.DigitOne) + Convert.ToString(eSubType.EntitySubTypeCode.DigitTwo);
            }
            else
            {
                // Almost everything is dealt with below

                code = code + Convert.ToString(e.EntityCode.DigitOne) + Convert.ToString(e.EntityCode.DigitTwo);

                if (eType != null)
                    code = code + Convert.ToString(eType.EntityTypeCode.DigitOne) + Convert.ToString(eType.EntityTypeCode.DigitTwo);
                else
                    code = code + "00";

                if (eSubType != null)
                    code = code + Convert.ToString(eSubType.EntitySubTypeCode.DigitOne) + Convert.ToString(eSubType.EntitySubTypeCode.DigitTwo);
                else
                    code = code + "00";
            }
            
            if (sig != null)
            {
                code = code + sig.GraphicSuffix;
            }

            return code;
        }
        string IModifierExport.Line(SymbolSet ss, string modNumber, ModifiersTypeModifier m)
        {
            _notes = "";

            string result = "";
            string graphicPath = "";

            switch (modNumber)
            {
                case "1":
                    graphicPath = _configHelper.GetPath(ss.ID, FindEnum.FindModifierOnes);
                    break;

                case "2":
                    graphicPath = _configHelper.GetPath(ss.ID, FindEnum.FindModifierTwos);
                    break;
            }

            string itemRootedPath = _configHelper.BuildRootedPath(graphicPath, m.Graphic);
            string itemOriginalPath = _configHelper.BuildOriginalPath(graphicPath, m.Graphic);

            if (!File.Exists(itemOriginalPath))
            { 
                _notes = _notes + "image file does not exist;";
                logger.Warn("Image File Missing: " + itemOriginalPath);
            }

            string itemName = BuildModifierItemName(ss, modNumber, m);
            string itemCategory = BuildModifierItemCategory(ss, modNumber);
            string itemTags = BuildModifierItemTags(ss, modNumber, m, _omitSource, _omitLegacy);
            string itemID = BuildModifierCode(ss, modNumber, m);

            result = itemRootedPath + "," +
                     Convert.ToString(_configHelper.PointSize) + "," +
                     itemName + "," +
                     itemCategory + "," +
                     itemTags + "," +
                     itemID + "," +
                     "Point" + "," +
                     _notes;

            return result;
        }
        string IModifierExport.Line(SymbolSet ss, string modNumber, ModifiersTypeModifier m)
        {
            string result = Convert.ToString(ss.SymbolSetCode.DigitOne) + Convert.ToString(ss.SymbolSetCode.DigitTwo);

            result = result + "," + modNumber + ",";

            if (m.Category != null)
                result = result + m.Category.Replace(',', '-') + ",";
            else
                result = result + ",";

            result = result + m.Label.Replace(',', '-') + ",";

            result = result + Convert.ToString(m.ModifierCode.DigitOne) + Convert.ToString(m.ModifierCode.DigitTwo);

            result = result + "," + BuildModifierItemName(ss, modNumber, m);

            return result;
        }
        protected string BuildModifierCode(SymbolSet ss, string modNumber, ModifiersTypeModifier m)
        {
            // Constructs a string containing the symbol set and modifier codes for a given
            // set of those objects.

            string code = "";

            if(ss != null)
            {
                code = code + Convert.ToString(ss.SymbolSetCode.DigitOne) + Convert.ToString(ss.SymbolSetCode.DigitTwo);
            }

            code = code + Convert.ToString(m.ModifierCode.DigitOne) + Convert.ToString(m.ModifierCode.DigitTwo);

            if (ss != null)
            {
                code = code + modNumber;
            }

            return code;
        }
        public string Line(LibraryStandardIdentityGroup sig, SymbolSet ss, SymbolSetLegacySymbol symbol, LegacyEntityType entity, LegacyFunctionCodeType code)
        {
            string result = "";
            string graphic = "";

            _notes = "";

            string graphicPath = _configHelper.GetPath("JMSML_2525C", FindEnum.Find2525C);

            if (entity.Graphic != "" && entity.Icon != IconType.FULL_FRAME)
                graphic = entity.Graphic;
            else
                graphic = GrabGraphic(entity.CloverGraphic, entity.RectangleGraphic, entity.SquareGraphic, entity.DiamondGraphic, sig.GraphicSuffix);

            string id = graphic.Substring(0, graphic.Length - 4); ;

            IconType iType = entity.Icon;
            string geometryType = GeometryIs(entity.GeometryType);

            string itemRootedPath = _configHelper.BuildRootedPath(graphicPath, graphic);
            string itemOriginalPath = _configHelper.BuildOriginalPath(graphicPath, graphic);

            if (!File.Exists(itemOriginalPath))
                _notes = _notes + "image file does not exist;";

            result = result + itemRootedPath;
            result = result + "," + Convert.ToString(_configHelper.PointSize);
            result = result + "," + id;
            result = result + "," + BuildEntityItemCategory(ss, iType, geometryType);
            result = result + "," + BuildEntityItemTags(sig, ss, symbol, entity, code);
            result = result + "," + id;
            result = result + "," + geometryType;
            result = result + "," + _notes;

            return result;
        }
 private void _serializeSymbolSet(SymbolSet ss, string path)
 {
     if (ss != null)
     {
         var serializer = new XmlSerializer(typeof(SymbolSet));
         using (FileStream writer = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
         {
             try
             {
                 serializer.Serialize(writer, ss);
             }
             catch (IOException ex)
             {
                 logger.Error(ex.Message);
             }
         }
     }
 }
        internal SymbolSetEntity Entity(SymbolSet symbolSet, string entityID)
        {
            SymbolSetEntity retObj = null;

            if (symbolSet != null)
            {
                if (symbolSet.Entities != null)
                {
                    foreach (SymbolSetEntity lObj in symbolSet.Entities)
                    {
                        if (lObj.ID == entityID)
                        {
                            return lObj;
                        }
                    }
                }
            }

            _statusFlag -= 2048;

            return retObj;
        }
        private void _exportMod(StreamWriter w, SymbolSet s, ModifiersTypeModifier mod, string modNumber, IModifierExport exporter, string expression)
        {
            string line;

            if (!(exporter is ImageModifierExport) || mod.ModifierCode.DigitOne != 0 || mod.ModifierCode.DigitTwo != 0)
            {
                if (expression == "" ||
                    System.Text.RegularExpressions.Regex.IsMatch(mod.Label, expression, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                {
                    line = string.Format("{0}", exporter.Line(s, modNumber, mod));

                    w.WriteLine(line);
                    w.Flush();
                }
                else if (mod.Category != null)
                {
                    if (System.Text.RegularExpressions.Regex.IsMatch(mod.Category, expression, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                    {
                        line = string.Format("{0}", exporter.Line(s, modNumber, mod));

                        w.WriteLine(line);
                        w.Flush();
                    }
                }
            }
        }
        private void _exportSpecialEntities(ETLExportEnum exportType, IEntityExport exporter, SymbolSet s, StreamWriter w, EntitySubTypeType[] array)
        {
            // Exports special entities to a CSV file

            string line = "";

            if (array != null)
            {
                foreach (EntitySubTypeType eSubType in array)
                {
                    if (eSubType.Icon == IconType.SPECIAL && exportType == ETLExportEnum.ETLExportImage)
                    {
                        foreach (LibraryStandardIdentityGroup sig in _library.StandardIdentityGroups)
                        {
                            line = string.Format("{0}", exporter.Line(sig, s, eSubType));

                            w.WriteLine(line);
                            w.Flush();
                        }
                    }
                    else
                    {
                        if (exportType == ETLExportEnum.ETLExportDomain)
                            line = string.Format("{0}", exporter.Line(eSubType));
                        else
                            line = string.Format("{0}", exporter.Line(null, s, eSubType));

                        w.WriteLine(line);
                        w.Flush();
                    }
                }
            }
        }
        internal SymbolSetLegacySymbol LegacySymbol(string legacySIDC, ref LibraryDimension dimensionOut, ref SymbolSet ssOut)
        {
            SymbolSetLegacySymbol retObj = null;

            dimensionOut = null;
            ssOut = null;

            string codingSchemeLetter = legacySIDC.Substring(0, 1);
            string code = legacySIDC.Substring(2, 1);
            string firstLetterInFunction = legacySIDC.Substring(4, 1);

            foreach (LibraryDimension lObj in _library.Dimensions)
            {
                if (lObj.LegacyDimensionCode != null)
                {
                    foreach (LegacyLetterCodeType lObj2 in lObj.LegacyDimensionCode)
                    {
                        if ((lObj2.Value == code && lObj2.FirstFunctionLetter == "" && lObj2.CodingSchemeLetter == "") ||
                            (lObj2.Value == code && lObj2.FirstFunctionLetter == firstLetterInFunction && lObj2.CodingSchemeLetter == "") ||
                            (lObj2.Value == code && lObj2.FirstFunctionLetter == "" && lObj2.CodingSchemeLetter == codingSchemeLetter) ||
                            (lObj2.Value == code && lObj2.FirstFunctionLetter == firstLetterInFunction && lObj2.CodingSchemeLetter == codingSchemeLetter))
                        {
                            if (lObj.SymbolSets != null)
                            {
                                foreach (LibraryDimensionSymbolSetRef ssRef in lObj.SymbolSets)
                                {
                                    SymbolSet ss = this.SymbolSet(ssRef.ID);

                                    if (ss != null)
                                    {
                                        retObj = this.LegacySymbol(ss, legacySIDC);

                                        if (retObj != null)
                                        {
                                            dimensionOut = lObj;
                                            ssOut = ss;

                                            return retObj;
                                        }
                                    }
                                }
                            }
                        }
                    }

                }
            }

            if (retObj == null)
            {
                _statusFlag -= 4;  // Can't find a Dimension
                _statusFlag -= 16; // Can't find a SymbolSet
                _statusFlag -= 65536; // Can't find a LegacySymbol
            }

            return retObj;
        }
        internal SymbolSetLegacySymbol LegacySymbol(SymbolSet symbolSet, string legacySIDC)
        {
            SymbolSetLegacySymbol retObj = null;

            string schema = legacySIDC.Substring(0, 1);
            string functionCode = legacySIDC.Substring(4, 6);
            string dimension = legacySIDC.Substring(2, 1);
            string hqtffd = legacySIDC.Substring(10, 1);
            string amplifier = legacySIDC.Substring(11, 1);
            string tail = legacySIDC.Substring(12, 3);

            if (symbolSet != null)
            {
                if (symbolSet.LegacySymbols != null)
                {
                    foreach (SymbolSetLegacySymbol lObj in symbolSet.LegacySymbols)
                    {
                        foreach (LegacyFunctionCodeType lObj2 in lObj.LegacyFunctionCode)
                        {
                            if (lObj2.Value == functionCode)
                            {
                                //
                                // Thanks to many exceptions in 2525C, given also that function codes are not unique, we need to check other legacy code values
                                //
                                if ((lObj2.SchemaOverride == "" || (lObj2.SchemaOverride != "" && lObj2.SchemaOverride == schema)) &&
                                    (lObj2.DimensionOverride == "" || (lObj2.DimensionOverride != "" && lObj2.DimensionOverride == dimension)) &&
                                    (lObj2.HQTFFDOverride == "" || (lObj2.HQTFFDOverride != "" && lObj2.HQTFFDOverride == hqtffd)) &&
                                    (lObj2.AmplifierOverride == "" || (lObj2.AmplifierOverride != "" && lObj2.AmplifierOverride == amplifier)) &&
                                    (lObj2.TailOverride == "" || (lObj2.TailOverride != "" && lObj2.TailOverride == tail)))
                                {
                                    return lObj;
                                }
                            }
                        }
                    }
                }
            }

            return retObj;
        }
        internal EntitySubTypeType EntitySubType(SymbolSet ss, ushort entitySubTypeCodeOne, ushort entitySubTypeCodeTwo)
        {
            EntitySubTypeType retObj = null;

            if (ss != null)
            {
                if (ss.SpecialEntitySubTypes != null)
                {
                    foreach (EntitySubTypeType lObj in ss.SpecialEntitySubTypes)
                    {
                        if (lObj.EntitySubTypeCode.DigitOne == entitySubTypeCodeOne &&
                            lObj.EntitySubTypeCode.DigitTwo == entitySubTypeCodeTwo)
                        {
                            return lObj;
                        }
                    }
                }
            }

            return retObj;
        }
        internal EntitySubTypeType EntitySubType(SymbolSet ss, SymbolSetEntityEntityType entityType, string entitySubTypeID)
        {
            EntitySubTypeType retObj = null;

            if (entityType != null)
            {
                if (entityType.EntitySubTypes != null)
                {
                    foreach (EntitySubTypeType lObj in entityType.EntitySubTypes)
                    {
                        if (lObj.ID == entitySubTypeID)
                        {
                            return lObj;
                        }
                    }
                }

                // Can't find it.  Check to see if the symbol set has special entity subtypes

                if (ss != null)
                {
                    if (ss.SpecialEntitySubTypes != null)
                    {
                        foreach (EntitySubTypeType lObj in ss.SpecialEntitySubTypes)
                        {
                            if (lObj.ID == entitySubTypeID)
                            {
                                return lObj;
                            }
                        }
                    }
                }
            }

            _statusFlag -= 8192;

            return retObj;
        }
        protected string BuildQuotedEntityCode(LibraryStandardIdentityGroup sig,
                                               SymbolSet ss,
                                               SymbolSetEntity e,
                                               SymbolSetEntityEntityType eType,
                                               EntitySubTypeType eSubType)
        {
            // Constructs a quoted string containing the symbol set and entity codes for a given
            // set of those objects.

            string code = '"' + this.BuildEntityCode(sig, ss, e, eType, eSubType) + '"';

            return code;
        }
        // The following has been commented out as being potentially superflous
        //internal LibraryAffiliation AffiliationByLegacyCode(string legacyStandardIdentityCode, string legacyDimensionCode, string legacyFirstLetterInFunction, string legacyCodingSchemeLetter)
        //{
        //    LibraryAffiliation retObj = null;
        //    // For each affiliation (combination of context, dimension, and standard identity)
        //    foreach(LibraryAffiliation lObj in this._library.Affiliations)
        //    {
        //        if (lObj.LegacyStandardIdentityCode != null)
        //        {
        //            // For each standard identity
        //            foreach (LegacyLetterCodeType lObj2 in lObj.LegacyStandardIdentityCode)
        //            {
        //                // If this is the standard identity we are looking for...
        //                if (lObj2.Value == legacyStandardIdentityCode)
        //                {
        //                    // Grab the dimension associated with the current affiliation
        //                    LibraryDimension lDim = this.Dimension(lObj.DimensionID);
        //                    // For each dimension code in that dimension...
        //                    foreach (LegacyLetterCodeType lObj3 in lDim.LegacyDimensionCode)
        //                    {
        //                        // Test to see if this is the dimension we are looking for by checking to see if the codes match and there is no
        //                        // first function letter and coding schema letter override, or...
        //                        // use the overriding first function letter to refine the test, or...
        //                        // use the overriding coding scheme letter to refine the test.
        //                        if((lObj3.Value == legacyDimensionCode && lObj3.FirstFunctionLetter == "" && lObj3.CodingSchemeLetter == "") ||
        //                           (lObj3.Value == legacyDimensionCode && lObj3.FirstFunctionLetter == legacyFirstLetterInFunction && lObj3.CodingSchemeLetter == "") ||
        //                           (lObj3.Value == legacyDimensionCode && lObj3.FirstFunctionLetter == ""  && lObj3.CodingSchemeLetter == legacyCodingSchemeLetter) ||
        //                           (lObj3.Value == legacyDimensionCode && lObj3.FirstFunctionLetter == legacyFirstLetterInFunction && lObj3.CodingSchemeLetter == legacyCodingSchemeLetter))
        //                            // We have a match, so return the current affiliation
        //                            return lObj;
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    _statusFlag -= 512;
        //    return retObj;
        //}
        internal SymbolSetEntity Entity(SymbolSet symbolSet, ushort entityCodeOne, ushort entityCodeTwo)
        {
            SymbolSetEntity retObj = null;

            if (symbolSet != null)
            {
                if (symbolSet.Entities != null)
                {
                    foreach (SymbolSetEntity lObj in symbolSet.Entities)
                    {
                        if (lObj.EntityCode.DigitOne == entityCodeOne &&
                            lObj.EntityCode.DigitTwo == entityCodeTwo)
                        {
                            return lObj;
                        }
                    }
                }
            }

            _statusFlag -= 2048;

            return retObj;
        }
        internal ModifiersTypeModifier ModifierTwo(SymbolSet symbolSet, string modifierID)
        {
            ModifiersTypeModifier retObj = null;

            if (symbolSet != null)
                if(symbolSet.SectorTwoModifiers != null)
                {
                    foreach (ModifiersTypeModifier lObj in symbolSet.SectorTwoModifiers)
                    {
                        if (lObj.ID == modifierID || modifierID == "NA" && lObj.ModifierCode.DigitOne == 0 && lObj.ModifierCode.DigitTwo == 0)
                        {
                            return lObj;
                        }
                    }
                }

            _statusFlag -= 32768;

            return retObj;
        }
        internal ModifiersTypeModifier ModifierTwo(SymbolSet symbolSet, ushort modifierCodeOne, ushort modifierCodeTwo)
        {
            ModifiersTypeModifier retObj = null;

            if (symbolSet != null)
                if(symbolSet.SectorTwoModifiers != null)
                {
                    foreach (ModifiersTypeModifier lObj in symbolSet.SectorTwoModifiers)
                    {
                        if (lObj.ModifierCode.DigitOne == modifierCodeOne &&
                           lObj.ModifierCode.DigitTwo == modifierCodeTwo)
                        {
                            return lObj;
                        }
                    }
                }

            _statusFlag -= 32768;

            return retObj;
        }
        private void _SetInvalidSymbolProps()
        {
            // If a symbol can't be recognized, this method sets up
            // the current symbol to represent the special Invalid symbol.

            _version = _librarian.Version(1, 0);
            _context = _librarian.Context(0);
            _dimension = _librarian.Dimension("INTERNAL");
            _standardIdentity = _librarian.StandardIdentity(1);
            _symbolSet = _librarian.SymbolSet(9, 8);
            _status = _librarian.Status(0);
            _hqTFDummy = _librarian.HQTFDummy(0);
            _amplifierGroup = _librarian.AmplifierGroup(0);
            _amplifier = _librarian.Amplifier(_amplifierGroup, 0);
            _affiliation = _librarian.Affiliation("REALITY", "INTERNAL", "SI_UNKNOWN");
            _entity = _librarian.Entity(_symbolSet, "INVALID");
            _entityType = null;
            _entitySubType = null;
            _modifierOne = null;
            _modifierTwo = null;
        }
        private void _UpdateFromCurrent()
        {
            // Search for the appropriate JMSML Library elements, given the current (2525D)
            // SIDC for this Symbol.

            string first10 = _sidc.PartAString;
            string second10 = _sidc.PartBString;

            _librarian.ResetStatusCode();

            _version = _librarian.Version(Convert.ToUInt16(first10.Substring(0, 1)),
                                          Convert.ToUInt16(first10.Substring(1, 1)));

            _context = _librarian.Context(Convert.ToUInt16(first10.Substring(2, 1)));
            _standardIdentity = _librarian.StandardIdentity(Convert.ToUInt16(first10.Substring(3, 1)));
            _sig = _librarian.StandardIdentityGroup(_standardIdentity);
            _symbolSet = _librarian.SymbolSet(Convert.ToUInt16(first10.Substring(4, 1)), Convert.ToUInt16(first10.Substring(5, 1)));

            if (_symbolSet != null)
            {
                _dimension = _librarian.DimensionBySymbolSet(_symbolSet.ID);
            }

            if (_context != null && _dimension != null && _standardIdentity != null)
            {
                _affiliation = _librarian.Affiliation(_context.ID, _dimension.ID, _standardIdentity.ID);
            }

            _status = _librarian.Status(Convert.ToUInt16(first10.Substring(6, 1)));
            _hqTFDummy = _librarian.HQTFDummy(Convert.ToUInt16(first10.Substring(7, 1)));
            _amplifierGroup = _librarian.AmplifierGroup(Convert.ToUInt16(first10.Substring(8, 1)));

            if (_amplifierGroup != null)
            {
                _amplifier = _librarian.Amplifier(_amplifierGroup, Convert.ToUInt16(first10.Substring(9, 1)));
            }

            if (_symbolSet != null)
            {
                _entity = _librarian.Entity(_symbolSet, Convert.ToUInt16(second10.Substring(0, 1)), Convert.ToUInt16(second10.Substring(1, 1)));

                if (_entity != null)
                {
                    _entityType = _librarian.EntityType(_entity, Convert.ToUInt16(second10.Substring(2, 1)), Convert.ToUInt16(second10.Substring(3, 1)));
                }

                if (_entityType != null)
                {
                    _entitySubType = _librarian.EntitySubType(_entityType, Convert.ToUInt16(second10.Substring(4, 1)), Convert.ToUInt16(second10.Substring(5, 1)));

                    if (_entitySubType == null)
                    {
                        _entitySubType = _librarian.EntitySubType(_symbolSet, Convert.ToUInt16(second10.Substring(4, 1)), Convert.ToUInt16(second10.Substring(5, 1)));
                    }
                }

                _modifierOne = _librarian.ModifierOne(_symbolSet, Convert.ToUInt16(second10.Substring(6, 1)), Convert.ToUInt16(second10.Substring(7, 1)));
                _modifierTwo = _librarian.ModifierTwo(_symbolSet, Convert.ToUInt16(second10.Substring(8, 1)), Convert.ToUInt16(second10.Substring(9, 1)));

                _legacySymbol = _librarian.LegacySymbol(_symbolSet, _entity, _entityType, _entitySubType, _modifierOne, _modifierTwo);
            }

            _librarian.LogConversionResult(_sidc.PartAString + ", " + _sidc.PartBString);

            _ValidateStatus();
        }
        internal SymbolSetLegacySymbol LegacySymbol(SymbolSet symbolSet, 
                                                  SymbolSetEntity entity, 
                                                  SymbolSetEntityEntityType entityType, 
                                                  EntitySubTypeType entitySubType, 
                                                  ModifiersTypeModifier modifierOne, 
                                                  ModifiersTypeModifier modifierTwo)
        {
            SymbolSetLegacySymbol retObj = null;

            // Account now for non-null modifiers that are effectively treated like null (00)

            if (modifierOne != null)
            {
                if (modifierOne.ModifierCode.DigitOne == 0 &&
                    modifierOne.ModifierCode.DigitTwo == 0)

                    modifierOne = null;
            }

            if (modifierTwo != null)
            {
                if (modifierTwo.ModifierCode.DigitOne == 0 &&
                    modifierTwo.ModifierCode.DigitTwo == 0)

                    modifierTwo = null;
            }

            // Now build a legacy 15 character SIDC from the 2525D symbol objects

            if (symbolSet != null)
            {
                if (symbolSet.LegacySymbols != null)
                {
                    int match = 0;

                    foreach (SymbolSetLegacySymbol lObj in symbolSet.LegacySymbols)
                    {
                        if(entity != null)
                        {
                            if (lObj.EntityID != "NA")
                            {
                                if (lObj.EntityID == entity.ID)
                                    match++;
                            }
                        }
                        else if(lObj.EntityID == "NA")
                            match++;

                        if(entityType != null)
                        {
                            if (lObj.EntityTypeID != "NA")
                            {
                                if (lObj.EntityTypeID == entityType.ID)
                                    match++;
                            }
                        }
                        else if(lObj.EntityTypeID == "NA")
                            match++;

                        if(entitySubType != null)
                        {
                            if (lObj.EntitySubTypeID != "NA")
                            {
                                if (lObj.EntitySubTypeID == entitySubType.ID)
                                    match++;
                            }
                        }
                        else if(lObj.EntitySubTypeID == "NA")
                            match++;

                        if(modifierOne != null)
                        {
                            if (lObj.ModifierOneID != "NA")
                            {
                                if (lObj.ModifierOneID == modifierOne.ID)
                                    match++;
                            }
                        }
                        else if(lObj.ModifierOneID == "NA")
                            match++;

                        if(modifierTwo != null)
                        {
                            if (lObj.ModifierTwoID != "NA")
                            {
                                if (lObj.ModifierTwoID == modifierTwo.ID)
                                    match++;
                            }
                        }
                        else if(lObj.ModifierTwoID == "NA")
                            match++;

                        if(match == 5)
                        {
                            return lObj;
                        }

                        match = 0;
                    }
                }
            }

            _statusFlag -= 65536;

            return retObj;
        }