本文整理匯總了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;
}