/// <summary> /// Determines whether this instance [can process payload]. /// </summary> /// <param name="vmp">The payload.</param> /// <returns> /// <c>true</c> if this instance [can process payload]; otherwise, <c>false</c>. /// </returns> protected virtual bool CanProcessPayload(RegionViewMappingPayload vmp) { if (vmp.RegionName.IsNullOrEmpty() || RegisteredRegions.Contains(vmp.RegionName)) { return(false); } // if not registered as delayed region yet, ignore on unmap and on destroy actions if (!DelayedRegions.ContainsKey(vmp.RegionName)) { switch (vmp.ViewMappingType) { case RegionViewMappingType.UnmapView: case RegionViewMappingType.DestroyRegion: return(false); } } switch (vmp.ViewMappingType) { case RegionViewMappingType.MapView: case RegionViewMappingType.UnmapView: case RegionViewMappingType.DestroyRegion: return(true); } return(false); }
public void RegisterRegion(IRegion region) { ArgumentValidator.AssertNotNull(region, "region"); ArgumentValidator.AssertNotNullOrEmpty(region.Name, "region.Name"); if (RegisteredRegions.Contains(region.Name)) { return; } RegisteredRegions.Add(region.Name); if (!DelayedRegions.ContainsKey(region.Name)) { return; } var payloads = DelayedRegions[region.Name]; if (payloads.IsNullOrEmpty()) { return; } var ary = payloads.ToArray(); payloads.Clear(); foreach (var payload in ary) { region.ProcessPayload(payload); } }
public void UnregisterRegion(IRegion region) { ArgumentValidator.AssertNotNull(region, "region"); ArgumentValidator.AssertNotNullOrEmpty(region.Name, "region.Name"); if (!RegisteredRegions.Contains(region.Name)) { return; } RegisteredRegions.Remove(region.Name); }
/// <summary> /// Processes the payload. /// </summary> /// <param name="vmp">The payload.</param> protected virtual void ProcessPayload(RegionViewMappingPayload vmp) { if (RegisteredRegions.Contains(vmp.RegionName)) { return; } IList <RegionViewMappingPayload> payloads; if (!DelayedRegions.ContainsKey(vmp.RegionName)) { payloads = new List <RegionViewMappingPayload>(); DelayedRegions.Add(vmp.RegionName, payloads); } else { payloads = DelayedRegions[vmp.RegionName]; switch (vmp.ViewMappingType) { case RegionViewMappingType.UnmapView: var mapped = payloads.Where( mapping => mapping.ViewMappingType == RegionViewMappingType.MapView && (mapping.View == vmp.View || mapping.PrefabName == vmp.PrefabName)); foreach (var mapping in mapped.ToArray()) { payloads.Remove(mapping); } return; case RegionViewMappingType.DestroyRegion: DelayedRegions.Remove(vmp.RegionName); payloads.Clear(); return; } } if (payloads.Contains(vmp)) { return; } payloads.Add(vmp); }
public static bool IsValidIso3166RegionCode(string regionCodeToCheck) { return(RegisteredRegions.Contains(regionCodeToCheck) || IsPrivateUseRegionCode(regionCodeToCheck)); }