コード例 #1
0
ファイル: DbOps.cs プロジェクト: sillsdev/WorldPad
        /// <summary>
        /// Get a list of flids for the given class, and type.
        /// </summary>
        /// <param name="mdc"></param>
        /// <param name="clsid"></param>
        /// <param name="flidType"></param>
        /// <returns></returns>
        static public uint[] GetFieldsInClassOfType(IFwMetaDataCache mdc, uint clsid, FieldType flidType)
        {
            uint[] retval    = new uint[0];
            int    nflidType = (int)flidType;
            int    flidCount = mdc.GetFields(clsid, true, nflidType, 0, ArrayPtr.Null);

            if (flidCount > 0)
            {
                using (ArrayPtr rgflid = new ArrayPtr(flidCount * Marshal.SizeOf(typeof(uint))))
                {
                    int flidCount2 = mdc.GetFields(clsid, true, nflidType, flidCount, rgflid);
                    Debug.Assert(flidCount == flidCount2);
                    retval = (uint[])MarshalEx.NativeToArray(rgflid, flidCount, typeof(uint));
                }
            }
            return(retval);
        }
コード例 #2
0
ファイル: DbOps.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// Get a list of flids for the given class, and type.
		/// </summary>
		/// <param name="mdc"></param>
		/// <param name="clsid"></param>
		/// <param name="flidType"></param>
		/// <returns></returns>
		static public uint[] GetFieldsInClassOfType(IFwMetaDataCache mdc, uint clsid, FieldType flidType)
		{
			uint[] retval = new uint[0];
			int nflidType = (int)flidType;
			int flidCount = mdc.GetFields(clsid, true, nflidType, 0, ArrayPtr.Null);
			if(flidCount > 0)
			{
				using (ArrayPtr rgflid = new ArrayPtr(flidCount * Marshal.SizeOf(typeof(uint))))
				{
					int flidCount2 = mdc.GetFields(clsid, true, nflidType, flidCount, rgflid);
					Debug.Assert(flidCount == flidCount2);
					retval = (uint[])MarshalEx.NativeToArray(rgflid, flidCount, typeof(uint));
				}
			}
			return retval;
		}
