internal static IntPtr ToNative(this SecurityCredentials securityCredentials, PinCollection pin)
        {
            var nativeCredentials = new NativeTypes.FABRIC_SECURITY_CREDENTIALS[1];

            nativeCredentials[0].Kind  = NativeTypes.FABRIC_SECURITY_CREDENTIAL_KIND.FABRIC_SECURITY_CREDENTIAL_KIND_NONE;
            nativeCredentials[0].Value = IntPtr.Zero;

            switch (securityCredentials.CredentialType)
            {
            case CredentialType.X509:
            {
                var converter = new NativeX509CredentialConverter((X509Credentials)securityCredentials);
                nativeCredentials[0].Kind  = NativeTypes.FABRIC_SECURITY_CREDENTIAL_KIND.FABRIC_SECURITY_CREDENTIAL_KIND_X509;
                nativeCredentials[0].Value = converter.ToNative(pin);
                break;
            }

            case CredentialType.Windows:
            {
                var converter = new NativeWindowsCredentialConverter((WindowsCredentials)securityCredentials);
                nativeCredentials[0].Kind  = NativeTypes.FABRIC_SECURITY_CREDENTIAL_KIND.FABRIC_SECURITY_CREDENTIAL_KIND_WINDOWS;
                nativeCredentials[0].Value = converter.ToNative(pin);
                break;
            }

            case CredentialType.Claims:
            {
                var converter = new NativeClaimsCredentialConverter((ClaimsCredentials)securityCredentials);
                nativeCredentials[0].Kind  = NativeTypes.FABRIC_SECURITY_CREDENTIAL_KIND.FABRIC_SECURITY_CREDENTIAL_KIND_CLAIMS;
                nativeCredentials[0].Value = converter.ToNative(pin);
                break;
            }

            case CredentialType.None:
            {
                INativeCredentialConverter converter = new NativeNoneCredentialConverter();
                nativeCredentials[0].Kind  = NativeTypes.FABRIC_SECURITY_CREDENTIAL_KIND.FABRIC_SECURITY_CREDENTIAL_KIND_NONE;
                nativeCredentials[0].Value = converter.ToNative(pin);
                break;
            }

            default:
                AppTrace.TraceSource.WriteError("SecurityCredentials.ToNative", "Unknown credential type: {0}", securityCredentials.CredentialType);
                ReleaseAssert.Failfast("Unknown credential type: {0}", securityCredentials.CredentialType);
                break;
            }

            return(pin.AddBlittable(nativeCredentials));
        }
        /// <summary>
        /// Parses the response body to get the response code.
        /// </summary>
        ///
        /// <returns>The error code in the given response body.</returns>
        ///
        /// <param name="serverResponse">The server response from which to get the error code. This
        /// must describe an successful response from the server which contains an error in the
        /// response body.</param>
        private static Error GetErrorCode(ServerResponse serverResponse)
        {
            const string JsonKeyErrorCode = "Code";

            ReleaseAssert.IsNotNull(serverResponse, "A server response must be supplied.");
            ReleaseAssert.IsTrue(serverResponse.Result == HttpResult.Success, "The result must describe a successful server response.");
            ReleaseAssert.IsTrue(serverResponse.HttpResponseCode != SuccessHttpResponseCode && serverResponse.HttpResponseCode != UnexpectedErrorHttpResponseCode,
                                 "Must not be a successful or unexpected HTTP response code.");

            object errorCodeObject = serverResponse.Body[JsonKeyErrorCode];

            ReleaseAssert.IsTrue(errorCodeObject is long, "'Code' must be a long.");

            long errorCode = (long)errorCodeObject;

            switch (errorCode)
            {
            case 1007:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 422, @"Invalid HTTP response code for error code.");
                return(Error.InvalidRequest);

            case 1003:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 401, @"Invalid HTTP response code for error code.");
                return(Error.ExpiredConnectAccessToken);

            case 1004:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 401, @"Invalid HTTP response code for error code.");
                return(Error.InvalidConnectAccessToken);

            case 1008:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 503, @"Invalid HTTP response code for error code.");
                return(Error.TemporaryServiceError);

            case 8001:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 504, @"Invalid HTTP response code for error code.");
                return(Error.IapValidationServiceUnreachable);

            case 8003:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 502, @"Invalid HTTP response code for error code.");
                return(Error.IapValidationServiceResponseInvalid);

            case 8004:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 400, @"Invalid HTTP response code for error code.");
                return(Error.IapConfigurationNotSpecified);

            default:
                throw new ArgumentException("Invalid error code.");
            }
        }
