本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}