Ejemplo n.º 1
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            checkSelfSkipping = EditorGUILayout.Toggle("Check self is skipping?", checkSelfSkipping);
            if (checkSelfSkipping)
            {
                return;
            }

            listSource = (ListSource)EditorGUILayout.EnumPopup("Source:", listSource);
            if (listSource == ListSource.InScene)
            {
                parameterID = Action.ChooseParameterGUI("ActionList:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    actionList = null;
                }
                else
                {
                    actionList = (ActionList)EditorGUILayout.ObjectField("ActionList:", actionList, typeof(ActionList), true);

                    constantID = FieldToID <ActionList> (actionList, constantID);
                    actionList = IDToField <ActionList> (actionList, constantID, true);
                }
            }
            else if (listSource == ListSource.AssetFile)
            {
                actionListAsset = (ActionListAsset)EditorGUILayout.ObjectField("ActionList asset:", actionListAsset, typeof(ActionListAsset), true);
            }
        }
Ejemplo n.º 2
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            listSource = (ListSource)EditorGUILayout.EnumPopup("Source:", listSource);
            if (listSource == ListSource.InScene)
            {
                parameterID = Action.ChooseParameterGUI("ActionList:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    actionList = null;
                }
                else
                {
                    actionList = (ActionList)EditorGUILayout.ObjectField("ActionList:", actionList, typeof(ActionList), true);

                    constantID = FieldToID <ActionList> (actionList, constantID);
                    actionList = IDToField <ActionList> (actionList, constantID, true);
                }
            }
            else if (listSource == ListSource.AssetFile)
            {
                invActionList = (ActionListAsset)EditorGUILayout.ObjectField("ActionList asset:", invActionList, typeof(ActionListAsset), true);
                if (invActionList != null && invActionList.canRunMultipleInstances)
                {
                    killAllInstances = EditorGUILayout.Toggle("Kill all instances?", killAllInstances);
                }
            }

            AfterRunningOption();
        }
Ejemplo n.º 3
0
        public bool Insert <T>(List <WACParameter> parms, WACValidator.InsertValidateDelegate <T> vDel)
        {
            bool result = false;
            T    item   = default(T);

            parms.Add(new WACParameter("created_by", UserName, WACParameter.ParameterType.Property));
            try
            {
                item = vDel(parms);
                item = ((IWACDataProvider <T>)DataProvider).Insert(item);
                ListSource.SetCurrentItem <T>(item, ((IWACDataProvider <T>)DataProvider).GetPrimaryKey);
                ListSource.VList.Clear();
                result = true;
            }
            catch (WACEX_ValidationException wex)
            {
                WACAlert.Show("Insert failed, validation error: " + wex.ErrorText + " In " + this.ToString() + ".Insert", 0);
            }
            catch (WACEX_GeneralDatabaseException gex)
            {
                WACAlert.Show("Insert failed: " + gex.ErrorText + " In " + this.ToString() + ".Insert", gex.ErrorCode);
            }
            catch (Exception ex)
            {
                WACAlert.Show("Insert failed: " + ex.Message + " In " + this.ToString() + ".Insert", 0);
            }
            return(result);
        }
