Exemplo n.º 1
0
    public void RoundTripFromJsonObject()
    {
        var so1 = ServiceObject.Create(new JsonObject {
            ["foo"] = "bar"
        });
        var so2 = JsonSerializer.FromJson <ServiceObject>(JsonSerializer.ToJson(so1));

        Assert.IsTrue(so1.IsEquivalentTo(so2));
    }
Exemplo n.º 2
0
    public void EquivalenceFromJObject()
    {
        var so1 = ServiceObject.Create(new JObject {
            ["foo"] = "bar"
        });
        var so2 = ServiceObject.Create(new JObject {
            ["foo"] = "bar"
        });

        Assert.IsTrue(so1.IsEquivalentTo(so2));
    }
Exemplo n.º 3
0
    /// <summary>
    /// Creates an InternalError service error for an exception.
    /// </summary>
    public static ServiceErrorDto CreateInternalErrorForException(Exception exception)
    {
        var error      = ServiceErrors.CreateInternalError(exception.Message);
        var jException = new JObject {
            ["details"] = new JArray(exception.ToString().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).AsEnumerable())
        };

        error.DetailsObject = ServiceObject.Create(new JObject {
            ["exception"] = jException
        });
        return(error);
    }
        public static ServiceObject GetServiceObject(ServiceInstanceSettings serviceInstanceSettings, string serviceObjectName)
        {
            serviceInstanceSettings.ThrowIfNull("serviceInstanceSettings");

            var connection = WrapperFactory.Instance.GetSmartObjectManagementServerWrapper(null);

            using (connection.BaseAPIServer?.Connection)
            {
                var serviceObject = ServiceObject.Create(connection.GetServiceInstanceServiceObject(serviceInstanceSettings.Guid, serviceObjectName));
                return(serviceObject);
            }
        }