예제 #3
0
        /// <summary>
        /// Parses the response body to get the response code.
        /// </summary>
        ///
        /// <returns>The error code in the given response body.</returns>
        ///
        /// <param name="serverResponse">The server response from which to get the error code. This
        /// must describe an successful response from the server which contains an error in the
        /// response body.</param>
        private static Error GetErrorCode(ServerResponse serverResponse)
        {
            const string JsonKeyErrorCode = "Code";

            ReleaseAssert.IsNotNull(serverResponse, "A server response must be supplied.");
            ReleaseAssert.IsTrue(serverResponse.Result == HttpResult.Success, "The result must describe a successful server response.");
            ReleaseAssert.IsTrue(serverResponse.HttpResponseCode != SuccessHttpResponseCode && serverResponse.HttpResponseCode != UnexpectedErrorHttpResponseCode,
                                 "Must not be a successful or unexpected HTTP response code.");

            object errorCodeObject = serverResponse.Body[JsonKeyErrorCode];

            ReleaseAssert.IsTrue(errorCodeObject is long, "'Code' must be a long.");

            long errorCode = (long)errorCodeObject;

            switch (errorCode)
            {
            case 1007:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 422, @"Invalid HTTP response code for error code.");
                return(Error.InvalidRequest);

            case 1013:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 401, @"Invalid HTTP response code for error code.");
                return(Error.TrialExpired);

            case 1008:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 503, @"Invalid HTTP response code for error code.");
                return(Error.TemporaryServiceError);

            case 2002:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 422, @"Invalid HTTP response code for error code.");
                return(Error.FacebookAccessTokenInvalid);

            case 1001:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 401, @"Invalid HTTP response code for error code.");
                return(Error.InvalidGameToken);

            case 1006:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 401, @"Invalid HTTP response code for error code.");
                return(Error.LoginNotFound);

            case 10001:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 429, @"Invalid HTTP response code for error code.");
                return(Error.LimitReached);

            default:
                return(Error.UnexpectedError);
            }
        }
예제 #4
0
        /// <summary>
        /// Parses the response body to get the response code.
        /// </summary>
        ///
        /// <returns>The error code in the given response body.</returns>
        ///
        /// <param name="serverResponse">The server response from which to get the error code. This
        /// must describe an successful response from the server which contains an error in the
        /// response body.</param>
        private static Error GetErrorCode(ServerResponse serverResponse)
        {
            const string JsonKeyErrorCode = "Code";

            ReleaseAssert.IsNotNull(serverResponse, "A server response must be supplied.");
            ReleaseAssert.IsTrue(serverResponse.Result == HttpResult.Success, "The result must describe a successful server response.");
            ReleaseAssert.IsTrue(serverResponse.HttpResponseCode != SuccessHttpResponseCode && serverResponse.HttpResponseCode != UnexpectedErrorHttpResponseCode,
                                 "Must not be a successful or unexpected HTTP response code.");

            object errorCodeObject = serverResponse.Body[JsonKeyErrorCode];

            ReleaseAssert.IsTrue(errorCodeObject is long, "'Code' must be a long.");

            long errorCode = (long)errorCodeObject;

            switch (errorCode)
            {
            case 1007:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 422, @"Invalid HTTP response code for error code.");
                return(Error.InvalidRequest);

            case 10002:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 429, @"Invalid HTTP response code for error code.");
                return(Error.RateLimitReached);

            case 1008:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 503, @"Invalid HTTP response code for error code.");
                return(Error.TemporaryServiceError);

            case 1003:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 401, @"Invalid HTTP response code for error code.");
                return(Error.ExpiredConnectAccessToken);

            case 1004:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 401, @"Invalid HTTP response code for error code.");
                return(Error.InvalidConnectAccessToken);

            case 1011:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 403, @"Invalid HTTP response code for error code.");
                return(Error.MethodDisabled);

            case 6002:
                ReleaseAssert.IsTrue(serverResponse.HttpResponseCode == 401, @"Invalid HTTP response code for error code.");
                return(Error.PlayerContextNotSet);

            default:
                return(Error.UnexpectedError);
            }
        }
