コード例 #1
0
        public override IType NormalizeTypeReference(IType type)
        {
            if (type == null)
            {
                return(null);
            }
            var enumType = type as EnumType;

            if (enumType != null && enumType.ModelAsString)
            {
                type = new PrimaryTypeModel(KnownPrimaryType.String);
            }

            if (_visited.ContainsKey(type))
            {
                return(_visited[type]);
            }

            if (type is PrimaryType)
            {
                _visited[type] = new PrimaryTypeModel(type as PrimaryType);
                return(_visited[type]);
            }
            if (type is SequenceType)
            {
                SequenceTypeModel model = new SequenceTypeModel(type as SequenceType);
                _visited[type] = model;
                return(NormalizeSequenceType(model));
            }
            if (type is DictionaryType)
            {
                DictionaryTypeModel model = new DictionaryTypeModel(type as DictionaryType);
                _visited[type] = model;
                return(NormalizeDictionaryType(model));
            }
            if (type is CompositeType)
            {
                CompositeTypeModel model = NewCompositeTypeModel(type as CompositeType);
                _visited[type] = model;
                return(NormalizeCompositeType(model));
            }
            if (type is EnumType)
            {
                EnumTypeModel model = new EnumTypeModel(type as EnumType, _package);
                _visited[type] = model;
                return(NormalizeEnumType(model));
            }


            throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture,
                                                          "Type {0} is not supported.", type.GetType()));
        }
コード例 #2
0
ファイル: JavaCodeNamer.cs プロジェクト: Ranjana1996/autorest
        public override IType NormalizeTypeReference(IType type)
        {
            if (type == null)
            {
                return null;
            }
            var enumType = type as EnumType;
            if (enumType != null && enumType.ModelAsString)
            {
                type = new PrimaryTypeModel(KnownPrimaryType.String);
            }

            if (_visited.ContainsKey(type))
            {
                return _visited[type];
            }

            if (type is PrimaryType)
            {
                _visited[type] = new PrimaryTypeModel(type as PrimaryType);
                return _visited[type];
            }
            if (type is SequenceType)
            {
                SequenceTypeModel model = new SequenceTypeModel(type as SequenceType);
                _visited[type] = model;
                return NormalizeSequenceType(model);
            }
            if (type is DictionaryType)
            {
                DictionaryTypeModel model = new DictionaryTypeModel(type as DictionaryType);
                _visited[type] = model;
                return NormalizeDictionaryType(model);
            }
            if (type is CompositeType)
            {
                CompositeTypeModel model = NewCompositeTypeModel(type as CompositeType);
                _visited[type] = model;
                return NormalizeCompositeType(model);
            }
            if (type is EnumType)
            {
                EnumTypeModel model = new EnumTypeModel(type as EnumType, _package);
                _visited[type] = model;
                return NormalizeEnumType(model);
            }


            throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, 
                "Type {0} is not supported.", type.GetType()));
        }