Ejemplo n.º 1
0
        private static BaseAccount Create(string name, string type, IDictionary <string, string> options, BaseAccount account)
        {
            string clazzName = "F2B.processors." + type + "Account";
            Type   clazzType = Type.GetType(clazzName);

            if (clazzType == null)
            {
                Log.Error("AccountManager::Create(" + name + ", " + type
                          + ", ...) unable to resolve account class \"" + clazzName + "\"");
            }
            else
            {
                Log.Info("AccountManager::Create(" + name + ", " + type
                         + ", ...) resolved account class \"" + clazzName + "\"");
            }

            if (typeof(ICacheAccount).IsAssignableFrom(clazzType))
            {
                ConstructorInfo ctor = clazzType.GetConstructor(
                    new[] { typeof(string), typeof(IDictionary <string, string>), typeof(ICachableAccount) });
                return((BaseAccount)ctor.Invoke(new object[] { name, options, account }));
            }
            else
            {
                ConstructorInfo ctor = clazzType.GetConstructor(
                    new[] { typeof(string), typeof(IDictionary <string, string>) });
                return((BaseAccount)ctor.Invoke(new object[] { name, options }));
            }
        }
Ejemplo n.º 2
0
Archivo: Account.cs Proyecto: vokac/F2B
        private static BaseAccount Create(string name, string type, IDictionary<string, string> options, BaseAccount account)
        {
            string clazzName = "F2B.processors." + type + "Account";
            Type clazzType = Type.GetType(clazzName);

            if (clazzType == null)
            {
                Log.Error("AccountManager::Create(" + name + ", " + type
                    + ", ...) unable to resolve account class \"" + clazzName + "\"");
            }
            else
            {
                Log.Info("AccountManager::Create(" + name + ", " + type
                    + ", ...) resolved account class \"" + clazzName + "\"");
            }

            if (typeof(ICacheAccount).IsAssignableFrom(clazzType))
            {
                ConstructorInfo ctor = clazzType.GetConstructor(
                    new[] { typeof(string), typeof(IDictionary<string, string>), typeof(ICachableAccount) });
                return (BaseAccount)ctor.Invoke(new object[] { name, options, account });
            }
            else
            {
                ConstructorInfo ctor = clazzType.GetConstructor(
                    new[] { typeof(string), typeof(IDictionary<string, string>) });
                return (BaseAccount)ctor.Invoke(new object[] { name, options });
            }
        }