This commit is contained in:
Cinder Roxley
2024-06-30 17:12:54 -05:00
parent 762876802f
commit f577dc0e86
17 changed files with 52 additions and 41 deletions

View File

@@ -52,7 +52,7 @@ namespace LibreMetaverse.LslTools
protected bool Error(ref ParseStackEntry top, string str)
{
SYMBOL ns = (SYMBOL) new error(this, top);
var ns = (SYMBOL) new error(this, top);
if (this.m_debug)
Console.WriteLine("Error encountered: " + str);
ns.pos = top.m_value.pos;

View File

@@ -162,7 +162,7 @@ namespace LibreMetaverse.LslTools
{
if (s == null)
return (object)"";
Encoding encoding = (Encoding)new UnicodeEncoding();
var encoding = new UnicodeEncoding();
if (s.Encode)
{
byte[] bytes = encoding.GetBytes((string)o);
@@ -206,7 +206,7 @@ namespace LibreMetaverse.LslTools
private static object CharSerialise(object o, Serialiser s)
{
Encoding encoding = (Encoding)new UnicodeEncoding();
var encoding = new UnicodeEncoding();
if (s.Encode)
{
byte[] bytes = encoding.GetBytes(new string((char)o, 1));

View File

@@ -41,7 +41,7 @@ namespace LibreMetaverse.LslTools
public SymbolType(SymbolsGen yyp, string name, bool defined)
{
Lexer lexer = yyp.m_lexer;
int length = name.IndexOf("+", StringComparison.Ordinal);
int length = name.IndexOf('+');
int num = 0;
if (length > 0)
{

View File

@@ -36,9 +36,8 @@ namespace LibreMetaverse.LslTools
public TokClassDef(GenBase gbs, string name, string bas)
{
if (gbs is TokensGen)
if (gbs is TokensGen tokensGen)
{
TokensGen tokensGen = (TokensGen) gbs;
this.m_name = name;
tokensGen.m_tokens.tokens[(object) name] = (object) this;
this.m_refToken = bas;

View File

@@ -68,7 +68,6 @@ namespace OpenMetaverse.StructuredData
public OSDException(string message) : base(message) { }
public OSDException() { }
public OSDException(string message, Exception innerException) : base(message, innerException) { }
protected OSDException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
}
/// <summary>

View File

@@ -27,6 +27,7 @@
using System;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
namespace OpenMetaverse
{
@@ -242,7 +243,7 @@ namespace OpenMetaverse
public IList<TValue> FindAll(Predicate<TValue> predicate)
{
IList<TValue> list = new List<TValue>();
var list = new List<TValue>();
_rwLock.EnterReadLock();
try
@@ -260,7 +261,7 @@ namespace OpenMetaverse
public int RemoveAll(Predicate<TValue> predicate)
{
IList<TKey1> list = new List<TKey1>();
var list = new List<TKey1>();
_rwLock.EnterUpgradeableReadLock();
@@ -272,12 +273,8 @@ namespace OpenMetaverse
list.Add(kvp.Key);
}
IList<TKey2> list2 = new List<TKey2>(list.Count);
foreach (var kvp in _dictionary2)
{
if (predicate(kvp.Value))
list2.Add(kvp.Key);
}
var list2 = new List<TKey2>(list.Count);
list2.AddRange(from kvp in _dictionary2 where predicate(kvp.Value) select kvp.Key);
_rwLock.EnterWriteLock();

View File

@@ -80,16 +80,7 @@ namespace OpenMetaverse.Assets
if (filePath.Length > 100)
WriteEntry("././@LongLink", m_asciiEncoding.GetBytes(filePath), 'L');
char fileType;
if (filePath.EndsWith("/"))
{
fileType = '5';
}
else
{
fileType = '0';
}
var fileType = filePath.EndsWith("/") ? '5' : '0';
WriteEntry(filePath, data, fileType);
}

View File

@@ -341,11 +341,11 @@ namespace OpenMetaverse.Assets
}
else if (key == "name")
{
name = val.Remove(val.LastIndexOf("|", StringComparison.Ordinal));
name = val.Remove(val.LastIndexOf('|'));
}
else if (key == "desc")
{
description = val.Remove(val.LastIndexOf("|", StringComparison.Ordinal));
description = val.Remove(val.LastIndexOf('|'));
}
else if (key == "creation_date")
{
@@ -387,7 +387,7 @@ namespace OpenMetaverse.Assets
{
BodyText += lines[i++] + "\n";
}
BodyText = BodyText.Remove(BodyText.LastIndexOf("}", StringComparison.Ordinal));
BodyText = BodyText.Remove(BodyText.LastIndexOf('}'));
return true;
}
catch (Exception ex)

View File

@@ -107,7 +107,7 @@ namespace OpenMetaverse.Assets
public string EncodeXml()
{
TextWriter textWriter = new StringWriter();
var textWriter = new StringWriter();
using (XmlTextWriter xmlWriter = new XmlTextWriter(textWriter))
{
OarFile.SOGToXml2(xmlWriter, this);

View File

@@ -42,7 +42,6 @@ namespace OpenMetaverse
{
public InventoryException() { }
public InventoryException(string message) : base(message) { }
protected InventoryException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
public InventoryException(string message, Exception innerException) : base(message, innerException) { }
}

View File

@@ -549,7 +549,7 @@ namespace OpenMetaverse.Rendering
/// <returns>A standard .Net string</returns>
public static string TrimAt0(string s)
{
int pos = s.IndexOf("\0", StringComparison.Ordinal);
int pos = s.IndexOf('\0');
return pos >= 0 ? s.Substring(0, pos) : s;
}

View File

@@ -69,7 +69,7 @@ namespace GridProxy
logLogin = true;
else if (arg.Substring(0, 2) == "--")
{
int ipos = arg.IndexOf("=", StringComparison.Ordinal);
int ipos = arg.IndexOf('=');
if (ipos != -1)
{
string sw = arg.Substring(0, ipos);

View File

@@ -140,7 +140,7 @@ public class IRCClient
int nameIndex = words[0].IndexOf('!');
string name = nameIndex > 0 ? words[0].Substring(1, nameIndex - 1) : words[0];
string address = words[0].Substring(nameIndex + 1);
OnMessage(words[2], name, address, lines[i].Substring(lines[i].IndexOf(":", 1, StringComparison.Ordinal) + 1));
OnMessage(words[2], name, address, lines[i].Substring(lines[i].IndexOf(':', 1) + 1));
}
}
}

View File

@@ -1,4 +1,30 @@
using System.Text;
/*
* Copyright (c) 2006-2016, openmetaverse.co
* All rights reserved.
*
* - Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* - Neither the name of the openmetaverse.co nor the names
* of its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (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.Text;
namespace OpenMetaverse.TestClient.Commands
{
@@ -53,9 +79,9 @@ namespace OpenMetaverse.TestClient.Commands
if (searchType.StartsWith("au"))
searchTypeFlags = DirectoryManager.SearchTypeFlags.Auction;
else if (searchType.StartsWith("m"))
else if (searchType.StartsWith('m'))
searchTypeFlags = DirectoryManager.SearchTypeFlags.Mainland;
else if (searchType.StartsWith("e"))
else if (searchType.StartsWith('e'))
searchTypeFlags = DirectoryManager.SearchTypeFlags.Estate;
else if (searchType.StartsWith("al"))
searchTypeFlags = DirectoryManager.SearchTypeFlags.Any;

View File

@@ -32,7 +32,7 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell
// Use '/' as a path seperator.
}
InventoryFolder currentFolder = Client.CurrentDirectory;
if (pathStr.StartsWith("/"))
if (pathStr.StartsWith('/'))
currentFolder = Inventory.RootFolder;
if (currentFolder == null) // We need this to be set to something.

View File

@@ -38,7 +38,7 @@ namespace OpenMetaverse.TestClient
else
{
trimmed = current.Trim();
if (trimmed.StartsWith("\"") && trimmed.EndsWith("\""))
if (trimmed.StartsWith('\"') && trimmed.EndsWith('\"'))
{
trimmed = trimmed.Remove(0, 1);
trimmed = trimmed.Remove(trimmed.Length - 1);
@@ -71,7 +71,7 @@ namespace OpenMetaverse.TestClient
trimmed = current.Trim();
if (trimmed.StartsWith("\"") && trimmed.EndsWith("\""))
if (trimmed.StartsWith('\"') && trimmed.EndsWith('\"'))
{
trimmed = trimmed.Remove(0, 1);
trimmed = trimmed.Remove(trimmed.Length - 1);

View File

@@ -924,7 +924,7 @@ namespace Mapgenerator
{
ProtocolManager protocol;
List<string> unused = new List<string>();
TextWriter writer;
StreamWriter writer;
try
{
@@ -947,7 +947,7 @@ namespace Mapgenerator
}
// Read in the template.cs file and write it to our output
TextReader reader = new StreamReader(args[1]);
var reader = new StreamReader(args[1]);
writer.WriteLine(reader.ReadToEnd());
reader.Close();
}