예제 #5
0
        /// <summary>
        /// Initialises a new instance of the request with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        /// <param name="connectAccessToken">A valid session ConnectAccessToken obtained through one of the login endpoints.</param>
        /// <param name="serverUrl">The server url for this call.</param>
        public GetScoresForFacebookFriendsRequest(GetScoresForFacebookFriendsRequestDesc desc, string connectAccessToken, string serverUrl)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Key, "Key cannot be null.");

            ReleaseAssert.IsNotNull(connectAccessToken, "Connect Access Token cannot be null.");

            Key                = desc.Key;
            IncludeMe          = desc.IncludeMe;
            ConnectAccessToken = connectAccessToken;

            Url = serverUrl + "/1.0/leaderboard/scores/facebook";
            HttpRequestMethod = HttpRequestMethod.Post;
        }
예제 #6
0
        /// <summary>
        /// Initialises the response with the given json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the JSON data.</param>
        public LinkGoogleAccountResponse(IDictionary <string, object> jsonDictionary)
        {
            ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null.");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("ChilliConnectID"), "Json is missing required field 'ChilliConnectID'");

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Chilli Connect Id
                if (entry.Key == "ChilliConnectID")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    ChilliConnectId = (string)entry.Value;
                }
            }
        }
예제 #7
0
        internal static unsafe NodesHealthEvaluation FromNative(IntPtr nativeHealthEvaluationValuePtr)
        {
            ReleaseAssert.AssertIf(nativeHealthEvaluationValuePtr == IntPtr.Zero, string.Format(CultureInfo.CurrentCulture, StringResources.Error_NativeDataNull_Formatted, "nativeHealthEvaluationValue"));
            var nativeHealthEvaluation = *(NativeTypes.FABRIC_NODES_HEALTH_EVALUATION *)nativeHealthEvaluationValuePtr;

            var managedHealthEvaluation = new NodesHealthEvaluation();

            managedHealthEvaluation.Description              = NativeTypes.FromNativeString(nativeHealthEvaluation.Description);
            managedHealthEvaluation.AggregatedHealthState    = (HealthState)nativeHealthEvaluation.AggregatedHealthState;
            managedHealthEvaluation.UnhealthyEvaluations     = HealthEvaluation.FromNativeList(nativeHealthEvaluation.UnhealthyEvaluations);
            managedHealthEvaluation.TotalCount               = (long)nativeHealthEvaluation.TotalCount;
            managedHealthEvaluation.MaxPercentUnhealthyNodes = nativeHealthEvaluation.MaxPercentUnhealthyNodes;

            return(managedHealthEvaluation);
        }
        /// <summary>
        /// Initialises a new instance of the request with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        /// <param name="connectAccessToken">A valid session ConnectAccessToken obtained through one of the login endpoints.</param>
        public RemoveInventoryItemRequest(RemoveInventoryItemRequestDesc desc, string connectAccessToken)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.ItemId, "ItemId cannot be null.");

            ReleaseAssert.IsNotNull(connectAccessToken, "Connect Access Token cannot be null.");

            ItemId             = desc.ItemId;
            WriteLock          = desc.WriteLock;
            ConnectAccessToken = connectAccessToken;

            Url = "https://connect.chilliconnect.com/1.0/economy/inventory/remove";
            HttpRequestMethod = HttpRequestMethod.Post;
        }
        internal static unsafe ContainerDeactivationArgs CreateFromNative(IntPtr nativePtr)
        {
            ReleaseAssert.AssertIfNot(nativePtr != IntPtr.Zero, "ContainerDeactivationArgs.CreateFromNative() has null pointer.");

            var nativeArgs = *((NativeTypes.FABRIC_CONTAINER_DEACTIVATION_ARGS *)nativePtr);

            return(new ContainerDeactivationArgs
            {
                ContainerName = NativeTypes.FromNativeString(nativeArgs.ContainerName),
                ConfiguredForAutoRemove = NativeTypes.FromBOOLEAN(nativeArgs.ConfiguredForAutoRemove),
                IsContainerRoot = NativeTypes.FromBOOLEAN(nativeArgs.IsContainerRoot),
                CgroupName = NativeTypes.FromNativeString(nativeArgs.CgroupName),
                IsGracefulDeactivation = NativeTypes.FromBOOLEAN(nativeArgs.IsGracefulDeactivation)
            });
        }
        /// <summary>
        /// Initialises the response with the given json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the JSON data.</param>
        public SetPlayerDataResponse(IDictionary <string, object> jsonDictionary)
        {
            ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null.");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("WriteLock"), "Json is missing required field 'WriteLock'");

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Write Lock
                if (entry.Key == "WriteLock")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    WriteLock = (string)entry.Value;
                }
            }
        }
        public IEnumerable <Task> StartProcessing(CancellationToken token)
        {
            Trace.WriteInfo(TraceType, "StartProcessing called");

            ReleaseAssert.AssertIf(
                this.streamingTask != null && !this.streamingTask.IsCompleted,
                "StartProcessing should be called only once");

            this.streamingTask = this.RunStreamChannelAsync(token);

            return(new List <Task>()
            {
                this.streamingTask
            });
        }
        /// <summary>
        /// Initialises a new instance of the request with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        /// <param name="connectAccessToken">A valid session ConnectAccessToken obtained through one of the login endpoints.</param>
        /// <param name="serverUrl">The server url for this call.</param>
        public RedeemMessageRewardsRequest(RedeemMessageRewardsRequestDesc desc, string connectAccessToken, string serverUrl)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.MessageId, "MessageId cannot be null.");

            ReleaseAssert.IsNotNull(connectAccessToken, "Connect Access Token cannot be null.");

            MessageId          = desc.MessageId;
            MarkAsRead         = desc.MarkAsRead;
            ConnectAccessToken = connectAccessToken;

            Url = serverUrl + "/1.0/message/player/redeem";
            HttpRequestMethod = HttpRequestMethod.Post;
        }
        /// <summary>
        /// Initialises a new instance of the request with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        /// <param name="connectAccessToken">A valid session ConnectAccessToken obtained through one of the login endpoints.</param>
        /// <param name="serverUrl">The server url for this call.</param>
        public GetMatchTurnsRequest(GetMatchTurnsRequestDesc desc, string connectAccessToken, string serverUrl)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.MatchId, "MatchId cannot be null.");

            ReleaseAssert.IsNotNull(connectAccessToken, "Connect Access Token cannot be null.");

            MatchId            = desc.MatchId;
            SinceTurn          = desc.SinceTurn;
            ConnectAccessToken = connectAccessToken;

            Url = serverUrl + "/1.0/multiplayer/async/match/turns";
            HttpRequestMethod = HttpRequestMethod.Post;
        }
