Exemple #1
0
        private static void ProcessComplexProperty(ConstructableMetadata model, EdmStructuredType owningType, ODataComplexValue complexValue, bool isOpenProperty)
        {
            string namespaceName = "";
            var schematype = owningType as IEdmSchemaType;
            if (schematype != null)
            {
                namespaceName = schematype.Namespace;
            }

            ExceptionUtilities.Assert(complexValue.TypeName.StartsWith(namespaceName + "."), "The type name must start with the same namespace as its owning type.");

            EdmComplexType complexType = model.FindType(complexValue.TypeName) as EdmComplexType;
            if (complexType == null)
            {
                string complexTypeLocalName = complexValue.GetUnqualifiedTypeName(namespaceName);
                complexType = model.AddComplexType(complexTypeLocalName, null, null, false) as EdmComplexType;
                CreateMetadataProperties(model, complexType, complexValue.Properties);
            }

            if (isOpenProperty)
            {
                //TODO: Find way to set parent type to open.
            }
            else
            {
                ExceptionUtilities.CheckObjectNotNull(complexType, "Complex type cannot be null");
                owningType.AddProperty(new EdmStructuralProperty(owningType, complexType.Name, complexType.ToTypeReference()));
            }
        }