ExtendedItemTransactionCollection, m_AddingToCollection and RejectItem

Hi.

The AddInternal method checks the m_AddingToCollection field for zero and calls RejectItem. I can create an action to throw an item when the RejectItem fires.
But I want to know in advance if there is a place?
The CanAddItem method tries to add item and if there is no m_AddingToCollection = null;

Perhaps there is a way to find out m_AddingToCollection?

Now I have done this ExtendedItemTransactionCollection:

C#:
        protected ItemCollection m_AddingToCollection;
    
        public ItemCollection AddingToCollection => m_AddingToCollection;

And I have an action that checks if it can add.

C#:
protected override bool CanInvokeInternal(ItemInfo itemInfo, ItemUser itemUser)
{
    //....
    var addedItemInfo = itemCollection.CanAddItem(itemInfo);
    if (addedItemInfo.HasValue == false)
        return false;

    return itemCollection.AddingToCollection != null;
}

This decision is normal, or there are other options?
 
Last edited:
Interesting, I hadn't really thought of that. I'm currently on vacation until the 3rd, but once I am back I'll have a closer look into this. Perhaps I can add this (or something similar) to the base class. But in the mean time do create your own class such that you can proceed normally
 
It looks like I was inattentive again, the documentation has an example of checking:

C#:
//create the Item Info you plan to add.
var itemInfoToAdd = (ItemInfo)(5, myItem);

// Check if the item can be added, the return type is a ItemInfo? (The ? means it is NULLABLE).
var canAddItemResult = itemCollection.CanAddItem(itemInfoToAdd);
if(canAddItemResult.HasValue){
    if(canAddItemResult.Value.Amount == itemInfoToAdd.Amount ){
        // The Item Amount can be fully added.
    }else{
        // The Item can be added but only partially.
    }
}else{
    // The item cannot be added.
}
 
Top