예제 #14
0
        /// <summary>
        /// Initialises a new instance of the request with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        /// <param name="connectAccessToken">A valid session ConnectAccessToken obtained through one of the login endpoints.</param>
        public GetMessageRequest(GetMessageRequestDesc desc, string connectAccessToken)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.MessageId, "MessageId cannot be null.");

            ReleaseAssert.IsNotNull(connectAccessToken, "Connect Access Token cannot be null.");

            MessageId          = desc.MessageId;
            MarkAsRead         = desc.MarkAsRead;
            ConnectAccessToken = connectAccessToken;

            Url = "https://connect.chilliconnect.com/1.0/message/player/get";
            HttpRequestMethod = HttpRequestMethod.Post;
        }
예제 #15
0
        /// <summary>
        /// Initialises a new instance from the given Json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the Json data.</param>
        public CatalogMeta(IDictionary <string, object> jsonDictionary)
        {
            ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null.");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Version"), "Json is missing required field 'Version'");

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Version
                if (entry.Key == "Version")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    Version = (string)entry.Value;
                }
            }
        }
예제 #16
0
        /// <summary>
        /// Initialises the response with the given json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the JSON data.</param>
        public StartMatchResponse(IDictionary <string, object> jsonDictionary)
        {
            ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null.");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Match"), "Json is missing required field 'Match'");

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Match
                if (entry.Key == "Match")
                {
                    ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type.");
                    Match = new Match((IDictionary <string, object>)entry.Value);
                }
            }
        }
        /// <summary>
        /// Initialises a new instance of the request with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        /// <param name="connectAccessToken">A valid session ConnectAccessToken obtained through one of the login endpoints.</param>
        public AddInventoryItemRequest(AddInventoryItemRequestDesc desc, string connectAccessToken)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Key, "Key cannot be null.");

            ReleaseAssert.IsNotNull(connectAccessToken, "Connect Access Token cannot be null.");

            Key                = desc.Key;
            InstanceData       = desc.InstanceData;
            ConnectAccessToken = connectAccessToken;

            Url = "https://connect.chilliconnect.com/1.0/economy/inventory/add";
            HttpRequestMethod = HttpRequestMethod.Post;
        }
        internal static unsafe DeployedApplicationHealthEvaluation FromNative(IntPtr nativeHealthEvaluationValuePtr)
        {
            ReleaseAssert.AssertIf(nativeHealthEvaluationValuePtr == IntPtr.Zero, string.Format(CultureInfo.CurrentCulture, StringResources.Error_NativeDataNull_Formatted, "nativeHealthEvaluationValue"));
            var nativeHealthEvaluation = *(NativeTypes.FABRIC_DEPLOYED_APPLICATION_HEALTH_EVALUATION *)nativeHealthEvaluationValuePtr;

            var managedHealthEvaluation = new DeployedApplicationHealthEvaluation();

            managedHealthEvaluation.Description           = NativeTypes.FromNativeString(nativeHealthEvaluation.Description);
            managedHealthEvaluation.AggregatedHealthState = (HealthState)nativeHealthEvaluation.AggregatedHealthState;
            managedHealthEvaluation.UnhealthyEvaluations  = HealthEvaluation.FromNativeList(nativeHealthEvaluation.UnhealthyEvaluations);
            managedHealthEvaluation.ApplicationName       = NativeTypes.FromNativeUri(nativeHealthEvaluation.ApplicationName);
            managedHealthEvaluation.NodeName = NativeTypes.FromNativeString(nativeHealthEvaluation.NodeName);

            return(managedHealthEvaluation);
        }
