当前位置: 首页>>代码示例>>C#>>正文


C# ControllerContext.UserDistanceUnits方法代码示例

本文整理汇总了C#中System.Web.Mvc.ControllerContext.UserDistanceUnits方法的典型用法代码示例。如果您正苦于以下问题:C# ControllerContext.UserDistanceUnits方法的具体用法?C# ControllerContext.UserDistanceUnits怎么用?C# ControllerContext.UserDistanceUnits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Mvc.ControllerContext的用法示例。


在下文中一共展示了ControllerContext.UserDistanceUnits方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BindModel

        public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            Distance distance;
            double parsedDistance;
            if (double.TryParse(Get(bindingContext, "distance"), out parsedDistance))
                distance = new Distance(parsedDistance, controllerContext.UserDistanceUnits());
            else
                distance = new Distance(0, controllerContext.UserDistanceUnits());

            OnModelUpdating(controllerContext, bindingContext);
            bindingContext.ModelMetadata.Model = distance;
            OnModelUpdated(controllerContext, bindingContext);
            return bindingContext.Model;
        }
开发者ID:andywhitfield,项目名称:RunnersPal,代码行数:14,代码来源:DistanceBinder.cs

示例2: ProfileModel

        public ProfileModel(ControllerContext context)
        {
            if (!context.HasValidUserAccount())
            {
                Name = "";
                Weight = new WeightData();
                return;
            }

            var userAccount = context.UserAccount();
            Name = userAccount.DisplayName;

            Weight = DefaultWeightData();
            var userPref = ((object)userAccount).UserPrefs().Latest();
            if (userPref != null)
            {
                Weight.Units = userPref.WeightUnits;
                switch (Weight.Units)
                {
                    case "kg":
                        Weight.Kg = userPref.Weight;
                        break;
                    case "lbs":
                    case "st":
                        Weight.Lbs = userPref.Weight;
                        Weight.Units = "lbs";
                        break;
                }
                Weight.UpdateFromUnits();
                if (userPref.WeightUnits == "st")
                    Weight.Units = "st";
            }

            DistUnits = (int)context.UserDistanceUnits();
        }
开发者ID:andywhitfield,项目名称:RunnersPal,代码行数:35,代码来源:ProfileModel.cs

示例3: BindModel

        public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            long? route = null;
            long parsedRoute;
            if (long.TryParse(Get(bindingContext, "route"), out parsedRoute))
                route = parsedRoute;

            Distance distance;
            double parsedDistance;
            if (double.TryParse(Get(bindingContext, "distance"), out parsedDistance))
                distance = new Distance(parsedDistance, controllerContext.UserDistanceUnits());
            else
                distance = new Distance(0, controllerContext.UserDistanceUnits());

            OnModelUpdating(controllerContext, bindingContext);
            bindingContext.ModelMetadata.Model = new PaceData { Calc = Get(bindingContext, "calc"), Pace = Get(bindingContext, "pace"), Distance = distance, Time = Get(bindingContext, "time"), Route = route };
            OnModelUpdated(controllerContext, bindingContext);
            return bindingContext.Model;
        }
开发者ID:andywhitfield,项目名称:RunnersPal,代码行数:19,代码来源:PaceDataModelBinder.cs

示例4: RunLogModel

            public RunLogModel(ControllerContext context, dynamic runLogEvent)
            {
                this.context = context;
                RunLogEvent = runLogEvent;

                TimeTaken = runLogEvent.TimeTaken;
                Route = ((object)RunLogEvent).Route();
                Distance = ((object)Route).Distance().ConvertTo(context.UserDistanceUnits());

                var paceData = new PaceData { Distance = Distance, Time = TimeTaken, Calc = "Pace" };
                var paceCalc = new PaceCalculator();
                paceCalc.Calculate(paceData);
                Pace = paceData;
            }
开发者ID:andywhitfield,项目名称:RunnersPal,代码行数:14,代码来源:RunLogViewModel.cs


注:本文中的System.Web.Mvc.ControllerContext.UserDistanceUnits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。