Click here to Skip to main content
15,885,881 members
Articles / Desktop Programming / WPF

Extending Castle DynamicProxy

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
8 May 2010CPOL7 min read 25.7K   183   12  
Shows how to extend the proxy generated by this framework by using Reflection.Emit.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
using PresentationModelBase;

namespace Castle.Facilities.PresentationModelIntegration
{
    public class WpfDialogSystem : IDialogSystem
    {
        public void ShowWarning(string warning)
        {
            throw new NotImplementedException();
        }

        public void ShowWarning(string warning, string title)
        {
            throw new NotImplementedException();
        }

        public void ShowError(string error)
        {
            throw new NotImplementedException();
        }

        public void ShowError(string error, string title)
        {
            throw new NotImplementedException();
        }

        public QuestionResult AskQuestion(string question)
        {
            return AskQuestion(question, "Question");
        }

        public QuestionResult AskQuestion(string question, string title)
        {
            var result = System.Windows.MessageBox.Show(question, title, System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question);
            switch (result)
            {
                case System.Windows.MessageBoxResult.Yes:
                    return QuestionResult.Yes;
                default:
                    return QuestionResult.No;
            }
        }

        public System.IO.FileInfo ChooseFile(string title, string filter)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Title = title;
            dialog.Filter = filter;
            dialog.ShowDialog();
            if (dialog.FileName != null && dialog.FileName.Trim() != string.Empty)
                return new System.IO.FileInfo(dialog.FileName);
            return null;
        }

        public System.IO.FileInfo ChooseImage()
        {
            return ChooseImage("");
        }

        public System.IO.FileInfo ChooseImage(string title)
        {
            return ChooseFile(title, "Image Files (*.bmp, *.jpg, *.jpeg, *.png)|*.bmp;*.jpg;*.jpeg;*.png");
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Brazil Brazil
Software developer specialized in the .NET framework

Comments and Discussions