Ejemplo n.º 4
0
        public bool Update <T>(List <WACParameter> parms, WACValidator.UpdateValidateDelegate <T> vDel)
        {
            bool result = false;
            T    item   = default(T);

            parms.Add(new WACParameter("modified_by", UserName));
            parms.Add(new WACParameter("modified", DateTime.Now));
            try
            {
                item = vDel(parms, (T)ListSource.GetCurrentItem());
                ListSource.RemoveItemFromViewlist <T>(item);
                ((IWACDataProvider <T>)DataProvider).Update(item);
                ListSource.SetCurrentItem <T>(item, ((IWACDataProvider <T>)DataProvider).GetPrimaryKey);
                result = true;
            }
            catch (WACEX_ValidationException wex)
            {
                WACAlert.Show("Update failed, validation error: " + wex.ErrorText + " In " + this.ToString() + ".Update", 0);
            }
            catch (WACEX_GeneralDatabaseException gex)
            {
                WACAlert.Show("Update failed: " + gex.ErrorText + " In " + this.ToString() + ".Update", gex.ErrorCode);
            }
            catch (Exception ex)
            {
                WACAlert.Show("Update failed: " + ex.Message + " In " + this.ToString() + ".Update", 0);
            }
            return(result);
        }
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            listSource = (ListSource)EditorGUILayout.EnumPopup("Source:", listSource);
            if (listSource == ListSource.InScene)
            {
                parameterID = Action.ChooseParameterGUI("ActionList:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    actionList = null;
                }
                else
                {
                    actionList = (ActionList)EditorGUILayout.ObjectField("ActionList:", actionList, typeof(ActionList), true);

                    constantID = FieldToID <ActionList> (actionList, constantID);
                    actionList = IDToField <ActionList> (actionList, constantID, true);
                }
            }
            else if (listSource == ListSource.AssetFile)
            {
                invActionList = (ActionListAsset)EditorGUILayout.ObjectField("ActionList asset:", invActionList, typeof(ActionListAsset), true);
            }


            AfterRunningOption();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets the filter value control.
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="filterMode">The filter mode.</param>
        /// <returns></returns>
        public override Control FilterValueControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode)
        {
            var ddlList = new RockDropDownList();

            ddlList.ID = string.Format("{0}_ddlList", id);
            ddlList.AddCssClass("js-filter-control");

            if (!required)
            {
                ddlList.Items.Add(new ListItem());
            }

            if (ListSource.Any())
            {
                foreach (var item in ListSource)
                {
                    ListItem listItem = new ListItem(item.Value, item.Key);
                    ddlList.Items.Add(listItem);
                }

                return(ddlList);
            }

            return(null);
        }
Ejemplo n.º 7
0
 public KvintOut(ListSource source, string marka, string paramName, int cardId, int paramNo) : base(source)
 {
     _marka     = marka;
     _paramName = paramName;
     _cardId    = cardId;
     _paramNo   = paramNo;
 }
Ejemplo n.º 8
0
        public void ReturnToViewMode(WACFormControl form)
        {
            FormView fv = WACGlobal_Methods.FindControl <FormView>(form);

            fv.ChangeMode(FormViewMode.ReadOnly);
            fv.DataSource = ListSource.GetSingleItemList();
            fv.DataBind();
            ShowModal(form, true);
            ContentStateChanged(form);
        }
Ejemplo n.º 9
0
        public void SortGridView(GridView gv, List <WACParameter> parms)
        {
            string srt           = WACParameter.GetParameterValue(parms, WACParameter.ParameterType.ListSort) as string;
            string sortDirection = ToggleSortDirection(srt);

            sortExpression = srt;
            IList sorted = ListSource.GetSortedList(DataProvider.SortedList, sortExpression, sortDirection);

            BindGridView(gv, sorted);
        }
Ejemplo n.º 10
0
 public void BindFormView(FormView fv, List <WACParameter> parms, MasterDetailDataObject.ItemGetterDelegate _getItem)
 {
     try
     {
         fv.DataKeyNames = ListSource.DataKeyNames;
         fv.DataSource   = ListSource.GetSingleItemList(parms, _getItem);
         fv.DataBind();
     }
     catch (Exception ex) { WACAlert.Show(ex.Message + " In " + this.ToString() + ".BindFormView", 0); }
 }
