Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RegionViewMappingPayload" /> class.
        /// </summary>
        /// <param name="regionName">Name of the region.</param>
        /// <param name="viewMappingType">Type of the view mapping.</param>
        /// <param name="prefabName">Name of the prefab.</param>
        /// <param name="dataContext">The data context.</param>
        /// <exception cref="InvalidOperationException">If "viewMappingType" is not
        /// MapView, UnmapView, ShowView, HideView, LockView, UnlockView, UpdateDataContext</exception>
        /// <exception cref="ArgumentNullException">If "regionName" is null\empty</exception>
        /// <exception cref="ArgumentNullException">If "prefabName" is null\empty</exception>
        public RegionViewMappingPayload(string regionName, RegionViewMappingType viewMappingType,
                                        string prefabName, object dataContext = null) : this()
        {
            ArgumentValidator.AssertNotNullOrEmpty(regionName, "regionName");
            ArgumentValidator.AssertNotNullOrEmpty(prefabName, "prefabName");

            if (viewMappingType != RegionViewMappingType.MapView &&
                viewMappingType != RegionViewMappingType.UnmapView &&
                viewMappingType != RegionViewMappingType.ShowView &&
                viewMappingType != RegionViewMappingType.HideView &&
                viewMappingType != RegionViewMappingType.LockView &&
                viewMappingType != RegionViewMappingType.UnlockView &&
                viewMappingType != RegionViewMappingType.UpdateDataContext)
            {
                var allowedMappingTypes = string.Format(
                    "This constructor can be used for these operations only: {0}, {1}, {2}, {3}, {4}, {5}, {6}.",
                    RegionViewMappingType.MapView,
                    RegionViewMappingType.UnmapView,
                    RegionViewMappingType.ShowView,
                    RegionViewMappingType.HideView,
                    RegionViewMappingType.LockView,
                    RegionViewMappingType.UnlockView,
                    RegionViewMappingType.UpdateDataContext);
                ThrowInvalidMappingTypeException(allowedMappingTypes, viewMappingType);
            }

            RegionName      = regionName;
            ViewMappingType = viewMappingType;
            PrefabName      = prefabName;
            DataContext     = dataContext;
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RegionViewMappingPayload"/> class.
        /// </summary>
        /// <param name="regionName">Name of the region.</param>
        /// <param name="viewMappingType">Type of the view mapping.</param>
        /// <param name="prefabName">Name of the prefab.</param>
        /// <param name="index">The index.</param>
        /// <param name="assignViewName">Name of the assign view.</param>
        /// <param name="dataContext">The data context.</param>
        /// <exception cref="System.ArgumentNullException">If "regionName" is null\empty</exception>
        /// <exception cref="System.ArgumentNullException">If "prefabName" is null\empty</exception>
        /// <exception cref="System.InvalidOperationException">If "viewMappingType" is not MapView</exception>
        public RegionViewMappingPayload(string regionName, RegionViewMappingType viewMappingType,
                                        string prefabName, int?index = null, string assignViewName = null, object dataContext = null) : this()
            //: this(regionName, viewMappingType)
        {
            ArgumentValidator.AssertNotNullOrEmpty(regionName, "regionName");
            ArgumentValidator.AssertNotNullOrEmpty(prefabName, "prefabName");

            RegionName      = regionName;
            ViewMappingType = viewMappingType;

            if (viewMappingType != RegionViewMappingType.MapView)
            {
                var allowedMappingTypes = string.Format(
                    "This constructor can be used for this operation: {0}", RegionViewMappingType.MapView);
                ThrowInvalidMappingTypeException(allowedMappingTypes, viewMappingType);
            }

            PrefabName     = prefabName;
            AssignViewName = assignViewName;
            DataContext    = dataContext;
            if (index.HasValue)
            {
                Index = index.Value;
            }
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RegionViewMappingPayload" /> class.
        /// </summary>
        /// <param name="regionName">Name of the region.</param>
        /// <param name="viewMappingType">Type of the view mapping.</param>
        /// <exception cref="System.ArgumentNullException">If "regionName" is null\empty</exception>
        /// <exception cref="System.InvalidOperationException">If "viewMappingType" is not one of values:
        /// UnmapAllViews, HideAllViews, ShowAllViews, LockAllViews, UnlockAllViews, DestroyRegion</exception>
        public RegionViewMappingPayload(string regionName, RegionViewMappingType viewMappingType) : this()
        {
            ArgumentValidator.AssertNotNullOrEmpty(regionName, "regionName");

            if (viewMappingType != RegionViewMappingType.UnmapAllViews &&
                viewMappingType != RegionViewMappingType.HideAllViews &&
                viewMappingType != RegionViewMappingType.ShowAllViews &&
                viewMappingType != RegionViewMappingType.LockAllViews &&
                viewMappingType != RegionViewMappingType.UnlockAllViews &&
                viewMappingType != RegionViewMappingType.DestroyRegion)
            {
                var allowedMappingTypes = string.Format(
                    "This constructor can be used for these operations only: {0}, {1}, {2}, {3}, {4}, {5}",
                    RegionViewMappingType.UnmapAllViews,
                    RegionViewMappingType.HideAllViews,
                    RegionViewMappingType.ShowAllViews,
                    RegionViewMappingType.LockAllViews,
                    RegionViewMappingType.UnlockAllViews,
                    RegionViewMappingType.DestroyRegion);
                ThrowInvalidMappingTypeException(allowedMappingTypes, viewMappingType);
            }

            RegionName      = regionName;
            ViewMappingType = viewMappingType;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewMappingActionAttribute"/> class.
 /// </summary>
 /// <param name="mappingType">Type of the mapping.</param>
 public ViewMappingActionAttribute(RegionViewMappingType mappingType)
 {
     MappingType = mappingType;
 }
Example #5
0
        private static void ThrowInvalidMappingTypeException(string allowedMappingTypes, RegionViewMappingType viewMappingType)
        {
#if UNITY_WSA
            throw new InvalidOperationException(allowedMappingTypes);
#else
            var innerExc = new InvalidEnumArgumentException("viewMappingType", (int)viewMappingType, typeof(RegionViewMappingType));
            throw new InvalidOperationException(allowedMappingTypes, innerExc);
#endif
        }