コード例 #1
0
        /// <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);
        }
コード例 #2
0
 /// <summary>
 /// Before calling the mapping action.
 /// </summary>
 /// <param name="ownerType">Type of the owner.</param>
 /// <param name="method">The method.</param>
 /// <param name="mapping">The mapping.</param>
 /// <param name="payload">The payload.</param>
 protected internal virtual bool BeforeAction(
     Type ownerType, MethodInfo method,
     RegionMapping mapping, RegionViewMappingPayload payload)
 {
     // TODO
     return(true);
 }
コード例 #3
0
ファイル: RegionMapping.cs プロジェクト: supermax/TMS
        protected static void MapView(RegionMapping mapping, RegionViewMappingPayload vmp)
        {
            var vm = vmp.View != null?
                     mapping.MapView(vmp.View) :
                         mapping.MapView(vmp.PrefabName);

            vm.DataContext = vmp.DataContext;
        }
コード例 #4
0
ファイル: RegionMapping.cs プロジェクト: supermax/TMS
 protected static void ShowView(RegionMapping mapping, RegionViewMappingPayload vmp)
 {
     if (vmp.View != null)
     {
         mapping.ShowView(mapping, vmp.View);
     }
     else
     {
         mapping.ShowView(mapping, vmp.PrefabName);
     }
 }
コード例 #5
0
ファイル: RegionMapping.cs プロジェクト: supermax/TMS
        /// <summary>
        /// Invokes the region view mapping action.
        /// </summary>
        /// <param name="method">The method.</param>
        /// <param name="attribute">The attribute.</param>
        /// <param name="mapping">The mapping.</param>
        /// <param name="payload">The payload.</param>
        protected static void InvokeRegionViewMappingAction(
            MethodInfo method, ViewMappingActionAttribute attribute,
            RegionMapping mapping, RegionViewMappingPayload payload)
        {
            var canProceed = attribute.BeforeAction(method.DeclaringType, method, mapping, payload);

            if (!canProceed)
            {
                return;
            }

            method.Invoke(mapping, new object[] { mapping, payload });

            attribute.AfterAction(method.DeclaringType, method, mapping, payload);
        }
コード例 #6
0
ファイル: RegionMapping.cs プロジェクト: supermax/TMS
        /// <summary>
        /// Called when [view mapping] payload received.
        /// </summary>
        /// <param name="vmp">The VMP.</param>
        public virtual void ProcessPayload(RegionViewMappingPayload vmp)
        {
            if (!RegionViewMappingActions.ContainsKey(vmp.ViewMappingType))
            {
                LogError("Cannot find action to perform \"{0}\".", vmp.ViewMappingType);
                return;
            }

            var act = RegionViewMappingActions[vmp.ViewMappingType];

            if (act == null)
            {
                LogError("The action for \"{0}\" is NULL.", vmp.ViewMappingType);
                return;
            }

            act(this, vmp);
        }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
 /// <summary>
 /// Afters the action.
 /// </summary>
 /// <param name="ownerType">Type of the owner.</param>
 /// <param name="method">The method.</param>
 /// <param name="mapping">The mapping.</param>
 /// <param name="payload">The payload.</param>
 protected internal virtual void AfterAction(
     Type ownerType, MethodInfo method,
     RegionMapping mapping, RegionViewMappingPayload payload)
 {
     // TODO
 }
コード例 #9
0
ファイル: RegionMapping.cs プロジェクト: supermax/TMS
 protected static void UpdateDataContext(RegionMapping mapping, RegionViewMappingPayload vmp)
 {
     mapping.UpdateDataContext(vmp.DataContext);
 }
コード例 #10
0
ファイル: RegionMapping.cs プロジェクト: supermax/TMS
 protected static void HideAllViews(RegionMapping mapping, RegionViewMappingPayload vmp)
 {
     mapping.HideAllViews();
 }
コード例 #11
0
ファイル: RegionMapping.cs プロジェクト: supermax/TMS
 protected static void HideView(RegionMapping mapping, RegionViewMappingPayload vmp)
 {
 }
コード例 #12
0
ファイル: RegionMapping.cs プロジェクト: supermax/TMS
 protected static void UnlockAllViews(RegionMapping mapping, RegionViewMappingPayload vmp)
 {
     mapping.Unlock();
 }
コード例 #13
0
ファイル: RegionMapping.cs プロジェクト: supermax/TMS
 protected static void UnlockView(RegionMapping mapping, RegionViewMappingPayload vmp)
 {
     // TODO pass specific view
     mapping.Unlock();
 }
コード例 #14
0
ファイル: RegionMapping.cs プロジェクト: supermax/TMS
 protected static void DestroyRegion(RegionMapping mapping, RegionViewMappingPayload vmp)
 {
     mapping.DestroyRegion();
 }