~ubuntu-branches/ubuntu/trusty/mono-addins/trusty-proposed

« back to all changes in this revision

Viewing changes to Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Resource.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-04-25 11:11:33 UTC
  • mfrom: (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110425111133-t05u5p7o5fxx70fu
Tags: 0.6-2
Upload to Unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// Resource.cs
 
2
// ResourceType.cs
3
3
//
4
4
// Author:
5
5
//   Jb Evain (jbevain@gmail.com)
6
6
//
7
 
// (C) 2005 Jb Evain
 
7
// Copyright (c) 2008 - 2010 Jb Evain
8
8
//
9
9
// Permission is hereby granted, free of charge, to any person obtaining
10
10
// a copy of this software and associated documentation files (the
28
28
 
29
29
namespace Mono.Cecil {
30
30
 
31
 
        using System.Collections;
32
 
 
33
 
        public abstract class Resource : IAnnotationProvider, IReflectionStructureVisitable {
34
 
 
35
 
                string m_name;
36
 
                ManifestResourceAttributes m_attributes;
37
 
                IDictionary m_annotations;
 
31
        public enum ResourceType {
 
32
                Linked,
 
33
                Embedded,
 
34
                AssemblyLinked,
 
35
        }
 
36
 
 
37
        public abstract class Resource {
 
38
 
 
39
                string name;
 
40
                uint attributes;
38
41
 
39
42
                public string Name {
40
 
                        get { return m_name; }
41
 
                        set { m_name = value; }
42
 
                }
43
 
 
44
 
                public ManifestResourceAttributes Flags {
45
 
                        get { return m_attributes; }
46
 
                        set { m_attributes = value; }
47
 
                }
48
 
 
49
 
                IDictionary IAnnotationProvider.Annotations {
50
 
                        get {
51
 
                                if (m_annotations == null)
52
 
                                        m_annotations = new Hashtable ();
53
 
                                return m_annotations;
54
 
                        }
 
43
                        get { return name; }
 
44
                        set { name = value; }
 
45
                }
 
46
 
 
47
                public ManifestResourceAttributes Attributes {
 
48
                        get { return (ManifestResourceAttributes) attributes; }
 
49
                        set { attributes = (uint) value; }
 
50
                }
 
51
 
 
52
                public abstract ResourceType ResourceType {
 
53
                        get;
55
54
                }
56
55
 
57
56
                #region ManifestResourceAttributes
58
57
 
59
58
                public bool IsPublic {
60
 
                        get { return (m_attributes & ManifestResourceAttributes.VisibilityMask) == ManifestResourceAttributes.Public; }
61
 
                        set {
62
 
                                if (value) {
63
 
                                        m_attributes &= ~ManifestResourceAttributes.VisibilityMask;
64
 
                                        m_attributes |= ManifestResourceAttributes.Public;
65
 
                                } else
66
 
                                        m_attributes &= ~(ManifestResourceAttributes.VisibilityMask & ManifestResourceAttributes.Public);
67
 
                        }
 
59
                        get { return attributes.GetMaskedAttributes ((uint) ManifestResourceAttributes.VisibilityMask, (uint) ManifestResourceAttributes.Public); }
 
60
                        set { attributes = attributes.SetMaskedAttributes ((uint) ManifestResourceAttributes.VisibilityMask, (uint) ManifestResourceAttributes.Public, value); }
68
61
                }
69
62
 
70
63
                public bool IsPrivate {
71
 
                        get { return (m_attributes & ManifestResourceAttributes.VisibilityMask) == ManifestResourceAttributes.Private; }
72
 
                        set {
73
 
                                if (value) {
74
 
                                        m_attributes &= ~ManifestResourceAttributes.VisibilityMask;
75
 
                                        m_attributes |= ManifestResourceAttributes.Private;
76
 
                                } else
77
 
                                        m_attributes &= ~(ManifestResourceAttributes.VisibilityMask & ManifestResourceAttributes.Private);
78
 
                        }
 
64
                        get { return attributes.GetMaskedAttributes ((uint) ManifestResourceAttributes.VisibilityMask, (uint) ManifestResourceAttributes.Private); }
 
65
                        set { attributes = attributes.SetMaskedAttributes ((uint) ManifestResourceAttributes.VisibilityMask, (uint) ManifestResourceAttributes.Private, value); }
79
66
                }
80
67
 
81
68
                #endregion
82
69
 
83
70
                internal Resource (string name, ManifestResourceAttributes attributes)
84
71
                {
85
 
                        m_name = name;
86
 
                        m_attributes = attributes;
 
72
                        this.name = name;
 
73
                        this.attributes = (uint) attributes;
87
74
                }
88
 
 
89
 
                public abstract void Accept (IReflectionStructureVisitor visitor);
90
75
        }
91
76
}