// TODO : remove parameter itemType if generic constraints allow internal and parameterized constructors.
        // Parameter itemType is used as a workaround to instanciate a VolumeItem object,
        // because the internal VolumeItem constructor with the database parameter can't be used in generic code.
        // see http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=9a8e58ee-1371-4e99-8385-c3e2a4157fd6
        // see http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=80517ec1-2d08-43cc-bc90-9927877061a9

        /// <summary>
        /// Returns a specific VolumeItem object, but preassigns properties of the VolumeItem baseclass only.
        /// Filling properties of the specific, derived object, is job of the specific VolumeScanner implementation.
        /// </summary>
        /// <typeparam name="TVolumeItem">Type of the specific volume item.</typeparam>
        /// <returns>
        /// A new specific VolumeItem derived from base class VolumeItem
        /// with all base class properties preassigned.
        /// </returns>
        protected TVolumeItem GetNewVolumeItem <TVolumeItem>(long parentID,
                                                             string name,
                                                             string mimeType,
                                                             MetadataStore metaData,
                                                             VolumeItemType itemType)
            where TVolumeItem : VolumeItem
        {
            // TODO: check here if TMediaItem applies to TMedia?

            /* TVolumeItem item = new TVolumeItem(database); */
            TVolumeItem item = (TVolumeItem)VolumeItem.CreateInstance(itemType, database);

            // initialize fields of the VolumeItem base class.
            // don't initialize via properties. initializing via properties is error-prone
            // as the compiler won't error if a new field is added to the base class
            // and forgotten to be initialized here.
            item.SetVolumeItemFields(volume.VolumeID,
                                     itemID,
                                     parentID,
                                     name,
                                     mimeType,
                                     metaData,
                                     null,
                                     null);

            itemID++;

            return(item);
        }
Exemple #2
0
        internal static VolumeItem CreateInstance(VolumeItemType type, VolumeDatabase database)
        {
            VolumeItem item = null;

            switch (type)
            {
            case VolumeItemType.DirectoryVolumeItem:
                item = new DirectoryVolumeItem(database);
                break;

            case VolumeItemType.FileVolumeItem:
                item = new FileVolumeItem(database);
                break;

            case VolumeItemType.AudioCdRootVolumeItem:
                item = new AudioCdRootVolumeItem(database);
                break;

            case VolumeItemType.AudioTrackVolumeItem:
                item = new AudioTrackVolumeItem(database);
                break;

            default:
                throw new NotImplementedException(string.Format("Instantiation of type {0} is not implemented", type.ToString()));
            }
            return(item);
        }
Exemple #3
0
 internal FileSystemVolumeItem(VolumeDatabase database, VolumeItemType volumeItemType)
     : base(database, volumeItemType)
 {
     this.location			= null;
     //this.createdDate	 = DateTime.MinValue;
     this.lastWriteTime		= DateTime.MinValue;
     this.symLinkTargetID	= VolumeDatabase.ID_NONE;
 }
Exemple #4
0
 internal FileSystemVolumeItem(VolumeDatabase database, VolumeItemType volumeItemType)
     : base(database, volumeItemType)
 {
     this.location = null;
     //this.createdDate	 = DateTime.MinValue;
     this.lastWriteTime   = DateTime.MinValue;
     this.symLinkTargetID = VolumeDatabase.ID_NONE;
 }
Exemple #5
0
        public static ItemEditor CreateInstance(VolumeItemType itemType)
        {
            switch (itemType)
            {
            case VolumeItemType.FileVolumeItem:
                return(new FileItemEditor());

            case VolumeItemType.DirectoryVolumeItem:
                return(new DirectoryItemEditor());

            case VolumeItemType.AudioTrackVolumeItem:
                return(new AudioTrackItemEditor());

            default:
                throw new NotImplementedException(string.Format("ItemEditor widget for VolumeItemType {0} is not implemented", itemType.ToString()));
            }
        }
Exemple #6
0
        internal VolumeItem(VolumeDatabase database, VolumeItemType itemType)
            : base(tableName, primarykeyFields)
        {
            this.volumeID = 0L;
            this.itemID   = 0L;
            //this.rootID	  = 0L;
            this.parentID = 0L;

            this.name     = null;
            this.mimeType = null;
            this.metaData = MetadataStore.Empty;
            this.note     = null;
            this.keywords = null;

            //this.ownerVolume	  = null;

            this.database = database;
            this.itemType = itemType;
        }
Exemple #7
0
        internal VolumeItem(VolumeDatabase database, VolumeItemType itemType)
            : base(tableName, primarykeyFields)
        {
            this.volumeID		= 0L;
            this.itemID			= 0L;
            //this.rootID	  = 0L;
            this.parentID		= 0L;

            this.name			= null;
            this.mimeType		= null;
            this.metaData		= MetadataStore.Empty;
            this.note			= null;
            this.keywords		= null;

            //this.ownerVolume	  = null;

            this.database		= database;
            this.itemType		= itemType;
        }
Exemple #8
0
 internal static VolumeItem CreateInstance(VolumeItemType type, VolumeDatabase database)
 {
     VolumeItem item = null;
     switch (type) {
         case VolumeItemType.DirectoryVolumeItem:
             item = new DirectoryVolumeItem(database);
             break;
         case VolumeItemType.FileVolumeItem:
             item = new FileVolumeItem(database);
             break;
         case VolumeItemType.AudioCdRootVolumeItem:
             item = new AudioCdRootVolumeItem(database);
             break;
         case VolumeItemType.AudioTrackVolumeItem:
             item = new AudioTrackVolumeItem(database);
             break;
         default:
             throw new NotImplementedException(string.Format("Instantiation of type {0} is not implemented", type.ToString()));
     }
     return item;
 }