Esempio n. 1
0
        string GetSubKey <T>(Expression <Func <T, bool> > where) where T : IMQEvent
        {
            var type  = typeof(T);
            var props = TypeEventBusMetas.GetProperties(type);

            if (props == null || props.Count == 0)
            {
                return(string.Empty);
            }
            var body = where.Body as BinaryExpression;
            var dic  = new Dictionary <string, string>();

            GetMembers(body, dic);
            var sb = new StringBuilder();

            props.ForEach(e =>
            {
                if (dic.ContainsKey(e.Name))
                {
                    sb.Append(dic[e.Name]);
                    sb.Append('.');
                }
                else
                {
                    sb.Append("*.");
                }
            });
            return(sb.ToString());
        }
Esempio n. 2
0
        string GetPubKey <T>(T @event) where T : IMQEvent
        {
            var type  = @event.GetType();
            var props = TypeEventBusMetas.GetProperties(type);

            if (props == null || props.Count == 0)
            {
                return(string.Empty);
            }
            var sb = new StringBuilder();

            foreach (var p in props)
            {
                var value = p.Property.Invoke(@event);
                if (value.GetType().IsValueType)
                {
                    value = ((int)value).ToString();
                }
                sb.Append(value.ToString());
                sb.Append('.');
            }
            var key = sb.ToString();

            return(key);
        }
Esempio n. 3
0
        string GetSubKey <T>() where T : IMQEvent
        {
            var type  = typeof(T);
            var props = TypeEventBusMetas.GetProperties(type);

            if (props == null || props.Count == 0)
            {
                return(string.Empty);
            }
            return("#.");
        }