本文整理汇总了C#中ValidationContext.LogError方法的典型用法代码示例。如果您正苦于以下问题:C# ValidationContext.LogError方法的具体用法?C# ValidationContext.LogError怎么用?C# ValidationContext.LogError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValidationContext
的用法示例。
在下文中一共展示了ValidationContext.LogError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateNameIsUnique
internal void ValidateNameIsUnique(ValidationContext context)
{
try
{
IEnumerable<AutomationSettingsSchema> sameNamedElements = this.Owner.AutomationSettings
.Where(setting => setting.Name.Equals(this.Name, System.StringComparison.OrdinalIgnoreCase));
if (sameNamedElements.Count() > 1)
{
// Check if one of the properties is a system property
if (sameNamedElements.FirstOrDefault(property => property.IsSystem == true) != null)
{
context.LogError(
string.Format(CultureInfo.CurrentCulture, Properties.Resources.Validate_AutomationSettingsNameSameAsSystem, this.Name),
Properties.Resources.Validate_AutomationSettingsNameSameAsSystemCode, this);
}
else
{
context.LogError(
string.Format(CultureInfo.CurrentCulture, Properties.Resources.Validate_AutomationSettingsNameIsNotUnique, this.Name),
Properties.Resources.Validate_AutomationSettingsNameIsNotUniqueCode, this);
}
}
}
catch (Exception ex)
{
tracer.Error(
ex,
Resources.ValidationMethodFailed_Error,
Reflector<AutomationSettingsSchema>.GetMethod(n => n.ValidateNameIsUnique(context)).Name);
throw;
}
}
示例2: Validate
public void Validate(ValidationContext context)
{
//if (!this.IsDirty) return;
var timer = nHydrate.Dsl.Custom.DebugHelper.StartTimer();
try
{
#region Check valid name
if (!ValidationHelper.ValidDatabaseIdenitifer(this.DatabaseName))
context.LogError(string.Format(ValidationHelper.ErrorTextInvalidIdentifierViewField, this.Name, this.View.Name), string.Empty, this);
else if (!ValidationHelper.ValidCodeIdentifier(this.PascalName))
context.LogError(string.Format(ValidationHelper.ErrorTextInvalidIdentifierViewField, this.Name, this.View.Name), string.Empty, this);
#endregion
#region Validate max lengths
var validatedLength = this.DataType.ValidateDataTypeMax(this.Length);
if (validatedLength != this.Length)
{
context.LogError(string.Format(ValidationHelper.ErrorTextColumnMaxLengthViolation, this.View.Name + "." + this.Name, validatedLength, this.DataType.ToString()), string.Empty, this);
}
#endregion
}
catch (Exception ex)
{
throw;
}
finally
{
nHydrate.Dsl.Custom.DebugHelper.StopTimer(timer, "Stored Procedure Parameter Validate - Main");
}
}
示例3: ValidateGroupName
private void ValidateGroupName(ValidationContext context)
{
if (string.IsNullOrEmpty(this.GroupName) || string.IsNullOrWhiteSpace(this.GroupName))
context.LogError(Validation.GroupNameEmpty, Validation.GroupNameEmptyCode, this);
if (this.GroupName.Length > 50)
context.LogError(Validation.GroupNameLength, Validation.GroupNameLengthCode, this);
}
示例4: ValidateScheduledTaskName
private void ValidateScheduledTaskName(ValidationContext context)
{
if (string.IsNullOrEmpty(this.Name) || string.IsNullOrWhiteSpace(this.Name))
context.LogError(Validation.STaskNameEmpty, Validation.STaskNameEmptyErrorCode, this);
if (this.Name.Length > 50)
context.LogError(Validation.STaskNameLength, Validation.STaskNameLengthCode, this);
}
示例5: ValidateOptimal
private void ValidateOptimal(ValidationContext context)
{
string error = "";
if (Type == FlowType.Optimal)
{
if (!(TargetActivity is Stop) && !(TargetActivity is ToProcessConnector))
{
int iCount = GetLinksToTargetActs(TargetActivity).Where(a => a.Type == FlowType.Optimal).Count();
if (iCount > 1)
{
error = "Optimal path can not have more than one route";
}
else if (iCount == 0)
error = "Optimal path must preceed with another optimal path from start to stop";
else
error = "";
if (error != string.Empty)
{
context.LogError("FlowBase: " + error, "Flow", this);
}
}
if (!(SourceActivity is Start) && !(TargetActivity is FromProcessConnector))
{
int iCount = GetLinksToSourceActs(SourceActivity).Where(a => a.Type == FlowType.Optimal).Count();
if (iCount == 0)
error = "Optimal path must preceed with another optimal path from start to stop";
else
error = "";
if (error != string.Empty)
{
context.LogError("FlowBase: " + error, "Flow", this);
}
}
}
if (SourceActivity is Start && ((Start)SourceActivity).IsStartable && !(TargetActivity is Stop))
{
int iCount = GetLinksToTargetActs(TargetActivity).Where(a => a.Type == FlowType.Optimal).Count();
if (iCount > 0)
{
var iiCount = GetLinksToTargetActs(SourceActivity).Where(a => a.Type == FlowType.Optimal).Count();
if (iiCount == 0)
error = "Optimal path must preceed with another optimal path from start to stop";
else
error = "";
if (error != string.Empty)
{
context.LogError("FlowBase: " + error, "Flow", this);
}
}
}
}
示例6: ValidateIcon
internal void ValidateIcon(ValidationContext context)
{
try
{
if (!string.IsNullOrEmpty(this.Icon))
{
var uriService = ((IServiceProvider)this.Store).GetService<IUriReferenceService>();
ResourcePack resolvedIcon = null;
try
{
resolvedIcon = uriService.ResolveUri<ResourcePack>(new Uri(this.Icon));
}
catch (UriFormatException)
{
context.LogError(
string.Format(CultureInfo.CurrentCulture, Resources.Validate_NamedElementIconDoesNotPointToAValidFile, this.Name),
Resources.Validate_NamedElementIconDoesNotPointToAValidFileCode,
this);
return;
}
if (resolvedIcon == null)
{
context.LogError(
string.Format(CultureInfo.CurrentCulture, Resources.Validate_NamedElementIconDoesNotPointToAValidFile, this.Name),
Resources.Validate_NamedElementIconDoesNotPointToAValidFileCode,
this);
return;
}
if (resolvedIcon.Type == ResourcePackType.ProjectItem)
{
var item = resolvedIcon.GetItem();
if (item.Data.ItemType != @"Resource")
{
context.LogError(
string.Format(CultureInfo.CurrentCulture, Resources.Validate_NamedElementIconIsNotAResource, this.Name, item.Name),
Resources.Validate_NamedElementIconIsNotAResource,
this);
}
}
}
}
catch (Exception ex)
{
tracer.Error(
ex,
Resources.ValidationMethodFailed_Error,
Reflector<PatternElementSchema>.GetMethod(n => n.ValidateIcon(context)).Name);
throw;
}
}
示例7: ValidateShape
public void ValidateShape(ValidationContext context)
{
if (this.DomainClass != null && this.Source != null && this.Target != null)
{
if( this.Source.Source.RolePlayer != this.DomainClass )
context.LogError("The source relationship of the MappingRelationshipShapeClass " + this.Name + " needs to start from the class " + this.DomainClass.Name, "", null); //element);
if (this.Target.Source.RolePlayer != this.DomainClass)
context.LogError("The target relationship of the MappingRelationshipShapeClass " + this.Name + " needs to start from the class " + this.DomainClass.Name, "", null); //element);
}
}
示例8: ValidateDomainProperty
public void ValidateDomainProperty(ValidationContext context)
{
if( this.Type == null )
context.LogError(this.Name + " on " + this.Element.Name + " needs to reference a DomainType", "", null);
if (this.Type != null)
if (this.SerializationRepresentationType == LanguageDSL.SerializationRepresentationType.Attribute)
if (this.Type.SerializationStyle == SerializationStyle.CDATA)
{
context.LogError(this.Name + " on " + this.Element.Name + " can not be serialized as attibute, because its referenced type is serialized as CDATA", "", null);
}
}
示例9: ValidateDomainRelationship
public void ValidateDomainRelationship(ValidationContext context)
{
// Abstract relationships can only be created between abstract classes!
if (this.InheritanceModifier == LanguageDSL.InheritanceModifier.Abstract)
{
if( this.Source.RolePlayer.InheritanceModifier != LanguageDSL.InheritanceModifier.Abstract )
context.LogError(this.Name + " can not be declared abstract because the source element is not declared abstract.", "NotAbstractSource", null); //this);
if (this.Target.RolePlayer.InheritanceModifier != LanguageDSL.InheritanceModifier.Abstract)
context.LogError(this.Name + " can not be declared abstract because the target element is not declared abstract.", "NotAbstractTarget", null); // this);
}
}
示例10: ValidateNamespace
private void ValidateNamespace(ValidationContext context)
{
if (String.IsNullOrEmpty(this.Namespace))
{
string message = String.Format(CultureInfo.CurrentCulture, Properties.Resources.Error_ModelNamespaceEmpty);
context.LogError(message, Properties.Resources.ErrorCode_ModelNamespaceEmpty, this);
}
else if (EscherAttributeContentValidator.IsValidCSDLNamespaceName(this.Namespace) == false)
{
string message = String.Format(CultureInfo.CurrentCulture, Properties.Resources.Error_ModelNamespaceInvalid, this.Namespace);
context.LogError(message, Properties.Resources.ErrorCode_ModelNamespaceInvalid, this);
}
}
示例11: ValidatePage
private void ValidatePage(ValidationContext context)
{
if (string.IsNullOrEmpty(Page))
{
context.LogError(string.Format(Messages.StatePageEmpty, Key), "StatePageEmpty", this);
}
else
{
if (!pageExp.IsMatch(Page))
{
context.LogError(string.Format(Messages.StatePageInvalid, Key), "StatePageInvalid", this);
}
}
}
示例12: ValidateTitleAndResource
private void ValidateTitleAndResource(ValidationContext context)
{
if (!string.IsNullOrEmpty(Title) && (!string.IsNullOrEmpty(ResourceType) || !string.IsNullOrEmpty(ResourceKey)))
{
context.LogError(string.Format(Messages.StateTitleAndResourceInvalid, Key), "StateTitleAndResourceInvalid", this);
}
else
{
if ((!string.IsNullOrEmpty(ResourceType) && string.IsNullOrEmpty(ResourceKey))
|| (string.IsNullOrEmpty(ResourceType) && !string.IsNullOrEmpty(ResourceKey)))
{
context.LogError(string.Format(Messages.StateResourceInvalid, Key), "StateResourceInvalid", this);
}
}
}
示例13: ValidateMinMax
public void ValidateMinMax(ValidationContext context)
{
if (this.Min > this.Max) {
context.LogError("The minimum number of features in an alternative set cannot be greater than the maximum number","",this);
}
if (this.Min < 1 || this.Max < 1) {
context.LogError("The minimum or maximum number of features in an alternative set cannot be lower than one", "", this);
}
if (this.Min > this.SubFeatureModelElements.Count) {
context.LogError("The minimum number of features in an alternative set should not be greater than the actual number of features connected to the alternative set", "", this);
}
if (this.Max > this.SubFeatureModelElements.Count) {
context.LogError("The maximum number of features in an alternative set should not be greater than the actual number of features connected to the alternative set", "", this);
}
}
示例14: ValidateMonoRailProjectPath
private void ValidateMonoRailProjectPath(ValidationContext context)
{
if (GenerateMonoRailProject && string.IsNullOrEmpty(MonoRailProjectPath))
{
context.LogError("MonoRail project must have a path defined", "AW001ValidateMonoRailProjectPathError", this);
}
}
示例15: ValidateMonoRailProjectName
private void ValidateMonoRailProjectName(ValidationContext context)
{
if (GenerateMonoRailProject && string.IsNullOrEmpty(MonoRailProjectName))
{
context.LogError("MonoRail project must have a name", "AW001ValidateMonoRailProjectName", this);
}
}