~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.MacDev/MonoDevelop.MacDev.InterfaceBuilder/Collections.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
// 
3
 
// Collections.cs
4
 
//  
5
 
// Author:
6
 
//       Michael Hutchinson <mhutchinson@novell.com>
7
 
// 
8
 
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
9
 
// 
10
 
// Permission is hereby granted, free of charge, to any person obtaining a copy
11
 
// of this software and associated documentation files (the "Software"), to deal
12
 
// in the Software without restriction, including without limitation the rights
13
 
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
 
// copies of the Software, and to permit persons to whom the Software is
15
 
// furnished to do so, subject to the following conditions:
16
 
// 
17
 
// The above copyright notice and this permission notice shall be included in
18
 
// all copies or substantial portions of the Software.
19
 
// 
20
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
 
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
 
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
 
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
 
// THE SOFTWARE.
27
 
 
28
 
using System;
29
 
using System.Collections.Generic;
30
 
 
31
 
 
32
 
namespace MonoDevelop.MacDev.InterfaceBuilder
33
 
{
34
 
        
35
 
        public class NSArray : IBObject
36
 
        {
37
 
                List<object> values;
38
 
                
39
 
                public List<object> Values {
40
 
                        get {
41
 
                                if (values == null)
42
 
                                        values = new List<object> ();
43
 
                                return values;
44
 
                        }
45
 
                }
46
 
                
47
 
                protected override void OnPropertyDeserialized (string name, object value, IReferenceResolver resolver)
48
 
                {
49
 
                        if (name == null)
50
 
                                Values.Add (value);
51
 
                        else
52
 
                                base.OnPropertyDeserialized (name, value, resolver);
53
 
                }
54
 
        }
55
 
        
56
 
        public class NSMutableArray : NSArray
57
 
        {
58
 
        }
59
 
        
60
 
        public class NSMutableDictionaryDirect : NSMutableDictionary
61
 
        {
62
 
                protected override void OnPropertyDeserialized (string name, object value, IReferenceResolver resolver)
63
 
                {
64
 
                        Values[name] = value;
65
 
                }
66
 
        }
67
 
        
68
 
        public class NSMutableDictionary : IBObject
69
 
        {
70
 
                Unref<NSArray> sortedKeys, values;
71
 
                Dictionary<object, object> dict;
72
 
                List<object> nonCoderKeys;
73
 
                
74
 
                public Dictionary<object, object> Values {
75
 
                        get {
76
 
                                if (dict == null) {
77
 
                                        List<object> k = sortedKeys.Value.Values;
78
 
                                        List<object> v = values.Value.Values;
79
 
                                        dict = new Dictionary<object, object> (k.Count);
80
 
                                        for (int i = 0; i < k.Count; i++) {
81
 
                                                dict[k[i]] = v[i];
82
 
                                        }
83
 
                                }
84
 
                                return dict;
85
 
                        }
86
 
                }
87
 
                
88
 
                protected override void OnPropertyDeserialized (string name, object value, IReferenceResolver resolver)
89
 
                {
90
 
                        if (EncodedWithXMLCoder) {
91
 
                                if (name == "dict.sortedKeys") {
92
 
                                        sortedKeys = new Unref<NSArray> (value);
93
 
                                } else if (name == "dict.values") {
94
 
                                        values = new Unref<NSArray> (value);
95
 
                                } else {
96
 
                                        base.OnPropertyDeserialized (name, value, resolver);
97
 
                                }
98
 
                        } else {
99
 
                                if (nonCoderKeys == null) {
100
 
                                        nonCoderKeys = new List<object> ();
101
 
                                        dict = new Dictionary<object, object> ();
102
 
                                }
103
 
                                if (name.StartsWith ("NS.key.")) {
104
 
                                        int idx = Int32.Parse (name.Substring ("NS.key.".Length));
105
 
                                        while (nonCoderKeys.Count <= idx)
106
 
                                                nonCoderKeys.Add (null);
107
 
                                        nonCoderKeys[idx] = value;
108
 
                                } else if (name.StartsWith ("NS.object.")) {
109
 
                                        int idx = Int32.Parse (name.Substring ("NS.object.".Length));
110
 
                                        dict[nonCoderKeys[idx]] = value;
111
 
                                } else {
112
 
                                        base.OnPropertyDeserialized (name, value, resolver);
113
 
                                }
114
 
                        }
115
 
                }
116
 
        }
117
 
        
118
 
        public class IBMutableOrderedSet : IBObject
119
 
        {
120
 
                List<object> orderedObjects;
121
 
                
122
 
                public List<object> OrderedObjects {
123
 
                        get {
124
 
                                if (orderedObjects == null)
125
 
                                        orderedObjects = new List<object> ();
126
 
                                return orderedObjects;
127
 
                        }
128
 
                }
129
 
                
130
 
                protected override void OnPropertyDeserialized (string name, object value, IReferenceResolver resolver)
131
 
                {
132
 
                        if (name == "orderedObjects" && value is NSArray)
133
 
                                orderedObjects = ((NSArray)value).Values;
134
 
                        else
135
 
                                base.OnPropertyDeserialized (name, value, resolver);
136
 
                }
137
 
        }
138
 
}
 
 
b'\\ No newline at end of file'