EscapeQName() 정적인 개인적인 메소드

static private EscapeQName ( string name ) : string
name string
리턴 string
예제 #1
0
        private void ImportAccessorMapping(MemberMapping accessor, FieldModel model, SoapAttributes a, string ns, XmlSchemaForm form, RecursionLimiter limiter)
        {
            Type   accessorType = model.FieldType;
            string accessorName = model.Name;

            accessor.TypeDesc = _typeScope.GetTypeDesc(accessorType);
            if (accessor.TypeDesc.IsVoid)
            {
                throw new InvalidOperationException(SR.XmlInvalidVoid);
            }

            SoapAttributeFlags flags = a.GetSoapFlags();

            if ((flags & SoapAttributeFlags.Attribute) == SoapAttributeFlags.Attribute)
            {
                if (!accessor.TypeDesc.IsPrimitive && !accessor.TypeDesc.IsEnum)
                {
                    throw new InvalidOperationException(SR.Format(SR.XmlIllegalSoapAttribute, accessorName, accessor.TypeDesc.FullName));
                }

                if ((flags & SoapAttributeFlags.Attribute) != flags)
                {
                    throw new InvalidOperationException(SR.XmlInvalidElementAttribute);
                }

                AttributeAccessor attribute = new AttributeAccessor();
                attribute.Name      = Accessor.EscapeQName(a.SoapAttribute == null || a.SoapAttribute.AttributeName.Length == 0 ? accessorName : a.SoapAttribute.AttributeName);
                attribute.Namespace = a.SoapAttribute == null || a.SoapAttribute.Namespace == null ? ns : a.SoapAttribute.Namespace;
                attribute.Form      = XmlSchemaForm.Qualified; // attributes are always qualified since they're only used for encoded soap headers
                attribute.Mapping   = ImportTypeMapping(_modelScope.GetTypeModel(accessorType), (a.SoapAttribute == null ? String.Empty : a.SoapAttribute.DataType), limiter);
                attribute.Default   = GetDefaultValue(model.FieldTypeDesc, a);
                accessor.Attribute  = attribute;
                accessor.Elements   = Array.Empty <ElementAccessor>();
            }
            else
            {
                if ((flags & SoapAttributeFlags.Element) != flags)
                {
                    throw new InvalidOperationException(SR.XmlInvalidElementAttribute);
                }

                ElementAccessor element = new ElementAccessor();
                element.IsSoap    = true;
                element.Name      = XmlConvert.EncodeLocalName(a.SoapElement == null || a.SoapElement.ElementName.Length == 0 ? accessorName : a.SoapElement.ElementName);
                element.Namespace = ns;
                element.Form      = form;
                element.Mapping   = ImportTypeMapping(_modelScope.GetTypeModel(accessorType), (a.SoapElement == null ? String.Empty : a.SoapElement.DataType), limiter);
                if (a.SoapElement != null)
                {
                    element.IsNullable = a.SoapElement.IsNullable;
                }
                accessor.Elements = new ElementAccessor[] { element };
            }
        }
예제 #2
0
        private void ImportAccessorMapping(MemberMapping accessor, FieldModel model, SoapAttributes a, string ns, XmlSchemaForm form, RecursionLimiter limiter)
        {
            Type   fieldType = model.FieldType;
            string name      = model.Name;

            accessor.TypeDesc = this.typeScope.GetTypeDesc(fieldType);
            if (accessor.TypeDesc.IsVoid)
            {
                throw new InvalidOperationException(Res.GetString("XmlInvalidVoid"));
            }
            SoapAttributeFlags soapFlags = a.SoapFlags;

            if ((soapFlags & SoapAttributeFlags.Attribute) == SoapAttributeFlags.Attribute)
            {
                if (!accessor.TypeDesc.IsPrimitive && !accessor.TypeDesc.IsEnum)
                {
                    throw new InvalidOperationException(Res.GetString("XmlIllegalSoapAttribute", new object[] { name, accessor.TypeDesc.FullName }));
                }
                if ((soapFlags & SoapAttributeFlags.Attribute) != soapFlags)
                {
                    throw new InvalidOperationException(Res.GetString("XmlInvalidElementAttribute"));
                }
                AttributeAccessor accessor2 = new AttributeAccessor {
                    Name      = Accessor.EscapeQName(((a.SoapAttribute == null) || (a.SoapAttribute.AttributeName.Length == 0)) ? name : a.SoapAttribute.AttributeName),
                    Namespace = ((a.SoapAttribute == null) || (a.SoapAttribute.Namespace == null)) ? ns : a.SoapAttribute.Namespace,
                    Form      = XmlSchemaForm.Qualified,
                    Mapping   = this.ImportTypeMapping(this.modelScope.GetTypeModel(fieldType), (a.SoapAttribute == null) ? string.Empty : a.SoapAttribute.DataType, limiter),
                    Default   = this.GetDefaultValue(model.FieldTypeDesc, a)
                };
                accessor.Attribute = accessor2;
                accessor.Elements  = new ElementAccessor[0];
            }
            else
            {
                if ((soapFlags & SoapAttributeFlags.Element) != soapFlags)
                {
                    throw new InvalidOperationException(Res.GetString("XmlInvalidElementAttribute"));
                }
                ElementAccessor accessor3 = new ElementAccessor {
                    IsSoap    = true,
                    Name      = XmlConvert.EncodeLocalName(((a.SoapElement == null) || (a.SoapElement.ElementName.Length == 0)) ? name : a.SoapElement.ElementName),
                    Namespace = ns,
                    Form      = form,
                    Mapping   = this.ImportTypeMapping(this.modelScope.GetTypeModel(fieldType), (a.SoapElement == null) ? string.Empty : a.SoapElement.DataType, limiter)
                };
                if (a.SoapElement != null)
                {
                    accessor3.IsNullable = a.SoapElement.IsNullable;
                }
                accessor.Elements = new ElementAccessor[] { accessor3 };
            }
        }