public object CreateProxyObject(string objectName, long objectInstanceHandle, long objectClassHandle) { //ObjectInstanceDescriptor oid = descriptorManager.GetObjectInstanceDescriptor(new XRTIObjectInstanceHandle(objectInstanceHandle)); //ObjectClassDescriptor ocd = descriptorManager.GetObjectClassDescriptor(oid.ClassHandle); ObjectClassDescriptor ocd = descriptorManager.GetObjectClassDescriptor(new XRTIObjectClassHandle(objectClassHandle)); HLAProxyAttribute attr = new HLAProxyAttribute(); attr.ObjectClassHandle = objectClassHandle; attr.ObjectInstanceHandle = objectInstanceHandle; attr.ObjectName = ocd.Name; object obj = HLAobjectRoot.NewRemoteInstance(ocd.NativeName, attr); if (log.IsDebugEnabled) log.Debug("The constructor of object " + objectName + " has been called"); //return Activator.CreateInstance(ocd.NativeName, null, new object[] { attr }); return obj; }
private static object NewInstance(Type type, HLAProxyAttribute proxyInfo, params object[] args) { // type == typeof(HLAobjectRoot) || if (type.IsSubclassOf(typeof(HLAobjectRoot))) { object obj; /* 1. Creates a new object */ if (args != null) obj = _generator.CreateClassProxy(type, new HLAProxySink2(), args); else obj = _generator.CreateClassProxy(type, new HLAProxySink2()); /* 2. Sets-up properties for the new object */ HLAobjectRoot objRoot = obj as HLAobjectRoot; //if (objRoot.OwnFederateAmbassador == null) // return obj; // It is a true proxy for a remote object if (proxyInfo != null) { objRoot.HLAprivilegeToDeleteObject_ = false; objRoot.instanceHandle = new XRTIObjectInstanceHandle(proxyInfo.ObjectInstanceHandle); objRoot.objectName = proxyInfo.ObjectName; objRoot.classHandle = new XRTIObjectClassHandle(proxyInfo.ObjectClassHandle); } // It is a local object else { objRoot.HLAprivilegeToDeleteObject_ = true; objRoot.OwnFederate = HLAobjectRoot.DefaultFederate; objRoot.OwnFederateAmbassador = HLAobjectRoot.DefaultFederateAmbassador; objRoot.OwnFederationExecutionHandle = HLAobjectRoot.DefaultFederationExecutionHandle; objRoot.instanceHandle = new XRTIObjectInstanceHandle(((BaseAmbassador)objRoot.OwnFederateAmbassador).HandleCounter); string className = obj.GetType().BaseType.Name; objRoot.objectName = className + objRoot.InstanceHandle.ToString(); } /* 3. Executes reflection process for aop engine */ HLAProxySink2.ProcessConstruction(objRoot, type); /* 4. Warns to the creation listeners */ foreach (IHLACreateObjectRootListener l in creationListeners) { l.OnReceiveCreatedNewObject(obj); } // It is a local object if (proxyInfo == null) { // COMMENT ANGEL: Permite enviar la modificación de propiedades que se produce en el constructor objRoot.FlushAttributeValues(null); objRoot.AutoFlushDisabled = false; } if (log.IsDebugEnabled) log.Debug("Created an instance of " + obj.GetType().BaseType.Name + " [" + objRoot.InstanceHandle + "]"); return obj; } else throw new Exception("Must be a subclass of HLAobjectRoot"); }
internal static object NewRemoteInstance(Type type, HLAProxyAttribute proxyInfo, params object[] args) { return NewInstance(type, proxyInfo, args); }
internal static object NewRemoteInstance(Type type, HLAProxyAttribute proxyInfo) { return NewInstance(type, proxyInfo, null); }
private static object NewInstance(Type type, HLAProxyAttribute proxyInfo, params object[] args) { // type == typeof(HLAobjectRoot) || if (type.IsSubclassOf(typeof(HLAobjectRoot))) { object obj; /* 1. Creates a new object */ if (args != null) { obj = _generator.CreateClassProxy(type, new HLAProxySink2(), args); } else { obj = _generator.CreateClassProxy(type, new HLAProxySink2()); } /* 2. Sets-up properties for the new object */ HLAobjectRoot objRoot = obj as HLAobjectRoot; //if (objRoot.OwnFederateAmbassador == null) // return obj; // It is a true proxy for a remote object if (proxyInfo != null) { objRoot.HLAprivilegeToDeleteObject_ = false; objRoot.instanceHandle = new XRTIObjectInstanceHandle(proxyInfo.ObjectInstanceHandle); objRoot.objectName = proxyInfo.ObjectName; objRoot.classHandle = new XRTIObjectClassHandle(proxyInfo.ObjectClassHandle); } // It is a local object else { objRoot.HLAprivilegeToDeleteObject_ = true; objRoot.OwnFederate = HLAobjectRoot.DefaultFederate; objRoot.OwnFederateAmbassador = HLAobjectRoot.DefaultFederateAmbassador; objRoot.OwnFederationExecutionHandle = HLAobjectRoot.DefaultFederationExecutionHandle; objRoot.instanceHandle = new XRTIObjectInstanceHandle(((BaseAmbassador)objRoot.OwnFederateAmbassador).HandleCounter); string className = obj.GetType().BaseType.Name; objRoot.objectName = className + objRoot.InstanceHandle.ToString(); } /* 3. Executes reflection process for aop engine */ HLAProxySink2.ProcessConstruction(objRoot, type); /* 4. Warns to the creation listeners */ foreach (IHLACreateObjectRootListener l in creationListeners) { l.OnReceiveCreatedNewObject(obj); } // It is a local object if (proxyInfo == null) { // COMMENT ANGEL: Permite enviar la modificación de propiedades que se produce en el constructor objRoot.FlushAttributeValues(null); objRoot.AutoFlushDisabled = false; } if (log.IsDebugEnabled) { log.Debug("Created an instance of " + obj.GetType().BaseType.Name + " [" + objRoot.InstanceHandle + "]"); } return(obj); } else { throw new Exception("Must be a subclass of HLAobjectRoot"); } }
internal static object NewRemoteInstance(Type type, HLAProxyAttribute proxyInfo, params object[] args) { return(NewInstance(type, proxyInfo, args)); }
internal static object NewRemoteInstance(Type type, HLAProxyAttribute proxyInfo) { return(NewInstance(type, proxyInfo, null)); }