예제 #19
0
        /// <summary>
        /// Reads the state of this object from byte array.
        /// </summary>
        /// <param name="br">A BinaryReader object</param>
        /// <exception cref="EndOfStreamException">The end of the stream is reached. </exception>
        /// <exception cref="IOException">An I/O error occurs. </exception>
        public override void Read(BinaryReader br)
        {
            decimal objectVersion = br.ReadDecimal();

            if (objectVersion >= ChaosConstants.ApiVersion62)
            {
                this.Hour   = br.ReadInt32();
                this.Minute = br.ReadInt32();
            }
            else
            {
                TestabilityTrace.TraceSource.WriteError(TraceComponent, "Attempting to read a version of object below lowest version. Saw {0}. Expected >=6.2", objectVersion);
                ReleaseAssert.Fail("Failed to read byte serialization of ChaosScheduleTimeUtc");
            }
        }
예제 #20
0
        /// <summary>
        /// Initialises a new instance with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        public UnrealMobilePatchDefinition(UnrealMobilePatchDefinitionDesc desc)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Key, "Key cannot be null.");
            ReleaseAssert.IsNotNull(desc.Name, "Name cannot be null.");
            ReleaseAssert.IsNotNull(desc.Tags, "Tags cannot be null.");
            ReleaseAssert.IsNotNull(desc.Patches, "Patches cannot be null.");

            Key        = desc.Key;
            Name       = desc.Name;
            Tags       = Mutability.ToImmutable(desc.Tags);
            CustomData = desc.CustomData;
            Patches    = Mutability.ToImmutable(desc.Patches);
        }
