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


C# Result.AddWarning方法代码示例

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


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

示例1: CheckScenario

        public Result<bool> CheckScenario(Scenario item)
        {
            var result = new Result<bool>();

            if (item.ActionBag == null)
                result.AddWarning(new Warning("Необходимо выбрать вид действия"));
            if (string.IsNullOrEmpty(item.Name))
                result.AddWarning(new Warning("Необходимо ввести имя сценария"));
            if (_scenarios.Count(x => x.Name == item.Name && item.Guid != x.Guid) > 0)
                result.AddWarning(new Warning("Действие с таким именем уже существует"));
            if (_scenarios.Count(x => x.ServerCommand == item.ServerCommand && !string.IsNullOrEmpty(x.ServerCommand) && item.Guid != x.Guid) > 0)
                result.AddWarning(new Warning("Действие с такой командой сервера уже существует"));

            result.Value = result.Warnings.Count() == 0;
            return result;
        }
开发者ID:noant,项目名称:Pyrite,代码行数:16,代码来源:ScenariosPool.cs

示例2: CloneAction

 public static Result<ICustomAction> CloneAction(ICustomAction action)
 {
     var res = new Result<ICustomAction>();
     try
     {
         res.Value = (ICustomAction)HierarchicalObjectCrutch.CloneObject(action);
     }
     catch (Exception e)
     {
         res.AddWarning(new Warning(e.Message), true);
     }
     return res;
 }
开发者ID:noant,项目名称:Pyrite,代码行数:13,代码来源:ModulesControl.cs

示例3: CloneChecker

 public static Result<ICustomChecker> CloneChecker(ICustomChecker checker)
 {
     var res = new Result<ICustomChecker>();
     try
     {
         res.Value = (ICustomChecker)HierarchicalObjectCrutch.CloneObject(checker);
     }
     catch (Exception e)
     {
         res.AddWarning(new Warning(e.Message), true);
     }
     return res;
 }
开发者ID:noant,项目名称:Pyrite,代码行数:13,代码来源:ModulesControl.cs

示例4: RegisterChecker

        public Result<IEnumerable<Type>> RegisterChecker(string filename)
        {
            var result = new Result<IEnumerable<Type>>();
            IEnumerable<Type> types = null;
            try
            {
                var assembly = Assembly.LoadFrom(filename);
                types = assembly
                    .GetTypes()
                    .Where(x => x.GetInterfaces()
                        .Contains(typeof(ICustomChecker))
                        && x.CustomAttributes.Any(z => z.AttributeType.Equals(typeof(SerializableAttribute)))
                        );
            }
            catch (Exception e)
            {
                result.AddWarning(new Warning(e.Message));
            }

            var addedTypes = types.Where(x => CanRegisterChecker(x));
            _customCheckers.AddRange(addedTypes);
            HierarchicalObjectCrutch.Register(addedTypes);
            result.Value = addedTypes;
            return result;
        }
开发者ID:noant,项目名称:Pyrite,代码行数:25,代码来源:ModulesControl.cs

示例5: CreateCheckerInstance

        public Result<ICustomChecker> CreateCheckerInstance(Type type, bool beginSettings)
        {
            var result = new Result<ICustomChecker>();
            try
            {
                var checker = (ICustomChecker)type.GetConstructor(new Type[0]).Invoke(new object[0]);
                if (checker is ICoreElement)
                    ((ICoreElement)checker).CurrentPyrite = Pyrite;

                if (beginSettings)
                {
                    if (checker.BeginUserSettings())
                    {
                        result.Value = checker;
                        result.Value.Refresh();
                    }
                }
                else
                {
                    result.Value = checker;
                }
            }
            catch (Exception e)
            {
                result.AddWarning(new Warning(e.Message));
            }
            return result;
        }
开发者ID:noant,项目名称:Pyrite,代码行数:28,代码来源:ModulesControl.cs

示例6: CreateActionInstance

        public Result<ICustomAction> CreateActionInstance(Type type, bool beginSettings)
        {
            var result = new Result<ICustomAction>();
            try
            {
                var action = (ICustomAction)type.GetConstructor(new Type[0]).Invoke(new object[0]);
                if (action is ICoreElement)
                    ((ICoreElement)action).CurrentPyrite = Pyrite;

                if (beginSettings)
                {
                    if (action.BeginUserSettings())
                    {
                        result.Value = action;
                        result.Value.Refresh();
                    }
                }
                else result.Value = action;
            }
            catch (Exception e)
            {
                result.AddWarning(new Warning(e.Message));
            }

            return result;
        }
开发者ID:noant,项目名称:Pyrite,代码行数:26,代码来源:ModulesControl.cs


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