Formatting cleanup. Ignore some generated files.

0.6.6-post-fixes
Jeff Ames 2009-06-09 18:07:35 +00:00
parent 135ff63c3d
commit a7fcacf8f3
11 changed files with 264 additions and 263 deletions

View File

@ -81,7 +81,7 @@ namespace OpenSim.Framework
/// 30 minutes.
/// </para>
/// </remarks>
public static readonly TimeSpan DefaultExpirationTime = TimeSpan.FromMinutes( 30.0 );
public static readonly TimeSpan DefaultExpirationTime = TimeSpan.FromMinutes(30.0);
/// <summary>
/// Minimal allowed expiration time.
@ -91,7 +91,7 @@ namespace OpenSim.Framework
/// 5 minutes.
/// </para>
/// </remarks>
public static readonly TimeSpan MinExpirationTime = TimeSpan.FromSeconds( 10.0 );
public static readonly TimeSpan MinExpirationTime = TimeSpan.FromSeconds(10.0);
/// <summary>
/// Comparer used to compare element keys.
@ -171,7 +171,7 @@ namespace OpenSim.Framework
/// Initializes a new instance of the <see cref="CnmMemoryCache{TKey,TValue}"/> class.
/// </summary>
public CnmMemoryCache()
: this( DefaultMaxSize )
: this(DefaultMaxSize)
{
}
@ -181,8 +181,8 @@ namespace OpenSim.Framework
/// <param name="maximalSize">
/// Maximal cache size.
/// </param>
public CnmMemoryCache( long maximalSize )
: this( maximalSize, DefaultMaxCount )
public CnmMemoryCache(long maximalSize)
: this(maximalSize, DefaultMaxCount)
{
}
@ -195,8 +195,8 @@ namespace OpenSim.Framework
/// <param name="maximalCount">
/// Maximal element count.
/// </param>
public CnmMemoryCache( long maximalSize, int maximalCount )
: this( maximalSize, maximalCount, DefaultExpirationTime )
public CnmMemoryCache(long maximalSize, int maximalCount)
: this(maximalSize, maximalCount, DefaultExpirationTime)
{
}
@ -212,8 +212,8 @@ namespace OpenSim.Framework
/// <param name="expirationTime">
/// Elements expiration time.
/// </param>
public CnmMemoryCache( long maximalSize, int maximalCount, TimeSpan expirationTime )
: this( maximalSize, maximalCount, expirationTime, EqualityComparer<TKey>.Default )
public CnmMemoryCache(long maximalSize, int maximalCount, TimeSpan expirationTime)
: this(maximalSize, maximalCount, expirationTime, EqualityComparer<TKey>.Default)
{
}
@ -235,21 +235,21 @@ namespace OpenSim.Framework
/// <exception cref="ArgumentNullException">
/// <see cref="comparer"/>is <see langword="null"/> reference.
/// </exception>
public CnmMemoryCache( long maximalSize,
public CnmMemoryCache(long maximalSize,
int maximalCount,
TimeSpan expirationTime,
IEqualityComparer<TKey> comparer )
IEqualityComparer<TKey> comparer)
{
if( comparer == null )
throw new ArgumentNullException( "comparer" );
if (comparer == null)
throw new ArgumentNullException("comparer");
if( expirationTime < MinExpirationTime )
if (expirationTime < MinExpirationTime)
expirationTime = MinExpirationTime;
if( maximalCount < 8 )
if (maximalCount < 8)
maximalCount = 8;
if( maximalSize < 8 )
if (maximalSize < 8)
maximalSize = 8;
if( maximalCount > maximalSize )
if (maximalCount > maximalSize)
maximalCount = (int) maximalSize;
Comparer = comparer;
@ -275,14 +275,14 @@ namespace OpenSim.Framework
/// <param name="size">
/// The element's size.
/// </param>
protected virtual void AddToNewGeneration( int bucketIndex, TKey key, TValue value, long size )
protected virtual void AddToNewGeneration(int bucketIndex, TKey key, TValue value, long size)
{
// Add to newest generation
if( !m_newGeneration.Set( bucketIndex, key, value, size ) )
if (!m_newGeneration.Set(bucketIndex, key, value, size))
{
// Failed to add new generation
RecycleGenerations();
m_newGeneration.Set( bucketIndex, key, value, size );
m_newGeneration.Set(bucketIndex, key, value, size);
}
m_version++;
@ -314,9 +314,9 @@ namespace OpenSim.Framework
/// For example: key's hash is 72, bucket count is 5, element's bucket index is 72 % 5 = 2.
/// </para>
/// </remarks>
protected virtual int GetBucketIndex( TKey key )
protected virtual int GetBucketIndex(TKey key)
{
return (Comparer.GetHashCode( key ) & 0x7FFFFFFF) % m_generationBucketCount;
return (Comparer.GetHashCode(key) & 0x7FFFFFFF) % m_generationBucketCount;
}
/// <summary>
@ -325,7 +325,7 @@ namespace OpenSim.Framework
/// <param name="generation">
/// The generation that is purged.
/// </param>
protected virtual void PurgeGeneration( IGeneration generation )
protected virtual void PurgeGeneration(IGeneration generation)
{
generation.Clear();
m_version++;
@ -339,7 +339,7 @@ namespace OpenSim.Framework
// Do this only one in every m_operationsBetweenTimeChecks
// Fetching time is using several millisecons - it is better not to do all time.
m_operationsBetweenTimeChecks--;
if( m_operationsBetweenTimeChecks <= 0 )
if (m_operationsBetweenTimeChecks <= 0)
PurgeExpired();
}
@ -355,10 +355,10 @@ namespace OpenSim.Framework
m_generationElementCount = MaxCount / 2;
// Buckets need to be prime number to get better spread of hash values
m_generationBucketCount = PrimeNumberHelper.GetPrime( m_generationElementCount );
m_generationBucketCount = PrimeNumberHelper.GetPrime(m_generationElementCount);
m_newGeneration = new HashGeneration( this );
m_oldGeneration = new HashGeneration( this );
m_newGeneration = new HashGeneration(this);
m_oldGeneration = new HashGeneration(this);
m_oldGeneration.MakeOld();
}
@ -399,7 +399,7 @@ namespace OpenSim.Framework
/// <param name="cache">
/// The cache.
/// </param>
public Enumerator( CnmMemoryCache<TKey, TValue> cache )
public Enumerator(CnmMemoryCache<TKey, TValue> cache)
{
m_generationEnumerators[ 0 ] = cache.m_newGeneration.GetEnumerator();
m_generationEnumerators[ 1 ] = cache.m_oldGeneration.GetEnumerator();
@ -420,7 +420,7 @@ namespace OpenSim.Framework
{
get
{
if( m_currentEnumerator == -1 || m_currentEnumerator >= m_generationEnumerators.Length )
if (m_currentEnumerator == -1 || m_currentEnumerator >= m_generationEnumerators.Length)
throw new InvalidOperationException();
return m_generationEnumerators[ m_currentEnumerator ].Current;
@ -461,12 +461,12 @@ namespace OpenSim.Framework
/// <filterpriority>2</filterpriority>
public bool MoveNext()
{
if( m_currentEnumerator == -1 )
if (m_currentEnumerator == -1)
m_currentEnumerator = 0;
while( m_currentEnumerator < m_generationEnumerators.Length )
while (m_currentEnumerator < m_generationEnumerators.Length)
{
if( m_generationEnumerators[ m_currentEnumerator ].MoveNext() )
if (m_generationEnumerators[ m_currentEnumerator ].MoveNext())
return true;
m_currentEnumerator++;
@ -484,7 +484,7 @@ namespace OpenSim.Framework
/// <filterpriority>2</filterpriority>
public void Reset()
{
foreach( IEnumerator<KeyValuePair<TKey, TValue>> enumerator in m_generationEnumerators )
foreach (IEnumerator<KeyValuePair<TKey, TValue>> enumerator in m_generationEnumerators)
{
enumerator.Reset();
}
@ -582,7 +582,7 @@ namespace OpenSim.Framework
/// <param name="cache">
/// The cache.
/// </param>
public HashGeneration( CnmMemoryCache<TKey, TValue> cache )
public HashGeneration(CnmMemoryCache<TKey, TValue> cache)
{
m_cache = cache;
m_elements = new Element[m_cache.m_generationElementCount];
@ -608,16 +608,16 @@ namespace OpenSim.Framework
/// <returns>
/// Element's index, if found from the generation; -1 otherwise (if element is not found the generation).
/// </returns>
private int FindElementIndex( int bucketIndex, TKey key, bool moveToFront, out int previousIndex )
private int FindElementIndex(int bucketIndex, TKey key, bool moveToFront, out int previousIndex)
{
previousIndex = -1;
int elementIndex = m_buckets[ bucketIndex ];
while( elementIndex >= 0 )
while (elementIndex >= 0)
{
if( m_cache.Comparer.Equals( key, m_elements[ elementIndex ].Key ) )
if (m_cache.Comparer.Equals(key, m_elements[ elementIndex ].Key))
{
// Found match
if( moveToFront && previousIndex >= 0 )
if (moveToFront && previousIndex >= 0)
{
// Move entry to front
m_elements[ previousIndex ].Next = m_elements[ elementIndex ].Next;
@ -648,9 +648,9 @@ namespace OpenSim.Framework
/// <param name="previousIndex">
/// The element's previous index.
/// </param>
private void RemoveElement( int bucketIndex, int entryIndex, int previousIndex )
private void RemoveElement(int bucketIndex, int entryIndex, int previousIndex)
{
if( previousIndex >= 0 )
if (previousIndex >= 0)
m_elements[ previousIndex ].Next = m_elements[ entryIndex ].Next;
else
m_buckets[ bucketIndex ] = m_elements[ entryIndex ].Next;
@ -755,7 +755,7 @@ namespace OpenSim.Framework
/// <param name="generation">
/// The generation.
/// </param>
public Enumerator( HashGeneration generation )
public Enumerator(HashGeneration generation)
{
m_generation = generation;
m_version = m_generation.m_cache.m_version;
@ -776,7 +776,7 @@ namespace OpenSim.Framework
{
get
{
if( m_currentIndex == 0 || m_currentIndex >= m_generation.Count )
if (m_currentIndex == 0 || m_currentIndex >= m_generation.Count)
throw new InvalidOperationException();
return m_current;
@ -816,19 +816,19 @@ namespace OpenSim.Framework
/// </exception>
public bool MoveNext()
{
if( m_version != m_generation.m_cache.m_version )
if (m_version != m_generation.m_cache.m_version)
throw new InvalidOperationException();
while( m_currentIndex < m_generation.Count )
while (m_currentIndex < m_generation.Count)
{
if( m_generation.m_elements[ m_currentIndex ].IsFree )
if (m_generation.m_elements[ m_currentIndex ].IsFree)
{
m_currentIndex++;
continue;
}
m_current = new KeyValuePair<TKey, TValue>( m_generation.m_elements[ m_currentIndex ].Key,
m_generation.m_elements[ m_currentIndex ].Value );
m_current = new KeyValuePair<TKey, TValue>(m_generation.m_elements[ m_currentIndex ].Key,
m_generation.m_elements[ m_currentIndex ].Value);
m_currentIndex++;
return true;
}
@ -846,7 +846,7 @@ namespace OpenSim.Framework
/// <filterpriority>2</filterpriority>
public void Reset()
{
if( m_version != m_generation.m_cache.m_version )
if (m_version != m_generation.m_cache.m_version)
throw new InvalidOperationException();
m_currentIndex = 0;
@ -907,12 +907,12 @@ namespace OpenSim.Framework
/// <seealso cref="IGeneration.MakeOld"/>
public void Clear()
{
for( int i = m_buckets.Length - 1 ; i >= 0 ; i-- )
for (int i = m_buckets.Length - 1 ; i >= 0 ; i--)
{
m_buckets[ i ] = -1;
}
Array.Clear( m_elements, 0, m_elements.Length );
Array.Clear(m_elements, 0, m_elements.Length);
Size = 0;
m_firstFreeElement = -1;
m_freeCount = 0;
@ -934,10 +934,10 @@ namespace OpenSim.Framework
/// <see langword="true"/>if the <see cref="IGeneration"/> contains an element with the <see cref="key"/>;
/// otherwise <see langword="false"/>.
/// </returns>
public bool Contains( int bucketIndex, TKey key )
public bool Contains(int bucketIndex, TKey key)
{
int previousIndex;
if( FindElementIndex( bucketIndex, key, true, out previousIndex ) == -1 )
if (FindElementIndex(bucketIndex, key, true, out previousIndex) == -1)
return false;
AccessedSinceLastTimeCheck = true;
@ -953,7 +953,7 @@ namespace OpenSim.Framework
/// <filterpriority>1</filterpriority>
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
return new Enumerator( this );
return new Enumerator(this);
}
/// <summary>
@ -980,13 +980,13 @@ namespace OpenSim.Framework
/// <returns>
/// <see langword="true"/>, if remove was successful; otherwise <see langword="false"/>.
/// </returns>
public bool Remove( int bucketIndex, TKey key )
public bool Remove(int bucketIndex, TKey key)
{
int previousIndex;
int entryIndex = FindElementIndex( bucketIndex, key, false, out previousIndex );
if( entryIndex != -1 )
int entryIndex = FindElementIndex(bucketIndex, key, false, out previousIndex);
if (entryIndex != -1)
{
RemoveElement( bucketIndex, entryIndex, previousIndex );
RemoveElement(bucketIndex, entryIndex, previousIndex);
AccessedSinceLastTimeCheck = true;
return true;
}
@ -1020,18 +1020,18 @@ namespace OpenSim.Framework
/// size must fit generation's limits, before element is added to generation.
/// </para>
/// </remarks>
public bool Set( int bucketIndex, TKey key, TValue value, long size )
public bool Set(int bucketIndex, TKey key, TValue value, long size)
{
Debug.Assert( m_newGeneration, "It is possible to insert new elements only to newest generation." );
Debug.Assert( size > 0, "New element size should be more than 0." );
Debug.Assert(m_newGeneration, "It is possible to insert new elements only to newest generation.");
Debug.Assert(size > 0, "New element size should be more than 0.");
int previousIndex;
int elementIndex = FindElementIndex( bucketIndex, key, true, out previousIndex );
if( elementIndex == -1 )
int elementIndex = FindElementIndex(bucketIndex, key, true, out previousIndex);
if (elementIndex == -1)
{
// New key
if( Size + size > m_cache.m_generationMaxSize ||
(m_nextUnusedElement == m_cache.m_generationElementCount && m_freeCount == 0) )
if (Size + size > m_cache.m_generationMaxSize ||
(m_nextUnusedElement == m_cache.m_generationElementCount && m_freeCount == 0))
{
// Generation is full
return false;
@ -1041,7 +1041,7 @@ namespace OpenSim.Framework
Size += size;
// Get first free entry and update free entry list
if( m_firstFreeElement != -1 )
if (m_firstFreeElement != -1)
{
// There was entry that was removed
elementIndex = m_firstFreeElement;
@ -1055,7 +1055,7 @@ namespace OpenSim.Framework
m_nextUnusedElement++;
}
Debug.Assert( m_elements[ elementIndex ].IsFree, "Allocated element is not free." );
Debug.Assert(m_elements[ elementIndex ].IsFree, "Allocated element is not free.");
// Move new entry to front
m_elements[ elementIndex ].Next = m_buckets[ bucketIndex ];
@ -1067,12 +1067,12 @@ namespace OpenSim.Framework
else
{
// Existing key
if( Size - m_elements[ elementIndex ].Size + size > m_cache.m_generationMaxSize )
if (Size - m_elements[ elementIndex ].Size + size > m_cache.m_generationMaxSize)
{
// Generation is full
// Remove existing element, because generation is going to be recycled to
// old generation and element is stored to new generation
RemoveElement( bucketIndex, elementIndex, previousIndex );
RemoveElement(bucketIndex, elementIndex, previousIndex);
return false;
}
@ -1113,12 +1113,12 @@ namespace OpenSim.Framework
/// are set to default value (default(TValue) and 0).
/// </para>
/// </remarks>
public bool TryGetValue( int bucketIndex, TKey key, out TValue value, out long size )
public bool TryGetValue(int bucketIndex, TKey key, out TValue value, out long size)
{
// Find entry index,
int previousIndex;
int elementIndex = FindElementIndex( bucketIndex, key, m_newGeneration, out previousIndex );
if( elementIndex == -1 )
int elementIndex = FindElementIndex(bucketIndex, key, m_newGeneration, out previousIndex);
if (elementIndex == -1)
{
value = default(TValue);
size = 0;
@ -1128,10 +1128,10 @@ namespace OpenSim.Framework
value = m_elements[ elementIndex ].Value;
size = m_elements[ elementIndex ].Size;
if( !m_newGeneration )
if (!m_newGeneration)
{
// Old generation - remove element, because it is moved to new generation
RemoveElement( bucketIndex, elementIndex, previousIndex );
RemoveElement(bucketIndex, elementIndex, previousIndex);
}
AccessedSinceLastTimeCheck = true;
@ -1214,7 +1214,7 @@ namespace OpenSim.Framework
/// <see langword="true"/>if the <see cref="IGeneration"/> contains an element with the <see cref="key"/>;
/// otherwise <see langword="false"/>.
/// </returns>
bool Contains( int bucketIndex, TKey key );
bool Contains(int bucketIndex, TKey key);
/// <summary>
/// Make from generation old generation.
@ -1237,7 +1237,7 @@ namespace OpenSim.Framework
/// <returns>
/// <see langword="true"/>, if remove was successful; otherwise <see langword="false"/>.
/// </returns>
bool Remove( int bucketIndex, TKey key );
bool Remove(int bucketIndex, TKey key);
/// <summary>
/// Set or add element to generation.
@ -1265,7 +1265,7 @@ namespace OpenSim.Framework
/// size must fit generation's limits, before element is added to generation.
/// </para>
/// </remarks>
bool Set( int bucketIndex, TKey key, TValue value, long size );
bool Set(int bucketIndex, TKey key, TValue value, long size);
/// <summary>
/// Try to get element associated with key.
@ -1291,7 +1291,7 @@ namespace OpenSim.Framework
/// are set to default value (default(TValue) and 0).
/// </para>
/// </remarks>
bool TryGetValue( int bucketIndex, TKey key, out TValue value, out long size );
bool TryGetValue(int bucketIndex, TKey key, out TValue value, out long size);
}
#endregion
@ -1357,10 +1357,10 @@ namespace OpenSim.Framework
set
{
if( value < MinExpirationTime )
if (value < MinExpirationTime)
value = MinExpirationTime;
if( m_expirationTime == value )
if (m_expirationTime == value)
return;
m_newGeneration.ExpirationTime = (m_newGeneration.ExpirationTime - m_expirationTime) + value;
@ -1478,9 +1478,9 @@ namespace OpenSim.Framework
set
{
if( value < 8 )
if (value < 8)
value = 8;
if( m_maxCount == value )
if (m_maxCount == value)
return;
m_maxCount = value;
@ -1535,9 +1535,9 @@ namespace OpenSim.Framework
set
{
if( value < 8 )
if (value < 8)
value = 8;
if( m_maxSize == value )
if (m_maxSize == value)
return;
m_maxSize = value;
@ -1618,7 +1618,7 @@ namespace OpenSim.Framework
/// <filterpriority>1</filterpriority>
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
return new Enumerator( this );
return new Enumerator(this);
}
/// <summary>
@ -1644,28 +1644,28 @@ namespace OpenSim.Framework
{
m_operationsBetweenTimeChecks = DefaultOperationsBetweenTimeChecks;
if( !IsTimeLimited )
if (!IsTimeLimited)
return;
DateTime now = DateTime.Now;
if( m_newGeneration.AccessedSinceLastTimeCheck )
if (m_newGeneration.AccessedSinceLastTimeCheck)
{
// New generation has been accessed since last check
// Update it's expiration time.
m_newGeneration.ExpirationTime = now + ExpirationTime;
m_newGeneration.AccessedSinceLastTimeCheck = false;
}
else if( m_newGeneration.ExpirationTime < now )
else if (m_newGeneration.ExpirationTime < now)
{
// New generation has been expired.
// --> also old generation must be expired.
PurgeGeneration( m_newGeneration );
PurgeGeneration( m_oldGeneration );
PurgeGeneration(m_newGeneration);
PurgeGeneration(m_oldGeneration);
return;
}
if( m_oldGeneration.ExpirationTime < now )
PurgeGeneration( m_oldGeneration );
if (m_oldGeneration.ExpirationTime < now)
PurgeGeneration(m_oldGeneration);
}
/// <summary>
@ -1682,15 +1682,15 @@ namespace OpenSim.Framework
/// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
/// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
/// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
public void Remove( TKey key )
public void Remove(TKey key)
{
if( key == null )
throw new ArgumentNullException( "key" );
if (key == null)
throw new ArgumentNullException("key");
int bucketIndex = GetBucketIndex( key );
if( !m_newGeneration.Remove( bucketIndex, key ) )
int bucketIndex = GetBucketIndex(key);
if (!m_newGeneration.Remove(bucketIndex, key))
{
if( !m_oldGeneration.Remove( bucketIndex, key ) )
if (!m_oldGeneration.Remove(bucketIndex, key))
{
CheckExpired();
return;
@ -1715,19 +1715,19 @@ namespace OpenSim.Framework
/// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
/// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
/// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
public void RemoveRange( IEnumerable<TKey> keys )
public void RemoveRange(IEnumerable<TKey> keys)
{
if( keys == null )
throw new ArgumentNullException( "keys" );
if (keys == null)
throw new ArgumentNullException("keys");
foreach( TKey key in keys )
foreach (TKey key in keys)
{
if( key == null )
if (key == null)
continue;
int bucketIndex = GetBucketIndex( key );
if( !m_newGeneration.Remove( bucketIndex, key ) )
m_oldGeneration.Remove( bucketIndex, key );
int bucketIndex = GetBucketIndex(key);
if (!m_newGeneration.Remove(bucketIndex, key))
m_oldGeneration.Remove(bucketIndex, key);
}
CheckExpired();
@ -1779,27 +1779,27 @@ namespace OpenSim.Framework
/// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
/// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
/// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
public bool Set( TKey key, TValue value, long size )
public bool Set(TKey key, TValue value, long size)
{
if( key == null )
throw new ArgumentNullException( "key" );
if (key == null)
throw new ArgumentNullException("key");
if( size < 0 )
throw new ArgumentOutOfRangeException( "size", size, "Value's size can't be less than 0." );
if (size < 0)
throw new ArgumentOutOfRangeException("size", size, "Value's size can't be less than 0.");
if( size > MaxElementSize )
if (size > MaxElementSize)
{
// Entry size is too big to fit cache - ignore it
Remove( key );
Remove(key);
return false;
}
if( size == 0 )
if (size == 0)
size = 1;
int bucketIndex = GetBucketIndex( key );
m_oldGeneration.Remove( bucketIndex, key );
AddToNewGeneration( bucketIndex, key, value, size );
int bucketIndex = GetBucketIndex(key);
m_oldGeneration.Remove(bucketIndex, key);
AddToNewGeneration(bucketIndex, key, value, size);
CheckExpired();
return true;
@ -1828,23 +1828,23 @@ namespace OpenSim.Framework
/// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/>
/// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
/// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
public bool TryGetValue( TKey key, out TValue value )
public bool TryGetValue(TKey key, out TValue value)
{
if( key == null )
throw new ArgumentNullException( "key" );
if (key == null)
throw new ArgumentNullException("key");
int bucketIndex = GetBucketIndex( key );
int bucketIndex = GetBucketIndex(key);
long size;
if( m_newGeneration.TryGetValue( bucketIndex, key, out value, out size ) )
if (m_newGeneration.TryGetValue(bucketIndex, key, out value, out size))
{
CheckExpired();
return true;
}
if( m_oldGeneration.TryGetValue( bucketIndex, key, out value, out size ) )
if (m_oldGeneration.TryGetValue(bucketIndex, key, out value, out size))
{
// Move element to new generation
AddToNewGeneration( bucketIndex, key, value, size );
AddToNewGeneration(bucketIndex, key, value, size);
CheckExpired();
return true;
}

View File

@ -24,6 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
@ -65,7 +66,7 @@ namespace OpenSim.Framework
/// <param name="cache">
/// The cache.
/// </param>
private CnmSynchronizedCache( ICnmCache<TKey, TValue> cache )
private CnmSynchronizedCache(ICnmCache<TKey, TValue> cache)
{
m_cache = cache;
m_syncRoot = m_cache.SyncRoot;
@ -83,11 +84,11 @@ namespace OpenSim.Framework
/// <exception cref="ArgumentNullException">
/// <paramref name="cache"/>is null.
/// </exception>
public static ICnmCache<TKey, TValue> Synchronized( ICnmCache<TKey, TValue> cache )
public static ICnmCache<TKey, TValue> Synchronized(ICnmCache<TKey, TValue> cache)
{
if( cache == null )
throw new ArgumentNullException( "cache" );
return cache.IsSynchronized ? cache : new CnmSynchronizedCache<TKey, TValue>( cache );
if (cache == null)
throw new ArgumentNullException("cache");
return cache.IsSynchronized ? cache : new CnmSynchronizedCache<TKey, TValue>(cache);
}
#region Nested type: SynchronizedEnumerator
@ -116,11 +117,11 @@ namespace OpenSim.Framework
/// <param name="syncRoot">
/// The sync root.
/// </param>
public SynchronizedEnumerator( IEnumerator<KeyValuePair<TKey, TValue>> enumerator, object syncRoot )
public SynchronizedEnumerator(IEnumerator<KeyValuePair<TKey, TValue>> enumerator, object syncRoot)
{
m_syncRoot = syncRoot;
m_enumerator = enumerator;
Monitor.Enter( m_syncRoot );
Monitor.Enter(m_syncRoot);
}
/// <summary>
@ -166,14 +167,14 @@ namespace OpenSim.Framework
/// </summary>
public void Dispose()
{
if( m_syncRoot != null )
if (m_syncRoot != null)
{
Monitor.Exit( m_syncRoot );
Monitor.Exit(m_syncRoot);
m_syncRoot = null;
}
m_enumerator.Dispose();
GC.SuppressFinalize( this );
GC.SuppressFinalize(this);
}
/// <summary>
@ -225,7 +226,7 @@ namespace OpenSim.Framework
{
get
{
lock( m_syncRoot )
lock (m_syncRoot)
{
return m_cache.Count;
}
@ -271,7 +272,7 @@ namespace OpenSim.Framework
{
get
{
lock( m_syncRoot )
lock (m_syncRoot)
{
return m_cache.ExpirationTime;
}
@ -279,7 +280,7 @@ namespace OpenSim.Framework
set
{
lock( m_syncRoot )
lock (m_syncRoot)
{
m_cache.ExpirationTime = value;
}
@ -307,7 +308,7 @@ namespace OpenSim.Framework
{
get
{
lock( m_syncRoot )
lock (m_syncRoot)
{
return m_cache.IsCountLimited;
}
@ -336,7 +337,7 @@ namespace OpenSim.Framework
{
get
{
lock( m_syncRoot )
lock (m_syncRoot)
{
return m_cache.IsSizeLimited;
}
@ -385,7 +386,7 @@ namespace OpenSim.Framework
{
get
{
lock( m_syncRoot )
lock (m_syncRoot)
{
return m_cache.IsTimeLimited;
}
@ -409,7 +410,7 @@ namespace OpenSim.Framework
{
get
{
lock( m_syncRoot )
lock (m_syncRoot)
{
return m_cache.MaxCount;
}
@ -417,7 +418,7 @@ namespace OpenSim.Framework
set
{
lock( m_syncRoot )
lock (m_syncRoot)
{
m_cache.MaxCount = value;
}
@ -444,7 +445,7 @@ namespace OpenSim.Framework
{
get
{
lock( m_syncRoot )
lock (m_syncRoot)
{
return m_cache.MaxElementSize;
}
@ -474,7 +475,7 @@ namespace OpenSim.Framework
{
get
{
lock( m_syncRoot )
lock (m_syncRoot)
{
return m_cache.MaxSize;
}
@ -482,7 +483,7 @@ namespace OpenSim.Framework
set
{
lock( m_syncRoot )
lock (m_syncRoot)
{
m_cache.MaxSize = value;
}
@ -516,7 +517,7 @@ namespace OpenSim.Framework
{
get
{
lock( m_syncRoot )
lock (m_syncRoot)
{
return m_cache.Size;
}
@ -553,7 +554,7 @@ namespace OpenSim.Framework
/// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
public void Clear()
{
lock( m_syncRoot )
lock (m_syncRoot)
{
m_cache.Clear();
}
@ -568,9 +569,9 @@ namespace OpenSim.Framework
/// <filterpriority>1</filterpriority>
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
lock( m_syncRoot )
lock (m_syncRoot)
{
return new SynchronizedEnumerator( m_cache.GetEnumerator(), m_syncRoot );
return new SynchronizedEnumerator(m_cache.GetEnumerator(), m_syncRoot);
}
}
@ -595,7 +596,7 @@ namespace OpenSim.Framework
/// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
public void PurgeExpired()
{
lock( m_syncRoot )
lock (m_syncRoot)
{
m_cache.PurgeExpired();
}
@ -615,11 +616,11 @@ namespace OpenSim.Framework
/// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
/// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
/// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
public void Remove( TKey key )
public void Remove(TKey key)
{
lock( m_syncRoot )
lock (m_syncRoot)
{
m_cache.Remove( key );
m_cache.Remove(key);
}
}
@ -637,11 +638,11 @@ namespace OpenSim.Framework
/// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
/// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
/// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
public void RemoveRange( IEnumerable<TKey> keys )
public void RemoveRange(IEnumerable<TKey> keys)
{
lock( m_syncRoot )
lock (m_syncRoot)
{
m_cache.RemoveRange( keys );
m_cache.RemoveRange(keys);
}
}
@ -690,11 +691,11 @@ namespace OpenSim.Framework
/// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
/// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
/// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
public bool Set( TKey key, TValue value, long size )
public bool Set(TKey key, TValue value, long size)
{
lock( m_syncRoot )
lock (m_syncRoot)
{
return m_cache.Set( key, value, size );
return m_cache.Set(key, value, size);
}
}
@ -721,11 +722,11 @@ namespace OpenSim.Framework
/// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/>
/// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
/// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
public bool TryGetValue( TKey key, out TValue value )
public bool TryGetValue(TKey key, out TValue value)
{
lock( m_syncRoot )
lock (m_syncRoot)
{
return m_cache.TryGetValue( key, out value );
return m_cache.TryGetValue(key, out value);
}
}

View File

@ -58,28 +58,28 @@ namespace OpenSim.Framework
/// <returns>
/// Primer number that is equal or larger than <see cref="min"/>. If <see cref="min"/> is too large, return -1.
/// </returns>
public static int GetPrime( int min )
public static int GetPrime(int min)
{
if( min <= 2 )
if (min <= 2)
return 2;
if( Primes[ Primes.Length - 1 ] < min )
if (Primes[ Primes.Length - 1 ] < min)
{
for( int i = min | 1 ; i < 0x7FFFFFFF ; i += 2 )
for (int i = min | 1 ; i < 0x7FFFFFFF ; i += 2)
{
if( IsPrime( i ) )
if (IsPrime(i))
return i;
}
return -1;
}
for( int i = Primes.Length - 2 ; i >= 0 ; i-- )
for (int i = Primes.Length - 2 ; i >= 0 ; i--)
{
if( min == Primes[ i ] )
if (min == Primes[ i ])
return min;
if( min > Primes[ i ] )
if (min > Primes[ i ])
return Primes[ i + 1 ];
}
@ -95,17 +95,17 @@ namespace OpenSim.Framework
/// <returns>
/// true, if <see cref="candinate"/> is prime number; otherwise false.
/// </returns>
public static bool IsPrime( int candinate )
public static bool IsPrime(int candinate)
{
if( (candinate & 1) == 0 )
if ((candinate & 1) == 0)
// Even number - only prime if 2
return candinate == 2;
int upperBound = (int) Math.Sqrt( candinate );
for( int i = 3 ; i < upperBound ; i += 2 )
int upperBound = (int) Math.Sqrt(candinate);
for (int i = 3 ; i < upperBound ; i += 2)
{
if( candinate % i == 0 )
if (candinate % i == 0)
return false;
}

View File

@ -114,12 +114,12 @@ namespace OpenSim.Region.CoreModules.Asset
/// <summary>
/// Asset's default expiration time in the cache.
/// </summary>
public static readonly TimeSpan DefaultExpirationTime = TimeSpan.FromMinutes( 30.0 );
public static readonly TimeSpan DefaultExpirationTime = TimeSpan.FromMinutes(30.0);
/// <summary>
/// Log manager instance.
/// </summary>
private static readonly ILog Log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType );
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Cache object.
@ -159,7 +159,7 @@ namespace OpenSim.Region.CoreModules.Asset
/// </summary>
public void Initialize()
{
Initialize( DefaultMaxSize, DefaultMaxCount, DefaultExpirationTime );
Initialize(DefaultMaxSize, DefaultMaxCount, DefaultExpirationTime);
}
/// <summary>
@ -174,16 +174,16 @@ namespace OpenSim.Region.CoreModules.Asset
/// <param name="expirationTime">
/// Asset's expiration time.
/// </param>
public void Initialize( long maximalSize, int maximalCount, TimeSpan expirationTime )
public void Initialize(long maximalSize, int maximalCount, TimeSpan expirationTime)
{
if( maximalSize <= 0 || maximalCount <= 0 )
if (maximalSize <= 0 || maximalCount <= 0)
{
Log.Info( "[ASSET CACHE]: Cenome asset cache is not enabled." );
Log.Info("[ASSET CACHE]: Cenome asset cache is not enabled.");
m_enabled = false;
return;
}
if( expirationTime <= TimeSpan.Zero )
if (expirationTime <= TimeSpan.Zero)
{
// Disable expiration time
expirationTime = TimeSpan.MaxValue;
@ -191,14 +191,14 @@ namespace OpenSim.Region.CoreModules.Asset
// Create cache and add synchronization wrapper over it
m_cache =
CnmSynchronizedCache<string, AssetBase>.Synchronized( new CnmMemoryCache<string, AssetBase>(
maximalSize, maximalCount, expirationTime ) );
CnmSynchronizedCache<string, AssetBase>.Synchronized(new CnmMemoryCache<string, AssetBase>(
maximalSize, maximalCount, expirationTime));
m_enabled = true;
Log.InfoFormat(
"[ASSET CACHE]: Cenome asset cache enabled (MaxSize = {0} bytes, MaxCount = {1}, ExpirationTime = {2})",
maximalSize,
maximalCount,
expirationTime );
expirationTime);
}
#region IImprovedAssetCache Members
@ -209,10 +209,10 @@ namespace OpenSim.Region.CoreModules.Asset
/// <param name="asset">
/// The asset that is being cached.
/// </param>
public void Cache( AssetBase asset )
public void Cache(AssetBase asset)
{
long size = asset.Data != null ? asset.Data.Length : 1;
m_cache.Set( asset.ID, asset, size );
m_cache.Set(asset.ID, asset, size);
m_cachedCount++;
}
@ -230,9 +230,9 @@ namespace OpenSim.Region.CoreModules.Asset
/// <param name="id">
/// The expired asset's id.
/// </param>
public void Expire( string id )
public void Expire(string id)
{
m_cache.Remove( id );
m_cache.Remove(id);
}
/// <summary>
@ -250,14 +250,14 @@ namespace OpenSim.Region.CoreModules.Asset
/// Cache doesn't guarantee in any situation that asset is stored to it.
/// </para>
/// </remarks>
public AssetBase Get( string id )
public AssetBase Get(string id)
{
m_getCount++;
AssetBase assetBase;
if( m_cache.TryGetValue( id, out assetBase ) )
if (m_cache.TryGetValue(id, out assetBase))
m_hitCount++;
if( m_getCount == m_debugEpoch )
if (m_getCount == m_debugEpoch)
{
Log.InfoFormat(
"[ASSET CACHE]: Cached = {0}, Get = {1}, Hits = {2}%, Size = {3} bytes, Avg. A. Size = {4} bytes",
@ -265,7 +265,7 @@ namespace OpenSim.Region.CoreModules.Asset
m_getCount,
((double) m_hitCount / m_getCount) * 100.0,
m_cache.Size,
m_cache.Size / m_cache.Count );
m_cache.Size / m_cache.Count);
m_getCount = 0;
m_hitCount = 0;
m_cachedCount = 0;
@ -292,10 +292,10 @@ namespace OpenSim.Region.CoreModules.Asset
/// <param name="scene">
/// Region's scene.
/// </param>
public void AddRegion( Scene scene )
public void AddRegion(Scene scene)
{
if( m_enabled )
scene.RegisterModuleInterface<IImprovedAssetCache>( this );
if (m_enabled)
scene.RegisterModuleInterface<IImprovedAssetCache>(this);
}
/// <summary>
@ -314,19 +314,19 @@ namespace OpenSim.Region.CoreModules.Asset
/// <param name="source">
/// Configuration source.
/// </param>
public void Initialise( IConfigSource source )
public void Initialise(IConfigSource source)
{
m_cache = null;
m_enabled = false;
IConfig moduleConfig = source.Configs[ "Modules" ];
if( moduleConfig == null )
if (moduleConfig == null)
return;
string name = moduleConfig.GetString( "AssetCaching" );
Log.DebugFormat( "[XXX] name = {0} (this module's name: {1}", name, Name );
string name = moduleConfig.GetString("AssetCaching");
Log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name);
if( name != Name )
if (name != Name)
return;
// This module is used
@ -335,19 +335,19 @@ namespace OpenSim.Region.CoreModules.Asset
TimeSpan expirationTime = DefaultExpirationTime;
IConfig assetConfig = source.Configs[ "AssetCache" ];
if( assetConfig != null )
if (assetConfig != null)
{
// Get optional configurations
maxSize = assetConfig.GetLong( "MaxSize", DefaultMaxSize );
maxCount = assetConfig.GetInt( "MaxCount", DefaultMaxCount );
maxSize = assetConfig.GetLong("MaxSize", DefaultMaxSize);
maxCount = assetConfig.GetInt("MaxCount", DefaultMaxCount);
expirationTime =
TimeSpan.FromMinutes( assetConfig.GetInt( "ExpirationTime", (int) DefaultExpirationTime.TotalMinutes ) );
TimeSpan.FromMinutes(assetConfig.GetInt("ExpirationTime", (int) DefaultExpirationTime.TotalMinutes));
// Debugging purposes only
m_debugEpoch = assetConfig.GetInt( "DebugEpoch", 0 );
m_debugEpoch = assetConfig.GetInt("DebugEpoch", 0);
}
Initialize( maxSize, maxCount, expirationTime );
Initialize(maxSize, maxCount, expirationTime);
}
/// <summary>
@ -381,7 +381,7 @@ namespace OpenSim.Region.CoreModules.Asset
/// The extra function stub is just that much cleaner.
/// </para>
/// </remarks>
public void RegionLoaded( Scene scene )
public void RegionLoaded(Scene scene)
{
}
@ -391,7 +391,7 @@ namespace OpenSim.Region.CoreModules.Asset
/// <param name="scene">
/// Region scene that is being removed.
/// </param>
public void RemoveRegion( Scene scene )
public void RemoveRegion(Scene scene)
{
}

View File

@ -230,7 +230,7 @@ namespace Flotsam.RegionModules.AssetCache
private void UpdateMemoryCache(string key, AssetBase asset)
{
if( m_MemoryCacheEnabled )
if (m_MemoryCacheEnabled)
{
if (m_MemoryExpiration > TimeSpan.Zero)
{
@ -404,7 +404,7 @@ namespace Flotsam.RegionModules.AssetCache
File.Delete(filename);
}
if( m_MemoryCacheEnabled )
if (m_MemoryCacheEnabled)
m_MemoryCache.Remove(id);
}
catch (Exception e)
@ -423,7 +423,7 @@ namespace Flotsam.RegionModules.AssetCache
Directory.Delete(dir);
}
if( m_MemoryCacheEnabled )
if (m_MemoryCacheEnabled)
m_MemoryCache.Clear();
}

View File

@ -332,7 +332,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
UUID oldID = UUID.Zero;
lock(part)
lock (part)
{
// mostly keep the values from before
Primitive.TextureEntry tmptex = part.Shape.Textures;
@ -340,7 +340,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
// remove the old asset from the cache
oldID = tmptex.DefaultTexture.TextureID;
if(Face == ALL_SIDES)
if (Face == ALL_SIDES)
{
tmptex.DefaultTexture.TextureID = asset.FullID;
}

View File

@ -243,7 +243,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
string grant = myConfig.GetString("GrantLSL","");
if(grant.Length > 0) {
if (grant.Length > 0) {
foreach (string uuidl in grant.Split(',')) {
string uuid = uuidl.Trim(" \t".ToCharArray());
GrantLSL.Add(uuid, true);
@ -251,7 +251,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
}
grant = myConfig.GetString("GrantCS","");
if(grant.Length > 0) {
if (grant.Length > 0) {
foreach (string uuidl in grant.Split(',')) {
string uuid = uuidl.Trim(" \t".ToCharArray());
GrantCS.Add(uuid, true);
@ -259,7 +259,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
}
grant = myConfig.GetString("GrantVB","");
if(grant.Length > 0) {
if (grant.Length > 0) {
foreach (string uuidl in grant.Split(',')) {
string uuid = uuidl.Trim(" \t".ToCharArray());
GrantVB.Add(uuid, true);
@ -267,7 +267,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
}
grant = myConfig.GetString("GrantJS","");
if(grant.Length > 0) {
if (grant.Length > 0) {
foreach (string uuidl in grant.Split(',')) {
string uuid = uuidl.Trim(" \t".ToCharArray());
GrantJS.Add(uuid, true);
@ -563,7 +563,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
}
// Group permissions
if ( ( task.GroupID != UUID.Zero) && IsGroupMember(task.GroupID, user, 0) )
if ((task.GroupID != UUID.Zero) && IsGroupMember(task.GroupID, user, 0))
return objectGroupMask;
return objectEveryoneMask;
@ -650,7 +650,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
}
// Group members should be able to edit group objects
if ( (group.GroupID != UUID.Zero) && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0) && IsGroupMember(group.GroupID, currentUser, 0) )
if ((group.GroupID != UUID.Zero) && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0) && IsGroupMember(group.GroupID, currentUser, 0))
{
// Return immediately, so that the administrator can shares group objects
return true;
@ -731,7 +731,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
permission = true;
}
if( ( parcel.landData.GroupID != UUID.Zero) && IsGroupMember(parcel.landData.GroupID, user, groupPowers) )
if ((parcel.landData.GroupID != UUID.Zero) && IsGroupMember(parcel.landData.GroupID, user, groupPowers))
{
permission = true;
}
@ -758,7 +758,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
permission = true;
}
if( parcel.landData.IsGroupOwned && IsGroupMember(parcel.landData.GroupID, user, groupPowers) )
if (parcel.landData.IsGroupOwned && IsGroupMember(parcel.landData.GroupID, user, groupPowers))
{
permission = true;
}
@ -982,7 +982,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (part.GroupID == UUID.Zero)
return false;
if( !IsGroupMember(part.GroupID, user, 0) )
if (!IsGroupMember(part.GroupID, user, 0))
return false;
if ((part.GroupMask & (uint)PermissionMask.Modify) == 0)
@ -1002,7 +1002,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (ti.GroupID == UUID.Zero)
return false;
if( !IsGroupMember(ti.GroupID, user, 0) )
if (!IsGroupMember(ti.GroupID, user, 0))
return false;
}
@ -1411,7 +1411,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (part.GroupID == UUID.Zero)
return false;
if( !IsGroupMember(part.GroupID, user, 0) )
if (!IsGroupMember(part.GroupID, user, 0))
return false;
if ((part.GroupMask & (uint)PermissionMask.Modify) == 0)
@ -1431,7 +1431,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (ti.GroupID == UUID.Zero)
return false;
if( !IsGroupMember(ti.GroupID, user, 0) )
if (!IsGroupMember(ti.GroupID, user, 0))
return false;
}
@ -1504,7 +1504,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (part.GroupID == UUID.Zero)
return false;
if( !IsGroupMember(part.GroupID, user, 0) )
if (!IsGroupMember(part.GroupID, user, 0))
return false;
}
@ -1521,7 +1521,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (ti.GroupID == UUID.Zero)
return false;
if( !IsGroupMember(ti.GroupID, user, 0) )
if (!IsGroupMember(ti.GroupID, user, 0))
return false;
}
@ -1744,24 +1744,24 @@ namespace OpenSim.Region.CoreModules.World.Permissions
private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) {
//m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType);
switch(scriptType) {
switch (scriptType) {
case 0:
if(GrantLSL.Count == 0 || GrantLSL.ContainsKey(ownerUUID.ToString())) {
if (GrantLSL.Count == 0 || GrantLSL.ContainsKey(ownerUUID.ToString())) {
return(true);
}
break;
case 1:
if(GrantCS.Count == 0 || GrantCS.ContainsKey(ownerUUID.ToString())) {
if (GrantCS.Count == 0 || GrantCS.ContainsKey(ownerUUID.ToString())) {
return(true);
}
break;
case 2:
if(GrantVB.Count == 0 || GrantVB.ContainsKey(ownerUUID.ToString())) {
if (GrantVB.Count == 0 || GrantVB.ContainsKey(ownerUUID.ToString())) {
return(true);
}
break;
case 3:
if(GrantJS.Count == 0 || GrantJS.ContainsKey(ownerUUID.ToString())) {
if (GrantJS.Count == 0 || GrantJS.ContainsKey(ownerUUID.ToString())) {
return(true);
}
break;

View File

@ -1526,14 +1526,14 @@ namespace OpenSim.Region.Framework.Scenes
return;
if (part.OwnerID != remoteClient.AgentId)
{
// Group permissions
if ( (part.GroupID == UUID.Zero) || (remoteClient.GetGroupPowers(part.GroupID) == 0) || ((part.GroupMask & (uint)PermissionMask.Modify) == 0) )
return;
} else {
if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
return;
}
{
// Group permissions
if ((part.GroupID == UUID.Zero) || (remoteClient.GetGroupPowers(part.GroupID) == 0) || ((part.GroupMask & (uint)PermissionMask.Modify) == 0))
return;
} else {
if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
return;
}
if (!Permissions.CanCreateObjectInventory(
itemBase.InvType, part.UUID, remoteClient.AgentId))
@ -1605,15 +1605,15 @@ namespace OpenSim.Region.Framework.Scenes
// Must own the object, and have modify rights
if (srcPart.OwnerID != destPart.OwnerID)
{
// Group permissions
if ( (destPart.GroupID == UUID.Zero) || (destPart.GroupID != srcPart.GroupID) ||
((destPart.GroupMask & (uint)PermissionMask.Modify) == 0) )
return;
} else {
if ((destPart.OwnerMask & (uint)PermissionMask.Modify) == 0)
return;
}
{
// Group permissions
if ((destPart.GroupID == UUID.Zero) || (destPart.GroupID != srcPart.GroupID) ||
((destPart.GroupMask & (uint)PermissionMask.Modify) == 0))
return;
} else {
if ((destPart.OwnerMask & (uint)PermissionMask.Modify) == 0)
return;
}
if (destPart.ScriptAccessPin != pin)
{

View File

@ -136,7 +136,7 @@ namespace OpenSim.Region.Framework.Scenes
{
m_AssetService = RequestModuleInterface<IAssetService>();
if( m_AssetService == null )
if (m_AssetService == null)
{
throw new Exception("No IAssetService available.");
}
@ -1097,7 +1097,7 @@ namespace OpenSim.Region.Framework.Scenes
IMessageTransferModule tr = RequestModuleInterface<IMessageTransferModule>();
if (tr != null)
tr.SendInstantMessage(msg, delegate(bool success) {} );
tr.SendInstantMessage(msg, delegate(bool success) {});
}
m_returns.Clear();
}
@ -1465,7 +1465,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (SceneObjectPart part in group.Children.Values)
{
if (part.IsJoint() && ((part.ObjectFlags&(uint)PrimFlags.Physics) != 0) )
if (part.IsJoint() && ((part.ObjectFlags&(uint)PrimFlags.Physics) != 0))
{
PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
}

View File

@ -342,12 +342,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
throw new Exception(errtext);
}
if(m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)l) == false) {
// Not allowed to compile to this language!
string errtext = String.Empty;
errtext += ownerUUID + " is not in list of allowed users for this scripting language. Script will not be executed!";
throw new Exception(errtext);
}
if (m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)l) == false) {
// Not allowed to compile to this language!
string errtext = String.Empty;
errtext += ownerUUID + " is not in list of allowed users for this scripting language. Script will not be executed!";
throw new Exception(errtext);
}
string compileScript = Script;

View File

@ -135,8 +135,8 @@ state another_state
[Test]
public void TestLoneIdent()
{
// A lone ident should be removed completely as it's an error in C#
// (MONO at least).
// A lone ident should be removed completely as it's an error in C#
// (MONO at least).
string input = @"default
{
touch_start(integer num_detected)
@ -150,7 +150,7 @@ state another_state
"\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" +
"\n {" +
"\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0);" +
"\n ;" +
"\n ;" +
"\n }\n";
CSCodeGenerator cg = new CSCodeGenerator();