示例#1
0
        protected VisualisableType(IContainer factory, Type type, VisualisableTypeData data, SubjectOrAssociate subjectOrAssociate)
        {
            if (type == null)
            {
                throw new ArgumentNullResourceException("type", Resources.General_Given_Parameter_Cannot_Be_Null);
            }

            this.doNotUseFactory = factory;
            this.NetType = type;
            this.PersistentDataField = data;
            this.SubjectOrAssociate = subjectOrAssociate;
            this.PersistentDataField.Modifiers = new ModifiersData(type);
            this.AssemblyName = type.Assembly.GetName().Name;
            this.AssemblyFullName = type.Assembly.FullName;
            this.AssemblyFileName = type.Assembly.Location;
            var genericNameHelper = new TypeDescriptorHelper(type);
            this.Id = genericNameHelper.GenerateId(); // It is not reliable to use type.GUID different generic parameters do not yeild different guids.
            this.Name = genericNameHelper.IsGeneric ? genericNameHelper.GenerateName() : type.Name;
            this.AssemblyQualifiedName = type.AssemblyQualifiedName ?? string.Format(CultureInfo.InvariantCulture, "{0}, {1}", type.Name, this.AssemblyFullName);
            this.ThisTypeNamespace = type.Namespace;
            if (type.IsEnum)
            {
                this.EnumMemberCount = Enum.GetNames(type).Length;
            }

            this.SetToolTip(type);
            this.SetAssociations(type);
            this.SetLinesOfCodeAndStaticAssociations(type);
        }
        public static bool AreEqual(Type typeId1, string typeId2)
        {
            if (string.IsNullOrWhiteSpace(typeId2))
            {
                return false;
            }

            if (typeId1 == null)
            {
                return false;
            }

            if (typeId1.GUID.ToString() == typeId2)
            {
                return true;
            }

            var helper = new TypeDescriptorHelper(typeId1);
            var id1 = helper.GenerateId();
            return id1 == typeId2;
        }