Esempio n. 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
                                 ));
        }
Esempio n. 2
0
        public string XmlSerializationCtxt()
        {
            List <string> combinedXmlDeclarations = GenericXmlCtxtSerializer.XmlSerializationModelTypeCtxt(this);

            return(string.Format(
                       "{{{0}}}",
                       string.Join(", ", combinedXmlDeclarations)
                       ));
        }
Esempio n. 3
0
        public virtual string InitializeXmlProperty()
        {
            if (this.XmlProperties == null)
            {
                return("");
            }
            List <string> combinedXmlDeclarations = GenericXmlCtxtSerializer.XmlSerializationXmlPropCtxt(this.XmlProperties);

            return(string.Join(", ", combinedXmlDeclarations));
        }