Esempio n. 1
0
        internal ProcessTaskArgument(ShareManager shareManager, ShareDefinition shareDefinition)
        {
            shareManager.UpsertAndHydrate(this, shareDefinition);
            try
            {
                //if the import is into a repository other than the master original repository
                if (!shareManager.IsExportedObject(this.ProcessTask.LoadMetadata))
                {
                    //and we are a reference type e.g. to a ColumnInfo or something
                    var t = GetConcreteSystemType();

                    if (typeof(IMapsDirectlyToDatabaseTable).IsAssignableFrom(t) || typeof(IEnumerable <IMapsDirectlyToDatabaseTable>).IsAssignableFrom(t))
                    {
                        //then use the value Null because whatever ID is stored in us won't be pointing to the same object
                        //as when we were exported!
                        Value = null;
                        SaveToDatabase();
                    }
                }
            }
            catch (Exception e)
            {
                //couldn't work out the Type, maybe it is broken or something, or otherwise someone elses problem
                Console.WriteLine(e);
            }
        }
 public void ThrowIfDeleteDisallowed(IMapsDirectlyToDatabaseTable oTableWrapperObject)
 {
     if (_shareManager.IsExportedObject(oTableWrapperObject))
     {
         throw new Exception("You cannot Delete '" + oTableWrapperObject + "' because it is an Exported object declared in the ObjectExport table");
     }
 }
Esempio n. 3
0
        private void EnsureNotAlreadySharedLocally <T>(ICheckNotifier notifier, T m) where T : IMapsDirectlyToDatabaseTable
        {
            if (_shareManager.IsExportedObject(m))
            {
                var existingExport          = _shareManager.GetNewOrExistingExportFor(m);
                var existingImportReference = _shareManager.GetExistingImport(existingExport.SharingUID);

                if (existingImportReference != null)
                {
                    T existingImportInstance = m.Repository.GetObjectByID <T>(existingImportReference.ReferencedObjectID);
                    notifier.OnCheckPerformed(new CheckEventArgs(typeof(T) + " '" + m + "' is already locally shared as '" + existingImportInstance + "'", CheckResult.Fail));
                }
            }
        }
        public void CannotDeleteSharedObjectTest()
        {
            //create a test catalogue
            Catalogue c = new Catalogue(CatalogueRepository, "blah");

            Assert.IsFalse(_share.IsExportedObject(c));

            //make it exportable
            var exportDefinition = _share.GetNewOrExistingExportFor(c);

            Assert.IsTrue(_share.IsExportedObject(c));

            //cannot delete because object is shared externally
            Assert.Throws <Exception>(c.DeleteInDatabase);

            //no longer exportable
            exportDefinition.DeleteInDatabase();

            //no longer shared
            Assert.IsFalse(_share.IsExportedObject(c));

            //now we can delete it
            c.DeleteInDatabase();
        }