예제 #1
0
        static ReceiveReplyDesigner()
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();
            Type receiveType = typeof(ReceiveReply);


            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CorrelationInitializers"), PropertyValueEditor.CreateEditorAttribute(typeof(CorrelationInitializerValueEditor)));

            var categoryAttribute = new CategoryAttribute(EditorCategoryTemplateDictionary.Instance.GetCategoryTitle(CorrelationsCategoryLabelKey));

            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CorrelationInitializers"), categoryAttribute, BrowsableAttribute.Yes,
                                        PropertyValueEditor.CreateEditorAttribute(typeof(CorrelationInitializerValueEditor)));

            categoryAttribute = new CategoryAttribute(EditorCategoryTemplateDictionary.Instance.GetCategoryTitle(MiscellaneousCategoryLabelKey));

            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("DisplayName"), categoryAttribute);
            var descriptionAttribute = new DescriptionAttribute(StringResourceDictionary.Instance.GetString("messagingValueHint", "<Value to bind>"));

            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("Content"), categoryAttribute, descriptionAttribute, PropertyValueEditor.CreateEditorAttribute(typeof(ReceiveContentPropertyEditor)));
            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("Request"),
                                        categoryAttribute,
                                        PropertyValueEditor.CreateEditorAttribute(typeof(ActivityXRefPropertyEditor)));

            var advancedAttribute = new EditorBrowsableAttribute(EditorBrowsableState.Advanced);

            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("Action"), advancedAttribute, categoryAttribute);

            Action = receiveType.GetProperty("Action").Name;

            Type receiveMessageContentType = typeof(ReceiveMessageContent);

            Message             = receiveMessageContentType.GetProperty("Message").Name;
            DeclaredMessageType = receiveMessageContentType.GetProperty("DeclaredMessageType").Name;
            MetadataStore.AddAttributeTable(builder.CreateTable());

            Func <Activity, IEnumerable <ArgumentAccessor> > argumentAccessorGenerator = (activity) => new ArgumentAccessor[]
            {
                new ArgumentAccessor
                {
                    Getter = (ownerActivity) =>
                    {
                        ReceiveReply          receiveReply = (ReceiveReply)ownerActivity;
                        ReceiveMessageContent content      = receiveReply.Content as ReceiveMessageContent;
                        return(content != null ? content.Message : null);
                    },
                    Setter = (ownerActivity, arg) =>
                    {
                        ReceiveReply          receiveReply = (ReceiveReply)ownerActivity;
                        ReceiveMessageContent content      = receiveReply.Content as ReceiveMessageContent;
                        if (content != null)
                        {
                            content.Message = arg as OutArgument;
                        }
                    },
                },
            };

            ActivityArgumentHelper.RegisterAccessorsGenerator(receiveType, argumentAccessorGenerator);
        }
예제 #2
0
 void OnModelItemPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (string.Equals(e.PropertyName, Message))
     {
         ReceiveMessageContent messageContent = ((Receive)this.ModelItem.GetCurrentValue()).Content as ReceiveMessageContent;
         this.ModelItem.Properties[DeclaredMessageType].SetValue(null == messageContent ? null : messageContent.Message.ArgumentType);
     }
 }
        public override IList <string> Convert(object value)
        {
            List <string>         results = new List <string>();
            ReceiveMessageContent content = value as ReceiveMessageContent;

            if (null != content)
            {
                results.AddRange(new ArgumentSearchableStringConverter().Convert(content.Message));
                results.AddRange(new TypeSearchableStringConverter().Convert(content.DeclaredMessageType));
            }
            return(results);
        }
예제 #4
0
        static ReceiveDesigner()
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();
            Type receiveType = typeof(Receive);

            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CorrelationInitializers"), PropertyValueEditor.CreateEditorAttribute(typeof(CorrelationInitializerValueEditor)));

            var categoryAttribute    = new CategoryAttribute(EditorCategoryTemplateDictionary.Instance.GetCategoryTitle(CorrelationsCategoryLabelKey));
            var descriptionAttribute = new DescriptionAttribute(StringResourceDictionary.Instance.GetString("messagingCorrelatesWithHint", "<Correlation handle>"));

            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CorrelatesWith"), categoryAttribute, descriptionAttribute);

            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CorrelatesOn"), categoryAttribute, BrowsableAttribute.Yes,
                                        PropertyValueEditor.CreateEditorAttribute(typeof(CorrelatesOnValueEditor)));
            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CorrelationInitializers"), categoryAttribute, BrowsableAttribute.Yes,
                                        PropertyValueEditor.CreateEditorAttribute(typeof(CorrelationInitializerValueEditor)));

            categoryAttribute = new CategoryAttribute(EditorCategoryTemplateDictionary.Instance.GetCategoryTitle(MiscellaneousCategoryLabelKey));
            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("DisplayName"), categoryAttribute);
            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("OperationName"), categoryAttribute);
            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("ServiceContractName"), categoryAttribute, new TypeConverterAttribute(typeof(XNameConverter)));
            descriptionAttribute = new DescriptionAttribute(StringResourceDictionary.Instance.GetString("messagingValueHint", "<Value to bind>"));
            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("Content"), categoryAttribute, descriptionAttribute, PropertyValueEditor.CreateEditorAttribute(typeof(ReceiveContentPropertyEditor)));

            var advancedAttribute = new EditorBrowsableAttribute(EditorBrowsableState.Advanced);

            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("Action"), advancedAttribute, categoryAttribute);
            builder.AddCustomAttributes(
                receiveType,
                "KnownTypes",
                advancedAttribute,
                categoryAttribute,
                PropertyValueEditor.CreateEditorAttribute(typeof(TypeCollectionPropertyEditor)),
                new EditorOptionAttribute {
                Name = TypeCollectionPropertyEditor.AllowDuplicate, Value = false
            });

            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("ProtectionLevel"), advancedAttribute, categoryAttribute);
            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("SerializerOption"), advancedAttribute, categoryAttribute);
            builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CanCreateInstance"), advancedAttribute, categoryAttribute);

            Action = receiveType.GetProperty("Action").Name;

            Type receiveMessageContentType = typeof(ReceiveMessageContent);

            Message             = receiveMessageContentType.GetProperty("Message").Name;
            DeclaredMessageType = receiveMessageContentType.GetProperty("DeclaredMessageType").Name;
            MetadataStore.AddAttributeTable(builder.CreateTable());

            Func <Activity, IEnumerable <ArgumentAccessor> > argumentAccessorGenerator = (activity) => new ArgumentAccessor[]
            {
                new ArgumentAccessor
                {
                    Getter = (ownerActivity) =>
                    {
                        Receive receive = (Receive)ownerActivity;
                        ReceiveMessageContent content = receive.Content as ReceiveMessageContent;
                        return(content != null ? content.Message : null);
                    },
                    Setter = (ownerActivity, arg) =>
                    {
                        Receive receive = (Receive)ownerActivity;
                        ReceiveMessageContent content = receive.Content as ReceiveMessageContent;
                        if (content != null)
                        {
                            content.Message = arg as OutArgument;
                        }
                    },
                },
            };

            ActivityArgumentHelper.RegisterAccessorsGenerator(receiveType, argumentAccessorGenerator);
        }