Example #1
0
 public void Cancelled(CancelledCallback cancelled)
 {
     if (cancelled == null)
     {
         return;
     }
     lock (_guard)
     {
         if (IsCompleted)
         {
             if (State == PromiseState.Cancelled)
             {
                 cancelled(_exception as CancelledException);
             }
         }
         else
         {
             _rejected += (ex, s) => {
                 var cancel = ex as CancelledException;
                 if (cancel != null)
                 {
                     cancelled(cancel);
                 }
             };
         }
     }
 }
Example #2
0
        public static ELCraftBrowser Spawn(ELCraftType type, string profile, SelectFileCallback onFileSelected, CancelledCallback onCancel, bool showMergeOption)
        {
            if (prefab == null)
            {
                CreatePrefab();
            }

            var cb = Instantiate(prefab).GetComponent <ELCraftBrowser> ();

            cb.transform.SetParent(DialogCanvasUtil.DialogCanvasRect, false);

            cb.facility          = craftFacility[(int)type];
            cb.showMergeOption   = showMergeOption;
            cb.OnBrowseCancelled = onCancel;
            cb.OnFileSelected    = onFileSelected;
            cb.title             = "Select a craft to load";
            cb.profile           = profile;

            return(cb);
        }
        public static ELCraftBrowser Spawn(ELCraftType type, string profile, SelectFileCallback onFileSelected, CancelledCallback onCancel, bool showMergeOption)
        {
            if (prefab == null)
            {
                CreatePrefab();
            }

            var cb = Instantiate(prefab).GetComponent <ELCraftBrowser> ();

            cb.enabled = true;
            cb.transform.SetParent(DialogCanvasUtil.DialogCanvasRect, false);

            cb.facility          = craftFacility[(int)type];
            cb.showMergeOption   = showMergeOption;
            cb.OnBrowseCancelled = onCancel;
            cb.onFileSelected    = onFileSelected;
            if (onConfigNodeSelected != null)
            {
                var callback = Delegate.CreateDelegate(onConfigNodeSelected.FieldType, cb, typeof(ELCraftBrowser).GetMethod("selCB", bindingFlags));
                onConfigNodeSelected.SetValue(cb, callback);
            }
            else
            {
                cb.OnFileSelected = onFileSelected;
            }
            cb.title   = "Select a craft to load";
            cb.profile = profile;

            return(cb);
        }