SIL.FieldWorks.CacheLight.RealDataCache.CheckHvoTagMatch C# (CSharp) Method

CheckHvoTagMatch() private method

private CheckHvoTagMatch ( int hvo, int tag ) : void
hvo int
tag int
return void
		private void CheckHvoTagMatch(int hvo, int tag)
		{
			if (!m_checkWithMDC)
				return;

			// NB: This will throw an exception, if the class hasn't already been put into the cache.
			// But then, CheckBasics should already have been called,
			// which would have thrown it before.
			var clid = get_IntProp(hvo, (int)CmObjectFields.kflidCmObject_Class);
			// First find out how many there are.
			var countAllFlidsOut = MetaDataCache.GetFields(clid, true,
				(int)CellarPropertyTypeFilter.All, 0, null);
			// Now get them for real.
			using (var flids = MarshalEx.ArrayToNative<int>(countAllFlidsOut))
			{
				var foundFlid = false;
				countAllFlidsOut = MetaDataCache.GetFields(clid, true,
					(int)CellarPropertyTypeFilter.All, countAllFlidsOut, flids);
				var flids1 = MarshalEx.NativeToArray<int>(flids, countAllFlidsOut);
				for (var i = 0; i < flids1.Length; ++i)
				{
					var flid = flids1[i];
					if (flid != tag) continue;

					foundFlid = true;
					break;
				}
				if (!foundFlid)
					throw new ArgumentException(String.Format("Invalid 'tag' ({0}) for 'hvo' ({1})", tag, hvo));
			}
		}