public InfoOutput(InfoAttribute info, Type parameterType)
 {
     Info          = info;
     ParameterType = parameterType;
 }
Esempio n. 2
0
 public static ComplexInterfaceInfo ToComplexInterfaceInfo(this InfoAttribute infoAttribute, string name, Type type, bool?required = null, List <Type> seenTypes = null)
 => new ComplexInterfaceInfo(name, type, infoAttribute, required, seenTypes);
Esempio n. 3
0
 public static InfoOutput ToInfoOutput(this InfoAttribute info, Type parameterType) => new InfoOutput(info, parameterType);
Esempio n. 4
0
 public static InfoOutput ToInfoOutput(this InfoAttribute info) => new InfoOutput(info);
Esempio n. 5
0
 private static string DefaultNameGetter(TEnum value) => InfoAttribute.GetInfo(value);
Esempio n. 6
0
 public InfoOutput(InfoAttribute info)
 {
     Info = info;
 }
Esempio n. 7
0
 void DrawHelpBox(ref Rect position, InfoAttribute info)
 {
     EditorGUI.HelpBox(position, info.message, (MessageType)(int)info.type);
 }
Esempio n. 8
0
        public IActionResult AddAttribute([FromBody] InfoAttribute Vocattributes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            object          attributes = new TblAttributes();
            ErrorObject     response   = new ErrorObject();
            ResponseMessage rm         = new ResponseMessage();
            FieldErrors     error      = new FieldErrors();
            string          userName   = User.Claims.FirstOrDefault().Value;

            Vocattributes.CreateBy = userName;

            if (string.IsNullOrEmpty(Vocattributes.AttributeLabel) || string.IsNullOrEmpty(Vocattributes.AttributeType) || string.IsNullOrEmpty(Vocattributes.DataType))
            {
                List <FieldErrors> lsterror = new List <FieldErrors>();
                if (string.IsNullOrEmpty(Vocattributes.AttributeLabel))
                {
                    error.objectName = AttributeConstant.TypeAttribute;
                    error.field      = AttributeConstant.entityName;
                    error.message    = AttributeConstant.Message;
                    lsterror.Add(error);
                }
                if (string.IsNullOrEmpty(Vocattributes.AttributeType))
                {
                    error.objectName = AttributeConstant.TypeAttribute;
                    error.field      = AttributeConstant.entityType;
                    error.message    = AttributeConstant.Message;
                    lsterror.Add(error);
                }
                if (string.IsNullOrEmpty(Vocattributes.DataType))
                {
                    error.objectName = AttributeConstant.TypeAttribute;
                    error.field      = AttributeConstant.entityDataType;
                    error.message    = AttributeConstant.Message;
                    lsterror.Add(error);
                }
                rm.Title   = AttributeConstant.Title;
                rm.Message = AttributeConstant.MessageError;
                rm.Status  = AttributeConstant.statusError;
                var field = new { fieldErrors = lsterror };
                rm.fieldError = field;
                return(StatusCode(400, rm));
            }
            object objAttributes = _attributeRepository.AddAttribute(Vocattributes);
            int    code          = Convert.ToInt32(objAttributes.GetType().GetProperty(AttributeConstant.Code).GetValue(objAttributes, null));
            int    Id            = Convert.ToInt32(objAttributes.GetType().GetProperty(AttributeConstant.Id).GetValue(objAttributes, null));

            if (code == 1)
            {
                if (Id > 0)
                {
                    attributes = _attributeRepository.GetObjectAttributes(Id);
                }
                //_attributeRepository.SetStringCache(_organizationCode + AttributeConstant.Attributes_GetListAttributes, _attributeRepository.GetListAttributes(Vocattributes.ModuleParent));
                //_attributeRepository.GetStringCache(AttributeConstant.Attributes_GetListAttributes);
                var responeNew = new { TblAttributes = attributes };
                return(StatusCode(201, Newtonsoft.Json.JsonConvert.SerializeObject(responeNew)));
            }
            else if (code == 0)
            {
                response.title      = AttributeConstant.titleDuplicate;
                response.entityName = AttributeConstant.entityName;
                response.errorKey   = AttributeConstant.errorKey;
                response.status     = AttributeConstant.statusError;
                response.message    = AttributeConstant.MessageDulicateAttributename;
                return(StatusCode(400, response));
            }
            else
            {
                return(StatusCode(400));
            }
        }
Esempio n. 9
0
        public ExampleAndDesc(Type t, string name)
        {
            this.Type      = t;
            this.Name      = name;
            this.OrderCode = "";
            //var p1 = t.GetProperties();
            InfoAttribute[] exInfoList = t.GetCustomAttributes(s_infoAttrType, false) as InfoAttribute[];
            int             m          = exInfoList.Length;

            if (m > 0)
            {
                for (int n = 0; n < m; ++n)
                {
                    InfoAttribute info = exInfoList[n];
                    if (!string.IsNullOrEmpty(info.OrderCode))
                    {
                        this.OrderCode = info.OrderCode;
                    }
                    if (!string.IsNullOrEmpty(info.Description))
                    {
                        this.Description += " " + info.Description;
                    }
                    AvailableOn |= info.AvailableOn;
                }
            }
            if (AvailableOn == AvailableOn.Empty)
            {
                //if user dose not specific then
                //assume available on All
                AvailableOn |= AvailableOn.Agg | AvailableOn.GLES | AvailableOn.GdiPlus;
            }

            if (string.IsNullOrEmpty(this.Description))
            {
                this.Description = this.Name;
            }


            foreach (var property in t.GetProperties())
            {
                //1.
                var foundAttrs = property.GetCustomAttributes(s_demoConfigAttrType, true);
                if (foundAttrs.Length > 0)
                {
                    //this is configurable attrs
                    Type propertyType = property.PropertyType;
                    if (propertyType.IsClass &&
                        CreateExampleConfigGroup((DemoConfigAttribute)foundAttrs[0], property))
                    {
                        //check if config group or not
                        //if yes=> the the config group is created with CreateExampleConfigGroup()
                        //nothing to do more here

                        //else => go the another else block
                    }
                    else
                    {
                        _configList.Add(new ExampleConfigDesc((DemoConfigAttribute)foundAttrs[0], property));
                    }
                }
            }
            foreach (var met in t.GetMethods())
            {
                //only public and instance method
                if (met.IsStatic)
                {
                    continue;
                }
                if (met.DeclaringType == t)
                {
                    if (met.GetParameters().Length == 0)
                    {
                        var foundAttrs = met.GetCustomAttributes(s_demoAction, false);
                        if (foundAttrs.Length > 0)
                        {
                            //this is configurable attrs
                            _actionList.Add(new ExampleAction((DemoActionAttribute)foundAttrs[0], met));
                        }
                    }
                }
            }
            //------
            //some config is group config
            //... so extract more from that
            //------
        }
Esempio n. 10
0
 protected AttributeCommand(string[] data)
     : base(data)
 {
     this.attribute = (InfoAttribute)typeof(Weapon).GetCustomAttributes(false).First();
 }