本文整理汇总了C#中System.Xml.Schema.XmlSchemaDatatype类的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaDatatype类的具体用法?C# XmlSchemaDatatype怎么用?C# XmlSchemaDatatype使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlSchemaDatatype类属于System.Xml.Schema命名空间,在下文中一共展示了XmlSchemaDatatype类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckValueFacets
internal override Exception CheckValueFacets(double value, XmlSchemaDatatype datatype)
{
RestrictionFacets restriction = datatype.Restriction;
RestrictionFlags flags = (restriction != null) ? restriction.Flags : ((RestrictionFlags) 0);
XmlValueConverter valueConverter = datatype.ValueConverter;
if (((flags & RestrictionFlags.MaxInclusive) != 0) && (value > valueConverter.ToDouble(restriction.MaxInclusive)))
{
return new XmlSchemaException("Sch_MaxInclusiveConstraintFailed", string.Empty);
}
if (((flags & RestrictionFlags.MaxExclusive) != 0) && (value >= valueConverter.ToDouble(restriction.MaxExclusive)))
{
return new XmlSchemaException("Sch_MaxExclusiveConstraintFailed", string.Empty);
}
if (((flags & RestrictionFlags.MinInclusive) != 0) && (value < valueConverter.ToDouble(restriction.MinInclusive)))
{
return new XmlSchemaException("Sch_MinInclusiveConstraintFailed", string.Empty);
}
if (((flags & RestrictionFlags.MinExclusive) != 0) && (value <= valueConverter.ToDouble(restriction.MinExclusive)))
{
return new XmlSchemaException("Sch_MinExclusiveConstraintFailed", string.Empty);
}
if (((flags & RestrictionFlags.Enumeration) != 0) && !this.MatchEnumeration(value, restriction.Enumeration, valueConverter))
{
return new XmlSchemaException("Sch_EnumerationConstraintFailed", string.Empty);
}
return null;
}
示例2: CheckValueFacets
internal override Exception CheckValueFacets(byte[] value, XmlSchemaDatatype datatype)
{
RestrictionFacets restriction = datatype.Restriction;
int length = value.Length;
RestrictionFlags flags = (restriction != null) ? restriction.Flags : ((RestrictionFlags) 0);
if (flags != 0)
{
if (((flags & RestrictionFlags.Length) != 0) && (restriction.Length != length))
{
return new XmlSchemaException("Sch_LengthConstraintFailed", string.Empty);
}
if (((flags & RestrictionFlags.MinLength) != 0) && (length < restriction.MinLength))
{
return new XmlSchemaException("Sch_MinLengthConstraintFailed", string.Empty);
}
if (((flags & RestrictionFlags.MaxLength) != 0) && (restriction.MaxLength < length))
{
return new XmlSchemaException("Sch_MaxLengthConstraintFailed", string.Empty);
}
if (((flags & RestrictionFlags.Enumeration) != 0) && !this.MatchEnumeration(value, restriction.Enumeration, datatype))
{
return new XmlSchemaException("Sch_EnumerationConstraintFailed", string.Empty);
}
}
return null;
}
示例3: CheckValueFacets
internal override Exception CheckValueFacets(TimeSpan value, XmlSchemaDatatype datatype)
{
RestrictionFacets restriction = datatype.Restriction;
RestrictionFlags flags = (restriction != null) ? restriction.Flags : ((RestrictionFlags) 0);
if (((flags & RestrictionFlags.MaxInclusive) != 0) && (TimeSpan.Compare(value, (TimeSpan) restriction.MaxInclusive) > 0))
{
return new XmlSchemaException("Sch_MaxInclusiveConstraintFailed", string.Empty);
}
if (((flags & RestrictionFlags.MaxExclusive) != 0) && (TimeSpan.Compare(value, (TimeSpan) restriction.MaxExclusive) >= 0))
{
return new XmlSchemaException("Sch_MaxExclusiveConstraintFailed", string.Empty);
}
if (((flags & RestrictionFlags.MinInclusive) != 0) && (TimeSpan.Compare(value, (TimeSpan) restriction.MinInclusive) < 0))
{
return new XmlSchemaException("Sch_MinInclusiveConstraintFailed", string.Empty);
}
if (((flags & RestrictionFlags.MinExclusive) != 0) && (TimeSpan.Compare(value, (TimeSpan) restriction.MinExclusive) <= 0))
{
return new XmlSchemaException("Sch_MinExclusiveConstraintFailed", string.Empty);
}
if (((flags & RestrictionFlags.Enumeration) != 0) && !this.MatchEnumeration(value, restriction.Enumeration))
{
return new XmlSchemaException("Sch_EnumerationConstraintFailed", string.Empty);
}
return null;
}
示例4: CheckValueFacets
internal override Exception CheckValueFacets(object value, XmlSchemaDatatype datatype)
{
RestrictionFacets restriction = datatype.Restriction;
RestrictionFlags flags = (restriction != null) ? restriction.Flags : ((RestrictionFlags) 0);
if (((flags & RestrictionFlags.Enumeration) != 0) && !this.MatchEnumeration(value, restriction.Enumeration, datatype))
{
return new XmlSchemaException("Sch_EnumerationConstraintFailed", string.Empty);
}
return null;
}
示例5: MatchEnumeration
private bool MatchEnumeration(DateTime value, ArrayList enumeration, XmlSchemaDatatype datatype)
{
for (int i = 0; i < enumeration.Count; i++)
{
if (datatype.Compare(value, (DateTime) enumeration[i]) == 0)
{
return true;
}
}
return false;
}
示例6: TypedObject
public TypedObject(object obj, string svalue, XmlSchemaDatatype xsdtype)
{
this.ovalue = obj;
this.svalue = svalue;
this.xsdtype = xsdtype;
if (((xsdtype.Variety == XmlSchemaDatatypeVariety.List) || (xsdtype is Datatype_base64Binary)) || (xsdtype is Datatype_hexBinary))
{
this.isList = true;
this.dim = ((Array) obj).Length;
}
}
示例7: GetNewElement
private XElement GetNewElement(XName name, object value, XmlSchemaDatatype datatype, XElement parentElement) {
XElement newElement = null;
if (datatype != null) {
string stringValue = XTypedServices.GetXmlString(value, datatype, parentElement);
newElement = new XElement(name, stringValue);
}
else {
newElement = XTypedServices.GetXElement(value as XTypedElement, name);
}
return newElement;
}
示例8: MatchEnumeration
internal override bool MatchEnumeration(object value, ArrayList enumeration, XmlSchemaDatatype datatype)
{
for (int i = 0; i < enumeration.Count; i++)
{
if (datatype.Compare(value, enumeration[i]) == 0)
{
return true;
}
}
return false;
}
示例9: AddElementToParent
public virtual void AddElementToParent(XName name, object value, XElement parentElement, bool addToExisting, XmlSchemaDatatype datatype) {
Debug.Assert(value != null);
if (addToExisting) {
parentElement.Add(GetNewElement(name, value, datatype, parentElement));
}
else {
XElement existingElement = parentElement.Element(name);
if (existingElement == null) {
parentElement.Add(GetNewElement(name, value, datatype, parentElement));
}
else if (datatype != null) { //Update simple type value
existingElement.Value = XTypedServices.GetXmlString(value, datatype, existingElement);
}
else {
existingElement.AddBeforeSelf(XTypedServices.GetXElement(value as XTypedElement, name));
existingElement.Remove();
}
}
}
示例10: ParseFacetValue
private object ParseFacetValue(XmlSchemaDatatype datatype, XmlSchemaFacet facet, string code, IXmlNamespaceResolver nsmgr, XmlNameTable nameTable) {
object typedValue;
Exception ex = datatype.TryParseValue(facet.Value, nameTable, nsmgr, out typedValue);
if (ex == null) {
return typedValue;
}
else {
throw new XmlSchemaException(code, new string[] {ex.Message} , ex, facet.SourceUri, facet.LineNumber, facet.LinePosition, facet);
}
}
示例11: MatchEnumeration
internal override bool MatchEnumeration(object value, ArrayList enumeration, XmlSchemaDatatype datatype) {
return MatchEnumeration(datatype.ValueConverter.ToDouble(value), enumeration, datatype.ValueConverter);
}
示例12: CheckValueFacets
internal override Exception CheckValueFacets(object value, XmlSchemaDatatype datatype) {
double doubleValue = datatype.ValueConverter.ToDouble(value);
return CheckValueFacets(doubleValue, datatype);
}
示例13: CheckLexicalFacets
internal virtual Exception CheckLexicalFacets(ref string parseString, XmlSchemaDatatype datatype) {
CheckWhitespaceFacets(ref parseString, datatype);
return CheckPatternFacets(datatype.Restriction, parseString);
}
示例14: CheckWhitespaceFacets
internal void CheckWhitespaceFacets(ref string s, XmlSchemaDatatype datatype) {
// before parsing, check whitespace facet
RestrictionFacets restriction = datatype.Restriction;
switch (datatype.Variety) {
case XmlSchemaDatatypeVariety.List:
s = s.Trim();
break;
case XmlSchemaDatatypeVariety.Atomic:
if (datatype.BuiltInWhitespaceFacet == XmlSchemaWhiteSpace.Collapse) {
s = XmlComplianceUtil.NonCDataNormalize(s);
}
else if (datatype.BuiltInWhitespaceFacet == XmlSchemaWhiteSpace.Replace) {
s = XmlComplianceUtil.CDataNormalize(s);
}
else if (restriction != null && (restriction.Flags & RestrictionFlags.WhiteSpace) != 0) { //Restriction has whitespace facet specified
if (restriction.WhiteSpace == XmlSchemaWhiteSpace.Replace) {
s = XmlComplianceUtil.CDataNormalize(s);
}
else if (restriction.WhiteSpace == XmlSchemaWhiteSpace.Collapse) {
s = XmlComplianceUtil.NonCDataNormalize(s);
}
}
break;
default:
break;
}
}
示例15: FacetsCompiler
public FacetsCompiler(DatatypeImplementation baseDatatype, RestrictionFacets restriction) {
firstPattern = true;
regStr = null;
pattern_facet = null;
datatype = baseDatatype;
derivedRestriction = restriction;
baseFlags = datatype.Restriction != null ? datatype.Restriction.Flags : 0;
baseFixedFlags = datatype.Restriction != null ? datatype.Restriction.FixedFlags : 0;
validRestrictionFlags = datatype.ValidRestrictionFlags;
nonNegativeInt = DatatypeImplementation.GetSimpleTypeFromTypeCode(XmlTypeCode.NonNegativeInteger).Datatype;
builtInEnum = !(datatype is Datatype_union || datatype is Datatype_List) ? datatype.TypeCode : 0;
builtInType = (int)builtInEnum > 0 ? DatatypeImplementation.GetSimpleTypeFromTypeCode(builtInEnum).Datatype : datatype;
}