Unwrap() public méthode

public Unwrap ( ) : Object
Résultat Object
        public IList<DynamicStackFrame> GetStackFrames(ObjectHandle exception) {
            ContractUtils.RequiresNotNull(exception, "exception");
            var exceptionObj = exception.Unwrap() as Exception;
            ContractUtils.Requires(exceptionObj != null, "exception", "ObjectHandle must be to Exception object");

            return _context.GetStackFrames(exceptionObj);
        }
        public void GetExceptionMessage(ObjectHandle exception, out string message, out string errorTypeName) {
            ContractUtils.RequiresNotNull(exception, "exception");
            var exceptionObj = exception.Unwrap() as Exception;
            ContractUtils.Requires(exceptionObj != null, "exception", "ObjectHandle must be to Exception object");

            _context.GetExceptionMessage(exceptionObj, out message, out errorTypeName);
        }
        public bool HandleException(ObjectHandle exception) {
            ContractUtils.RequiresNotNull(exception, "exception");
            var exceptionObj = exception.Unwrap() as Exception;
            ContractUtils.Requires(exceptionObj != null, "exception", "ObjectHandle must be to Exception object");

            return false;
        }
Exemple #4
0
    static void Main()
    {
        // Construct a path to the current assembly.
        string assemblyPath = Environment.CurrentDirectory + "\\" +
                              typeof(MarshallableExample).Assembly.GetName().Name + ".exe";

        AppDomain ad = AppDomain.CreateDomain("MyDomain");

        System.Runtime.Remoting.ObjectHandle oh =
            ad.CreateInstanceFrom(assemblyPath, "MarshallableExample");

        object obj = oh.Unwrap();


        // Three ways to use the newly created object, depending on how
        // much is known about the type: Late bound, early bound through
        // a mutually known interface, or early binding of a known type.
        //
        obj.GetType().InvokeMember("Test",
                                   System.Reflection.BindingFlags.InvokeMethod,
                                   Type.DefaultBinder, obj, new object[] { "Hello" });

        ITest it = (ITest)obj;

        it.Test("Hi");

        MarshallableExample ex = (MarshallableExample)obj;

        ex.Test("Goodbye");
    }
        public string FormatException(ObjectHandle exception) {
            ContractUtils.RequiresNotNull(exception, "exception");
            var exceptionObj = exception.Unwrap() as Exception;
            ContractUtils.Requires(exceptionObj != null, "exception", "ObjectHandle must be to Exception object");

            return _context.FormatException(exceptionObj);
        }
    public void ReadXml(XmlReader reader, World world)
    {
        //reader.ReadToDescendant("ConstructionJobs");
        int count = 0;
        // ONLY USE THIS FOR SINGLE THREADED LOADING!!!!!!!
        Assembly         assembly     = new StackTrace().GetFrames().Last().GetMethod().Module.Assembly;
        HashSet <string> jobTypesRead = new HashSet <string>();

        if (reader.ReadToDescendant("Job"))
        {
            // We have at least one job to read
            do
            { // Read it while there are more jobs to read
                string className = reader.GetAttribute("Class");
                System.Runtime.Remoting.ObjectHandle oh = Activator.CreateInstanceFrom(assembly.CodeBase, className);
                Job job = (Job)Convert.ChangeType(oh.Unwrap(), Type.GetType(className));

                if (jobTypesRead.Contains(className))
                {
                    job.ReadXml(reader, world, this);
                }
                else
                {
                    job.ReadXml(reader, world, this, true);
                }

                jobTypesRead.Add(className);
                count++;
            } while (reader.ReadToNextSibling("Job"));
        }
    }
Exemple #7
0
    public SpellCollisionEffect.SpellCollisionBehaviour GetOnSpellCollisionEffect()
    {
        if (onCollisionEffectName == "" || onCollisionEffectName == null)
        {
            return(DefaultSpellCollisionBehaviour);
        }

        System.Runtime.Remoting.ObjectHandle handle = System.Activator.CreateInstance(null, onCollisionEffectName);
        SpellCollisionEffect onCollision            = handle.Unwrap() as SpellCollisionEffect;

        return(onCollision.SpellCollisionEffectBehaviour());
    }