コード例 #3
0
ファイル: FwModelBrowser.cs プロジェクト: sillsdev/WorldPad
        private void m_tvClasses_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            m_lvfields.Items.Clear();
            uint clid            = (uint)m_tvClasses.SelectedNode.Tag;
            int  countFoundFlids = m_mdc.GetFields(clid, true, (int)CellarModuleDefns.kgrfcptAll,
                                                   0, null);
            int allFlidCount = countFoundFlids;

            uint[] uIds;
            using (ArrayPtr flids = MarshalEx.ArrayToNative(allFlidCount, typeof(uint)))
            {
                countFoundFlids = m_mdc.GetFields(clid, true, (int)CellarModuleDefns.kgrfcptAll,
                                                  allFlidCount, flids);
                uIds = (uint[])MarshalEx.NativeToArray(flids, allFlidCount, typeof(uint));
            }
            m_lvfields.SuspendLayout();
            List <ListViewItem> list = new List <ListViewItem>();

            for (int i = uIds.Length - 1; i >= 0; --i)
            {
                uint flid = uIds[i];
                if (flid == 0)
                {
                    continue;                     // Keep looking for suitable flids lower in the array.
                }
                string       className = m_mdc.GetOwnClsName(flid);
                ListViewItem lvi       = new ListViewItem(className);           //m_lvfields.Items.Add(className);
                list.Add(lvi);
                // flid
                lvi.SubItems.Add(flid.ToString());
                // field name
                string fieldname = m_mdc.GetFieldName(flid);
                lvi.SubItems.Add(fieldname);
                int    flidType  = m_mdc.GetFieldType(flid);
                string type      = "Not recognized";
                string signature = "Not recognized";
                uint   dstClid;
                switch (flidType)
                {
                // Basic data types.
                case (int)CellarModuleDefns.kcptBoolean:
                    type      = "Basic";
                    signature = "Boolean";
                    break;

                case (int)CellarModuleDefns.kcptInteger:
                    type      = "Basic";
                    signature = "Integer";
                    break;

                case (int)CellarModuleDefns.kcptNumeric:
                    type      = "Basic";
                    signature = "Numeric";
                    break;

                case (int)CellarModuleDefns.kcptFloat:
                    type      = "Basic";
                    signature = "Float";
                    break;

                case (int)CellarModuleDefns.kcptTime:
                    type      = "Basic";
                    signature = "Time";
                    break;

                case (int)CellarModuleDefns.kcptGuid:
                    type      = "Basic";
                    signature = "Guid";
                    break;

                case (int)CellarModuleDefns.kcptImage:
                    type      = "Basic";
                    signature = "Image";
                    break;

                case (int)CellarModuleDefns.kcptGenDate:
                    type      = "Basic";
                    signature = "GenDate";
                    break;

                case (int)CellarModuleDefns.kcptBinary:
                    type      = "Basic";
                    signature = "Binary";
                    break;

                case (int)CellarModuleDefns.kcptString:
                    type      = "Basic";
                    signature = "String";
                    break;

                case (int)CellarModuleDefns.kcptBigString:
                    type      = "Basic";
                    signature = "String (big)";
                    break;

                case (int)CellarModuleDefns.kcptMultiString:
                    type      = "Basic";
                    signature = "MultiString";
                    break;

                case (int)CellarModuleDefns.kcptMultiBigString:
                    type      = "Basic";
                    signature = "MultiString (big)";
                    break;

                case (int)CellarModuleDefns.kcptUnicode:
                    type      = "Basic";
                    signature = "Unicode";
                    break;

                case (int)CellarModuleDefns.kcptBigUnicode:
                    type      = "Basic";
                    signature = "Unicode (big)";
                    break;

                case (int)CellarModuleDefns.kcptMultiUnicode:
                    type      = "Basic";
                    signature = "MultiUnicode";
                    break;

                case (int)CellarModuleDefns.kcptMultiBigUnicode:
                    type      = "Basic";
                    signature = "MultiUnicode (big)";
                    break;

                // CmObjects.
                case (int)CellarModuleDefns.kcptOwningAtom:
                    type      = "OA";
                    dstClid   = m_mdc.GetDstClsId(flid);
                    signature = m_mdc.GetClassName(dstClid);
                    break;

                case (int)CellarModuleDefns.kcptReferenceAtom:
                    type      = "RA";
                    dstClid   = m_mdc.GetDstClsId(flid);
                    signature = m_mdc.GetClassName(dstClid);
                    break;

                case (int)CellarModuleDefns.kcptOwningCollection:
                    type      = "OC";
                    dstClid   = m_mdc.GetDstClsId(flid);
                    signature = m_mdc.GetClassName(dstClid);
                    break;

                case (int)CellarModuleDefns.kcptReferenceCollection:
                    type      = "RC";
                    dstClid   = m_mdc.GetDstClsId(flid);
                    signature = m_mdc.GetClassName(dstClid);
                    break;

                case (int)CellarModuleDefns.kcptOwningSequence:
                    type      = "OS";
                    dstClid   = m_mdc.GetDstClsId(flid);
                    signature = m_mdc.GetClassName(dstClid);
                    break;

                case (int)CellarModuleDefns.kcptReferenceSequence:
                    type      = "RS";
                    dstClid   = m_mdc.GetDstClsId(flid);
                    signature = m_mdc.GetClassName(dstClid);
                    break;
                }
                // Type
                lvi.SubItems.Add(type);
                // Signature
                lvi.SubItems.Add(signature);
            }
            m_lvfields.Items.AddRange(list.ToArray());
            m_lvfields.ResumeLayout(true);
        }