Changeset 210


Ignore:
Timestamp:
Feb 4, 2009, 8:59:54 PM (13 years ago)
Author:
Thomas Schmid
Message:
  • added exception handling to PluginBase
Location:
trunk
Files:
4 added
2 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPluginBase/CrypPluginBase.csproj

    r162 r210  
    102102    <Compile Include="IPlugin.cs" />
    103103    <Compile Include="ISettings.cs" />
     104    <Compile Include="Resources\Resource.Designer.cs">
     105      <AutoGen>True</AutoGen>
     106      <DesignTime>True</DesignTime>
     107      <DependentUpon>Resource.resx</DependentUpon>
     108    </Compile>
    104109    <Compile Include="Tool\ITool.cs" />
    105110    <Compile Include="IO\IInput.cs" />
     
    121126    </ProjectReference>
    122127  </ItemGroup>
     128  <ItemGroup>
     129    <EmbeddedResource Include="Resources\Resource.resx">
     130      <Generator>PublicResXFileCodeGenerator</Generator>
     131      <LastGenOutput>Resource.Designer.cs</LastGenOutput>
     132    </EmbeddedResource>
     133  </ItemGroup>
    123134  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
    124135  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • trunk/CrypPluginBase/PluginExtension.cs

    r4 r210  
    210210using System.Windows.Documents;
    211211using System.Windows.Markup;
     212using Cryptool.PluginBase.Miscellaneous;
     213using Cryptool.PluginBase.Resources;
    212214
    213215namespace Cryptool.PluginBase
     
    215217    public static class PluginExtension
    216218    {
     219        public static event GuiLogNotificationEventHandler OnGuiLogNotificationOccured;
     220
     221        private static void GuiLogMessage(string message, NotificationLevel logLevel)
     222        {
     223          EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, null, new GuiLogEventArgs(message, null, logLevel));
     224        }
     225
    217226        /// <summary>
    218227        /// Gets the properties marked with the PropertyInfoAttribute.
     
    353362            return img;
    354363          }
    355           catch { return null; }
     364          catch (Exception exception)
     365          {
     366            if (type != null)
     367              GuiLogMessage(string.Format(Resource.plugin_extension_error_get_image, new object[] { type.Name, exception.Message }), NotificationLevel.Error);
     368            else
     369              GuiLogMessage(exception.Message, NotificationLevel.Error);
     370            return null;
     371          }
    356372        }
    357373
     
    365381            return (FlowDocument)xaml.LoadAsync(Application.GetResourceStream(new Uri(string.Format("pack://application:,,,/{0};component/{1}", description.Substring(0, sIndex), description.Substring(sIndex + 1)))).Stream);
    366382          }
    367           catch { return null; }
     383          catch (Exception exception)
     384          {
     385            if (plugin != null)
     386              GuiLogMessage(string.Format(Resource.plugin_extension_error_get_description, new object[] { plugin.GetType().Name, exception.Message }), NotificationLevel.Error);
     387            else
     388              GuiLogMessage(exception.Message, NotificationLevel.Error);
     389            return null;
     390          }
    368391        }
    369392
    370393        public static IPlugin CreateObject(this Type type)
    371394        {
    372             if (type.GetInterface(typeof(IPlugin).Name) != null)
    373                 try {
    374                     return (IPlugin)Activator.CreateInstance(type);
    375                 } catch (Exception e) {
    376                     //needs some work to return error messages etc
    377                     return null;
    378                 }
    379             return null;
     395          if (type.GetInterface(typeof(IPlugin).Name) != null)
     396          {
     397            try
     398            {
     399              return (IPlugin)Activator.CreateInstance(type);
     400            }
     401            catch (Exception exception)
     402            {
     403              if (type != null)
     404                GuiLogMessage(string.Format(Resource.plugin_extension_error_get_description, new object[] { type.Name, exception.Message }), NotificationLevel.Error);
     405              else
     406                GuiLogMessage(exception.Message, NotificationLevel.Error);
     407              return null;
     408            }
     409          }
     410          return null;
    380411        }
    381412    }
  • trunk/CrypPlugins/AES/AES.cs

    r125 r210  
    222222{
    223223    [Author("Dr. Arno Wacker", "arno.wacker@cryptool.org", "Uni Duisburg", "http://www.uni-duisburg-essen.de")]
    224     [PluginInfo(false, "AES", "Advanced Encryption Standard (Rijndael)", "AES/DetailedDescription/Description.xaml", "AES/Images/AES.png", "AES/Images/encrypt.png", "AES/Images/decrypt.png", "AES/Rijndael.png")]
     224  [PluginInfo(false, "AES", "Advanced Encryption Standard (Rijndael)", "AES/DetailedDescription/Description.xaml", "AES/Images/AES.png", "AES/Images/encrypt.png", "AES/Images/decrypt.png", "AES/Images/Rijndael.png")]
    225225    [EncryptionType(EncryptionType.SymmetricBlock)]   
    226226    public class AES : ContextBoundObject, IEncryption
  • trunk/CrypPlugins/AES/AES.csproj

    r18 r210  
    7171  </ItemGroup>
    7272  <ItemGroup>
    73     <Resource Include="AES.png" />
    74   </ItemGroup>
    75   <ItemGroup>
    7673    <Resource Include="Images\decrypt.png" />
    7774    <Resource Include="Images\encrypt.png" />
     
    8481  </ItemGroup>
    8582  <ItemGroup>
    86     <Resource Include="Rijndael.png" />
     83    <Resource Include="Images\Rijndael.png" />
    8784  </ItemGroup>
    8885  <ItemGroup>
  • trunk/CrypPlugins/AES/DetailedDescription/Description.xaml

    r4 r210  
    22              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    33              Background="White">
    4   <Paragraph>
    5     <Run FontWeight="Bold" FontSize="18.6666666666667" xml:lang="de-de">
    6       <Run.TextDecorations>
    7         <TextDecoration Location="Underline" />
    8       </Run.TextDecorations> AES
    9     </Run>
    10   </Paragraph>
    11   <Paragraph>
    12     <Run FontSize="14.6666666666667" xml:lang="de-de">In cryptography, the Advanced Encryption Standard (AES), also known as Rijndael, is a block cipher adopted as an encryption standard by the U.S. government. It has been analyzed extensively and is now used worldwide, as was the case with its predecessor, the Data Encryption Standard (DES). AES was announced by National Institute of Standards and Technology (NIST) as U.S. FIPS PUB 197 (FIPS 197) on November 26, 2001 after a 5-year standardization process (see Advanced Encryption Standard process for more details). It became effective as a standard May 26, 2002. As of 2006, AES is one of the most popular algorithms used in symmetric key cryptography.  This marks the first time that the public has had access to a cipher approved by NSA for top secret information.\n\nStrictly speaking, AES is not precisely Rijndael (although in practice they are used interchangeably) as Rijndael supports a larger range of block and key sizes; AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits, whereas Rijndael can be specified with key and block sizes in any multiple of 32 bits, with a minimum of 128 bits and a maximum of 256 bits.</Run>
    13   </Paragraph>
     4    <Paragraph>
     5        <Run FontWeight="Bold" FontSize="18.6666666666667" xml:lang="de-de">
     6            <Run.TextDecorations>
     7                <TextDecoration Location="Underline" />
     8            </Run.TextDecorations> AES
     9        </Run>
     10    </Paragraph>
     11    <Paragraph>
     12        <Run FontSize="14.6666666666667" xml:lang="de-de">In cryptography, the Advanced Encryption Standard (AES), also known as Rijndael, is a block cipher adopted as an encryption standard by the U.S. government. It has been analyzed extensively and is now used worldwide, as was the case with its predecessor, the Data Encryption Standard (DES). AES was announced by National Institute of Standards and Technology (NIST) as U.S. FIPS PUB 197 (FIPS 197) on November 26, 2001 after a 5-year standardization process (see Advanced Encryption Standard process for more details). It became effective as a standard May 26, 2002. As of 2006, AES is one of the most popular algorithms used in symmetric key cryptography.  This marks the first time that the public has had access to a cipher approved by NSA for top secret information.\n\nStrictly speaking, AES is not precisely Rijndael (although in practice they are used interchangeably) as Rijndael supports a larger range of block and key sizes; AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits, whereas Rijndael can be specified with key and block sizes in any multiple of 32 bits, with a minimum of 128 bits and a maximum of 256 bits.</Run>
     13    </Paragraph>
    1414</FlowDocument>
Note: See TracChangeset for help on using the changeset viewer.