GME  13
MgaGateway.cs
Go to the documentation of this file.
00001 using System;
00002 using System.Collections.Generic;
00003 using System.Linq;
00004 using System.Text;
00005 using GME.MGA;
00006 using GME;
00007 using GME.MGA.Meta;
00008 using GME.MGA.Core;
00009 
00010 namespace GME.CSharp
00011 {
00012     class MgaGateway
00013     {
00014         public MgaGateway(IMgaProject project)
00015         {
00016             this.project = project;
00017         }
00018 
00019         public IMgaProject project = null;
00020         public IMgaTerritory territory = null;
00021 
00022         #region TRANSACTION HANDLING
00023         public void BeginTransaction(transactiontype_enum mode = transactiontype_enum.TRANSACTION_GENERAL)
00024         {
00025             project.BeginTransaction(territory, mode);
00026         }
00027 
00028         public void CommitTransaction()
00029         {
00030             if ((project.ProjectStatus & 8) != 0)
00031             {
00032                 project.CommitTransaction();
00033             }
00034         }
00035 
00036         public void AbortTransaction()
00037         {
00038             if ((project.ProjectStatus & 8) != 0)
00039             {
00040                 project.AbortTransaction();
00041             }
00042         }
00043 
00044         public delegate void voidDelegate();
00045         public void PerformInTransaction(voidDelegate d, transactiontype_enum mode = transactiontype_enum.TRANSACTION_GENERAL)
00046         {
00047             BeginTransaction(mode);
00048             try
00049             {
00050                 d();
00051                 CommitTransaction();
00052             }
00053             finally
00054             {
00055                 AbortTransaction();
00056             }
00057         }
00058         #endregion
00059         #region UTILITIES
00060         public IMgaMetaBase GetMetaByName(string name)
00061         {
00062             try
00063             {
00064                 return project.RootMeta.RootFolder.get_DefinedFCOByName(name, false) as MgaMetaFCO;
00065             }
00066 #pragma warning disable 0168
00067             catch (System.Runtime.InteropServices.COMException e)
00068             {
00069                 return project.RootMeta.RootFolder.get_DefinedFolderByName(name, false) as MgaMetaFolder;
00070             }
00071 #pragma warning restore 0168
00072         }
00073 
00074         #endregion
00075 
00076 
00077     }
00078 }