private void AppBarButton_PreviewMouseLeftButtonDown(object sender, RoutedEventArgs e)
 {
     Button button = sender as Button;
     if (button == null || IsActionConfirmationRequired == false || ConfirmationActionCommand == null)
         return;
     const string defaultMessage = "Do you really want to {0}";
     string confirmationPopUpMessage = string.IsNullOrEmpty(ActionConfirmationMessage)
       ? DebugFormat.Format(defaultMessage, button.Content)
       : ActionConfirmationMessage;
     ConfirmationDailogDetails confirmationDailogDetails = new ConfirmationDailogDetails
     {
         Message = confirmationPopUpMessage,
         ActionName = button.Content.ToString(),
         Template = button.Template,
         ActionCommand = ConfirmationActionCommand
     };
     **//instead of ConfirmationActionCommand want to use base.Command**
    ConfirmationDailog dialog = new ConfirmationDailog(confirmationDailogDetails)
    {
        PlacementTarget = button,
        IsOpen = true
    };
     //validation here
     dialog.ShowDialog();
     var confirmed = dialog.IsConfirmed;
     e.Handled = confirmed;
 }
        private void Print(NodePin node, TextWriter output, int depth, DebugFormat format)
        {
            bool   formatted = format != DebugFormat.Compact;
            string prefix    = formatted ? Environment.NewLine + new String(' ', depth << 1) : "";

            output.Write("{0}{{", formatted ? " " : "");
            if (formatted)
            {
                prefix += "  ";
            }

            for (int i = 0; i < node.Ptr.Count; i++)
            {
                if (i > 0 || node.Ptr[i].IsValue)
                {
                    output.Write("{0}{1}", prefix, node.Ptr[i].Key);
                }
                if (formatted && node.Ptr.IsLeaf)
                {
                    output.Write(" = {0}", node.Ptr[i].Payload);
                }
                if (format == DebugFormat.Full)
                {
                    output.Write(" (IsLeaf={0})", node.Ptr.IsLeaf);
                    output.Write(" (Count={0})", node.Ptr.Count);
                }

                if (node.Ptr[i].IsNode)
                {
                    using (NodePin child = _storage.Lock(node, node.Ptr[i].ChildNode))
                    {
                        Print(child, output, depth + 1, format);
#if DEBUG
                        if (format == DebugFormat.Full)
                        {
                            try { Validate(child, node, i, 1); }
                            catch (Exception ex)
                            {
                                output.WriteLine();
                                output.WriteLine("{0} Error = {1}", prefix, ex.Message);
                            }
                        }
#endif
                    }
                }
                else if (formatted)
                {
                    output.Write("={0}", node.Ptr[i].Payload);
                }
                if (i + 1 < node.Ptr.Count)
                {
                    output.Write(',');
                }
            }
            if (formatted)
            {
                prefix = prefix.Substring(0, prefix.Length - 2);
            }
            output.Write("{0}}}", prefix);
        }
예제 #3
0
 private Action <V> TryCatchAction <V>                               (Action <V> action, Component component = null)
 {
     return(x =>
     {
         try { action(x); }
         catch (Exception e) { DebugFormat.LogException(component, e); }
     });
 }
예제 #4
0
 public static void            DeleteAllSaves()
 {
     DebugFormat.Log <Saver <T> >($"path: {PERSISTANT_DATA_PATH}");
     if (Directory.Exists(PERSISTANT_DATA_PATH))
     {
         Directory.Delete(PERSISTANT_DATA_PATH, true);
     }
 }
 public void SaveAsyncDelayed()
 {
     if (saver == null)
     {
         DebugFormat.LogError(this, "Saver is not initialized!");
     }
     saver.data = PrepeareDataBeforeSave(Data);
     saver.SaveAsyncDelayed();
     onSaveStarted.OnNext(Data);
 }
예제 #6
0
    protected override void OnAfterClick()
    {
        base.OnAfterClick();

        if (autoSwitchStates && isAcceptMode.Value == acceptStateBeforeClick)
        {
            DebugFormat.Log(this, "Auto switch");
            isAcceptMode.Value = !isAcceptMode.Value;
        }
    }