Ejemplo n.º 11
0
        public void ListSourceConstructor()
        {
            tlog.Debug(tag, $"ListSourceConstructor START");

            var testingTarget = new ListSource();

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <ListSource>(testingTarget, "should be an instance of testing target class!");

            testingTarget.Dispose();
            tlog.Debug(tag, $"ListSourceConstructor END (OK)");
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 更新实体
 /// </summary>
 /// <param name="entity">实体对象</param>
 public void Update(object entity)
 {
     if (this.DataSource != null && this.DataSource is IList)
     {
         int index = ListSource.IndexOf(entity);
         if (index >= 0)
         {
             ListSource[index] = entity;
             View.RefreshRow(View.GetRowHandle(index));
         }
     }
 }
Ejemplo n.º 13
0
 // Choose previous object on list
 public void PreviousOnList()
 {
     if (TargetIndex == 0)
     {
         TargetIndex = TotalObjNum;
     }
     TargetIndex      = TargetIndex - 1;
     TargetPosition   = TargetObjects [TargetIndex].transform.position;
     ListSource       = TargetObjects [TargetIndex].gameObject.GetComponent <AudioSource> ();
     ListSource.pitch = Math.Max(1.5f - 0.5f * (float)Math.Log10(TargetDistance + 1f), 0.5f);
     ListSource.Play();
 }
Ejemplo n.º 14
0
        public void ListSourceConstructorWithEnumerableObject()
        {
            tlog.Debug(tag, $"ListSourceConstructorWithEnumerableObject START");

            IEnumerable <string> para = new List <string>();
            var testingTarget         = new ListSource(para);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <ListSource>(testingTarget, "should be an instance of testing target class!");

            testingTarget.Dispose();
            tlog.Debug(tag, $"ListSourceConstructorWithEnumerableObject END (OK)");
        }
Ejemplo n.º 15
0
        public override void Insert(WACFormControl wfc, FormView fv, List <WACParameter> parms)
        {
            WACParameter masterKey = ListSource.MasterKey;

            parms.Add(new WACParameter("fk_taxParcel", masterKey.ParmValue, WACParameter.ParameterType.Property));
            if (base.Insert <TaxParcelOwner>(parms, TaxParcelOwnerValidator.ValidateInsert))
            {
                parms.Clear();
                parms.Add(new WACParameter(string.Empty, WACFormControl.FormState.ItemInserted, WACParameter.ParameterType.FormState));
                parms.Add(masterKey);
                ListSource.SetCurrentItem <TaxParcelOwner>(null, null);
                wfc.StateChanged(parms);
            }
        }
Ejemplo n.º 16
0
        public void ListSourceSyncRoot()
        {
            tlog.Debug(tag, $"ListSourceSyncRoot START");

            var para          = new TestEnumerable();
            var testingTarget = new ListSource(para);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <ListSource>(testingTarget, "should be an instance of testing target class!");
            Assert.IsNotNull(testingTarget.SyncRoot, "SyncRoot of ListSouce should not be null.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"ListSourceSyncRoot END (OK)");
        }
Ejemplo n.º 17
0
        public void ListSourceCount()
        {
            tlog.Debug(tag, $"ListSourceCount START");

            var para          = new TestEnumerable();
            var testingTarget = new ListSource(para);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <ListSource>(testingTarget, "should be an instance of testing target class!");
            Assert.AreEqual(testingTarget.Count, 3, "Count of ListSouce should be equal to 3.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"ListSourceCount END (OK)");
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Formats the filter value value.
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public override string FormatFilterValueValue(Dictionary <string, ConfigurationValue> configurationValues, string value)
        {
            var values = new List <string>();

            foreach (string key in value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (ListSource.ContainsKey(key))
                {
                    values.Add(ListSource[key]);
                }
            }

            return(AddQuotes(values.ToList().AsDelimited("' OR '")));
        }
Ejemplo n.º 19
0
        public void ListSourceGetItem()
        {
            tlog.Debug(tag, $"ListSourceGetItem START");

            var para          = new TestEnumerable();
            var testingTarget = new ListSource(para);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <ListSource>(testingTarget, "should be an instance of testing target class!");
            Assert.AreEqual(testingTarget.GetItem(0), 1, "The value of the first item of ListSouce should be 1.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"ListSourceGetItem END (OK)");
        }
Ejemplo n.º 20
0
 public virtual void OpenFormViewUpdate(WACFormControl form, List <WACParameter> parms)
 {
     if (UserAuthorized("Update", AuthorizationArea))
     {
         FormView fv = WACGlobal_Methods.FindControl <FormView>(form);
         checkDependencies(fv, parms, DataProvider, ListSource);
         fv.ChangeMode(FormViewMode.Edit);
         BindFormView(fv, parms, DataProvider.GetItem);
         BindControlDDLs(fv, parms, ListSource.GetCurrentItem());
         form.CurrentState = WACFormControl.FormState.OpenUpdate;
         InitControls(form, parms);
         ShowModal(form, true);
         ContentStateChanged(form);
     }
 }
Ejemplo n.º 21
0
        public void ListSourceIsSynchronized()
        {
            tlog.Debug(tag, $"ListSourceIsSynchronized START");

            var para          = new TestEnumerable();
            var testingTarget = new ListSource(para);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <ListSource>(testingTarget, "should be an instance of testing target class!");

            tlog.Debug(tag, "IsSynchronized : " + testingTarget.IsSynchronized);

            testingTarget.Dispose();
            tlog.Debug(tag, $"ListSourceIsSynchronized END (OK)");
        }
        /// <summary>
        /// Permet de supprimer un enregistrement de la grille de données.
        /// </summary>
        /// <param name="obj"></param>
        private void FonctionEraseDelegate(object obj)
        {
            if (IsLoading == Visibility.Visible)
            {
                ShowMessageBox.Show(TYPE_WINDOW_BOX.AVERTISSEMENT, messLoading, "");
            }
            else
            {
                this.Mode = MODE_COMPOSANT_REFERENTIIEL.ERASE;

                BLL.Remove(CurrentElement as IDTO);
                ListSource.Remove(CurrentElement as IDTO);

                this.Mode = MODE_COMPOSANT_REFERENTIIEL.CONSULT;
            }
        }
Ejemplo n.º 23
0
        public void ListSourceIsFooter()
        {
            tlog.Debug(tag, $"ListSourceIsFooter START");

            var para          = new TestEnumerable();
            var testingTarget = new ListSource(para);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <ListSource>(testingTarget, "should be an instance of testing target class!");

            testingTarget.HasFooter = true;
            tlog.Debug(tag, "IsFooter : " + testingTarget.IsFooter(2));

            testingTarget.Dispose();
            tlog.Debug(tag, $"ListSourceIsFooter END (OK)");
        }
Ejemplo n.º 24
0
        public void ListSourceClear()
        {
            tlog.Debug(tag, $"ListSourceClear START");

            var para          = new TestEnumerable();
            var testingTarget = new ListSource(para);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <ListSource>(testingTarget, "should be an instance of testing target class!");

            testingTarget.Clear();
            Assert.AreEqual(testingTarget.Count, 0, "The ListSouce should be empty after cleared.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"ListSourceClear END (OK)");
        }
Ejemplo n.º 25
0
        public void ListSourceIsHeader()
        {
            tlog.Debug(tag, $"ListSourceIsHeader START");

            var para          = new TestEnumerable();
            var testingTarget = new ListSource(para);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <ListSource>(testingTarget, "should be an instance of testing target class!");

            testingTarget.HasHeader = true;
            Assert.IsTrue(testingTarget.IsHeader(0), "The first item of ListSouce should be header.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"ListSourceIsHeader END (OK)");
        }
Ejemplo n.º 26
0
        public void ListSourceIndexOf()
        {
            tlog.Debug(tag, $"ListSourceIndexOf START");

            var para          = new TestEnumerable();
            var testingTarget = new ListSource(para);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <ListSource>(testingTarget, "should be an instance of testing target class!");

            var ret = testingTarget.IndexOf(1);

            Assert.AreEqual(ret, 0, "The index of ListSouce should be 0.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"ListSourceIndexOf END (OK)");
        }
Ejemplo n.º 27
0
        public void ListSourceContains()
        {
            tlog.Debug(tag, $"ListSourceContains START");

            var para          = new TestEnumerable();
            var testingTarget = new ListSource(para);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <ListSource>(testingTarget, "should be an instance of testing target class!");

            var ret = testingTarget.Contains(3);

            Assert.IsTrue(ret, "The ListSouce should contain 3.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"ListSourceContains END (OK)");
        }
Ejemplo n.º 28
0
        public override void ContentStateChanged(Control listControl, Enum state)
        {
            ServiceRequest sr = new ServiceRequest(listControl);

            sr.ParmList.Add(new WACParameter(string.Empty, state, WACParameter.ParameterType.ListState));
            sr.ParmList.Add(new WACParameter(string.Empty, ListSource.RowCount().ToString(), WACParameter.ParameterType.RowCount));
            if (ListSource.SelectedKey != null)
            {
                sr.ParmList.Add(ListSource.SelectedKey);
            }
            if (ListSource.PrimaryKey != null)
            {
                sr.ParmList.Add(ListSource.PrimaryKey);
            }
            sr.ServiceRequested = ServiceFactory.ServiceTypes.ContentStateChanged;
            OnServiceRequested(listControl, new ServiceRequestEventArgs(sr));
            sr = null;
        }
Ejemplo n.º 29
0
        public void ListSourceAdd()
        {
            tlog.Debug(tag, $"ListSourceAdd START");

            var para          = new TestEnumerable();
            var testingTarget = new ListSource(para);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <ListSource>(testingTarget, "should be an instance of testing target class!");

            var ret = testingTarget.Add(4);

            Assert.AreEqual(ret, 3, "The index of ListSouce should is 3.");
            Assert.AreEqual(testingTarget.Count, 4, "The count of ListSouce should be 4.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"ListSourceAdd END (OK)");
        }
 private IEnumerable<ListSource> DoSource()
 {
     var _listS = new List<ListSource>();
     for (int i = 0; i < 1000; i++)
     {
         var s = new ListSource
         {
             First = "First" + i,
             Second = "Second" + i,
             Third = "Third" + i,
             Forth = "Forth" + i,
             Firth = "Firth" + i,
             Sixth = string.Format("Sixth{0}", i)
         };
         _listS.Add(s);
     }
     return _listS;
 }
        /// <summary>
        /// Permet d'ajouter un enregistrement à la grille de données.
        /// Dans un premier temps, la grille est vérouillé tant que l'utilisateur ne valide pas la saisie de ce nouvel enregistrement.
        /// </summary>
        /// <param name="obj"></param>
        private void FonctionAddDelegate(object obj)
        {
            if (IsLoading == Visibility.Visible)
            {
                ShowMessageBox.Show(TYPE_WINDOW_BOX.AVERTISSEMENT, messLoading, "");
            }
            else
            {
                bool flag = true;
                if (this.Mode == MODE_COMPOSANT_REFERENTIIEL.CONSULT)
                {
                    IDTO dto = BLL.CreateElement();

                    // L'observer est appelé pour mettre à jour les champs que le développeur souhaite
                    // Ex : Champs de traca (Date heure creation, modif, ...)
                    if (Client != null)
                    {
                        Client.AfterCreate(ref dto);
                    }

                    ListSource.Add(dto);
                    CurrentElement = dto;
                }
                else
                {
                    if (this.Mode == MODE_COMPOSANT_REFERENTIIEL.ADD)
                    {
                        foreach (ChampGenerique current in this.ControlChamps.CollectionChamps)
                        {
                            if (!current.IsValid)
                            {
                                flag = false;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            ShowMessageBox.Show(TYPE_WINDOW_BOX.AVERTISSEMENT, "", "La validation a échoué. Certains champs sont invalides par rapport aux contraintes définies dans la configuration.");
                        }
                    }
                }
                this.Mode = (flag ? ((this.Mode == MODE_COMPOSANT_REFERENTIIEL.CONSULT) ? MODE_COMPOSANT_REFERENTIIEL.ADD : MODE_COMPOSANT_REFERENTIIEL.CONSULT) : this.Mode);
            }
        }
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            listSource = (ListSource) EditorGUILayout.EnumPopup ("Source:", listSource);
            if (listSource == ListSource.InScene)
            {
                parameterID = Action.ChooseParameterGUI ("ActionList:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    localParameters.Clear ();
                    constantID = 0;
                    actionList = null;
                }
                else
                {
                    actionList = (ActionList) EditorGUILayout.ObjectField ("ActionList:", actionList, typeof (ActionList), true);

                    constantID = FieldToID <ActionList> (actionList, constantID);
                    actionList = IDToField <ActionList> (actionList, constantID, true);
                }

                if (actionList != null && actionList.useParameters && actionList.parameters.Count > 0)
                {
                    SetParametersGUI (actionList.parameters, parameters);
                }

                runFromStart = EditorGUILayout.Toggle ("Run from start?", runFromStart);

                if (!runFromStart)
                {
                    jumpToActionParameterID = Action.ChooseParameterGUI ("Action # to skip to:", parameters, jumpToActionParameterID, ParameterType.Integer);
                    if (jumpToActionParameterID == -1 && actionList != null && actionList.actions.Count > 1)
                    {
                        JumpToActionGUI (actionList.actions);
                    }
                }
            }
            else if (listSource == ListSource.AssetFile)
            {
                invActionList = (ActionListAsset) EditorGUILayout.ObjectField ("ActionList asset:", invActionList, typeof (ActionListAsset), true);

                if (invActionList != null && invActionList.useParameters && invActionList.parameters.Count > 0)
                {
                    SetParametersGUI (invActionList.parameters, parameters);
                }

                runFromStart = EditorGUILayout.Toggle ("Run from start?", runFromStart);

                if (!runFromStart && invActionList != null && invActionList.actions.Count > 1)
                {
                    JumpToActionGUI (invActionList.actions);
                }
            }

            if (!runInParallel)
            {
                Upgrade ();
            }

            willWait = EditorGUILayout.Toggle ("Wait until finish?", willWait);
            AfterRunningOption ();
        }
Ejemplo n.º 33
0
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            listSource = (ListSource) EditorGUILayout.EnumPopup ("Source:", listSource);
            if (listSource == ListSource.InScene)
            {
                parameterID = Action.ChooseParameterGUI ("ActionList:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    actionList = null;
                }
                else
                {
                    actionList = (ActionList) EditorGUILayout.ObjectField ("ActionList:", actionList, typeof (ActionList), true);

                    constantID = FieldToID <ActionList> (actionList, constantID);
                    actionList = IDToField <ActionList> (actionList, constantID, true);
                }
            }
            else if (listSource == ListSource.AssetFile)
            {
                actionListAsset = (ActionListAsset) EditorGUILayout.ObjectField ("ActionList asset:", actionListAsset, typeof (ActionListAsset), true);
            }
        }
Ejemplo n.º 34
0
		public void GetListTest ()
		{
			ListSource lsource = new ListSource (true);
			Stack stack = new Stack ();
			stack.Push (3);

			Assert.IsTrue (ListBindingHelper.GetList (lsource) is SimpleItem [], "#A1");
			Assert.AreEqual ("NonList", ListBindingHelper.GetList ("NonList"), "#A2");
			Assert.AreEqual (null, ListBindingHelper.GetList (null), "#A3");
			Assert.AreEqual (stack, ListBindingHelper.GetList (stack), "#A4"); // IEnumerable

			Assert.IsTrue (ListBindingHelper.GetList (lsource, String.Empty) is SimpleItem [], "#B1");
			Assert.AreEqual ("NonList", ListBindingHelper.GetList ("NonList", String.Empty), "#B2");
			Assert.AreEqual (null, ListBindingHelper.GetList (null, "DontExist"), "#B3");
			Assert.IsTrue (ListBindingHelper.GetList (lsource, null) is SimpleItem [], "#B4");

			ListContainer list_container = new ListContainer ();
			Assert.AreEqual (new object [0], ListBindingHelper.GetList (list_container, "List"), "#C1");

			// Even if IListSource.ContainsListCollection is false, we return the result of GetList ()
			lsource = new ListSource (false);
			Assert.IsTrue (ListBindingHelper.GetList (lsource) is SimpleItem [], "#D1");

			// DataMember is not if IList type
			Assert.AreEqual (new SimpleItem (), ListBindingHelper.GetList (list_container, "NonList"), "#E1");

			// List (IEnumerable)
			stack.Clear ();
			stack.Push (new SimpleItem (3));
			stack.Push (new SimpleItem (7));
			object obj = ListBindingHelper.GetList (stack, "Value");
			Assert.IsTrue (obj != null, "#F1");
			Assert.IsTrue (obj is int, "#F2");
			Assert.AreEqual (7, (int) obj, "#F3");

			// ListSource returning an IEnumerable,
			// which in turn retrieves dataMember
			obj = ListBindingHelper.GetList (lsource, "Value");
			Assert.IsTrue (obj != null, "#G1");
			Assert.IsTrue (obj is int, "#G2");
			Assert.AreEqual (0, (int)obj, "#G3");

			// Empty IEnumerable - valid property for list item type
			// Since it's empty, it needs to check whether the datamember is
			// a valid value, and thus we need the datasource to also be IList
			// Then we need a parameterized IEnumerable, which returns null.
			// *Observation: if it is empty and it doesn't implement IList,
			// it doesn't have a way to get the properties, and will throw an exc
			StringCollection str_coll = new StringCollection ();
			obj = ListBindingHelper.GetList (str_coll, "Length");
			Assert.IsNull (obj, "#H1");

			// IEnumerable that returns instances of ICustomTypeDescriptor
			// Use DataTable as source, which returns, when enumerating,
			// instances of DataRowView, which in turn implement ICustomTypeDescriptor
			DataTable table = new DataTable ();
			table.Columns.Add ("Id", typeof (int));
			table.Rows.Add (666);
			object l = ListBindingHelper.GetList (table, "Id");
			Assert.AreEqual (666, l, "#J1");

			try {
				ListBindingHelper.GetList (list_container, "DontExist");
				Assert.Fail ("#EXC1");
			} catch (ArgumentException) {
			}

			// Empty IEnumerable not implementing IList
			// Don't have a way to know whether at least datamember is valid or not.
			try {
				stack.Clear ();
				obj = ListBindingHelper.GetList (stack, "Value");
				Assert.Fail ("#EXC3");
			} catch (ArgumentException) {
			}

		}