internal static string GetSchemaAttributes(SMERelationshipProperty relationship, SMEResource resource) { if (relationship == null) return String.Empty; var builder = new StringBuilder(); //builder.AppendFormat("{0}=\"{1}\" ", SDataResource.FormatSME(IncludeByDefaultName), IncludeByDefaultName, relationship.IncludeByDefault ? "true" : "false"); if (relationship.Relationship != 0) builder.AppendFormat("{0}=\"{1}\" ", SDataResource.FormatSME(RelationshipName), relationship.Relationship); if (resource == null) { builder.AppendFormat("{0}=\"{1}\" ", SDataResource.FormatSME(CanGetName), relationship.CanGet ? "true" : "false"); builder.AppendFormat("{0}=\"{1}\" ", SDataResource.FormatSME(CanPostName), relationship.CanPost ? "true" : "false"); builder.AppendFormat("{0}=\"{1}\" ", SDataResource.FormatSME(CanPutName), relationship.CanPut ? "true" : "false"); builder.AppendFormat("{0}=\"{1}\" ", SDataResource.FormatSME(CanDeleteName), relationship.CanDelete ? "true" : "false"); builder.AppendFormat("{0}=\"{1}\" ", SDataResource.FormatSME(CanPagePreviousName), relationship.CanPagePrevious ? "true" : "false"); builder.AppendFormat("{0}=\"{1}\" ", SDataResource.FormatSME(CanPageNextName), relationship.CanPageNext ? "true" : "false"); builder.AppendFormat("{0}=\"{1}\" ", SDataResource.FormatSME(CanPageIndexName), relationship.CanPageIndex ? "true" : "false"); } builder.AppendFormat("{0}=\"{1}\" ", SDataResource.FormatSME(IsCollectionName), relationship.IsCollection ? "true" : "false"); builder.AppendFormat("{0}=\"{1}\"", SDataResource.XmlConstants.MinOccurs, relationship.MinOccurs); if (relationship.MaxOccurs != 0) builder.AppendFormat("{0}=\"{1}\"", SDataResource.XmlConstants.MaxOccurs, relationship.MaxOccurs == -1 ? SDataResource.XmlConstants.Unbounded : relationship.MaxOccurs.ToString()); return builder.ToString(); }
/// <summary> /// Loads the Metadata using combination of the specified <see cref="Type"/> and Xml schema type. /// </summary> /// <param name="name">The qualified name of the xml type.</param> /// <param name="schemaSet">Collection of schemas.</param> public void Load(XmlQualifiedName name, XmlSchemaSet schemaSet) { _bLoading = true; // Holds the namespaces associated with this meta data _oNamespaces = new XmlNamespaceManager(new NameTable()); // Holds the SME resource details _oResourceInfo = new SMEResource(); // If we have a specified name we can get the default type name and namespace if (TypeInfoHelper.IsValidQualifiedName(name)) { _strTypeName = name.Name; Namespace = name.Namespace; Name = name.Name; } // Next find the associated schema type var schemaObject = GetSchemaObject(name, schemaSet); var complexType = schemaObject as XmlSchemaComplexType; XmlSchemaParticle particle; var properties = new List<SMEProperty>(); // If its a complex type load the details if (complexType != null) particle = BeginLoadComplexType(properties, complexType, schemaSet); else particle = null; // If we don't have a name at this point we just use the type name if (String.IsNullOrEmpty(Name)) Name = _strTypeName; // At this point we can build the list of properties using any of the following // 1) The particles for the associated schema type (preferred) // 2) The properties on the type if (particle != null) { // XmlSchemaChoice or XmlSchemaSequence var schemaGroup = particle as XmlSchemaGroupBase; if (schemaGroup != null) { foreach (var groupItem in schemaGroup.Items) { var element = groupItem as XmlSchemaElement; if (element == null) continue; var originalElement = element; // Check for a reference name if (!element.RefName.IsEmpty) { // Find the referenced type foreach (var schema in GetSchemas(element.RefName, schemaSet)) { var possible = schema.Elements[element.RefName] as XmlSchemaElement; if (possible != null) { // We process the referenced type element = possible; break; } } } var metaDataProperty = LoadProperty(element, originalElement, schemaSet); if (metaDataProperty != null) properties.Add(metaDataProperty); } } } _oProperties = new List<SMEProperty>(); _oNameToProperty = new Dictionary<string, SMEProperty>(StringComparer.InvariantCultureIgnoreCase); foreach (var property in properties) AddProperty(property); OnLoaded(); }
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 SMEResource(SMEResource copy) { _bCanGet = copy.CanGet; _bCanPost = copy.CanPost; _bCanPut = copy.CanPut; _bCanDelete = copy.CanDelete; _bCanSearch = copy.CanSearch; _strPath = copy.Path; _strPluralName = copy.PluralName; _strLabel = copy.Label; _bCanPagePrevious = copy.CanPagePrevious; _bCanPageNext = copy.CanPageNext; _bCanPageIndex = copy.CanPageIndex; _bSupportsETag = copy.SupportsETag; _bHasUuid = copy.HasUuid; _bHasTemplate = copy.HasTemplate; _eBatchingMode = copy.BatchingMode; _eRole = copy.Role; _bIsSyncSource = copy.IsSyncSource; _bIsSyncTarget = copy.IsSyncTarget; }