Esempio n. 1
0
		static internal int InsertObjectIntoVirtualBackref(FdoCache cache, Mediator mediator,
			int hvoSlice, int clidNewObj, int flid)
		{
			var metadata = cache.ServiceLocator.GetInstance<IFwMetaDataCacheManaged>();
			if (metadata.get_IsVirtual(flid))
			{
				var sliceObj = cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(hvoSlice);
				int clidSlice = sliceObj.ClassID;
				if (clidNewObj == LexEntryTags.kClassId &&
					clidSlice == LexEntryTags.kClassId)
				{
					if (metadata.GetFieldName(flid) == "VariantFormEntryBackRefs")
					{
						using (var dlg = new InsertVariantDlg())
						{
							var entOld = (ILexEntry) sliceObj;
							dlg.SetHelpTopic("khtpInsertVariantDlg");
							dlg.SetDlgInfo(cache, mediator, entOld);
							if (dlg.ShowDialog() == DialogResult.OK && dlg.NewlyCreatedVariantEntryRefResult)
							{
								return entOld.VariantFormEntryBackRefs.Count();
							}
							// say we've handled this.
							return -2;
						}
					}
				}
			}
			return -1;
		}
Esempio n. 2
0
		static internal int InsertObjectIntoVirtualBackref(FdoCache cache, Mediator mediator, IVwVirtualHandler vh,
			int hvoSlice, uint clidNewObj, uint clidOwner, uint flid)
		{
			if (vh != null)
			{
				int clidSlice = cache.GetClassOfObject(hvoSlice);
				if (clidNewObj == LexEntry.kclsidLexEntry &&
					clidSlice == LexEntry.kclsidLexEntry &&
					clidOwner == LexDb.kclsidLexDb)
				{
					if (vh.FieldName == "VariantFormEntryBackRefs")
					{
						using (InsertVariantDlg dlg = new InsertVariantDlg())
						{
							ILexEntry entOld = LexEntry.CreateFromDBObject(cache, hvoSlice);
							dlg.SetHelpTopic("khtpInsertVariantDlg");
							dlg.SetDlgInfo(cache, mediator, entOld as IVariantComponentLexeme);
							if (dlg.ShowDialog() == DialogResult.OK && dlg.NewlyCreatedVariantEntryRefResult)
							{
								int insertPos = cache.GetVectorSize(hvoSlice, (int)flid);
								cache.PropChanged(hvoSlice, (int)flid, insertPos, 1, 0);
								return insertPos;
							}
							// say we've handled this.
							return -2;
						}
					}
				}
			}
			return -1;
		}