public SingularContentDefinition(ParticleDefinition particle, ICustomAttributeProvider customAttributeProvider, Type runtimeType, string runtimeName, string targetNamespace, bool defaultQualifiedElement)
            : base(particle)
        {
            if (customAttributeProvider.GetXmlArrayAttribute() != null || customAttributeProvider.GetXmlArrayItemAttribute() != null)
            {
                throw new SchemaDefinitionException($"Single content property `{particle} ({runtimeName})` should not use XmlArray or XmlArrayItem attributes in definition.");
            }

            var elementAttribute      = customAttributeProvider.GetXmlElementAttribute();
            var xroadElementAttribute = elementAttribute as XRoadXmlElementAttribute;

            Name = XName.Get(
                (elementAttribute?.ElementName).GetStringOrDefault(runtimeName),
                GetQualifiedNamespace(
                    elementAttribute?.Namespace ?? "",
                    elementAttribute?.Form,
                    targetNamespace,
                    defaultQualifiedElement
                    )
                );

            IsNullable           = (elementAttribute?.IsNullable).GetValueOrDefault();
            Order                = (elementAttribute?.Order).GetValueOrDefault(-1);
            UseXop               = typeof(Stream).GetTypeInfo().IsAssignableFrom(runtimeType) && (xroadElementAttribute?.UseXop).GetValueOrDefault(true);
            TypeName             = (elementAttribute?.DataType).MapNotEmpty(x => XName.Get(x, NamespaceConstants.XSD));
            IsOptional           = xroadElementAttribute?.IsOptional == true;
            State                = DefinitionState.Default;
            Documentation        = new DocumentationDefinition(customAttributeProvider);
            MergeContent         = customAttributeProvider.HasMergeAttribute();
            RuntimeType          = runtimeType;
            EmptyTagHandlingMode = xroadElementAttribute?.EmptyTagHandlingMode;
        }
Beispiel #2
0
        /// <summary>
        /// Initializes new definition object using default settings.
        /// </summary>
        public OperationDefinition(XName qualifiedName, uint?version, MethodInfo methodInfo)
        {
            MethodInfo = methodInfo;

            var attribute = methodInfo.GetServices().SingleOrDefault(x => x.Name == qualifiedName.LocalName);

            Name                      = qualifiedName;
            IsAbstract                = (attribute?.IsAbstract).GetValueOrDefault();
            InputBinaryMode           = BinaryMode.Xml;
            OutputBinaryMode          = BinaryMode.Xml;
            State                     = (attribute?.IsHidden).GetValueOrDefault() ? DefinitionState.Hidden : DefinitionState.Default;
            Version                   = version.GetValueOrDefault(attribute?.AddedInVersion ?? 0u);
            CopyRequestPartToResponse = true;
            InputMessageName          = qualifiedName.LocalName;
            OutputMessageName         = $"{qualifiedName.LocalName}Response";
            Documentation             = new DocumentationDefinition(methodInfo);
            ServiceMapType            = attribute?.ServiceMapType ?? typeof(ServiceMap);
            ExtensionSchemaExporter   = attribute?.SchemaExporter;
        }
Beispiel #3
0
 public TypeDefinition(Type type)
 {
     Documentation = new DocumentationDefinition(type.GetTypeInfo());
     Type          = type;
 }
Beispiel #4
0
 public TypeDefinition(Type type, string targetNamespace)
 {
     Documentation   = new DocumentationDefinition(type.GetTypeInfo());
     TargetNamespace = targetNamespace;
     Type            = type;
 }