예제 #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// gives the CSharp type corresponding to the given the fieldworks class ID
		/// </summary>
		/// <param name="fcCache"></param>
		/// <param name="iClassId"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public static Type GetTypeFromFWClassID(FdoCache fcCache, int iClassId)
		{
			//CmObject is a special case because it is not part of a module.
			if (iClassId == CmObject.kClassId)
				return typeof(CmObject);
			// if the class ID is cached then return the type now.
			if (s_classIdToType.ContainsKey(iClassId))
				return s_classIdToType[iClassId];

			Type t = null;
			// Find the class name of this object
			string sClassName = fcCache.GetClassName((uint)iClassId);
			// find the Type for this class, which is painful 'cause we don't know the namespace
			string[] modules = new string[]{"Cellar", "Ling", "Scripture", "FeatSys", "LangProj", "Notebk"};
			foreach(string moduleName in modules)
			{
				string fullTypeName = string.Format("SIL.FieldWorks.FDO.{0}.{1}", moduleName, sClassName);
				t = fcCache.GetTypeInAssembly(fullTypeName);
				//t = Assembly.GetExecutingAssembly().GetType(fullTypeName, false, false);
				if (t != null)
					break;
			}
			Debug.Assert(t != null);

			// cache the type info and return it.
			s_classIdToType.Add(iClassId, t);
			return t;
		}
예제 #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// returns the CSharp type corresponding to be fully qualified name given
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="sFullClassName">e.g. "SIL.FieldWorks.FDO.Ling.WordformLookupList"</param>
		/// <returns>the CSharp type</returns>
		/// ------------------------------------------------------------------------------------
		public static Type GetTypeFromFullClassName(FdoCache cache, string sFullClassName)
		{
			Type t = cache.GetTypeInAssembly(sFullClassName);
			Debug.Assert(t != null);
			return t;
		}