예제 #1
0
        /// <summary>
        /// Returns a new instance of VideoRentalOutlet class deserialized (loaded)
        /// from binary file stream.
        /// </summary>
        /// <returns>a new instance of VideoRentalOutlet database</returns>
        /// <remakrs>VideoRentalOutlet factory method</remakrs>
        ///
        public static VideoRentalOutlet Deserialize(Stream fileStream)
        {
            BinaryFormatter formatter = new BinaryFormatter();

            // Deserialize Video Rental Outlet database from the file and
            // assign the reference to the local variable.
            //
            object            deserializedObject = formatter.Deserialize(fileStream);
            VideoRentalOutlet store = deserializedObject as VideoRentalOutlet;

            if (store != null && !store.IsValidVersion)
            {
                string info = store.Version == null
                    ? "of unkown version" : "v" + store.Version;

                throw new Exception("Incompatible VRO database version!\r\n\r\n"
                                    + "File format is " + info
                                    + ". Application can handle only files in v"
                                    + VROLibVersion + " format.");
            }

            if (store == null)
            {
                throw new Exception("Failed to deserialize VRO database.");
            }

            return(store);
        }
예제 #2
0
        /////////////////////////////////////////////////////////////////////////////////

        #region [ Constructors ]

        /// <summary>
        /// Initializes a new instance with an empty collection without forwarding
        /// events to owning database.
        /// </summary>
        ///
        public GenericObjectCollection(VideoRentalOutlet database,
                                       string className, string itemName)
            : base(database, className)
        {
            this.Items = new List <T> ();

            this.ItemName = itemName;

            this.ForwardChangedEventsToDatabase = false;
        }
예제 #3
0
        /// <summary>
        /// Verifies whether this instance may be added to database as a new.
        /// </summary>
        ///
        protected void VerifyAddTo(VideoRentalOutlet database)
        {
            ThrowExceptionIfNotMutable();

            if (database == null)
            {
                throw new ArgumentNullException(
                          "Record must belong to some database.");
            }

            VerifyIntegrity();
        }
예제 #4
0
        /////////////////////////////////////////////////////////////////////////////////

        #region [ Constructors ]

        /// <summary>
        /// Constructs a new instance of MonitoredObject class.
        /// </summary>
        ///
        public MonitoredObject(VideoRentalOutlet database, string name)
            : base(database, name)
        {
        }
예제 #5
0
        /////////////////////////////////////////////////////////////////////////////////

        #region [ Constructors ]

        /// <summary>
        /// Creates a new instance of the generic VideoRentalOutlet database object.
        /// </summary>
        ///
        public GenericObject(VideoRentalOutlet database, string className)
        {
            this.Database  = database;
            this.ClassName = className;
        }