Exemplo n.º 1
0
		/// <summary>Member get_IsPropInCache</summary>
		/// <param name='hvo'>hvo</param>
		/// <param name='tag'>tag</param>
		/// <param name='cpt'>cpt</param>
		/// <param name='ws'>ws</param>
		/// <returns>A System.Boolean</returns>
		public bool get_IsPropInCache(int hvo, int tag, int cpt, int ws)
		{
			CheckDisposed();

			var key = new HvoFlidKey(hvo, tag);
			var keyWs = new HvoFlidWSKey(hvo, tag, ws);
			switch ((CellarPropertyType)cpt)
			{
				default:
					throw new ArgumentException("Invalid field type (cpt).");
				case CellarPropertyType.Boolean:
					return m_boolCache.ContainsKey(key);
				case CellarPropertyType.Integer:
					return m_intCache.ContainsKey(key);
				case CellarPropertyType.Numeric:
					return false; // m_intCache.ContainsKey(key);
				case CellarPropertyType.Float:
					return false; // m_intCache.ContainsKey(key);
				case CellarPropertyType.Time:
					return m_longCache.ContainsKey(key);
				case CellarPropertyType.Guid:
					return m_guidCache.ContainsKey(key);
				case CellarPropertyType.Image:
					return false; //  m_intCache.ContainsKey(key);
				case CellarPropertyType.GenDate:
					return false; //  m_intCache.ContainsKey(key);
				case CellarPropertyType.Binary:
					return false;
				case CellarPropertyType.String:
					return m_basicITsStringCache.ContainsKey(key);
				case CellarPropertyType.MultiUnicode: // Fall through.
				case CellarPropertyType.MultiString:
					return m_extendedKeyCache.ContainsKey(keyWs);
				case CellarPropertyType.Unicode:
					return m_basicStringCache.ContainsKey(key);

				case CellarPropertyType.OwningAtomic:
					return m_intCache.ContainsKey(key);
				case CellarPropertyType.ReferenceAtomic:
					return m_intCache.ContainsKey(key);
				case CellarPropertyType.OwningCollection:
				case CellarPropertyType.ReferenceCollection:
				case CellarPropertyType.OwningSequence:
				case CellarPropertyType.ReferenceSequence:
					return m_vectorCache.ContainsKey(key);
			}
		}
Exemplo n.º 2
0
		/// <summary>Member Replace</summary>
		/// <param name='hvoObj'>hvoObj</param>
		/// <param name='tag'>tag</param>
		/// <param name='ihvoMin'>ihvoMin</param>
		/// <param name='ihvoLim'>ihvoLim</param>
		/// <param name='rghvo'>rghvo</param>
		/// <param name='chvo'>chvo</param>
		public void Replace(int hvoObj, int tag, int ihvoMin, int ihvoLim, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] int[] rghvo, int chvo)
		{
			CheckDisposed();

			List<int> list;
			HvoFlidKey key = new HvoFlidKey(hvoObj, tag);
			if (m_vectorCache.TryGetValue(key, out list))
			{
				while (ihvoLim > ihvoMin)
				{
					list.RemoveAt(ihvoMin);
					ihvoLim--;
				}
			}
			else
				m_vectorCache[key] = list = new List<int>(chvo);

			ihvoMin = Math.Min(ihvoMin, list.Count);
			list.InsertRange(ihvoMin, rghvo);

			for (int i = ihvoMin; i < list.Count; i++)
				CacheIntProp(list[i], (int)CmObjectFields.kflidCmObject_OwnOrd, i);
		}
