/// <summary>
        /// Locate the equivalent store in a market if available
        /// </summary>
        protected void FindEquivalentMarketStore()
        {
            // determine what resource types allow market transactions
            switch (this.GetType().Name)
            {
            case "FinanceType":
            case "HumanFoodStoreType":
            //case "WaterType":
            //case "AnimalFoodType":
            //case "EquipmentType":
            //case "GreenhousGasesType":
            case "ProductStoreType":
                break;

            default:
                throw new NotImplementedException($"\n[r={this.Parent.GetType().Name}] resource does not currently support transactions to and from a [m=Market]\nThis problem has arisen because a resource transaction in the code is flagged to exchange resources with the [m=Market]\nPlease contact developers for assistance.");
            }

            // if not already checked
            if (!EquivalentMarketStoreDetermined)
            {
                // haven't already found a market store
                if (EquivalentMarketStore is null)
                {
                    ResourcesHolder holder = Apsim.Parent(this, typeof(ResourcesHolder)) as ResourcesHolder;
                    // is there a market
                    if (holder != null && holder.FindMarket != null)
                    {
                        IResourceWithTransactionType store = holder.FindMarket.Resources.LinkToMarketResourceType(this);
                        if (store != null)
                        {
                            EquivalentMarketStore = store as CLEMResourceTypeBase;
                        }
                    }
                }
                EquivalentMarketStoreDetermined = true;
            }
        }
 /// <summary>
 /// Add all events when a new child is added to this resource in run time
 /// </summary>
 /// <param name="child"></param>
 public virtual void AddNewResourceType(IResourceWithTransactionType child)
 {
     throw new NotImplementedException();
 }
Beispiel #3
0
 /// <summary>
 /// Add all events when a new child is added to this resource in run time
 /// </summary>
 /// <param name="child"></param>
 public override void AddNewResourceType(IResourceWithTransactionType child)
 {
     (child as HumanFoodStoreType).Pools.Clear();
     child.TransactionOccurred += Resource_TransactionOccurred;
     this.Children.Add(child as Model);
 }
Beispiel #4
0
 /// <summary>
 /// Add all events when a new child is added to this resource in run time
 /// </summary>
 /// <param name="child"></param>
 public override void AddNewResourceType(IResourceWithTransactionType child)
 {
     child.TransactionOccurred += Resource_TransactionOccurred;
     this.Children.Add(child as Model);
 }
Beispiel #5
0
 /// <summary>
 /// Add all events when a new child is added to this resource in run time
 /// </summary>
 /// <param name="child"></param>
 public void AddChildEvents(IResourceWithTransactionType child)
 {
     child.TransactionOccurred += Resource_TransactionOccurred;
 }