Ejemplo n.º 1
0
        public ExchangeSnapInHelper(NamespaceSnapInBase snapIn, IExchangeSnapIn exchangeSnapIn)
        {
            this.snapIn                   = snapIn;
            this.exchangeSnapIn           = exchangeSnapIn;
            Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
            Application.EnableVisualStyles();
            this.snapInName = this.snapIn.GetType().Name;
            try
            {
                Thread.CurrentThread.Name = this.snapInName;
            }
            catch (InvalidOperationException)
            {
            }
            SynchronizationContext synchronizationContext = new SynchronizeInvokeSynchronizationContext(this.snapIn);

            SynchronizationContext.SetSynchronizationContext(synchronizationContext);
            ManagementGUICommon.RegisterAssembly(0, "Microsoft.Exchange.ManagementGUI, Version=15.00.0000.000, Culture=neutral, PublicKeyToken=31bf3856ad364e35", "ObjectPickerSchema.xml");
            ManagementGUICommon.RegisterAssembly(1, "Microsoft.Exchange.ManagementGUI, Version=15.00.0000.000, Culture=neutral, PublicKeyToken=31bf3856ad364e35", "ResultPaneSchema.xml");
            ManagementGUICommon.RegisterAssembly(2, "Microsoft.Exchange.ManagementGUI, Version=15.00.0000.000, Culture=neutral, PublicKeyToken=31bf3856ad364e35", "StrongTypeEditorSchema.xml");
            Assembly assembly = Assembly.Load("Microsoft.Exchange.ManagementGUI, Version=15.00.0000.000, Culture=neutral, PublicKeyToken=31bf3856ad364e35");

            ManagementGUICommon.RegisterResourcesAssembly(ExchangeResourceManager.GetResourceManager("Microsoft.Exchange.ManagementGUI.Resources.Strings", assembly), ExchangeResourceManager.GetResourceManager("Microsoft.Exchange.ManagementGUI.Resources.Icons", assembly));
            this.uiService        = new UIService(null);
            this.settingsProvider = new ExchangeSettingsProvider();
            this.services         = new ServiceContainer();
            this.services.AddService(typeof(IUIService), this.uiService);
            this.services.AddService(typeof(SynchronizationContext), synchronizationContext);
            this.services.AddService(typeof(ISettingsProviderService), this.settingsProvider);
            this.components = new ServicedContainer(this.services);
            this.LoadTestStub();
        }
Ejemplo n.º 2
0
        private static string FromEnum(Type enumType, object value, ExchangeResourceManager resourceManager)
        {
            string result = null;

            if (resourceManager != null)
            {
                string   text  = LocalizedDescriptionAttribute.Enum2LocStringId(enumType, value);
                string[] array = text.ToString().Split(new char[]
                {
                    ','
                });
                StringBuilder stringBuilder = new StringBuilder();
                int           i;
                for (i = 0; i < array.Length; i++)
                {
                    string @string = resourceManager.GetString(array[i].Trim());
                    if (@string == null)
                    {
                        throw new InvalidOperationException(string.Format("failed to find locstring id={0}. This string is used as LocDescription of {1} value in enum type {2}", array[i], value, enumType.FullName));
                    }
                    if (i != 0)
                    {
                        stringBuilder.Append(", ");
                    }
                    stringBuilder.Append(@string);
                }
                if (i == array.Length)
                {
                    result = stringBuilder.ToString();
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
 public static void AddType(Type type, ExchangeResourceManager resourceManager, bool isForOwaOption = false)
 {
     if (isForOwaOption)
     {
         LocalizedDescriptionAttribute.enumType2ResourceManagerTableForOwaOption.Add(type, resourceManager);
         return;
     }
     LocalizedDescriptionAttribute.enumType2ResourceManagerTable.Add(type, resourceManager);
 }
Ejemplo n.º 4
0
 public static ExchangeResourceManager GetResourceManager(string baseName, System.Reflection.Assembly assembly)
 {
     if (null == assembly)
         throw new System.ArgumentNullException(nameof(assembly));
     var key = baseName + assembly.GetName()
                                  .Name;
     lock (resourceManagers) {
         ExchangeResourceManager local_1 = null;
         if (!resourceManagers.TryGetValue(key, out local_1)) {
             local_1 = new ExchangeResourceManager(baseName, assembly);
             resourceManagers.Add(key, local_1);
         }
         return local_1;
     }
 }
Ejemplo n.º 5
0
 public static Util.PreferedCultureSelector GetPreferedCultureSelector(ExchangeResourceManager resourceManager)
 {
     Util.PreferedCultureSelector result;
     lock (Util.PreferedCultureSelector.preferedCultureSelectorCache)
     {
         Util.PreferedCultureSelector preferedCultureSelector;
         if (!Util.PreferedCultureSelector.preferedCultureSelectorCache.TryGetValue(resourceManager, out preferedCultureSelector))
         {
             preferedCultureSelector = new Util.PreferedCultureSelector(resourceManager);
             Util.PreferedCultureSelector.preferedCultureSelectorCache[resourceManager] = preferedCultureSelector;
         }
         result = preferedCultureSelector;
     }
     return(result);
 }
Ejemplo n.º 6
0
 private PreferedCultureSelector(ExchangeResourceManager resourceManager)
 {
     this.resourceManager = resourceManager;
 }