Exemplo n.º 3
0
		/// <summary>Member get_Prop</summary>
		/// <param name='hvo'>hvo</param>
		/// <param name='tag'>tag</param>
		/// <returns>A System.Object</returns>
		public object get_Prop(int hvo, int tag)
		{
			CheckDisposed();

			object result = null;
			var fieldType = MetaDataCache.GetFieldType(tag);
			if (get_IsPropInCache(hvo, tag, fieldType, 0))
			{
				var key = new HvoFlidKey(hvo, tag);
				switch ((CellarPropertyType)fieldType)
				{
					case CellarPropertyType.Boolean:
						result = m_boolCache[key];
						break;
					case CellarPropertyType.Integer:
						result = m_intCache[key];
						break;
					case CellarPropertyType.Numeric:
						break; // m_intCache.ContainsKey(key);
					case CellarPropertyType.Float:
						break; // m_intCache.ContainsKey(key);
					case CellarPropertyType.Time:
						result = m_longCache[key];
						break;
					case CellarPropertyType.Guid:
						result = m_guidCache[key];
						break;
					case CellarPropertyType.Image:
						break; //  m_intCache.ContainsKey(key);
					case CellarPropertyType.GenDate:
						break; //  m_intCache.ContainsKey(key);
					case CellarPropertyType.Binary:
						break;
					case CellarPropertyType.String:
						result = m_basicITsStringCache[key];
						break;
					case CellarPropertyType.MultiUnicode:
					case CellarPropertyType.MultiString:
						result = get_MultiStringProp(hvo, tag);
						break;
					case CellarPropertyType.Unicode:
						result = m_basicStringCache[key];
						break;

					case CellarPropertyType.OwningAtomic: // Fall through
					case CellarPropertyType.ReferenceAtomic:
						return m_intCache[key];

					case CellarPropertyType.OwningCollection:
					case CellarPropertyType.ReferenceCollection:
					case CellarPropertyType.OwningSequence:
					case CellarPropertyType.ReferenceSequence:
						result = m_vectorCache[key];
						break;
				}
			}
			else
			{
				var ms = get_MultiStringProp(hvo, tag);
				if (ms.StringCount > 0)
					result = ms;
				else if (Marshal.IsComObject(ms))
					Marshal.ReleaseComObject(ms);
			}

			return result;
		}
Exemplo n.º 4
0
		/// <summary>Member get_VecSize</summary>
		/// <param name='hvo'>hvo</param>
		/// <param name='tag'>tag</param>
		/// <returns>A System.Int32</returns>
		public int get_VecSize(int hvo, int tag)
		{
			CheckDisposed();

			var key = new HvoFlidKey(hvo, tag);
			List<int> collection;
			return m_vectorCache.TryGetValue(key, out collection) ? collection.Count : 0;
		}
Exemplo n.º 5
0
		/// <summary>Member GetObjIndex</summary>
		/// <param name='hvoOwn'>hvoOwn</param>
		/// <param name='flid'>flid</param>
		/// <param name='hvo'>hvo</param>
		/// <returns>A System.Int32</returns>
		/// <remarks>IVwCacheDa method</remarks>
		public int GetObjIndex(int hvoOwn, int flid, int hvo)
		{
			CheckDisposed();

			var key = new HvoFlidKey(hvoOwn, flid);
			var val = m_vectorCache[key];
			return val.IndexOf(hvo);
		}
Exemplo n.º 6
0
		/// <summary>Member BinaryPropRgb</summary>
		/// <param name='obj'>obj</param>
		/// <param name='tag'>tag</param>
		/// <param name='rgb'>rgb</param>
		/// <param name='cbMax'>cbMax</param>
		/// <param name='cb'>cb</param>
		/// <remarks>ISilDataAccess method</remarks>
		public void BinaryPropRgb(int obj, int tag, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ArrayPtrMarshaler), SizeParamIndex = 3)] ArrayPtr/*byte[]*/ rgb, int cbMax, out int cb)
		{
			CheckDisposed();

			CheckBasics(obj);

			var key = new HvoFlidKey(obj, tag);
			var removeFromCache = false;
			if (!m_basicByteArrayCache.ContainsKey(key))
				removeFromCache = CheckForVirtual(obj, tag);
			var array = m_basicByteArrayCache[key];
			if (removeFromCache)
				m_basicByteArrayCache.Remove(key);
			cb = array.Length;
			if (cbMax == 0)
				return;
			if (cb > cbMax)
				throw new ArgumentException("cb cannot be larger than cbMax");

			MarshalEx.ArrayToNative(rgb, cbMax, array);
		}
Exemplo n.º 7
0
		/// <summary>Member get_VecSize</summary>
		/// <param name='hvo'>hvo</param>
		/// <param name='tag'>tag</param>
		/// <returns>A System.Int32</returns>
		public int get_VecSize(int hvo, int tag)
		{
			CheckDisposed();

			HvoFlidKey key = new HvoFlidKey(hvo, (uint)tag);
			List<int> val = m_vectorCache[key];
			return val.Count;
		}
