/// <summary> /// Initialises a new instance of the <see cref="SDataResource"/> class /// using the details of the specified instance. /// </summary> /// <param name="copy">The instance to copy.</param> internal SMEProperty(SMEProperty copy) { _strLabel = copy.Label; Default = copy.Default; Nillable = copy.Nillable; _strPattern = copy.Pattern; _iAverageLength = copy.AverageLength; IsAttribute = copy.IsAttribute; Name = copy.Name; Namespace = copy.Namespace; DataType = copy.DataType; _bCanSort = copy.CanSort; _bCanGroup = copy.CanGroup; _bCanFilter = copy.CanFilter; _iPrecedence = copy.Precedence; _strGroupName = copy.GroupName; _bIsMandatory = copy.IsMandatory; _bIsUniqueKey = copy.IsUniqueKey; _bIsGlobalId = copy.IsGlobalId; _bIsLocalized = copy.IsLocalized; _bIsIdentifier = copy.IsIdentifier; _bIsDescriptor = copy.IsDescriptor; _bIsReadOnly = copy.IsReadOnly; _strCopiedFrom = copy.CopiedFrom; _bUnsupported = copy.Unsupported; }
private XmlSchemaParticle BeginLoadComplexType(IList<SMEProperty> properties, XmlSchemaComplexType complexType, XmlSchemaSet schemaSet) { // The typename defaults to the complex type _strTypeName = complexType.Name; // And the namespace defaults to the complex types Namespace = complexType.QualifiedName.Namespace; // Find the namespaces in use foreach (var schema in GetSchemas(complexType.QualifiedName, schemaSet)) { foreach (var name in schema.Namespaces.ToArray()) { // Don't add default namespaces if (!String.IsNullOrEmpty(name.Name)) _oNamespaces.AddNamespace(name.Name, name.Namespace); } } // Now find out what sort out content the Complex Type has var content = complexType.ContentModel; var complexContent = content as XmlSchemaComplexContent; var simpleContent = content as XmlSchemaSimpleContent; var particle = complexType.Particle; if (complexType.Attributes.Count > 0) LoadAttributes(properties, complexType.Attributes, schemaSet); // Load base type information if any is present if (complexContent != null) { var complexExtension = complexContent.Content as XmlSchemaComplexContentExtension; if (complexExtension != null && TypeInfoHelper.IsValidQualifiedName(complexExtension.BaseTypeName)) { try { _oBaseType = MetadataManager.GetMetadata(complexExtension.BaseTypeName, schemaSet); } catch { _oBaseType = null; // Any error and we just set the base type as empty } particle = complexExtension.Particle; if (complexExtension.Attributes.Count > 0) LoadAttributes(properties, complexExtension.Attributes, schemaSet); } } if (simpleContent != null) { var simpleExtension = simpleContent.Content as XmlSchemaSimpleContentExtension; if (simpleExtension != null) { if (TypeInfoHelper.IsValidQualifiedName(simpleExtension.BaseTypeName)) _oBaseType = GetXSDMetadataProperty(simpleExtension.BaseTypeName, simpleExtension.BaseTypeName); if (simpleExtension.Attributes.Count > 0) LoadAttributes(properties, simpleExtension.Attributes, schemaSet); } } // Load SData/SME attributes which are applied at the resource level if (complexType.UnhandledAttributes != null && complexType.UnhandledAttributes.Length > 0) { foreach (var attribute in complexType.UnhandledAttributes) LoadUnhandledAttribute(attribute); } return particle; }
private void Clone(SDataResource source) { _strTypeName = source.TypeName; _oBaseType = source.BaseType; if (source.RelationshipInformation != null) _oRelationshipInformation = new SMERelationshipProperty(source.RelationshipInformation); if (source.ResourceInformation != null) _oResourceInfo = new SMEResource(source.ResourceInformation); _oProperties = new List<SMEProperty>(); _oNameToProperty = new Dictionary<string, SMEProperty>(StringComparer.InvariantCultureIgnoreCase); foreach (var property in source.Properties) AddProperty(property); _oNamespaces = new XmlNamespaceManager(new NameTable()); foreach (var ns in source.Namespaces.GetNamespacesInScope(XmlNamespaceScope.All)) { // Don't add default namespaces if (!String.IsNullOrEmpty(ns.Key)) _oNamespaces.AddNamespace(ns.Key, ns.Value); } }
internal void AddProperty(SMEProperty property) { _oProperties.Add(property); _oNameToProperty[property.Name] = property; }