コード例 #1
0
ファイル: KnownTypesView.cs プロジェクト: omnimark/PTVS
        public KnownTypesView(IPythonInterpreter interpreter, Version version) {
            int count = (int)BuiltinTypeIdExtensions.LastTypeId;
            _children = new IAnalysisItemView[count];
            for (int value = 1; value <= count; ++value) {
                var expectedName = SharedDatabaseState.GetBuiltinTypeName((BuiltinTypeId)value, version);
                string name = string.Format("{0} ({1})",
                    expectedName,
                    Enum.GetName(typeof(BuiltinTypeId), value)
                );

                IPythonType type;
                try {
                    type = interpreter.GetBuiltinType((BuiltinTypeId)value);
                    if (expectedName != type.Name) {
                        name = string.Format("{2} ({1}/{0})",
                            expectedName,
                            Enum.GetName(typeof(BuiltinTypeId), value),
                            type.Name
                        );
                    }
                } catch {
                    type = null;
                }

                if (type != null) {
                    _children[value - 1] = new ClassView(
                        null,
                        name,
                        type
                    );
                } else {
                    _children[value - 1] = new NullMember(name);
                }
            }
        }
コード例 #2
0
ファイル: KnownTypesView.cs プロジェクト: JoshVarty/PTVS
        public KnownTypesView(IPythonInterpreter interpreter, Version version)
        {
            int count = (int)BuiltinTypeIdExtensions.LastTypeId;

            _children = new IAnalysisItemView[count];
            for (int value = 1; value <= count; ++value)
            {
                var    expectedName = SharedDatabaseState.GetBuiltinTypeName((BuiltinTypeId)value, version);
                string name         = string.Format("{0} ({1})",
                                                    expectedName,
                                                    Enum.GetName(typeof(BuiltinTypeId), value)
                                                    );

                IPythonType type;
                try {
                    type = interpreter.GetBuiltinType((BuiltinTypeId)value);
                    if (expectedName != type.Name)
                    {
                        name = string.Format("{2} ({1}/{0})",
                                             expectedName,
                                             Enum.GetName(typeof(BuiltinTypeId), value),
                                             type.Name
                                             );
                    }
                } catch {
                    type = null;
                }

                if (type != null)
                {
                    _children[value - 1] = new ClassView(
                        null,
                        name,
                        type
                        );
                }
                else
                {
                    _children[value - 1] = new NullMember(name);
                }
            }
        }