示例#1
0
        public FieldInfo Field(IFieldDeclaration fieldDefinition, TypeInfo type)
        {
            if (_fieldCorrespondence.ContainsKey(fieldDefinition))
            {
                return(_fieldCorrespondence[fieldDefinition]);
            }

            var fieldInfo = new FieldInfo
            {
                Text                   = fieldDefinition.ToString(),
                Name                   = fieldDefinition.Name,
                FullName               = fieldDefinition.Name,
                IsInternal             = fieldDefinition.Visibility == FieldVisibility.Assembly,
                IsPrivate              = fieldDefinition.Visibility == FieldVisibility.Private,
                IsPublic               = fieldDefinition.Visibility == FieldVisibility.Public,
                IsProtected            = fieldDefinition.Visibility == FieldVisibility.Family,
                IsProtectedAndInternal = fieldDefinition.Visibility == FieldVisibility.FamilyAndAssembly,
                IsProtectedOrInternal  = fieldDefinition.Visibility == FieldVisibility.FamilyOrAssembly,
                IsStatic               = fieldDefinition.Static,
                IsLiteral              = fieldDefinition.Literal,
                IsInitOnly             = fieldDefinition.ReadOnly,
                IsSpecialName          = fieldDefinition.SpecialName,
                MemberReference        = fieldDefinition,
                DeclaringType          = type
            };

            _fieldCorrespondence.Add(fieldDefinition, fieldInfo);

            fieldInfo.Text = fieldInfo.Text.Substring(fieldInfo.Text.LastIndexOf('.') + 1);
            fieldInfo.Name = fieldInfo.Name.Substring(fieldInfo.Name.LastIndexOf('.') + 1);

            fieldInfo.Icon = Images.Images.GetFieldIcon(fieldInfo);

            return(fieldInfo);
        }
        public FieldInfo Field(IFieldDeclaration fieldDefinition, TypeInfo type)
        {
            if (_fieldCorrespondence.ContainsKey(fieldDefinition))
            {
                return _fieldCorrespondence[fieldDefinition];
            }

            var fieldInfo = new FieldInfo
            {
                Text = fieldDefinition.ToString(),
                Name = fieldDefinition.Name,
                FullName = fieldDefinition.Name,
                IsInternal = fieldDefinition.Visibility == FieldVisibility.Assembly,
                IsPrivate = fieldDefinition.Visibility == FieldVisibility.Private,
                IsPublic = fieldDefinition.Visibility == FieldVisibility.Public,
                IsProtected = fieldDefinition.Visibility == FieldVisibility.Family,
                IsProtectedAndInternal = fieldDefinition.Visibility == FieldVisibility.FamilyAndAssembly,
                IsProtectedOrInternal = fieldDefinition.Visibility == FieldVisibility.FamilyOrAssembly,
                IsStatic = fieldDefinition.Static,
                IsLiteral = fieldDefinition.Literal,
                IsInitOnly = fieldDefinition.ReadOnly,
                IsSpecialName = fieldDefinition.SpecialName,
                MemberReference = fieldDefinition,
                DeclaringType = type
            };
            _fieldCorrespondence.Add(fieldDefinition, fieldInfo);

            fieldInfo.Text = fieldInfo.Text.Substring(fieldInfo.Text.LastIndexOf('.') + 1);
            fieldInfo.Name = fieldInfo.Name.Substring(fieldInfo.Name.LastIndexOf('.') + 1);

            fieldInfo.Icon = Images.Images.GetFieldIcon(fieldInfo);

            return fieldInfo;
        }