Annotation of /branches/taiga-0.1/ModularRex/RexParts/RexObjectPropertiesManager.cs
Parent Directory
|
Revision Log
Revision 341 -
(view)
(download)
Original Path: branches/os-0.6.9-post-fixes/ModularRex/RexParts/RexObjectPropertiesManager.cs
| 1 : | tuco | 57 | using System; |
| 2 : | using System.Collections; | ||
| 3 : | using System.Collections.Generic; | ||
| 4 : | using System.Reflection; | ||
| 5 : | using log4net; | ||
| 6 : | using ModularRex.RexFramework; | ||
| 7 : | using OpenMetaverse; | ||
| 8 : | |||
| 9 : | namespace ModularRex.RexParts | ||
| 10 : | { | ||
| 11 : | public class RexObjectPropertiesManager : IEnumerable<RexObjectProperties> | ||
| 12 : | { | ||
| 13 : | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
| 14 : | |||
| 15 : | private Dictionary<UUID,RexObjectProperties> m_objs = new Dictionary<UUID, RexObjectProperties>(); | ||
| 16 : | |||
| 17 : | public void Add(UUID id,RexObjectProperties rexobj) | ||
| 18 : | { | ||
| 19 : | lock (m_objs) | ||
| 20 : | { | ||
| 21 : | try | ||
| 22 : | { | ||
| 23 : | m_objs.Add(id, rexobj); | ||
| 24 : | } | ||
| 25 : | catch (Exception e) | ||
| 26 : | { | ||
| 27 : | m_log.ErrorFormat("Add RexObjectProperties failed: {0}", e.Message); | ||
| 28 : | } | ||
| 29 : | } | ||
| 30 : | } | ||
| 31 : | |||
| 32 : | |||
| 33 : | public void InsertOrReplace(RexObjectProperties rexobj) | ||
| 34 : | { | ||
| 35 : | lock (m_objs) | ||
| 36 : | { | ||
| 37 : | try | ||
| 38 : | { | ||
| 39 : | m_objs[rexobj.ParentObjectID] = rexobj; | ||
| 40 : | } | ||
| 41 : | catch (Exception e) | ||
| 42 : | { | ||
| 43 : | m_log.ErrorFormat("Insert or Replace RexObjectProperties failed: {0}", e.Message); | ||
| 44 : | } | ||
| 45 : | } | ||
| 46 : | } | ||
| 47 : | |||
| 48 : | public void Clear() | ||
| 49 : | { | ||
| 50 : | lock (m_objs) | ||
| 51 : | { | ||
| 52 : | m_objs.Clear(); | ||
| 53 : | } | ||
| 54 : | } | ||
| 55 : | |||
| 56 : | public int Count | ||
| 57 : | { | ||
| 58 : | get | ||
| 59 : | { | ||
| 60 : | lock (m_objs) | ||
| 61 : | { | ||
| 62 : | return m_objs.Count; | ||
| 63 : | } | ||
| 64 : | } | ||
| 65 : | } | ||
| 66 : | |||
| 67 : | public bool ContainsKey(UUID id) | ||
| 68 : | { | ||
| 69 : | lock (m_objs) | ||
| 70 : | { | ||
| 71 : | try | ||
| 72 : | { | ||
| 73 : | return m_objs.ContainsKey(id); | ||
| 74 : | } | ||
| 75 : | catch | ||
| 76 : | { | ||
| 77 : | return false; | ||
| 78 : | } | ||
| 79 : | } | ||
| 80 : | } | ||
| 81 : | |||
| 82 : | public bool Remove(UUID id) | ||
| 83 : | { | ||
| 84 : | lock (m_objs) | ||
| 85 : | { | ||
| 86 : | try | ||
| 87 : | { | ||
| 88 : | return m_objs.Remove(id); | ||
| 89 : | } | ||
| 90 : | catch (Exception e) | ||
| 91 : | { | ||
| 92 : | m_log.ErrorFormat("Remove RexObjectProperties failed for {0}", id, e); | ||
| 93 : | return false; | ||
| 94 : | } | ||
| 95 : | } | ||
| 96 : | } | ||
| 97 : | |||
| 98 : | public List<RexObjectProperties> GetAllRexObjectProperties() | ||
| 99 : | { | ||
| 100 : | lock (m_objs) | ||
| 101 : | { | ||
| 102 : | return new List<RexObjectProperties>(m_objs.Values); | ||
| 103 : | } | ||
| 104 : | } | ||
| 105 : | |||
| 106 : | public RexObjectProperties this[UUID id] | ||
| 107 : | { | ||
| 108 : | get | ||
| 109 : | { | ||
| 110 : | lock (m_objs) | ||
| 111 : | { | ||
| 112 : | try | ||
| 113 : | { | ||
| 114 : | return m_objs[id]; | ||
| 115 : | } | ||
| 116 : | catch | ||
| 117 : | { | ||
| 118 : | return null; | ||
| 119 : | } | ||
| 120 : | } | ||
| 121 : | } | ||
| 122 : | set | ||
| 123 : | { | ||
| 124 : | InsertOrReplace(value); | ||
| 125 : | } | ||
| 126 : | } | ||
| 127 : | |||
| 128 : | public bool TryGetValue(UUID key, out RexObjectProperties obj) | ||
| 129 : | { | ||
| 130 : | lock (m_objs) | ||
| 131 : | { | ||
| 132 : | return m_objs.TryGetValue(key, out obj); | ||
| 133 : | } | ||
| 134 : | } | ||
| 135 : | |||
| 136 : | public IEnumerator<RexObjectProperties> GetEnumerator() | ||
| 137 : | { | ||
| 138 : | return GetAllRexObjectProperties().GetEnumerator(); | ||
| 139 : | } | ||
| 140 : | |||
| 141 : | IEnumerator IEnumerable.GetEnumerator() | ||
| 142 : | { | ||
| 143 : | return GetEnumerator(); | ||
| 144 : | } | ||
| 145 : | } | ||
| 146 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

