Esempio n. 1
0
        public M_RecvProp(PropertyInfo prop)
        {
            EntitySendAttribute sendAtt = null;

            foreach (var att in prop.GetCustomAttributes())
            {
                if (att.GetType() != typeof(EntitySendAttribute))
                {
                    continue;
                }

                sendAtt = att as EntitySendAttribute;
                break;
            }

            Name     = prop.Name;
            Property = prop;

            PropType type;

            GetPropType(prop, out type);
            Type = type;

            if (sendAtt != null)
            {
                if (!String.IsNullOrEmpty(sendAtt.Name))
                {
                    Name = sendAtt.Name;
                }

                if (sendAtt.Flags.HasValue)
                {
                    Flags = sendAtt.Flags.Value;
                }
            }
        }
Esempio n. 2
0
        public M_SendProp(PropertyInfo prop)
        {
            EntitySendAttribute sendAtt = null;

            foreach (var att in prop.GetCustomAttributes())
            {
                if (att.GetType() != typeof(EntitySendAttribute))
                {
                    continue;
                }

                sendAtt = att as EntitySendAttribute;
                break;
            }

            Name     = prop.Name;
            Property = prop;

            PropType type;

            GetPropType(prop, out type);
            Type = type;

            switch (Type)
            {
            case PropType.DPT_Float:
            case PropType.DPT_Int:
                FieldLength = 32;
                break;

            case PropType.DPT_String:
                FieldLength = 64;
                break;
            }

            if (sendAtt != null)
            {
                if (!String.IsNullOrEmpty(sendAtt.Name))
                {
                    Name = sendAtt.Name;
                }

                if (sendAtt.Flags.HasValue)
                {
                    Flags = sendAtt.Flags.Value;
                }

                if (sendAtt.FloatMin.HasValue)
                {
                    FloatMin = sendAtt.FloatMin.Value;
                }

                if (sendAtt.FloatMax.HasValue)
                {
                    FloatMax = sendAtt.FloatMax.Value;
                }

                if (sendAtt.FieldLength.HasValue)
                {
                    FieldLength = sendAtt.FieldLength.Value;
                }
            }
        }