public void CheckClassDependency(Schema.LoadedLibrary library, ClassDefinition classDefinition) { Schema.RegisteredClass classValue = Catalog.ClassLoader.GetClass(CatalogDeviceSession, classDefinition); if (!library.IsRequiredLibrary(classValue.Library)) { throw new Schema.SchemaException(Schema.SchemaException.Codes.NonRequiredClassDependency, classValue.Name, library.Name, classValue.Library.Name); // TODO: Better exception } }
public void AttachDependency(Schema.Object objectValue) { if (_creationObjects == null) { _creationObjects = new List <Schema.Object>(); } if (_creationObjects.Count > 0) { // If this is a generated object, attach the dependency to the generator, rather than the object directly. // Unless it is a device object, in which case the dependency should be attached to the generated object. if (objectValue.IsGenerated && !(objectValue is Schema.DeviceObject) && (objectValue.GeneratorID >= 0)) { objectValue = objectValue.ResolveGenerator(CatalogDeviceSession); } if (objectValue is Schema.Property) { objectValue = ((Schema.Property)objectValue).Representation; } Schema.Object localObjectValue = (Schema.Object)_creationObjects[_creationObjects.Count - 1]; if ((localObjectValue != objectValue) && (!(objectValue is Schema.Reference) || (localObjectValue is Schema.TableVar)) && (!localObjectValue.HasDependencies() || !localObjectValue.Dependencies.Contains(objectValue.ID))) { if (!_serverProcess.ServerSession.Server.IsEngine) { if ( (localObjectValue.Library != null) && !localObjectValue.IsSessionObject && !localObjectValue.IsATObject ) { Schema.LoadedLibrary library = localObjectValue.Library; Schema.LoadedLibrary dependentLibrary = objectValue.Library; if (dependentLibrary == null) { throw new Schema.SchemaException(Schema.SchemaException.Codes.NonLibraryDependency, localObjectValue.Name, library.Name, objectValue.Name); } if (!library.IsRequiredLibrary(dependentLibrary) && (!String.Equals(dependentLibrary.Name, Engine.SystemLibraryName, StringComparison.OrdinalIgnoreCase))) // Ignore dependencies to the system library, these are implicitly available { throw new Schema.SchemaException(Schema.SchemaException.Codes.NonRequiredLibraryDependency, localObjectValue.Name, library.Name, objectValue.Name, dependentLibrary.Name); } } // if LObject is not a session object or an AT object, AObject cannot be a session object if ((localObjectValue is Schema.CatalogObject) && !localObjectValue.IsSessionObject && !localObjectValue.IsATObject && objectValue.IsSessionObject) { throw new Schema.SchemaException(Schema.SchemaException.Codes.SessionObjectDependency, localObjectValue.Name, ((Schema.CatalogObject)objectValue).SessionObjectName); } // if LObject is not a generated or an AT object or a plan object (Name == SessionObjectName), AObject cannot be an AT object if (((localObjectValue is Schema.CatalogObject) && (((Schema.CatalogObject)localObjectValue).SessionObjectName != localObjectValue.Name)) && !localObjectValue.IsGenerated && !localObjectValue.IsATObject && objectValue.IsATObject) { if (objectValue is Schema.TableVar) { throw new Schema.SchemaException(Schema.SchemaException.Codes.ApplicationTransactionObjectDependency, localObjectValue.Name, ((Schema.TableVar)objectValue).SourceTableName); } else { throw new Schema.SchemaException(Schema.SchemaException.Codes.ApplicationTransactionObjectDependency, localObjectValue.Name, ((Schema.Operator)objectValue).SourceOperatorName); } } } Error.AssertFail(objectValue.ID > 0, "Object {0} does not have an object id and cannot be tracked as a dependency.", objectValue.Name); localObjectValue.AddDependency(objectValue); } } }