Exemplo n.º 8
0
		/// <summary>Member get_GuidProp</summary>
		/// <param name='hvo'>hvo</param>
		/// <param name='tag'>tag</param>
		/// <returns>A System.Guid</returns>
		/// <remarks>ISilDataAccess method</remarks>
		public System.Guid get_GuidProp(int hvo, int tag)
		{
			CheckDisposed();

			CheckBasics(hvo);

			HvoFlidKey key = new HvoFlidKey(hvo, (uint)tag);
			Guid val;
			bool removeFromCache = false;
			if (!m_guidCache.ContainsKey(key))
				removeFromCache = CheckForVirtual(hvo, tag);
			val = m_guidCache[key];
			if (removeFromCache)
				m_guidCache.Remove(key);
			return val;
		}
Exemplo n.º 9
0
		public object get_UnknownProp(int hvo, int tag)
		{
			CheckDisposed();

			CheckBasics(hvo);

			HvoFlidKey key = new HvoFlidKey(hvo, (uint)tag);
			bool removeFromCache = false;
			if (!m_basicObjectCache.ContainsKey(key))
				removeFromCache = CheckForVirtual(hvo, tag);
			object val = m_basicObjectCache[key];
			if (removeFromCache)
				m_basicObjectCache.Remove(key);
			return val;
		}
Exemplo n.º 10
0
		private int GetFromIntCache(int hvo, int tag)
		{
			CheckBasics(hvo);

			HvoFlidKey key = new HvoFlidKey(hvo, (uint)tag);
			int val;
			bool removeFromCache = false;
			if (!m_intCache.ContainsKey(key))
				removeFromCache = CheckForVirtual(hvo, tag);
			val = m_intCache[key];
			if (removeFromCache)
				m_intCache.Remove(key);
			return val;
		}
Exemplo n.º 11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Member get_BooleanProp
		/// </summary>
		/// <param name="hvo">hvo</param>
		/// <param name="tag">tag</param>
		/// <returns>A System.Boolean</returns>
		/// <remarks>ISilDataAccess method</remarks>
		/// ------------------------------------------------------------------------------------
		public bool get_BooleanProp(int hvo, int tag)
		{
			CheckDisposed();

			CheckBasics(hvo);

			HvoFlidKey key = new HvoFlidKey(hvo, (uint)tag);
			bool val;
			bool removeFromCache = false;
			if (!m_boolCache.ContainsKey(key))
				removeFromCache = CheckForVirtual(hvo, tag);
			val = m_boolCache[key];
			if (removeFromCache)
				m_boolCache.Remove(key);
			return val;
		}
Exemplo n.º 12
0
		/// <summary>Member get_IsPropInCache</summary>
		/// <param name='hvo'>hvo</param>
		/// <param name='tag'>tag</param>
		/// <param name='cpt'>cpt</param>
		/// <param name='ws'>ws</param>
		/// <returns>A System.Boolean</returns>
		public bool get_IsPropInCache(int hvo, int tag, int cpt, int ws)
		{
			CheckDisposed();

			HvoFlidKey key = new HvoFlidKey(hvo, (uint)tag);
			HvoFlidWSKey keyWs = new HvoFlidWSKey(hvo, (uint)tag, ws);
			switch (cpt)
			{
				default:
					throw new ArgumentException("Invalid field type (cpt).");
				case (int)CellarModuleDefns.kcptBoolean:
					return m_boolCache.ContainsKey(key);
				case (int)CellarModuleDefns.kcptInteger:
					return m_intCache.ContainsKey(key);
				case (int)CellarModuleDefns.kcptNumeric:
					return false; // m_intCache.ContainsKey(key);
				case (int)CellarModuleDefns.kcptFloat:
					return false; // m_intCache.ContainsKey(key);
				case (int)CellarModuleDefns.kcptTime:
					return m_longCache.ContainsKey(key);
				case (int)CellarModuleDefns.kcptGuid:
					return m_guidCache.ContainsKey(key);
				case (int)CellarModuleDefns.kcptImage:
					return false; //  m_intCache.ContainsKey(key);
				case (int)CellarModuleDefns.kcptGenDate:
					return false; //  m_intCache.ContainsKey(key);
				case (int)CellarModuleDefns.kcptBinary:
					return false;
				case (int)CellarModuleDefns.kcptString: // Fall through.
				case (int)CellarModuleDefns.kcptBigString:
					return m_basicITsStringCache.ContainsKey(key);
				case (int)CellarModuleDefns.kcptMultiUnicode: // Fall through.
				case (int)CellarModuleDefns.kcptMultiBigUnicode: // Fall through.
				case (int)CellarModuleDefns.kcptMultiString: // Fall through.
				case (int)CellarModuleDefns.kcptMultiBigString:
					return m_extendedKeyCache.ContainsKey(keyWs);
				case (int)CellarModuleDefns.kcptUnicode: // Fall through.
				case (int)CellarModuleDefns.kcptBigUnicode:
					return m_basicStringCache.ContainsKey(key);

				case (int)CellarModuleDefns.kcptOwningAtom:
					return m_intCache.ContainsKey(key);
				case (int)CellarModuleDefns.kcptReferenceAtom:
					return m_intCache.ContainsKey(key);
				case (int)CellarModuleDefns.kcptOwningCollection:
				case (int)CellarModuleDefns.kcptReferenceCollection:
				case (int)CellarModuleDefns.kcptOwningSequence:
				case (int)CellarModuleDefns.kcptReferenceSequence:
					return m_vectorCache.ContainsKey(key);
			}
		}
