forked from izrik/FbxSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObjectDstPropertyCollection.cs
152 lines (128 loc) · 3.65 KB
/
ObjectDstPropertyCollection.cs
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using System;
using System.Collections.Generic;
namespace FbxSharp
{
public class ObjectDstPropertyCollection : IList<FbxProperty>
{
// An ordered collection of Property objects
public ObjectDstPropertyCollection(FbxObject container)
{
_container = container;
}
public override string ToString()
{
return string.Format("[ObjectDstPropertyCollection: Count={0}]", Count);
}
public void AddRange(params FbxProperty[] items)
{
AddRange((IEnumerable<FbxProperty>)items);
}
public void AddRange(IEnumerable<FbxProperty> items)
{
foreach (FbxProperty item in items)
{
Add(item);
}
}
public void RemoveRange(params FbxProperty[] items)
{
RemoveRange((IEnumerable<FbxProperty>)items);
}
public void RemoveRange(IEnumerable<FbxProperty> items)
{
foreach (FbxProperty item in items)
{
Remove(item);
}
}
//ICollection<Property>
public virtual void Add(FbxProperty item)
{
if (!Contains(item))
{
_list.Add(item);
item.SrcObjects.Add(_container);
}
}
public virtual bool Contains(FbxProperty item)
{
return _list.Contains(item);
}
public virtual bool Remove(FbxProperty item)
{
if (Contains(item))
{
bool ret = _list.Remove(item);
item.SrcObjects.Remove(_container);
return ret;
}
return false;
}
public virtual void Clear()
{
FbxProperty[] array = new FbxProperty[Count];
CopyTo(array, 0);
foreach (FbxProperty item in array)
{
Remove(item);
}
_list.Clear();
}
public virtual void CopyTo(FbxProperty[] array, int arrayIndex)
{
_list.CopyTo(array, arrayIndex);
}
public virtual IEnumerator<FbxProperty> GetEnumerator()
{
return _list.GetEnumerator();
}
//IList<Property>
public virtual int IndexOf(FbxProperty item)
{
return _list.IndexOf(item);
}
public virtual void Insert(int index, FbxProperty item)
{
if (Contains(item))
{
if (IndexOf(item) < index)
{
index--;
}
Remove(item);
}
item.SrcObjects.Remove(_container);
_list.Insert(index, item);
item.SrcObjects.Add(_container);
}
public virtual void RemoveAt(int index)
{
Remove(this[index]);
}
//ICollection<Property>
public virtual int Count
{
get { return _list.Count; }
}
public virtual bool IsReadOnly
{
get { return (_list as ICollection<FbxProperty>).IsReadOnly; }
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
//IList<Property>
public virtual FbxProperty this [ int index ]
{
get { return _list[index]; }
set
{
RemoveAt(index);
Insert(index, value);
}
}
private FbxObject _container;
private List<FbxProperty> _list = new List<FbxProperty>();
}
}