private void GetItemClassFromAttributes(XmlReader xrdr, out string sItemClass, out int clid) { sItemClass = xrdr.GetAttribute("itemClass"); if (String.IsNullOrEmpty(sItemClass)) { throw new Exception("Missing itemClass attribute for <List> element"); } clid = m_mdc.GetClassId(sItemClass); if (clid == 0) { throw new Exception("Invalid itemClass attribute value for <List> element"); } bool fOk = false; for (int i = 0; i < m_rgItemClasses.Length; ++i) { if (clid == m_rgItemClasses[i]) { fOk = true; break; } } if (!fOk) { throw new Exception("Invalid itemClass attribute value for <List> element: not a CmPossibility"); } // Find the names of subclasses of our particular class. One or more may be used in the XML file // instead of sItemClass. m_itemClassNames.Clear(); int[] subClassIds = m_mdc.GetAllSubclasses(clid); for (int i = 0; i < subClassIds.Length; ++i) { m_itemClassNames.Add(m_mdc.GetClassName(subClassIds [i])); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Import a file (encapsulated by a TextReader) containing translations for one or more lists. /// </summary> /// ------------------------------------------------------------------------------------ public bool ImportTranslatedLists(TextReader reader, FdoCache cache, IProgress progress) { m_cache = cache; m_mdc = cache.ServiceLocator.GetInstance <IFwMetaDataCacheManaged>(); m_rgItemClasses = m_mdc.GetAllSubclasses(CmPossibilityTags.kClassId); m_wsf = cache.WritingSystemFactory; m_wsEn = GetWsFromStr("en"); Debug.Assert(m_wsEn != 0); m_progress = progress; using (var xreader = XmlReader.Create(reader)) Import(xreader); return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Import a file (encapsulated by a TextReader) containing translations for one or more lists. /// </summary> /// ------------------------------------------------------------------------------------ public bool ImportTranslatedLists(TextReader reader, FdoCache cache, IProgress progress) { m_cache = cache; m_mdc = cache.ServiceLocator.GetInstance<IFwMetaDataCacheManaged>(); m_rgItemClasses = m_mdc.GetAllSubclasses(CmPossibilityTags.kClassId); m_wsf = cache.WritingSystemFactory; m_wsEn = GetWsFromStr("en"); Debug.Assert(m_wsEn != 0); m_progress = progress; using (var xreader = XmlReader.Create(reader)) Import(xreader); return true; }
/// <summary> /// Gets all subclasses of the given class, including itself (which is always the first /// result in the list, so it can easily be skipped if desired). The list is therefore /// a complete list of the classes which are valid to store in a property whose /// signature is the class identified by luClid. ///</summary> /// <param name='luClid'> </param> /// <param name='cluMax'> </param> /// <param name='_cluOut'> </param> /// <param name='_rgluSubclasses'> </param> public virtual void GetAllSubclasses(int luClid, int cluMax, out int _cluOut, ArrayPtr _rgluSubclasses) { m_metaDataCache.GetAllSubclasses(luClid, cluMax, out _cluOut, _rgluSubclasses); }