少年修仙传客户端基础资源
leonard Wu
2018-08-02 cc7db021dd09248131ad546f5bc5806cdb2eb418
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
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
 
namespace UnityEditor.XCodeEditor
{
    public class PBXSortedDictionary : SortedDictionary<string, object>
    {
        
        public void Append( PBXDictionary dictionary )
        {
            foreach( var item in dictionary) {
                this.Add( item.Key, item.Value );
            }
        }
        
        public void Append<T>( PBXDictionary<T> dictionary ) where T : PBXObject
        {
            foreach( var item in dictionary) {
                this.Add( item.Key, item.Value );
            }
        }
    }
    
    public class PBXSortedDictionary<T> : SortedDictionary<string, T> where T : PBXObject
    {
        public PBXSortedDictionary()
        {
            
        }
        
        public PBXSortedDictionary( PBXDictionary genericDictionary )
        {
            foreach( KeyValuePair<string, object> currentItem in genericDictionary ) {
                if( ((string)((PBXDictionary)currentItem.Value)[ "isa" ]).CompareTo( typeof(T).Name ) == 0 ) {
                    T instance = (T)System.Activator.CreateInstance( typeof(T), currentItem.Key, (PBXDictionary)currentItem.Value );
                    this.Add( currentItem.Key, instance );
                }
            }    
        }
        
        public void Add( T newObject )
        {
            this.Add( newObject.guid, newObject );
        }
        
        public void Append( PBXDictionary<T> dictionary )
        {
            foreach( KeyValuePair<string, T> item in dictionary) {
                this.Add( item.Key, (T)item.Value );
            }
        }
        
    }
}