Exemplo n.º 13
0
		/// <summary>Member get_Prop</summary>
		/// <param name='hvo'>hvo</param>
		/// <param name='tag'>tag</param>
		/// <returns>A System.Object</returns>
		public object get_Prop(int hvo, int tag)
		{
			CheckDisposed();

			object result = null;
			int fieldType = MetaDataCache.GetFieldType((uint)tag);
			if (get_IsPropInCache(hvo, tag, fieldType, 0))
			{
				HvoFlidKey key = new HvoFlidKey(hvo, (uint)tag);
				switch (fieldType)
				{
					case (int)CellarModuleDefns.kcptBoolean:
						result = m_boolCache[key];
						break;
					case (int)CellarModuleDefns.kcptInteger:
						result = m_intCache[key];
						break;
					case (int)CellarModuleDefns.kcptNumeric:
						break; // m_intCache.ContainsKey(key);
					case (int)CellarModuleDefns.kcptFloat:
						break; // m_intCache.ContainsKey(key);
					case (int)CellarModuleDefns.kcptTime:
						result = m_longCache[key];
						break;
					case (int)CellarModuleDefns.kcptGuid:
						result = m_guidCache[key];
						break;
					case (int)CellarModuleDefns.kcptImage:
						break; //  m_intCache.ContainsKey(key);
					case (int)CellarModuleDefns.kcptGenDate:
						break; //  m_intCache.ContainsKey(key);
					case (int)CellarModuleDefns.kcptBinary:
						break;
					case (int)CellarModuleDefns.kcptString: // Fall through.
					case (int)CellarModuleDefns.kcptBigString:
						result = m_basicITsStringCache[key];
						break;
					case (int)CellarModuleDefns.kcptMultiUnicode: // Fall through.
					case (int)CellarModuleDefns.kcptMultiBigUnicode: // Fall through.
					case (int)CellarModuleDefns.kcptMultiString: // Fall through.
					case (int)CellarModuleDefns.kcptMultiBigString:
						result = get_MultiStringProp(hvo, tag);
						break;
					case (int)CellarModuleDefns.kcptUnicode: // Fall through.
					case (int)CellarModuleDefns.kcptBigUnicode:
						result = m_basicStringCache[key];
						break;

					case (int)CellarModuleDefns.kcptOwningAtom: // Fall through
					case (int)CellarModuleDefns.kcptReferenceAtom:
						return m_intCache[key];

					case (int)CellarModuleDefns.kcptOwningCollection:
					case (int)CellarModuleDefns.kcptReferenceCollection:
					case (int)CellarModuleDefns.kcptOwningSequence:
					case (int)CellarModuleDefns.kcptReferenceSequence:
						result = m_vectorCache[key];
						break;
				}
			}
			else
			{
				ITsMultiString ms = get_MultiStringProp(hvo, tag);
				if (ms.StringCount > 0)
					result = ms;
			}

			return result;
		}
Exemplo n.º 14
0
		/// <summary>Member GetObjIndex</summary>
		/// <param name='hvoOwn'>hvoOwn</param>
		/// <param name='flid'>flid</param>
		/// <param name='hvo'>hvo</param>
		/// <returns>A System.Int32</returns>
		/// <remarks>IVwCacheDa method</remarks>
		public int GetObjIndex(int hvoOwn, int flid, int hvo)
		{
			CheckDisposed();

			HvoFlidKey key = new HvoFlidKey(hvoOwn, (uint)flid);
			List<int> val = m_vectorCache[key];
			return val.IndexOf(hvo);
		}