예제 #21
0
        /// <summary>
        /// Initialises the response with the given json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the JSON data.</param>
        public GetMatchOutcomeAttachmentResponse(IDictionary <string, object> jsonDictionary)
        {
            ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null.");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("OutcomeAttachment"), "Json is missing required field 'OutcomeAttachment'");

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Outcome Attachment
                if (entry.Key == "OutcomeAttachment")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    OutcomeAttachment = (string)entry.Value;
                }
            }
        }
        /// <summary>
        /// Initialises a new instance with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        public MetricsEvent(MetricsEventDesc desc)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Type, "Type cannot be null.");
            ReleaseAssert.IsNotNull(desc.Date, "Date cannot be null.");

            Type = desc.Type;
            Date = desc.Date;
            if (desc.Parameters != null)
            {
                Parameters = Mutability.ToImmutable(desc.Parameters);
            }
            Count = desc.Count;
        }
예제 #23
0
        /// <summary>
        /// Initialises a new instance of the request with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        /// <param name="connectAccessToken">A valid session ConnectAccessToken obtained through one of the login endpoints.</param>
        public DeletePlayerDataRequest(DeletePlayerDataRequestDesc desc, string connectAccessToken)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Key, "Key cannot be null.");

            ReleaseAssert.IsNotNull(connectAccessToken, "Connect Access Token cannot be null.");

            Key                = desc.Key;
            WriteLock          = desc.WriteLock;
            ConnectAccessToken = connectAccessToken;

            Url = "https://connect.chilliconnect.com/1.0/data/player/delete";
            HttpRequestMethod = HttpRequestMethod.Post;
        }
예제 #24
0
        /// <summary>
        /// Initialises a new instance of the request with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        /// <param name="connectAccessToken">A valid session ConnectAccessToken obtained through one of the login endpoints.</param>
        /// <param name="serverUrl">The server url for this call.</param>
        public DeleteScoreRequest(DeleteScoreRequestDesc desc, string connectAccessToken, string serverUrl)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Key, "Key cannot be null.");

            ReleaseAssert.IsNotNull(connectAccessToken, "Connect Access Token cannot be null.");

            Key                = desc.Key;
            PartitionKey       = desc.PartitionKey;
            ConnectAccessToken = connectAccessToken;

            Url = serverUrl + "/1.0/leaderboard/scores/delete";
            HttpRequestMethod = HttpRequestMethod.Post;
        }
예제 #25
0
        /// <summary>
        /// Initialises a new instance with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        public PlayerData(PlayerDataDesc desc)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Key, "Key cannot be null.");
            ReleaseAssert.IsNotNull(desc.Value, "Value cannot be null.");
            ReleaseAssert.IsNotNull(desc.DateCreated, "DateCreated cannot be null.");
            ReleaseAssert.IsNotNull(desc.DateModified, "DateModified cannot be null.");

            Key          = desc.Key;
            Value        = desc.Value;
            WriteLock    = desc.WriteLock;
            DateCreated  = desc.DateCreated;
            DateModified = desc.DateModified;
        }
