public void TestOperation() { DummyHttpServer instance = new DummyHttpServer(); CodeGenerationInvokerStrategy strategy = new CodeGenerationInvokerStrategy(); MDynamicSupport dynamic = strategy.Create(instance); Assert(!instance.Started); dynamic.Invoke("Start", null, null); Assert(instance.Started); }
public void TestInfo() { Object instance = new DummyHttpServer(); ReflectionInvokerStrategy strategy = new ReflectionInvokerStrategy(); MDynamicSupport dynamic = strategy.Create(instance); AssertNotNull(dynamic); AssertNotNull(dynamic.Info); AssertEquals(3, dynamic.Info.Operations.Count); AssertEquals(1, dynamic.Info.Attributes.Count); }
public Entry(Object instance, MDynamicSupport invoker) { this.instance = instance; this.invoker = invoker; }
public ManagedInstance RegisterManagedObject(Object instance, ManagedObjectName name) { if (name == null) { throw new ArgumentNullException("name"); } if (instance == null) { throw new ArgumentNullException("instance"); } ComponentType cType = MInspector.Inspect(instance); MDynamicSupport dynamic = null; if (cType == ComponentType.None) { throw new InvalidComponentException("Component is not a managed component."); } if (cType == ComponentType.Standard) { dynamic = MDynamicSupportFactory.Create(instance); } else if (cType == ComponentType.Dynamic) { dynamic = (MDynamicSupport)instance; } String domainName = name.Domain; Domain domain = null; lock (domains) { domain = domains[domainName]; if (domain == null) { domain = new Domain(domainName); domains.Add(domain); } } Entry entry = new Entry(instance, dynamic); try { MRegistrationListener registration = instance as MRegistrationListener; InvokeBeforeRegister(registration, name); lock (domain) { if (domain.Contains(name)) { throw new InstanceAlreadyRegistredException(name.ToString()); } domain.Add(name, entry); } InvokeAfterRegister(registration); } catch (Exception e) { domain.Remove(name); throw e; } return(new ManagedInstance(instance.GetType().FullName, name)); }