예제 #1
0
파일: IO_CRUD.cs 프로젝트: BHoM/BHoM_UI
        /*************************************/
        /**** Input Methods               ****/
        /*************************************/

        public virtual bool AddInput(int index, string name, Type type = null)
        {
            if (name == null || index < 0)
            {
                return(false);
            }

            ParamInfo match = InputParams.Find(x => x.Name == name);

            if (match != null)
            {
                match.IsSelected = true;
            }
            else
            {
                ParamInfo param = Engine.UI.Create.ParamInfo(name, type);
                InputParams.Insert(index, param);
                m_CompiledGetters.Insert(index, Engine.UI.Create.InputAccessor(m_DataAccessor.GetType(), param.DataType));
            }

            return(true);
        }
예제 #2
0
파일: SetInputs.cs 프로젝트: BHoM/BHoM_UI
        /*************************************/
        /**** Targeted Methods            ****/
        /*************************************/

        protected virtual void SetInputs(MethodBase method)
        {
            if (method == null)
            {
                InputParams = new List <ParamInfo>();
            }
            else
            {
                List <PreviousInputNamesAttribute> previousNames = method.GetCustomAttributes <PreviousInputNamesAttribute>().ToList();
                Dictionary <string, string>        descriptions  = method.InputDescriptions();
                InputParams = method.GetParameters().Select(x =>
                {
                    ParamInfo p = Engine.UI.Create.ParamInfo(x, descriptions.ContainsKey(x.Name) ? descriptions[x.Name] : "");
                    PreviousInputNamesAttribute match = previousNames.FirstOrDefault(a => a.Name == p.Name);
                    if (match != null)
                    {
                        p.Fragments.Add(new PreviousNamesFragment {
                            OldNames = match.PreviousNames
                        });
                    }
                    return(p);
                }).ToList();

                if (method is MethodInfo && !method.IsStatic)
                {
                    InputParams.Insert(0, new ParamInfo
                    {
                        Name            = method.DeclaringType.Name.ToLower(),
                        DataType        = method.DeclaringType,
                        Description     = "",
                        Kind            = ParamKind.Input,
                        HasDefaultValue = false,
                        DefaultValue    = System.DBNull.Value,
                        IsRequired      = true
                    });
                }
            }
        }