예제 #26
0
        /// <summary>
        /// Initialises a new instance with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        public ConversionDefinition(ConversionDefinitionDesc desc)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Key, "Key cannot be null.");
            ReleaseAssert.IsNotNull(desc.Name, "Name cannot be null.");
            ReleaseAssert.IsNotNull(desc.Tags, "Tags cannot be null.");
            ReleaseAssert.IsNotNull(desc.Rules, "Rules cannot be null.");

            Key        = desc.Key;
            Name       = desc.Name;
            Tags       = Mutability.ToImmutable(desc.Tags);
            CustomData = desc.CustomData;
            Rules      = Mutability.ToImmutable(desc.Rules);
        }
예제 #27
0
        /// <summary>
        /// Initialises a new instance of the request with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        /// <param name="connectAccessToken">A valid session ConnectAccessToken obtained through one of the login endpoints.</param>
        public GetPlayerDataForFacebookFriendsRequest(GetPlayerDataForFacebookFriendsRequestDesc desc, string connectAccessToken)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Key, "Key cannot be null.");

            ReleaseAssert.IsNotNull(connectAccessToken, "Connect Access Token cannot be null.");

            Key                = desc.Key;
            IncludeMe          = desc.IncludeMe;
            ConnectAccessToken = connectAccessToken;

            Url = "https://connect.chilliconnect.com/1.0/data/player/get/facebook";
            HttpRequestMethod = HttpRequestMethod.Post;
        }
예제 #28
0
        internal static unsafe ReplicaHealthEvaluation FromNative(IntPtr nativeHealthEvaluationValuePtr)
        {
            ReleaseAssert.AssertIf(nativeHealthEvaluationValuePtr == IntPtr.Zero, string.Format(CultureInfo.CurrentCulture, StringResources.Error_NativeDataNull_Formatted, "nativeHealthEvaluationValue"));
            var nativeHealthEvaluation = *(NativeTypes.FABRIC_REPLICA_HEALTH_EVALUATION *)nativeHealthEvaluationValuePtr;

            var managedHealthEvaluation = new ReplicaHealthEvaluation();

            managedHealthEvaluation.Description           = NativeTypes.FromNativeString(nativeHealthEvaluation.Description);
            managedHealthEvaluation.AggregatedHealthState = (HealthState)nativeHealthEvaluation.AggregatedHealthState;
            managedHealthEvaluation.UnhealthyEvaluations  = HealthEvaluation.FromNativeList(nativeHealthEvaluation.UnhealthyEvaluations);
            managedHealthEvaluation.PartitionId           = nativeHealthEvaluation.PartitionId;
            managedHealthEvaluation.ReplicaOrInstanceId   = nativeHealthEvaluation.ReplicaOrInstanceId;

            return(managedHealthEvaluation);
        }
예제 #29
0
        /// <summary>
        /// Initialises a new instance of the request with the given properties.
        /// </summary>
        ///
        /// <param name="userId">ID that uniquely identifies this player. This ID should not clash with any other
        /// player and should persist across Sessions.</param>
        /// <param name="appVersion">The version of your game from which the Session was started.</param>
        /// <param name="gameToken">The GameToken.</param>
        public StartSessionRequest(string userId, string appVersion, string gameToken)
        {
            ReleaseAssert.IsNotNull(userId, "User Id cannot be null.");
            ReleaseAssert.IsNotNull(appVersion, "App Version cannot be null.");

            ReleaseAssert.IsNotNull(gameToken, "Game Token cannot be null.");

            UserId     = userId;
            AppVersion = appVersion;
            GameToken  = gameToken;
            Date       = DateTime.Now;

            Url = "https://metrics.chilliconnect.com/1.0/session/start";
            HttpRequestMethod = HttpRequestMethod.Post;
        }
예제 #30
0
        /// <summary>
        /// Initialises the response with the given json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the JSON data.</param>
        public GetPlayerDataAttachmentForChilliConnectIdResponse(IDictionary <string, object> jsonDictionary)
        {
            ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null.");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Attachment"), "Json is missing required field 'Attachment'");

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Attachment
                if (entry.Key == "Attachment")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    Attachment = (string)entry.Value;
                }
            }
        }