public LocationValuablesCollectionManagerEventArgs(ResourceActivationContext ctxt, LocationValuablesCollection lvc, bool resetState = false)
 {
     this.ResetState   = resetState;
     LocationValuables = new LocationValuablesCollectionItemContainer[]
     {
         new LocationValuablesCollectionItemContainer(ctxt, lvc)
     };
 }
        public void AddLocationValuablesCollection(ResourceActivationContext context, LocationValuablesCollection lvc)
        {
            if (context.IsClosed)
            {
                return;
            }

            context.Open();

            m_contexts.Add(context.InstanceId, context);

            List <Location> addedLocations = null;

            lock (m_valuablesByLocation)
            {
                var typeTagContainer = new LocationValuablesInstance
                {
                    ActivationContext   = context,
                    ValuablesCollection = lvc
                };

                if (lvc.LocationTypes != null)
                {
                    foreach (var t in lvc.LocationTypes)
                    {
                        m_valuablesByType.Add(t, typeTagContainer);
                    }
                }

                if (lvc.StoryTags != null)
                {
                    foreach (var t in lvc.StoryTags)
                    {
                        m_valuablesByTag.Add(t, typeTagContainer);
                    }
                }
            }

            bool isUpdating;

            var container = new LocationValuablesCollectionItemContainer(context, lvc);

            m_allValuables.Add(context.InstanceId, container);

            lock (this)
            {
                isUpdating = m_updating;

                if (isUpdating)
                {
                    m_addedValuables.Add(context.InstanceId, container);
                    m_removedValuables.Remove(context.InstanceId);
                }
            }

            if (!isUpdating)
            {
                if (ValuablesAdded != null)
                {
                    ValuablesAdded(this, new LocationValuablesCollectionManagerEventArgs(context, lvc));
                }

                if (addedLocations != null && LocationsAdded != null)
                {
                    LocationsAdded(this, new LocationValuablesCollectionManagerEventArgs(addedLocations.ToArray()));
                }
            }
        }