Exemple #8
0
    private void PushPhase(string phaseID)
    {
        System.Runtime.Remoting.ObjectHandle handle = System.Activator.CreateInstance(_appProxyConfig.m_assemblyPrimary, phaseID);
        IPhase phase = handle.Unwrap() as IPhase;

        if (LoggingManager.Instance.Filter(LoggingManager.Domain.Phases))
        {
            Debug.Log("(AppManager) Entering phase: " + phaseID + " (" + _phases.Count + ")");
        }
        _phases.Add(phase);
        phase.Setup(this);
    }
Exemple #9
0
    public OnHitEffect.DamageBehaviour GetOnHitEffect()
    {
        /// Debug.LogError(onHitEffectName);
        if (onHitEffectName == "" || onHitEffectName == null)
        {
            return(DefaultDamageBehaviour);
        }

        System.Runtime.Remoting.ObjectHandle handle = System.Activator.CreateInstance(null, onHitEffectName);
        OnHitEffect onHitEffect = handle.Unwrap() as OnHitEffect;

        return(onHitEffect.GetOnHitEffectBehaviour());
    }
Exemple #10
0
    static void Main()
    {
        // Create an instance of the StringBuilder typer using
        // Activator.CreateInstance.
        object o = Activator.CreateInstance(typeof(StringBuilder));

        // Append a string into the StringBuilder object and display the StringBuilder.
        StringBuilder sb = (StringBuilder)o;

        sb.Append("Hello, there.");
        Console.WriteLine(sb);

        // Create an instance of the SomeType class that is defined in this assembly.
        System.Runtime.Remoting.ObjectHandle oh =
            Activator.CreateInstanceFrom(Assembly.GetEntryAssembly().CodeBase, typeof(SomeType).FullName);

        // Call an instance method defined by the SomeType type using this object.
        SomeType st = (SomeType)oh.Unwrap();

        st.DoSomething(5);
    }
        void GotNewAppDomain(ObjectHandle oh)
        {
            Invariant.Assert(PresentationAppDomainManager.SaveAppDomain);

            // In stress situations or with a corrupt application store, ClickOnce may fail to return us
            // an AppDomain, without throwing an exception. This might also happen if something goes wrong
            // with ApplicationActivator's use of our custom AppDomainManager (Dev10.581515).
            if (oh != null)
            {
                AppDomain newDomain = (AppDomain)oh.Unwrap();
                if (newDomain != null)
                {
                    PresentationAppDomainManager.NewAppDomain = newDomain;
                    return;
                }
            }
            // Note that DocObjHost enables the unhandled exception page just before trying to run the
            // application, so this exception message should be displayed to the user (except if we are
            // trying direct activation, in which case the exception is caught and we fall back to the full
            // IPHM activation).
            throw new ApplicationException(SR.Get(SRID.AppActivationException));
        }
 /// <summary>
 /// Gets the overloads available for the provided remote object if it is invokable.
 /// </summary>
 public ICollection<OverloadDoc> GetOverloads(ObjectHandle value)
 {
     return _provider.GetOverloads(value.Unwrap());
 }
 /// <summary>
 /// Gets the available members on the provided remote object.
 /// </summary>
 public ICollection<MemberDoc> GetMembers(ObjectHandle value)
 {
     return _provider.GetMembers(value.Unwrap());
 }
 public ObjectHandle GetSetCommandDispatcher(ObjectHandle dispatcher) {
     var res = _context.GetSetCommandDispatcher((Action<Action>)dispatcher.Unwrap());
     if (res != null) {
         return new ObjectHandle(res);
     }
                 
     return null;
 }
Exemple #15
0
        public void TryGetVariableAsHandle_MultipleCases()
        {
            ScriptScopeDictionary global = new ScriptScopeDictionary();
            // Populate with some test data
            string[] key = { "test1", "test2", "test3" };
            int tExpectedVal1 = 1111;
            global[key[0]] = tExpectedVal1; // case 1

            ScriptScope TestScope = _testEng.CreateScope(new ObjectDictionaryExpando(global));
            // out value;
            int value = -1;

            ObjectHandle objHVal = new ObjectHandle(value);

            // Case 1
            Assert.IsTrue(TestScope.TryGetVariableHandle(key[0], out objHVal));
            Assert.IsTrue((int)(objHVal.Unwrap()) == tExpectedVal1);

            // reset
            value = -1;
            objHVal = new ObjectHandle(value);
            // Case 2
            Assert.IsFalse(TestScope.TryGetVariableHandle(key[1], out objHVal));
            Assert.IsNull(objHVal);
        }