Exemplo n.º 1
0
 internal static string MapNameToOID(string name, OidGroup oidGroup)
 {
   if (name == null)
     throw new ArgumentNullException("name");
   CryptoConfig.InitializeConfigInfo();
   string str = (string) null;
   lock (CryptoConfig.InternalSyncObject)
     str = CryptoConfig.appOidHT.GetValueOrDefault(name);
   if (str == null)
     str = CryptoConfig.machineOidHT.GetValueOrDefault(name);
   if (str == null)
     str = CryptoConfig.DefaultOidHT.GetValueOrDefault(name);
   if (str == null)
     str = X509Utils.GetOidFromFriendlyName(name, oidGroup);
   return str;
 }
Exemplo n.º 2
0
 public static object CreateFromName(string name, params object[] args)
 {
   if (name == null)
     throw new ArgumentNullException("name");
   Type type = (Type) null;
   CryptoConfig.InitializeConfigInfo();
   lock (CryptoConfig.InternalSyncObject)
     type = CryptoConfig.appNameHT.GetValueOrDefault(name);
   if (type == (Type) null)
   {
     string valueOrDefault = CryptoConfig.machineNameHT.GetValueOrDefault(name);
     if (valueOrDefault != null)
     {
       type = Type.GetType(valueOrDefault, false, false);
       if (type != (Type) null && !type.IsVisible)
         type = (Type) null;
     }
   }
   if (type == (Type) null)
   {
     object valueOrDefault = CryptoConfig.DefaultNameHT.GetValueOrDefault(name);
     if (valueOrDefault != null)
     {
       if (valueOrDefault is Type)
         type = (Type) valueOrDefault;
       else if (valueOrDefault is string)
       {
         type = Type.GetType((string) valueOrDefault, false, false);
         if (type != (Type) null && !type.IsVisible)
           type = (Type) null;
       }
     }
   }
   if (type == (Type) null)
   {
     type = Type.GetType(name, false, false);
     if (type != (Type) null && !type.IsVisible)
       type = (Type) null;
   }
   if (type == (Type) null)
     return (object) null;
   RuntimeType runtimeType = type as RuntimeType;
   if (runtimeType == (RuntimeType) null)
     return (object) null;
   if (args == null)
     args = new object[0];
   MethodBase[] methodBaseArray = (MethodBase[]) runtimeType.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance);
   if (methodBaseArray == null)
     return (object) null;
   List<MethodBase> methodBaseList = new List<MethodBase>();
   for (int index = 0; index < methodBaseArray.Length; ++index)
   {
     MethodBase methodBase = methodBaseArray[index];
     if (methodBase.GetParameters().Length == args.Length)
       methodBaseList.Add(methodBase);
   }
   if (methodBaseList.Count == 0)
     return (object) null;
   object state;
   RuntimeConstructorInfo runtimeConstructorInfo = Type.DefaultBinder.BindToMethod(BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance, methodBaseList.ToArray(), ref args, (ParameterModifier[]) null, (CultureInfo) null, (string[]) null, out state) as RuntimeConstructorInfo;
   if ((ConstructorInfo) runtimeConstructorInfo == (ConstructorInfo) null || typeof (Delegate).IsAssignableFrom(runtimeConstructorInfo.DeclaringType))
     return (object) null;
   object obj = runtimeConstructorInfo.Invoke(BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance, Type.DefaultBinder, args, (CultureInfo) null);
   if (state == null)
     return obj;
   Type.DefaultBinder.ReorderArgumentArray(ref args, state);
   return obj;
 }