예제 #7
0
 protected override void                                    OnDataLoaded(SaveData data)
 {
     DebugFormat.Log(this);
     Data = new SaveData()
     {
         accessToken  = data.accessToken,
         refreshToken = data.refreshToken
     };
     AccessTokenHeader = Data.accessToken;
 }
예제 #8
0
 protected virtual bool Open(T unit)
 {
     if (IsOpen)
     {
         return(Open());
     }
     DebugFormat.Log(this, gameObject.name);
     ((Subject <T>)OnOpen).OnNext(lastUnit = unit);
     return(Open());
 }
 public T Load()
 {
     if (saver == null)
     {
         DebugFormat.LogError(this, "Saver is not initialized!");
     }
     Data = PrepareData(saver.Load());
     NotifyLoadingDataListeners(loadingDataListeners, Data);
     return(Data);
 }
예제 #10
0
    public DebugRequestEvents(CompositeDisposable compositeDisposable, Request <T> request, int id) : base()
    {
#if UNITY_EDITOR
        OnSuccess.Subscribe(x => DebugFormat.Log <Request <T> >($"[{request.RESTMethod}] {id} - OnSuccess\n\n{JsonConvert.SerializeObject(x, Formatting.Indented)}\n", deep: DEEP)).AddTo(compositeDisposable);
        OnSuccessRaw.Subscribe(x => DebugFormat.Log <Request <T> >($"[{request.RESTMethod}] {id} - OnSuccessRaw\n\n{Request<T>.JsonPrettify(x)}\n", deep: DEEP)).AddTo(compositeDisposable);
#endif
        OnSerializationError.Subscribe(x => DebugFormat.LogError <Request <T> >($"[{request.RESTMethod}] {id} - OnSerializationError: {x}", deep: DEEP)).AddTo(compositeDisposable);
        OnHttpError.Subscribe(x => DebugFormat.LogError <Request <T> >($"[{request.RESTMethod}] {id} - OnHttpError\n\n {JsonConvert.SerializeObject(x, Formatting.Indented)}\n", deep: DEEP)).AddTo(compositeDisposable);
        OnHttpErrorRaw.Subscribe(x => DebugFormat.LogError <Request <T> >($"[{request.RESTMethod}] {id} - OnHttpErrorRaw\n\n{x}\n", deep: DEEP)).AddTo(compositeDisposable);
        OnNetworkError.Subscribe(x => DebugFormat.LogError <Request <T> >($"[{request.RESTMethod}] {id} - OnNetworkError\n\n {JsonConvert.SerializeObject(x, Formatting.Indented)}\n", deep: DEEP)).AddTo(compositeDisposable);
    }
예제 #11
0
    protected override void                                    OnEnable()
    {
        AccessTokenHeader = null;

        base.OnEnable();
        DebugFormat.Log(this);

        compositeDisposable.Clear();
        GlobalEvents.OnHttpError.Where(httpError => httpError.httpResponseCode == AccessTokenExpiredCode)
        .Subscribe(httpError => SetToken(null, null))
        .AddTo(compositeDisposable);
    }
 public Task LoadAsync()
 {
     if (saver == null)
     {
         DebugFormat.LogError(this, "Saver is not initialized!");
     }
     return(saver.LoadAsync(task =>
     {
         Data = PrepareData(saver.data);
         NotifyLoadingDataListeners(loadingDataListeners, Data);
     }));
 }
예제 #13
0
    protected virtual void Close(T unit)
    {
        if (!IsOpen)
        {
            Close();
            return;
        }

        Close();
        DebugFormat.Log(this, gameObject.name);
        ((Subject <T>)OnClose).OnNext(lastUnit);
        lastUnit = null;
    }
예제 #14
0
    protected override UnityWebRequest CreateUnityWebRequest(string endpoint)
    {
        var json     = JsonConvert.SerializeObject(data);
        var byteData = Encoding.UTF8.GetBytes(json);

#if UNITY_EDITOR
        try                                             { DebugFormat.Log <RequestPost <T1, T2> >($"JSON {RESTMethod}:\n\n{JsonPrettify(json)}\n"); }
        catch (Exception e)             { DebugFormat.Log <RequestPost <T1, T2> >($"JSON {RESTMethod}:\n\n{json}\n"); }
#endif

        return(new UnityWebRequest(endpoint)
        {
            method = RESTMethod,
            uploadHandler = new UploadHandlerRaw(byteData),
            downloadHandler = new DownloadHandlerBuffer()
        });
    }
