Salut,

Je travaille toujours sur mon configurateur.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 
 
namespace Objects
{
    [Serializable]
    public class AppSettingsDocument
    {
        private string _location = null;
        private XDocument _document = null;
 
        public event AppSettingsDocumentChangeHandler OnAppSettingChange;
        public string Location
        {
            get
            {
                return _location;
            }
            set
            {
                _location = value;
                _document = Refreshers.LoadXDocument(_location);
                if(OnAppSettingChange!=null)
                    OnAppSettingChange(this, new AppSettingsDocumentChangeEventArgs(enAppSettingElementChanged.Location));
            }
        }
 
        [XmlIgnore]
        public XDocument Document
        {
            get
            {
                return _document;
            }
            set
            {
                _document = value;
                if(OnAppSettingChange!=null)
                    OnAppSettingChange(this, new AppSettingsDocumentChangeEventArgs(enAppSettingElementChanged.Document));
            }
        }
 
        public AppSettingsDocument() {
            this._document = new XDocument();
            this._document.Changed += _document_Changed;
        }
 
        private void _document_Changed(object sender, XObjectChangeEventArgs e)
        {
            if (OnAppSettingChange != null)
                OnAppSettingChange(this, new AppSettingsDocumentChangeEventArgs(enAppSettingElementChanged.Document));
        }
 
        public AppSettingsDocument(string location)
        {
            this._location = location;
            this._document = Refreshers.LoadXDocument(_location);
            this._document.Changed += _document_Changed;
        }
    }
}
Dans un autre endroit du code, je change la valeur d'un attribut :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
            n = config.AppSettings.Document.Descendants("add").Single(x => x.Attribute("key").Value == "Languages");
            string languagesSetting = string.Join(",", languages.Where(x => x.Selected).Select(x => StringEnum.GetStringValue(x.Language)).ToArray());
            n.SetAttributeValue("value", languagesSetting);
Pourriez-vous m'expliquer pourquoi ça ne passe pas par le setter de Document lorsqu'on modifie un de ses membres ?

Merci