add some missing default group owner powers on xmlrpc groups module

plus more dotnet6 code style changes
This commit is contained in:
UbitUmarov
2022-10-28 20:06:45 +01:00
parent 496deb92d4
commit aa572df663
12 changed files with 806 additions and 961 deletions

View File

@@ -194,7 +194,7 @@ namespace OpenSim.Server.Base
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static byte[] SerializeResult(XmlSerializer xs, object data)
public static byte[] SerializeResult(XmlSerializer xs, object data)
{
using (MemoryStream ms = new MemoryStream())
using (XmlTextWriter xw = new XmlTextWriter(ms, Util.UTF8))
@@ -216,7 +216,7 @@ namespace OpenSim.Server.Base
/// <param name="dllName"></param>
/// <param name="args">The arguments which control which constructor is invoked on the plugin</param>
/// <returns></returns>
public static T LoadPlugin<T> (string dllName, Object[] args) where T:class
public static T LoadPlugin<T>(string dllName, Object[] args) where T : class
{
// This is good to debug configuration problems
//if (dllName.Length == 0)
@@ -225,19 +225,19 @@ namespace OpenSim.Server.Base
string className = String.Empty;
// The path for a dynamic plugin will contain ":" on Windows
string[] parts = dllName.Split (new char[] {':'});
string[] parts = dllName.Split(new char[] { ':' });
if (parts.Length < 3)
{
// Linux. There will be ':' but the one we're looking for
dllName = parts [0];
dllName = parts[0];
if (parts.Length > 1)
className = parts[1];
}
else
{
// This is Windows - we must replace the ":" in the path
dllName = String.Format ("{0}:{1}", parts [0], parts [1]);
dllName = String.Format("{0}:{1}", parts[0], parts[1]);
if (parts.Length > 2)
className = parts[2];
}
@@ -245,10 +245,10 @@ namespace OpenSim.Server.Base
// Handle extra string arguments in a more generic way
if (dllName.Contains("@"))
{
string[] dllNameParts = dllName.Split(new char[] {'@'});
string[] dllNameParts = dllName.Split(new char[] { '@' });
dllName = dllNameParts[dllNameParts.Length - 1];
List<Object> argList = new List<Object>(args);
for (int i = 0 ; i < dllNameParts.Length - 1 ; ++i)
for (int i = 0; i < dllNameParts.Length - 1; ++i)
argList.Add(dllNameParts[i]);
args = argList.ToArray();
@@ -264,7 +264,7 @@ namespace OpenSim.Server.Base
/// <param name="className"></param>
/// <param name="args">The arguments which control which constructor is invoked on the plugin</param>
/// <returns></returns>
public static T LoadPlugin<T>(string dllName, string className, Object[] args) where T:class
public static T LoadPlugin<T>(string dllName, string className, Object[] args) where T : class
{
string interfaceName = typeof(T).ToString();
@@ -327,7 +327,7 @@ namespace OpenSim.Server.Base
public static Dictionary<string, object> ParseQueryString(string query)
{
string[] terms = query.Split(new char[] {'&'});
string[] terms = query.Split(new char[] { '&' });
int nterms = terms.Length;
if (nterms == 0)
@@ -336,14 +336,14 @@ namespace OpenSim.Server.Base
Dictionary<string, object> result = new Dictionary<string, object>(nterms);
string name;
for(int i = 0; i < nterms; ++i)
for (int i = 0; i < nterms; ++i)
{
string[] elems = terms[i].Split(new char[] {'='});
string[] elems = terms[i].Split(new char[] { '=' });
if (elems.Length == 0)
continue;
if(String.IsNullOrWhiteSpace(elems[0]))
if (String.IsNullOrWhiteSpace(elems[0]))
continue;
name = System.Web.HttpUtility.UrlDecode(elems[0]);
@@ -351,18 +351,17 @@ namespace OpenSim.Server.Base
if (name.EndsWith("[]"))
{
name = name.Substring(0, name.Length - 2);
if(String.IsNullOrWhiteSpace(name))
if (String.IsNullOrWhiteSpace(name))
continue;
if (result.ContainsKey(name))
{
if (!(result[name] is List<string>))
if (result[name] is not List<string> l)
continue;
List<string> l = (List<string>)result[name];
if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1]))
if (elems.Length > 1 && !string.IsNullOrWhiteSpace(elems[1]))
l.Add(System.Web.HttpUtility.UrlDecode(elems[1]));
else
l.Add(String.Empty);
l.Add(string.Empty);
}
else
{
@@ -399,21 +398,20 @@ namespace OpenSim.Server.Base
foreach (KeyValuePair<string, object> kvp in data)
{
if (kvp.Value is List<string>)
if (kvp.Value is List<string> l)
{
List<string> l = (List<String>)kvp.Value;
int llen = l.Count;
string nkey = System.Web.HttpUtility.UrlEncode(kvp.Key);
for(int i = 0; i < llen; ++i)
for (int i = 0; i < llen; ++i)
{
if (sb.Length != 0)
sb.Append("&");
sb.Append('&');
sb.Append(nkey);
sb.Append("[]=");
sb.Append(System.Web.HttpUtility.UrlEncode(l[i]));
}
}
else if(kvp.Value is Dictionary<string, object>)
else if (kvp.Value is Dictionary<string, object>)
{
// encode complex structures as JSON
// needed for estate bans with the encoding used on xml
@@ -425,30 +423,30 @@ namespace OpenSim.Server.Base
// bypass libovm, we dont need even more useless high level maps
// this should only be called once.. but no problem, i hope
// (other uses may need more..)
LitJson.JsonMapper.RegisterExporter<UUID>((uuid, writer) => writer.Write(uuid.ToString()) );
LitJson.JsonMapper.RegisterExporter<UUID>((uuid, writer) => writer.Write(uuid.ToString()));
js = LitJson.JsonMapper.ToJson(kvp.Value);
}
// catch(Exception e)
// catch(Exception e)
catch
{
continue;
}
if (sb.Length != 0)
sb.Append("&");
sb.Append('&');
sb.Append(System.Web.HttpUtility.UrlEncode(kvp.Key));
sb.Append("=");
sb.Append('=');
sb.Append(System.Web.HttpUtility.UrlEncode(js));
}
else
{
if (sb.Length != 0)
sb.Append("&");
sb.Append('&');
sb.Append(System.Web.HttpUtility.UrlEncode(kvp.Key));
pvalue = kvp.Value.ToString();
if (!String.IsNullOrEmpty(pvalue))
if (!string.IsNullOrEmpty(pvalue))
{
sb.Append("=");
sb.Append('=');
sb.Append(System.Web.HttpUtility.UrlEncode(pvalue));
}
}
@@ -462,12 +460,11 @@ namespace OpenSim.Server.Base
{
XmlDocument doc = new XmlDocument();
XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
"", "");
XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
doc.AppendChild(xmlnode);
XmlElement rootElement = doc.CreateElement("", "ServerResponse","");
XmlElement rootElement = doc.CreateElement("", "ServerResponse", "");
doc.AppendChild(rootElement);
@@ -480,26 +477,22 @@ namespace OpenSim.Server.Base
{
foreach (KeyValuePair<string, object> kvp in data)
{
if (kvp.Value == null)
if (kvp.Value is null)
continue;
XmlElement elem = parent.OwnerDocument.CreateElement("",
XmlConvert.EncodeLocalName(kvp.Key), "");
XmlElement elem = parent.OwnerDocument.CreateElement("", XmlConvert.EncodeLocalName(kvp.Key), "");
if (kvp.Value is Dictionary<string, object>)
if (kvp.Value is Dictionary<string, object> dic)
{
XmlAttribute type = parent.OwnerDocument.CreateAttribute("",
"type", "");
XmlAttribute type = parent.OwnerDocument.CreateAttribute("", "type", "");
type.Value = "List";
elem.Attributes.Append(type);
BuildXmlData(elem, (Dictionary<string, object>)kvp.Value);
BuildXmlData(elem, dic);
}
else
{
elem.AppendChild(parent.OwnerDocument.CreateTextNode(
kvp.Value.ToString()));
elem.AppendChild(parent.OwnerDocument.CreateTextNode(kvp.Value.ToString()));
}
parent.AppendChild(elem);
@@ -552,8 +545,8 @@ namespace OpenSim.Server.Base
xpc.Encoding = Util.UTF8NoBomEncoding;
using (XmlReader xr = XmlReader.Create(new StringReader(data), xset, xpc))
{
if(!xr.ReadToFollowing("ServerResponse"))
return new Dictionary<string, object>();
if (!xr.ReadToFollowing("ServerResponse"))
return new Dictionary<string, object>();
return ScanXmlResponse(xr);
}
}
@@ -612,7 +605,7 @@ namespace OpenSim.Server.Base
try
{
IConfigSource cs;
using( XmlReader r = XmlReader.Create(url))
using (XmlReader r = XmlReader.Create(url))
{
cs = new XmlConfigSource(r);
source.Merge(cs);