source: trunk/CrypPlugins/LengthOf/LengthOf.cs @ 1378

Last change on this file since 1378 was 777, checked in by Matthäus Wander, 12 years ago
  • enabled more generic usage of ArrayIndexer and LengthOf
  • added ArrayIndexer, HMAC, LengthOf to setup
File size: 4.5 KB
Line 
1/*
2   Copyright 2009 Christian Arnold, Uni Duisburg-Essen
3
4   Licensed under the Apache License, Version 2.0 (the "License");
5   you may not use this file except in compliance with the License.
6   You may obtain a copy of the License at
7
8       http://www.apache.org/licenses/LICENSE-2.0
9
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15*/
16using System;
17using System.Collections.Generic;
18using System.Linq;
19using System.Text;
20using Cryptool;
21using Cryptool.PluginBase.IO;
22using Cryptool.PluginBase;
23using Cryptool.PluginBase.Miscellaneous;
24using System.ComponentModel;
25
26// This PlugIn accepts every type. For arrays the number of elements is written.
27// For everything else the number of characters of the object's string representation is shown.
28namespace Cryptool.Plugins.LengthOf
29{
30    [Author("Christian Arnold", "christian.arnold@stud.uni-due.de", "Uni Duisburg-Essen", "http://www.uni-due.de")]
31    [PluginInfo(false, "LengthOf", "Operates the Length of an input", "", "LengthOf/LenOf.png")]
32    public class LengthOf : IThroughput
33    {
34        private LengthOfSettings settings = new LengthOfSettings();
35
36        private object objInput = null;
37        private int outputLen = 0;
38
39        #region IPlugin Members
40
41        public void Execute()
42        {
43            if (ObjInput != null)
44            {
45                if (ObjInput is Array)
46                {
47                    OutputLen = (ObjInput as Array).Length;
48                    GuiLogMessage("Object is an array. Length: " + OutputLen, NotificationLevel.Debug);
49                }
50                else //no array
51                {
52                    OutputLen = ObjInput.ToString().Length;
53                    GuiLogMessage("Object isn't an array. Length: " + OutputLen, NotificationLevel.Debug);
54                }
55            }
56        }
57
58        [PropertyInfo(Direction.InputData, "Object Input", "Input your Object here", "", true, false, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
59        public object ObjInput
60        {
61            get
62            {
63                return objInput;
64            }
65            set
66            {
67                this.objInput = value;
68                OnPropertyChanged("ObjInput");
69            }
70        }
71
72        [PropertyInfo(Direction.OutputData, "Integer Output", "The Length of your Object will be send here", "", DisplayLevel.Beginner)]
73        public int OutputLen
74        {
75            get
76            {
77                return outputLen;
78            }
79            set
80            {
81                this.outputLen = value;
82                OnPropertyChanged("OutputLen");
83            }
84        }
85
86        public void Dispose()
87        {
88        }
89
90        public void Initialize()
91        {
92        }
93
94        public event GuiLogNotificationEventHandler OnGuiLogNotificationOccured;
95
96        public event PluginProgressChangedEventHandler OnPluginProgressChanged;
97        public event StatusChangedEventHandler OnPluginStatusChanged;
98
99        public void Pause()
100        {
101        }
102
103        public void PostExecution()
104        {
105        }
106
107        public void PreExecution()
108        {
109        }
110
111        public System.Windows.Controls.UserControl Presentation
112        {
113            get { return null; }
114        }
115
116        public System.Windows.Controls.UserControl QuickWatchPresentation
117        {
118            get { return null; }
119        }
120
121        public Cryptool.PluginBase.ISettings Settings
122        {
123            get { return this.settings; }
124            set { this.settings = (LengthOfSettings)value; }
125        }
126
127        public void Stop()
128        {
129
130        }
131
132        #endregion
133
134        #region INotifyPropertyChanged Members
135
136        public event PropertyChangedEventHandler PropertyChanged;
137
138        public void OnPropertyChanged(string name)
139        {
140            EventsHelper.PropertyChanged(PropertyChanged, this, new PropertyChangedEventArgs(name));
141        }
142
143        private void GuiLogMessage(string p, NotificationLevel notificationLevel)
144        {
145            EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(p, this, notificationLevel));
146        }
147        #endregion
148    }
149}
Note: See TracBrowser for help on using the repository browser.