public override string GetElementNameForType(Type entityType, XmlSerializerContext context, bool isNullReturnDefault)
        {
            if (this.Metadata.TypeToElementMap.ContainsKey(entityType))
            {
                return(this.Metadata.TypeToElementMap[entityType]);
            }

            //obtengo el alias
            if (this.UseAlias)
            {
                string alias = context.GetAlias(entityType);
                if (!string.IsNullOrEmpty(alias))
                {
                    return(alias);
                }
            }

            //tengo que buscar los elementos registrados....
            if (!string.IsNullOrEmpty(this.Metadata.DefaultElementName))
            {
                return(this.Metadata.DefaultElementName);
            }

            //devuelvo el root del elemento
            TypeDescriptor itemTypeDesc = context.GetTypeDescriptor(entityType);

            return(itemTypeDesc.GetRootName());
        }
Esempio n. 2
0
        public ListItemPropertyDescriptor GetItemPropertyDescriptor(XmlSerializerContext context, bool isInline)
        {
            ListItemPropertyMetadata metadata;
            string alias = context.GetAlias(this.DeclaringItemType);

            if (string.IsNullOrEmpty(alias))
            {
                metadata = new ListItemPropertyMetadata("Item", this.DeclaringItemType, isInline, this.Metadata);
            }
            else
            {
                metadata = new ListItemPropertyMetadata(alias, this.DeclaringItemType, isInline, this.Metadata);
            }

            ListItemPropertyDescriptor output = new ListItemPropertyDescriptor(metadata);

            output.UseAlias = true;
            return(output);
        }