Exemplo n.º 15
0
		private long GetFromLongCache(int hvo, int tag)
		{
			CheckBasics(hvo);

			var key = new HvoFlidKey(hvo, tag);
			var removeFromCache = false;
			if (!m_longCache.ContainsKey(key))
				removeFromCache = CheckForVirtual(hvo, tag);
			var val = m_longCache[key];
			if (removeFromCache)
				m_longCache.Remove(key);
			return val;
		}
Exemplo n.º 16
0
		/// <summary>Get the full contents of the specified sequence in one go.</summary>
		/// <param name='hvo'>hvo</param>
		/// <param name='tag'>tag</param>
		/// <param name='chvoMax'>chvoMax</param>
		/// <param name='chvo'>chvo</param>
		/// <param name='rghvo'>rghvo</param>
		public void VecProp(int hvo, int tag, int chvoMax, out int chvo, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ArrayPtrMarshaler), SizeParamIndex = 2)] ArrayPtr/*long[]*/ rghvo)
		{
			CheckDisposed();

			CheckBasics(hvo);
			chvo = 0;

			var key = new HvoFlidKey(hvo, tag);
			var removeFromCache = false;
			if (!m_vectorCache.ContainsKey(key))
				removeFromCache = CheckForVirtual(hvo, tag);
			List<int> val = m_vectorCache[key];
			if (removeFromCache)
				m_vectorCache.Remove(key);

			if (val.Count > chvoMax)
				throw new ArgumentException("The count is greater than the parameter 'chvo'.");
			chvo = val.Count;
			MarshalEx.ArrayToNative(rghvo, chvoMax, val.ToArray());
		}
Exemplo n.º 17
0
		/// <summary>Member get_UnicodeProp</summary>
		/// <param name='obj'>obj</param>
		/// <param name='tag'>tag</param>
		/// <returns>A System.String</returns>
		/// <remarks>ISilDataAccess method</remarks>
		public string get_UnicodeProp(int obj, int tag)
		{
			CheckDisposed();

			CheckBasics(obj);

			var key = new HvoFlidKey(obj, tag);
			var removeFromCache = false;
			if (!m_basicStringCache.ContainsKey(key))
				removeFromCache = CheckForVirtual(obj, tag);
			var val = m_basicStringCache[key];
			if (removeFromCache)
				m_basicStringCache.Remove(key);
			return val;
		}
Exemplo n.º 18
0
		/// <summary>Member get_VecItem</summary>
		/// <param name='hvo'>hvo</param>
		/// <param name='tag'>tag</param>
		/// <param name='index'>index</param>
		/// <returns>A System.Int32</returns>
		public int get_VecItem(int hvo, int tag, int index)
		{
			CheckDisposed();

			var key = new HvoFlidKey(hvo, tag);
			var val = m_vectorCache[key];
			return val[index];
		}
Exemplo n.º 19
0
		/// <summary>Member get_StringProp</summary>
		/// <param name='hvo'>hvo</param>
		/// <param name='tag'>tag</param>
		/// <returns>A ITsString</returns>
		/// <remarks>ISilDataAccess method</remarks>
		public ITsString get_StringProp(int hvo, int tag)
		{
			CheckDisposed();

			CheckBasics(hvo);

			var key = new HvoFlidKey(hvo, tag);
			var removeFromCache = false;
			if (!m_basicITsStringCache.ContainsKey(key))
				removeFromCache = CheckForVirtual(hvo, tag);
			var val = m_basicITsStringCache[key];
			if (removeFromCache)
				m_basicITsStringCache.Remove(key);
			return val;
		}
Exemplo n.º 20
0
		/// <summary>Member get_VecItem</summary>
		/// <param name='hvo'>hvo</param>
		/// <param name='tag'>tag</param>
		/// <param name='index'>index</param>
		/// <returns>A System.Int32</returns>
		public int get_VecItem(int hvo, int tag, int index)
		{
			CheckDisposed();

			HvoFlidKey key = new HvoFlidKey(hvo, (uint)tag);
			List<int> val = m_vectorCache[key];
			return val[index];
		}