Пример #1
0
        public IntellectSecurityProxy()
        {
            byte[] assembly = (byte[])AppDomain.CurrentDomain.GetData("Intellect");

            var loadedAssembly = Assembly.Load(assembly);

            var types = loadedAssembly.GetTypes();
            var type  = types.First(x => x.GetInterface("IBeingInterface") != null);

            _intellect = (IBeingInterface)loadedAssembly.CreateInstance(type.FullName);
        }
Пример #2
0
        public static List <IBeingInterface> AddBeing(byte[] dll)
        {
            List <IBeingInterface> objects = new List <IBeingInterface>();
            Assembly assembly         = Assembly.Load(dll);
            string   iMyInterfaceName = typeof(IBeingInterface).ToString();

            TypeDelegator[] defaultConstructorParametersTypes = new TypeDelegator[0];
            object[]        defaultConstructorParameters      = new object[0];

            IBeingInterface iAI = null;

            foreach (Type type in assembly.GetTypes())
            {
                if (type.GetInterface(iMyInterfaceName) != null)
                {
                    ConstructorInfo defaultConstructor = type.GetConstructor(defaultConstructorParametersTypes);
                    object          instance           = defaultConstructor.Invoke(defaultConstructorParameters);
                    iAI = (IBeingInterface)instance;                    //Достаём таки нужный интерфейс
                    //
                    objects.Add(iAI);
                }
            }
            return(objects);
        }
Пример #3
0
        public IntellectDomainProxy(byte[] assembly)
        {
            _domain.SetData("Intellect", assembly);
            var asms = AppDomain.CurrentDomain.GetAssemblies();
            var s1   = AppDomain.CurrentDomain.BaseDirectory;
            var s2   = _domain.BaseDirectory;

            try
            {
                foreach (var asm in asms)
                {
                    if (asm.FullName.Contains("WarSpot.Contracts.Intellect"))
                    {
                        _domain.CreateInstanceFrom(asm.Location, typeof(BeingCharacteristics).FullName);
                    }
                }

                _reference = (IBeingInterface)_domain.CreateInstanceFromAndUnwrap(Assembly.GetExecutingAssembly().Location, typeof(IntellectSecurityProxy).FullName);
            }
            catch (Exception e)
            {
                throw;
            }
        }
Пример #4
0
 public void Unload()
 {
     _reference = null;
     AppDomain.Unload(_domain);
 }