本文整理汇总了C#中System.Web.Services.Description.ConformanceCheckContext.ReportRuleViolation方法的典型用法代码示例。如果您正苦于以下问题:C# ConformanceCheckContext.ReportRuleViolation方法的具体用法?C# ConformanceCheckContext.ReportRuleViolation怎么用?C# ConformanceCheckContext.ReportRuleViolation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Services.Description.ConformanceCheckContext
的用法示例。
在下文中一共展示了ConformanceCheckContext.ReportRuleViolation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAbsoluteUri
/*
private string GetAbsoluteUri (string baseUri, string relativeUri)
{
string actualBaseUri = baseUri ?? Path.GetFullPath (".") + Path.DirectorySeparatorChar;
Uri uri = new Uri (new Uri (actualBaseUri), relativeUri);
return uri.ToString ();
}
*/
public override void Check (ConformanceCheckContext ctx, Import value)
{
if (value.Location == "" || value.Location == null) {
ctx.ReportRuleViolation (value, BasicProfileRules.R2007);
return;
}
if (!new Uri (value.Namespace, UriKind.RelativeOrAbsolute).IsAbsoluteUri)
ctx.ReportRuleViolation (value, BasicProfileRules.R2803);
// LAMESPEC: RetrievalUrl does not seem to help here (in .NET)
//ServiceDescription importer = value.ServiceDescription;
//string absUri = GetAbsoluteUri (importer != null ? importer.RetrievalUrl : null, value.Location);
object doc = ctx.GetDocument (/*absUri*/value.Location, value.Namespace);
if (doc == null) // and looks like .net ignores non-resolvable documentation... I dunno if it makes sense. I don't care :/
return; //ctx.ReportError (value, "Document '" + value.Location + "' not found");
if (doc is XmlSchema)
ctx.ReportRuleViolation (value, BasicProfileRules.R2002);
ServiceDescription imported = doc as ServiceDescription;
if (imported == null) {
ctx.ReportRuleViolation (value, BasicProfileRules.R2001);
return;
}
if (imported.TargetNamespace != value.Namespace)
ctx.ReportRuleViolation (value, BasicProfileRules.R2005);
}
示例2: Check
public override void Check (ConformanceCheckContext ctx, Import value)
{
if (value.Location == "" || value.Location == null) {
ctx.ReportRuleViolation (value, BasicProfileRules.R2007);
return;
}
object doc = ctx.GetDocument (value.Location);
if (doc == null) ctx.ReportError (value, "Document '" + value.Location + "' not found");
if (doc is XmlSchema)
ctx.ReportRuleViolation (value, BasicProfileRules.R2002);
ServiceDescription imported = doc as ServiceDescription;
if (imported == null) {
ctx.ReportRuleViolation (value, BasicProfileRules.R2001);
return;
}
// TODO: rule R2003
if (imported.TargetNamespace != value.Namespace)
ctx.ReportRuleViolation (value, BasicProfileRules.R2005);
}
示例3: CheckWsdlQName
// Helper methods
void CheckWsdlQName (ConformanceCheckContext ctx, object element, XmlQualifiedName name)
{
if (name == null || name == XmlQualifiedName.Empty) return;
if (name.Namespace == "" || name.Namespace == XmlSchema.Namespace) return;
if (ctx.ServiceDescription.Types != null && ctx.ServiceDescription.Types.Schemas != null)
{
foreach (XmlSchema s in ctx.ServiceDescription.Types.Schemas)
{
if (s.TargetNamespace == name.Namespace) return;
foreach (XmlSchemaObject i in s.Includes)
if ((i is XmlSchemaImport) && ((XmlSchemaImport)i).Namespace == name.Namespace) return;
}
}
ctx.ReportRuleViolation (element, BasicProfileRules.R2101);
}
示例4: CheckMessageBinding
void CheckMessageBinding (ConformanceCheckContext ctx, Hashtable portParts, MessageBinding value)
{
SoapBodyBinding sbb = (SoapBodyBinding) value.Extensions.Find (typeof(SoapBodyBinding));
Message msg = FindMessage (ctx, value);
LiteralType bt = GetLiteralBindingType (value.OperationBinding.Binding);
if (sbb != null)
{
if (bt == LiteralType.Document)
{
if (sbb.Parts != null && sbb.Parts.Length > 1)
ctx.ReportRuleViolation (value, BasicProfileRules.R2201);
if (sbb.Parts == null) {
if (msg.Parts != null && msg.Parts.Count > 1)
ctx.ReportRuleViolation (value, BasicProfileRules.R2210);
if (msg.Parts.Count == 1)
portParts.Remove (msg.Parts[0]);
}
else {
if (sbb.Parts.Length == 0 && msg.Parts.Count == 1) {
portParts.Remove (msg.Parts[0]);
} else {
foreach (string part in sbb.Parts) {
MessagePart mp = msg.FindPartByName (part);
portParts.Remove (mp);
if (!mp.DefinedByElement)
ctx.ReportRuleViolation (value, BasicProfileRules.R2204);
}
}
}
}
else if (bt == LiteralType.Rpc)
{
if (sbb.Parts != null) {
foreach (string part in sbb.Parts) {
MessagePart mp = msg.FindPartByName (part);
portParts.Remove (mp);
if (!mp.DefinedByType)
ctx.ReportRuleViolation (value, BasicProfileRules.R2203);
}
}
}
}
SoapHeaderBinding shb = (SoapHeaderBinding) value.Extensions.Find (typeof(SoapHeaderBinding));
if (shb != null) {
Message hm = ctx.Services.GetMessage (shb.Message);
MessagePart mp = hm.FindPartByName (shb.Part);
portParts.Remove (mp);
if (mp != null && !mp.DefinedByElement)
ctx.ReportRuleViolation (value, BasicProfileRules.R2205);
}
SoapHeaderFaultBinding shfb = (SoapHeaderFaultBinding) value.Extensions.Find (typeof(SoapHeaderFaultBinding));
if (shfb != null) {
Message hm = ctx.Services.GetMessage (shfb.Message);
MessagePart mp = hm.FindPartByName (shfb.Part);
portParts.Remove (mp);
if (mp != null && !mp.DefinedByElement)
ctx.ReportRuleViolation (value, BasicProfileRules.R2205);
}
// TODO: SoapFaultBinding ??
}
示例5: Check
public override void Check (ConformanceCheckContext ctx, Binding value)
{
SoapBinding sb = (SoapBinding) value.Extensions.Find (typeof(SoapBinding));
if (sb == null)
return;
if (sb.Transport == null || sb.Transport == "") {
ctx.ReportRuleViolation (value, BasicProfileRules.R2701);
return;
}
if (sb.Transport != "http://schemas.xmlsoap.org/soap/http")
ctx.ReportRuleViolation (value, BasicProfileRules.R2702);
LiteralType type = GetLiteralBindingType (value);
if (type == LiteralType.NotLiteral)
ctx.ReportRuleViolation (value, BasicProfileRules.R2706);
else if (type == LiteralType.Inconsistent)
ctx.ReportRuleViolation (value, BasicProfileRules.R2705);
// Collect all parts referenced from this type
Hashtable parts = new Hashtable ();
PortType port = ctx.Services.GetPortType (value.Type);
foreach (Operation op in port.Operations) {
foreach (OperationMessage om in op.Messages) {
Message msg = ctx.Services.GetMessage (om.Message);
foreach (MessagePart part in msg.Parts)
parts [part] = part; // do not use Add() - there could be the same MessagePart instance.
}
}
foreach (OperationBinding ob in value.Operations) {
if (ob.Input != null) CheckMessageBinding (ctx, parts, ob.Input);
if (ob.Output != null) CheckMessageBinding (ctx, parts, ob.Output);
foreach (FaultBinding fb in ob.Faults)
CheckMessageBinding (ctx, parts, fb);
}
if (parts.Count > 0)
ctx.ReportRuleViolation (value, BasicProfileRules.R2209);
// check existence of corresponding operation in portType for each binding operation
if (CheckCorrespondingOperationsForBinding (ctx, value, port))
ctx.ReportRuleViolation (value, BasicProfileRules.R2718);
// check duplicate operation signature.
ArrayList sigs = new ArrayList ();
foreach (OperationBinding ob in value.Operations) {
if (sigs.Contains (ob.Name))
ctx.ReportRuleViolation (value, BasicProfileRules.R2710);
sigs.Add (ob.Name);
}
// check namespace declarations.
switch (type) {
case LiteralType.Document:
case LiteralType.Rpc:
CheckSoapBindingExtensions (ctx, value, type);
break;
}
}
示例6: CheckSchemaQName
void CheckSchemaQName (ConformanceCheckContext ctx, object element, XmlQualifiedName name)
{
if (name == null || name == XmlQualifiedName.Empty) return;
if (name.Namespace == "" || name.Namespace == XmlSchema.Namespace) return;
if (ctx.CurrentSchema.TargetNamespace == name.Namespace) return;
foreach (XmlSchemaObject i in ctx.CurrentSchema.Includes)
if ((i is XmlSchemaImport) && ((XmlSchemaImport)i).Namespace == name.Namespace) return;
ctx.ReportRuleViolation (element, BasicProfileRules.R2102);
}
示例7: CheckR2305
void CheckR2305 (ConformanceCheckContext ctx, Operation value)
{
string [] order = value.ParameterOrder;
ServiceDescription sd = value.PortType.ServiceDescription;
Message omitted = null;
foreach (OperationMessage m in value.Messages) {
if (m.Name == null)
continue; // it is doubtful, but R2305 is not to check such cases anyways.
Message msg = sd.Messages [m.Name];
if (msg == null)
continue; // it is doubtful, but R2305 is not to check such cases anyways.
foreach (MessagePart p in msg.Parts) {
if (order != null && Array.IndexOf (order, p.Name) >= 0)
continue;
if (omitted == null) {
omitted = msg;
continue;
}
ctx.ReportRuleViolation (value, BasicProfileRules.R2305);
return;
}
}
}
示例8: CheckSoapBindingExtensions
void CheckSoapBindingExtensions (ConformanceCheckContext ctx, Binding value, LiteralType type)
{
bool violationNS = false;
bool violation2717 = false;
bool violation2720 = false;
bool violation2721 = false;
foreach (OperationBinding op in value.Operations) {
SoapBodyBinding sbb = op.Extensions.Find (typeof (SoapBodyBinding)) as SoapBodyBinding;
if (sbb != null) {
if (type == LiteralType.Document && sbb.Namespace != null)
violationNS = true;
if (type == LiteralType.Rpc && sbb.Namespace == null)
violation2717 = true;
}
SoapHeaderBinding shb = op.Extensions.Find (typeof (SoapHeaderBinding)) as SoapHeaderBinding;
if (shb != null) {
violationNS |= shb.Namespace != null;
violation2720 |= !IsValidPart (shb.Part);
}
SoapHeaderFaultBinding sfhb = op.Extensions.Find (typeof (SoapHeaderFaultBinding)) as SoapHeaderFaultBinding;
if (sfhb != null) {
violationNS |= sfhb.Namespace != null;
violation2720 |= !IsValidPart (sfhb.Part);
}
SoapFaultBinding sfb = op.Extensions.Find (typeof (SoapFaultBinding)) as SoapFaultBinding;
if (sfb != null) {
violation2721 |= sfb.Name == null;
violationNS |= sfb.Namespace != null;
}
}
if (violationNS)
ctx.ReportRuleViolation (value,
type == LiteralType.Document ?
BasicProfileRules.R2716 :
BasicProfileRules.R2726);
if (violation2717)
ctx.ReportRuleViolation (value, BasicProfileRules.R2717);
if (violation2720)
ctx.ReportRuleViolation (value, BasicProfileRules.R2720);
if (violation2721)
ctx.ReportRuleViolation (value, BasicProfileRules.R2721);
}
示例9: CheckDuplicateSoapAddressBinding
void CheckDuplicateSoapAddressBinding (ConformanceCheckContext ctx, ServiceDescription value)
{
ArrayList locations = new ArrayList ();
foreach (PortType p in value.PortTypes) {
SoapAddressBinding b = (SoapAddressBinding) p.Extensions.Find (typeof (SoapAddressBinding));
if (b == null || b.Location == null || b.Location.Length == 0)
continue;
if (locations.Contains (b.Location)) {
ctx.ReportRuleViolation (value, BasicProfileRules.R2711);
// One report for one ServiceDescription should be enough.
return;
}
locations.Add (b.Location);
}
}