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


C# Material.Create方法代码示例

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


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

示例1: AddMaterialData

        public ActionResult AddMaterialData(AddEditMaterialViewModel vModel)
        {
            string message = string.Empty;
            var authedUser = UserManager.FindById(User.Identity.GetUserId());

            var newObj = new Material();
            newObj.Name = vModel.NewName;
            newObj.Conductive = vModel.NewConductive;
            newObj.Density = vModel.NewDensity;
            newObj.Ductility = vModel.NewDuctility;
            newObj.Flammable = vModel.NewFlammable;
            newObj.GasPoint = vModel.NewGasPoint;
            newObj.Magnetic = vModel.NewMagnetic;
            newObj.Mallebility = vModel.NewMallebility;
            newObj.Porosity = vModel.NewPorosity;
            newObj.SolidPoint = vModel.NewSolidPoint;
            newObj.TemperatureRetention = vModel.NewTemperatureRetention;
            newObj.Viscosity = vModel.NewViscosity;

            if (vModel.Resistances != null)
            {
                int resistancesIndex = 0;
                foreach (var type in vModel.Resistances)
                {
                    if (type > 0)
                    {
                        if (vModel.ResistanceValues.Count() <= resistancesIndex)
                            break;

                        var currentValue = vModel.ResistanceValues[resistancesIndex];

                        if (currentValue > 0)
                            newObj.Resistance.Add((DamageType)type, currentValue);
                    }

                    resistancesIndex++;
                }
            }

            if (vModel.Compositions != null)
            {
                int compositionsIndex = 0;
                foreach (var materialId in vModel.Compositions)
                {
                    if (materialId > 0)
                    {
                        if (vModel.CompositionPercentages.Count() <= compositionsIndex)
                            break;

                        var currentValue = vModel.CompositionPercentages[compositionsIndex];
                        var material = ReferenceWrapper.GetOne<Material>(materialId);

                        if (material != null && currentValue > 0)
                            newObj.Composition.Add(material, currentValue);
                    }

                    compositionsIndex++;
                }
            }

            if (newObj.Create() == null)
                message = "Error; Creation failed.";
            else
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - AddMaterialData[" + newObj.ID.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Creation Successful.";
            }

            return RedirectToAction("ManageMaterialData", new { Message = message });
        }
开发者ID:carriercomm,项目名称:NetMud,代码行数:70,代码来源:GameAdminController.cs


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