~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/mono-addins/Samples/TextEditor/TextEditorLib/OpenFileCondition.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
using System;
 
3
using System.IO;
 
4
using Mono.Addins;
 
5
 
 
6
namespace TextEditor
 
7
{
 
8
        public class OpenFileCondition: ConditionType
 
9
        {
 
10
                public OpenFileCondition ()
 
11
                {
 
12
                        // It's important to notify changes in the status of a condition,
 
13
                        // to make sure the extension points are properly updated.
 
14
                        TextEditorApp.OpenFileChanged += delegate {
 
15
                                NotifyChanged ();
 
16
                        };
 
17
                }
 
18
                
 
19
                public override bool Evaluate (NodeElement conditionNode)
 
20
                {
 
21
                        // Get the required extension value from an attribute,
 
22
                        // and check againts the extension of the currently open document
 
23
                        string val = conditionNode.GetAttribute ("extension");
 
24
                        if (val.Length > 0) {
 
25
                                string ext = Path.GetExtension (TextEditorApp.OpenFileName);
 
26
                                foreach (string requiredExtension in val.Split (','))
 
27
                                        if (ext == "." + requiredExtension)
 
28
                                                return true;
 
29
                        }
 
30
                        return false;
 
31
                }
 
32
        }
 
33
}