Exemple #1
0
 internal MessagePropertyDescription(MessagePropertyDescription other)
     : base(other)
 {
 }
Exemple #2
0
        public static MessageDescription CreateMessageDescription(
            Type messageType, string defaultNamespace, string action, bool isRequest, bool isCallback, MessageContractAttribute mca)
        {
            MessageDescription md = new MessageDescription(action, isRequest ^ isCallback ? MessageDirection.Input : MessageDirection.Output)
            {
                IsRequest = isRequest
            };

            md.MessageType = MessageFilterOutByRef(messageType);
            if (mca.HasProtectionLevel)
            {
                md.ProtectionLevel = mca.ProtectionLevel;
            }

            MessageBodyDescription mb = md.Body;

            if (mca.IsWrapped)
            {
                mb.WrapperName      = mca.WrapperName ?? messageType.Name;
                mb.WrapperNamespace = mca.WrapperNamespace ?? defaultNamespace;
            }

            int index = 0;

            foreach (MemberInfo bmi in messageType.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
            {
                Type   mtype = null;
                string mname = null;
                if (bmi is FieldInfo)
                {
                    FieldInfo fi = (FieldInfo)bmi;
                    mtype = fi.FieldType;
                    mname = fi.Name;
                }
                else if (bmi is PropertyInfo)
                {
                    PropertyInfo pi = (PropertyInfo)bmi;
                    mtype = pi.PropertyType;
                    mname = pi.Name;
                }
                else
                {
                    continue;
                }

                var mha = bmi.GetCustomAttribute <MessageHeaderAttribute> (false);
                if (mha != null)
                {
                    var pd = CreateHeaderDescription(mha, mname, defaultNamespace);
                    pd.Type       = MessageFilterOutByRef(mtype);
                    pd.MemberInfo = bmi;
                    md.Headers.Add(pd);
                }
                var mpa = bmi.GetCustomAttribute <MessagePropertyAttribute> (false);
                if (mpa != null)
                {
                    var pd = new MessagePropertyDescription(mpa.Name ?? mname);
                    pd.Type       = MessageFilterOutByRef(mtype);
                    pd.MemberInfo = bmi;
                    md.Properties.Add(pd);
                }
                var mba = GetMessageBodyMemberAttribute(bmi);
                if (mba != null)
                {
                    var pd = CreatePartCore(mba, mname, defaultNamespace);
                    if (pd.Index <= 0)
                    {
                        pd.Index = index++;
                    }
                    pd.Type       = MessageFilterOutByRef(mtype);
                    pd.MemberInfo = bmi;
                    mb.Parts.Add(pd);
                }
            }

            return(md);
        }
 internal MessagePropertyDescription(MessagePropertyDescription other)
     : base(other)
 {
 }