private bool CanInsertPictureOrMediaFile(object cmd, out int flid)
{
Command command = (Command) cmd;
string field = command.GetParameter("field");
string className = command.GetParameter("className");
Slice current = m_dataEntryForm.CurrentSlice;
if (current == null || current.IsDisposed) // LT-3347: there are no slices in this empty data set
{
flid = 0;
return false;
}
var obj = current.Object;
if (obj == null || !obj.IsValidObject)
{
// Something has gone horribly wrong, but let's not die.
flid = 0;
return false;
}
IFwMetaDataCache mdc = obj.Cache.DomainDataByFlid.MetaDataCache;
int clid = 0;
try { clid = mdc.GetClassId(className); }
catch { throw new ConfigurationException("Unknown class for insert command: " + className); }
try { flid = mdc.GetFieldId2(clid, field, true); }
catch { throw new ConfigurationException("Unknown field: " + className + "." + field); }
int clidObj = obj.ClassID;
return (clidObj == clid); // enhance JohnT: we could allow clidObj to be a subclass of clid.
}