예제 #15
0
    public async UniTask                                                 SendRequest()
    {
        UnityWebRequest unityRequest = null;

        try
        {
            unityRequest = CreateUnityWebRequest(RequestURL);

            await PrepeareRequest(unityRequest);

            await unityRequest.SendWebRequest();
        }
        catch (Exception e) { }
        finally
        {
            try
            {
                await RequestPostprocessing(unityRequest);

                if (unityRequest.result == UnityWebRequest.Result.ConnectionError)
                {
                    await ProcessNetworkError(unityRequest);
                }
                if (unityRequest.result == UnityWebRequest.Result.ProtocolError)
                {
                    await ProcessHttpError(unityRequest);
                }
                if (unityRequest.isDone && unityRequest.result == UnityWebRequest.Result.Success)
                {
                    var json = GetJSON(unityRequest);
                    ResponseRawData = json;
                    Events.SendSuccessRaw(json);

                    var data = FromJSON <T>(unityRequest);
                    await OnDataReceived(data);

                    Events.SendSuccess(data);
                }
            }
            catch (Exception e2)
            {
                DebugFormat.LogException <Request <T> >(e2);
            }
        }
    }
예제 #16
0
    public async UniTask <Request <T> > SendRequest <T>          (Request <T> request)
    {
        var compositeDisposable = request.Events.Subscribe(GlobalEvents);

        if (debug)
        {
            var id = Request <T> .IncrementalID;

            DebugFormat.Log(this, $"[{request.RESTMethod}] {id} - {request.RequestURL}", this);
            if (debugHeaders)
            {
                var headers = request.GetHeaders();
                foreach (var key in headers.Keys)
                {
                    DebugFormat.Log(this, $"Header {key} : {headers[key]}");
                }
            }
            var debugEvents = new DebugRequestEvents <T>(compositeDisposable, request, id);
            compositeDisposable.Add(request.Events.Subscribe(debugEvents));
        }

        await request.SendRequest();

        if (debug && debugHeaders && request.LastUnityRequest != null)
        {
            if (debugHeaders)
            {
                var headers = request.LastUnityRequest.GetResponseHeaders();
                foreach (var key in headers.Keys)
                {
                    DebugFormat.Log(this, $"Response Header {key} : {headers[key]}");
                }
            }
        }
        compositeDisposable.Dispose();
        return(request);

#if UNITY_EDITOR && ZENJECT
        if (!Application.isPlaying && Zenject.ProjectContext.HasInstance)
        {
            DestroyImmediate(Zenject.ProjectContext.Instance.gameObject);
        }
#endif
    }
예제 #17
0
    protected virtual K                                                               FromJSON <K>                                             (UnityWebRequest unityRequest)
    {
        string json = null;

        try
        {
            json = GetJSON(unityRequest);
            var result = JsonConvert.DeserializeObject <K>(json, jsonSerializerSettings);
            return(result);
        }
        catch (Exception e)
        {
            Events.SendSerializationError(e.Message);
            DebugFormat.LogException <Request <T> >(e);

            try                                     { DebugFormat.LogError(this, $"JSON ({typeof(K).Name}):\n\n{JsonPrettify(json)}\n"); }
            catch (Exception e2) { DebugFormat.LogError(this, $"JSON ({typeof(K).Name}):\n\n{json}\n"); }
        }
        return(default(K));
    }
 public void Print(TextWriter output, DebugFormat format)
 {
     using (RootLock root = LockRoot(LockType.Read, "Print", true))
         Print(root.Pin, output, 0, format);
 }
예제 #19
0
 protected virtual void OnHideAnimationCompleted()
 {
     DebugFormat.Log(this);
     gameObject.SetActive(false);
 }
예제 #20
0
 protected virtual void OnShowAnimationCompleted()
 {
     DebugFormat.Log(this);
 }