예제 #1
0
        public virtual string InitializeProperty(Property modelProperty)
        {
            if (modelProperty == null || modelProperty.ModelType == null)
            {
                throw new ArgumentNullException("modelProperty");
            }

            string xmlDeclarations = "";

            if (CodeModel.ShouldGenerateXmlSerialization)
            {
                List <string> combinedXmlDeclarations = GenericXmlCtxtSerializer.XmlSerializationPropertyCtxt(modelProperty);

                SequenceTypePy sequenceType = modelProperty.ModelType as SequenceTypePy;
                if (sequenceType != null && !string.IsNullOrEmpty(sequenceType.ElementXmlName))
                {
                    combinedXmlDeclarations.AddRange(sequenceType.ItemsSerializationContext());
                }

                xmlDeclarations = string.Format(CultureInfo.InvariantCulture,
                                                ", 'xml': {{{1}}}",
                                                modelProperty.Name,
                                                string.Join(", ", combinedXmlDeclarations)
                                                );
            }

            //'id':{'key':'id', 'type':'str'},
            return(string.Format(CultureInfo.InvariantCulture,
                                 "'{0}': {{'key': '{1}', 'type': '{2}'{3}}},",
                                 modelProperty.Name,
                                 modelProperty.SerializedName,
                                 ClientModelExtensions.GetPythonSerializationType(modelProperty.ModelType),
                                 xmlDeclarations
                                 ));
        }
예제 #2
0
        public virtual string InitializeProperty(Property modelProperty)
        {
            if (modelProperty == null || modelProperty.ModelType == null)
            {
                throw new ArgumentNullException("modelProperty");
            }

            //'id':{'key':'id', 'type':'str'},
            return(string.Format(CultureInfo.InvariantCulture,
                                 "'{0}': {{'key': '{1}', 'type': '{2}'}},",
                                 modelProperty.Name, modelProperty.SerializedName,
                                 ClientModelExtensions.GetPythonSerializationType(modelProperty.ModelType)));
        }
예제 #3
0
        public override string InitializeProperty(Property modelProperty)
        {
            if (modelProperty == null || modelProperty.Type == null)
            {
                throw new ArgumentNullException("modelProperty");
            }

            if (Azure.AzureExtensions.IsAzureResource(this) && modelProperty.SerializedName.Contains("properties."))
            {
                return(string.Format(CultureInfo.InvariantCulture,
                                     "'{0}': {{'key': '{1}', 'type': '{2}', 'flatten': True}},",
                                     modelProperty.Name, modelProperty.SerializedName,
                                     ClientModelExtensions.GetPythonSerializationType(modelProperty.Type)));
            }
            return(base.InitializeProperty(modelProperty));
        }