コード例 #1
0
        public void XmlRpcArray_Correctly_Parses_XElement_Array_Of_Different_Types()
        {
            string   arrayXml     = @"<value>
    <data>
        <value><i4>1</i4></value>
        <value><int>2</int></value>
        <value><string>Test String</string></value>
        <value><boolean>0</boolean></value>
        <value><i4>-1</i4></value>
        <value><double>64.23</double></value>
        <value><dateTime.iso8601>2021-04-06T16:36:44.1557489+02:00</dateTime.iso8601></value>
        <value><base64>VGVzdCBCYXNlNjQgU3RyaW5n</base64></value>
    </data>
</value>";
            XElement arrayElement = XElement.Parse(arrayXml);

            XmlRpcArray    array  = new(arrayElement);
            XmlRpcInteger  entry1 = (XmlRpcInteger)array.Values[0];
            XmlRpcInteger  entry2 = (XmlRpcInteger)array.Values[1];
            XmlRpcString   entry3 = (XmlRpcString)array.Values[2];
            XmlRpcBoolean  entry4 = (XmlRpcBoolean)array.Values[3];
            XmlRpcInteger  entry5 = (XmlRpcInteger)array.Values[4];
            XmlRpcDouble   entry6 = (XmlRpcDouble)array.Values[5];
            XmlRpcDateTime entry7 = (XmlRpcDateTime)array.Values[6];
            XmlRpcBase64   entry8 = (XmlRpcBase64)array.Values[7];

            DateTime expectedDateTime = DateTime.Parse("2021-04-06T16:36:44.1557489+02:00").ToUniversalTime();
            Base64   expectedBase64   = Base64.FromBase64String("VGVzdCBCYXNlNjQgU3RyaW5n");

            Assert.Equal(1, entry1.Value);
            Assert.Equal(2, entry2.Value);
            Assert.Equal("Test String", entry3.Value);
            Assert.False(entry4.Value);
            Assert.Equal(-1, entry5.Value);
            Assert.Equal(64.23, entry6.Value);
            Assert.Equal(expectedDateTime, entry7.Value);
            Assert.Equal(expectedBase64.Data, entry8.Value.Data);
        }
コード例 #2
0
    protected XmlRpcParameterArray CreateLoginParameters(Credential credential, Slurl slurl, bool getInventoryLibrary, bool godMode)
    {
        XmlRpcArray options = new XmlRpcArray();

        options.Append(new XmlRpcString("inventory-root"));
        options.Append(new XmlRpcString("inventory-skeleton"));
        //options.Append(new XmlRpcString("inventory-meat"));
        //options.Append(new XmlRpcString("inventory-skel-targets"));
        if (getInventoryLibrary == true)
        {
            options.Append(new XmlRpcString("inventory-lib-root"));
            options.Append(new XmlRpcString("inventory-lib-owner"));
            options.Append(new XmlRpcString("inventory-skel-lib"));
            //options.Append(new XmlRpcString("inventory-meat-lib"));
        }
        options.Append(new XmlRpcString("initial-outfit"));
        options.Append(new XmlRpcString("gestures"));
        options.Append(new XmlRpcString("display_names"));
        options.Append(new XmlRpcString("event_categories"));
        options.Append(new XmlRpcString("event_notifications"));
        options.Append(new XmlRpcString("classified_categories"));
        options.Append(new XmlRpcString("adult_compliant"));
        options.Append(new XmlRpcString("buddy-list"));
        options.Append(new XmlRpcString("newuser-config"));
        options.Append(new XmlRpcString("ui-config"));

        //send this info to login.cgi for stats gathering
        //since viewerstats isn't reliable enough
        options.Append(new XmlRpcString("advanced-mode"));

        options.Append(new XmlRpcString("max-agent-groups"));
        options.Append(new XmlRpcString("map-server-url"));
        options.Append(new XmlRpcString("voice-config"));
        options.Append(new XmlRpcString("tutorial_setting"));
        options.Append(new XmlRpcString("login-flags"));
        options.Append(new XmlRpcString("global-textures"));

        if (godMode == true)
        {
            options.Append(new XmlRpcString("UseDebugMenus"));
            options.Append(new XmlRpcString("god-connect"));
        }

        XmlRpcStruct data = new XmlRpcStruct();

        data["start"]              = new XmlRpcString(slurl.GetLoginString());
        data["agree_to_tos"]       = new XmlRpcBoolean(false);
        data["read_critical"]      = new XmlRpcBoolean(false);
        data["last_exec_event"]    = new XmlRpcInteger(LastExecEvent);
        data["last_exec_duration"] = new XmlRpcInteger(LastExecDuration);
        data["mac"]              = new XmlRpcString(MachineId);
        data["version"]          = new XmlRpcString(ViewerVersion);
        data["channel"]          = new XmlRpcString(ViewerChannel);
        data["platform"]         = new XmlRpcString(Platform);
        data["address_size"]     = new XmlRpcInteger(ADDRESS_SIZE);
        data["platform_version"] = new XmlRpcString(PlatformVersion);
        data["platform_string"]  = new XmlRpcString(PlatformVersionName);
        data["id0"]              = new XmlRpcString(SerialNumber);
        data["host_id"]          = new XmlRpcString(HostId);
        data["extended_errors"]  = new XmlRpcBoolean(true);

        data["passwd"] = new XmlRpcString(credential.Secret);
        data["first"]  = new XmlRpcString(credential.First);
        data["last"]   = new XmlRpcString(credential.Last);

        data["options"] = options;

        XmlRpcParameterArray parameters = new XmlRpcParameterArray();

        parameters.Append(data);
        return(parameters);
    }