public unsafe IObjectReference CreateInstance(string name, object baseInterface, out IObjectReference innerInterface)
        {
            MarshalString    __name           = default;
            IObjectReference __baseInterface  = default;
            IntPtr           __innerInterface = default;
            IntPtr           __retval         = default;

            try
            {
                __name          = MarshalString.CreateMarshaler(name);
                __baseInterface = MarshalInspectable <object> .CreateMarshaler(baseInterface);

                global::WinRT.ExceptionHelpers.ThrowExceptionForHR(_obj.Vftbl.CreateInstance_0(ThisPtr, MarshalString.GetAbi(__name), MarshalInspectable <object> .GetAbi(__baseInterface), &__innerInterface, &__retval));
                innerInterface = ObjectReference <IUnknownVftbl> .FromAbi(__innerInterface);

                return(ObjectReference <IUnknownVftbl> .Attach(ref __retval));
            }
            finally
            {
                MarshalString.DisposeMarshaler(__name);
                MarshalInspectable <object> .DisposeMarshaler(__baseInterface);

                MarshalInspectable <object> .DisposeAbi(__innerInterface);

                MarshalInspectable <object> .DisposeAbi(__retval);
            }
        }
        public void Stop(IObjectReference throwable)
        {
            Contract.Requires <ArgumentNullException>(throwable != null, "throwable");
            Contract.Requires <VirtualMachineMismatchException>(this.GetVirtualMachine().Equals(throwable.GetVirtualMachine()));

            throw new NotImplementedException();
        }
        internal MonitorEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, Location location, IObjectReference @object)
            : base(virtualMachine, suspendPolicy, request, thread, location)
        {
            Contract.Requires <ArgumentNullException>(@object != null, "object");

            _object = @object;
        }
        private EvaluatedExpression GetArrayElement(EvaluatedExpression array, EvaluatedExpression index)
        {
            Contract.Requires <ArgumentNullException>(array != null, "array");
            Contract.Requires <ArgumentNullException>(index != null, "index");
            Contract.Ensures(Contract.Result <EvaluatedExpression>() != null);

            IArrayReference arrayReference = array.Value as IArrayReference;

            if (arrayReference == null)
            {
                throw new InvalidOperationException();
            }

            long indexValue;

            if (TryGetIntegralValue(index.Value, out indexValue))
            {
                string           name            = string.Format("[{0}]", indexValue);
                string           fullName        = string.Format("({0})[{1}]", array.FullName, index.FullName);
                ILocalVariable   localVariable   = array.LocalVariable;
                IObjectReference referencer      = array.Value as IObjectReference;
                IField           field           = array.Field;
                IMethod          method          = null;
                IValue           value           = arrayReference.GetValue((int)indexValue);
                IType            valueType       = ((IArrayType)arrayReference.GetReferenceType()).GetComponentType();
                bool             strongReference = false;
                return(new EvaluatedExpression(name, fullName, localVariable, referencer, field, method, (int)indexValue, value, valueType, strongReference, array.HasSideEffects || index.HasSideEffects));
            }

            throw new InvalidOperationException();
        }
예제 #5
0
파일: OidMap.cs 프로젝트: xafdelta/xafdelta
        /// <summary>
        /// Creates the oid map.
        /// </summary>
        /// <param name="objectSpace">The object space.</param>
        /// <param name="reference">The reference.</param>
        /// <param name="nodeId">The node id.</param>
        /// <param name="appObject">The target.</param>
        /// <returns>Oid map</returns>
        public static OidMap CreateOidMap(IObjectSpace objectSpace,
                                          IObjectReference reference,
                                          string nodeId, object appObject)
        {
            if (objectSpace == null)
            {
                throw new ArgumentNullException("objectSpace");
            }
            if (reference == null)
            {
                throw new ArgumentNullException("reference");
            }
            if (nodeId == null)
            {
                throw new ArgumentNullException("nodeId");
            }
            if (appObject == null)
            {
                throw new ArgumentNullException("appObject");
            }

            var result = objectSpace.CreateObject <OidMap>();

            result.NodeId                = nodeId;
            result.ObjectId              = reference.ObjectId;
            result.ClassName             = reference.ClassName;
            result.AssemblyName          = reference.AssemblyName;
            result.AssemblyQualifiedName = reference.AssemblyQualifiedName;
            result.NewObject             = appObject;
            result.Save();
            return(result);
        }
예제 #6
0
        private void WriterNodes(IFlow flow, StreamWriter xmlwriter)
        {
            IEnumerator iter = flow.Logs.GetEnumerator();

            while (iter.MoveNext())
            {
                ILog eventLog = (ILog)iter.Current;
                xmlwriter.WriteLine("id->" + eventLog.Id);
                if (eventLog.EventType == EventType.FORK)
                {
                    IEnumerator flowIter = eventLog.GetObjectReferences("Flow").GetEnumerator();

                    while (flowIter.MoveNext())
                    {
                        ObjectReferenceImpl objectReference = (ObjectReferenceImpl)flowIter.Current;
                        DbSession           session         = OpenSession();
                        objectReference.Resolve(session);
                        session.Close();
                        IFlow subFlow = (IFlow)objectReference.GetObject();
                        xmlwriter.WriteLine("subflow" + subFlow + " ->" + subFlow);
                        WriterNodes(subFlow, xmlwriter);
                    }
                }
                else if (eventLog.EventType == EventType.SUB_PROCESS_INSTANCE_START)
                {
                    IObjectReference objectReference    = (IObjectReference)eventLog.GetObjectReferences("ProcessInstance").GetEnumerator().Current;
                    IProcessInstance subProcessInstance = (IProcessInstance)objectReference.GetObject();
                    WriterNodes(subProcessInstance.RootFlow, xmlwriter);
                }
            }
        }
예제 #7
0
        public unsafe IObjectReference CreateInstanceWithAllParameters(global::System.Collections.Specialized.NotifyCollectionChangedAction action, global::System.Collections.IList newItems, global::System.Collections.IList oldItems, int newIndex, int oldIndex, object baseInterface, out IObjectReference innerInterface)
        {
            IObjectReference __newItems       = default;
            IObjectReference __oldItems       = default;
            IObjectReference __baseInterface  = default;
            IntPtr           __innerInterface = default;
            IntPtr           __retval         = default;

            try
            {
                __newItems = MarshalInterface <global::System.Collections.IList> .CreateMarshaler(newItems);

                __oldItems = MarshalInterface <global::System.Collections.IList> .CreateMarshaler(oldItems);

                __baseInterface = MarshalInspectable <object> .CreateMarshaler(baseInterface);

                global::WinRT.ExceptionHelpers.ThrowExceptionForHR(_obj.Vftbl.CreateInstanceWithAllParameters_0(ThisPtr, action, MarshalInterface <global::System.Collections.IList> .GetAbi(__newItems), MarshalInterface <global::System.Collections.IList> .GetAbi(__oldItems), newIndex, oldIndex, MarshalInspectable <object> .GetAbi(__baseInterface), out __innerInterface, out __retval));
                innerInterface = ObjectReference <IUnknownVftbl> .FromAbi(__innerInterface);

                return(ObjectReference <IUnknownVftbl> .FromAbi(__retval));
            }
            finally
            {
                MarshalInterface <global::System.Collections.IList> .DisposeMarshaler(__newItems);

                MarshalInterface <global::System.Collections.IList> .DisposeMarshaler(__oldItems);

                MarshalInspectable <object> .DisposeMarshaler(__baseInterface);

                MarshalInspectable <object> .DisposeAbi(__innerInterface);

                MarshalInspectable <object> .DisposeAbi(__retval);
            }
        }
예제 #8
0
        /// <summary>
        /// Get inferior objects which contains in property with parametrName
        /// </summary>
        /// <param name="propertyOwner">Container object where we will search</param>
        /// <param name="propertyName">Name of property to search in container object. Parametr must be IObjectReference[] type</param>
        /// <returns>IObjectReference[] - inferior objects of propertyOwner</returns>
        public static IObjectReference[] GetInferiorObjects(IObjectReference propertyOwner, string propertyName)
        {
            if (ReferenceEquals(propertyOwner, null))
            {
                throw new ArgumentNullException("propertyOwner");
            }

            if (string.IsNullOrWhiteSpace(propertyName))
            {
                throw new ArgumentException("Property name can't be null or empty");
            }

            //Searching property in container
            var property = propertyOwner.GetValueOfProperty(propertyName);

            if (ReferenceEquals(property, null))
            {
                return(null);
            }

            //We can't get property Title of Book for example
            var result = property as IObjectReference[];

            if (ReferenceEquals(result, null))
            {
                throw new Exception("Property value must be IObjectReference[] type");
            }

            return(result);
        }
        public void AddInstanceFilter(IObjectReference instance)
        {
            Contract.Requires <ArgumentNullException>(instance != null, "instance");
            Contract.Requires <VirtualMachineMismatchException>(this.GetVirtualMachine().Equals(instance.GetVirtualMachine()));

            throw new NotImplementedException();
        }
        public void AddInstanceFilter(IObjectReference instance)
        {
            Contract.Requires<ArgumentNullException>(instance != null, "instance");
            Contract.Requires<VirtualMachineMismatchException>(this.GetVirtualMachine().Equals(instance.GetVirtualMachine()));

            throw new NotImplementedException();
        }
예제 #11
0
 internal DeviceServicingDetails(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(IDeviceServicingDetails).GetHelperType()));
     _defaultLazy    = new Lazy <IDeviceServicingDetails>(() => (IDeviceServicingDetails) new SingleInterfaceOptimizedObject(typeof(IDeviceServicingDetails), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
     };
 }
 internal ExtendedExecutionForegroundRevokedEventArgs(IObjectReference objRef)
 {
     _inner = objRef.As(GuidGenerator.GetIID(typeof(IExtendedExecutionForegroundRevokedEventArgs).GetHelperType()));
     _defaultLazy = new Lazy<IExtendedExecutionForegroundRevokedEventArgs>(() => (IExtendedExecutionForegroundRevokedEventArgs)new SingleInterfaceOptimizedObject(typeof(IExtendedExecutionForegroundRevokedEventArgs), _inner));
     _lazyInterfaces = new Dictionary<Type, object>()
     {
     };
 }
예제 #13
0
 internal CharacterGrouping(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(ICharacterGrouping).GetHelperType()));
     _defaultLazy    = new Lazy <ICharacterGrouping>(() => (ICharacterGrouping) new SingleInterfaceOptimizedObject(typeof(ICharacterGrouping), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
     };
 }
 internal BatteryReport(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(IBatteryReport).GetHelperType()));
     _defaultLazy    = new Lazy <IBatteryReport>(() => (IBatteryReport) new SingleInterfaceOptimizedObject(typeof(IBatteryReport), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
     };
 }
예제 #15
0
        internal ExceptionEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, Location location, IObjectReference exception, ILocation catchLocation)
            : base(virtualMachine, suspendPolicy, request, thread, location)
        {
            Contract.Requires <ArgumentNullException>(exception != null, "exception");

            _exception     = exception;
            _catchLocation = catchLocation;
        }
 internal PreviewBuildsState(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(IPreviewBuildsState).GetHelperType()));
     _defaultLazy    = new Lazy <IPreviewBuildsState>(() => (IPreviewBuildsState) new SingleInterfaceOptimizedObject(typeof(IPreviewBuildsState), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
     };
 }
 internal PlatformTelemetryRegistrationSettings(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(IPlatformTelemetryRegistrationSettings).GetHelperType()));
     _defaultLazy    = new Lazy <IPlatformTelemetryRegistrationSettings>(() => (IPlatformTelemetryRegistrationSettings) new SingleInterfaceOptimizedObject(typeof(IPlatformTelemetryRegistrationSettings), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
     };
 }
예제 #18
0
 internal CompositionDebugHeatMaps(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(ICompositionDebugHeatMaps).GetHelperType()));
     _defaultLazy    = new Lazy <ICompositionDebugHeatMaps>(() => (ICompositionDebugHeatMaps) new SingleInterfaceOptimizedObject(typeof(ICompositionDebugHeatMaps), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
     };
 }
 internal ScreenReaderPositionChangedEventArgs(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(IScreenReaderPositionChangedEventArgs).GetHelperType()));
     _defaultLazy    = new Lazy <IScreenReaderPositionChangedEventArgs>(() => (IScreenReaderPositionChangedEventArgs) new SingleInterfaceOptimizedObject(typeof(IScreenReaderPositionChangedEventArgs), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
     };
 }
예제 #20
0
 internal SystemNavigationCloseRequestedPreviewEventArgs(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(ISystemNavigationCloseRequestedPreviewEventArgs).GetHelperType()));
     _defaultLazy    = new Lazy <ISystemNavigationCloseRequestedPreviewEventArgs>(() => (ISystemNavigationCloseRequestedPreviewEventArgs) new SingleInterfaceOptimizedObject(typeof(ISystemNavigationCloseRequestedPreviewEventArgs), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
     };
 }
예제 #21
0
        internal ExceptionEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, Location location, IObjectReference exception, ILocation catchLocation)
            : base(virtualMachine, suspendPolicy, request, thread, location)
        {
            Contract.Requires<ArgumentNullException>(exception != null, "exception");

            _exception = exception;
            _catchLocation = catchLocation;
        }
예제 #22
0
        public void AddInstanceFilter(IObjectReference instance)
        {
            ObjectReference objectReference = instance as ObjectReference;
            if (objectReference == null || !objectReference.VirtualMachine.Equals(this.VirtualMachine))
                throw new VirtualMachineMismatchException();

            Modifiers.Add(Types.EventRequestModifier.InstanceFilter(objectReference.ObjectId));
        }
예제 #23
0
 internal NamedPolicyData(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(INamedPolicyData).GetHelperType()));
     _defaultLazy    = new Lazy <INamedPolicyData>(() => (INamedPolicyData) new SingleInterfaceOptimizedObject(typeof(INamedPolicyData), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
     };
 }
 internal VariablePhotoCapturedEventArgs(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(IVariablePhotoCapturedEventArgs).GetHelperType()));
     _defaultLazy    = new Lazy <IVariablePhotoCapturedEventArgs>(() => (IVariablePhotoCapturedEventArgs) new SingleInterfaceOptimizedObject(typeof(IVariablePhotoCapturedEventArgs), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
     };
 }
 internal SpatialGraphInteropFrameOfReferencePreview(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(ISpatialGraphInteropFrameOfReferencePreview).GetHelperType()));
     _defaultLazy    = new Lazy <ISpatialGraphInteropFrameOfReferencePreview>(() => (ISpatialGraphInteropFrameOfReferencePreview) new SingleInterfaceOptimizedObject(typeof(ISpatialGraphInteropFrameOfReferencePreview), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
     };
 }
예제 #26
0
 internal EnterpriseKeyCredentialRegistrationInfo(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(IEnterpriseKeyCredentialRegistrationInfo).GetHelperType()));
     _defaultLazy    = new Lazy <IEnterpriseKeyCredentialRegistrationInfo>(() => (IEnterpriseKeyCredentialRegistrationInfo) new SingleInterfaceOptimizedObject(typeof(IEnterpriseKeyCredentialRegistrationInfo), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
     };
 }
        private static bool TryGetCollectionValues(IObjectReference objectReference, out ReadOnlyCollection <IValue> values, out IType elementType)
        {
            IArrayReference arrayReference = objectReference as IArrayReference;

            if (arrayReference == null)
            {
                int size;
                if (TryGetCollectionSize(objectReference, out size))
                {
                    IClassType classType = objectReference.GetReferenceType() as IClassType;
                    if (classType != null)
                    {
                        IObjectReference collectionObject = null;

                        ReadOnlyCollection <IInterfaceType> interfaces = classType.GetInterfaces(true);
                        if (interfaces.Any(i => i.GetName() == "java.util.Collection"))
                        {
                            collectionObject = objectReference;
                        }
                        else if (interfaces.Any(i => i.GetName() == "java.util.Map"))
                        {
                            IMethod entrySetMethod             = classType.GetConcreteMethod("entrySet", "()Ljava/util/Set;");
                            IStrongValueHandle <IValue> result = objectReference.InvokeMethod(null, entrySetMethod, InvokeOptions.None);
                            if (result != null)
                            {
                                collectionObject = result.Value as IObjectReference;
                            }
                        }

                        if (collectionObject != null)
                        {
                            IClassType collectionObjectType = collectionObject.GetReferenceType() as IClassType;
                            if (collectionObjectType != null)
                            {
                                IMethod toArrayMethod = collectionObjectType.GetConcreteMethod("toArray", "()[Ljava/lang/Object;");
                                IStrongValueHandle <IValue> result = collectionObject.InvokeMethod(null, toArrayMethod, InvokeOptions.None);
                                if (result != null)
                                {
                                    arrayReference = result.Value as IArrayReference;
                                }
                            }
                        }
                    }
                }
            }

            if (arrayReference != null)
            {
                values = arrayReference.GetValues();
                IArrayType arrayType = (IArrayType)arrayReference.GetReferenceType();
                elementType = arrayType.GetComponentType();
                return(true);
            }

            values      = null;
            elementType = null;
            return(false);
        }
예제 #28
0
 public EvaluatedExpression(string name, string fullName, IObjectReference referencer, IField field, IValue value, bool hasSideEffects)
     : this(name, fullName, default(ILocalVariable), referencer, field, default(IMethod), default(int?), value, field.GetFieldType(), false, hasSideEffects)
 {
     Contract.Requires <ArgumentNullException>(name != null, "name");
     Contract.Requires <ArgumentNullException>(fullName != null, "fullName");
     Contract.Requires <ArgumentNullException>(field != null, "field");
     Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(name));
     Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(fullName));
 }
예제 #29
0
 public EvaluatedExpression(string name, string fullName, IObjectReference referencer, IField field, int index, IStrongValueHandle <IValue> value, bool hasSideEffects)
     : this(name, fullName, default(ILocalVariable), referencer, field, default(IMethod), index, value != null ? value.Value : null, field.GetFieldType(), true, hasSideEffects)
 {
     Contract.Requires <ArgumentNullException>(name != null, "name");
     Contract.Requires <ArgumentNullException>(fullName != null, "fullName");
     Contract.Requires <ArgumentNullException>(value != null, "value");
     Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(name));
     Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(fullName));
 }
예제 #30
0
 internal ContactPickerUI(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(IContactPickerUI).GetHelperType()));
     _defaultLazy    = new Lazy <IContactPickerUI>(() => (IContactPickerUI) new SingleInterfaceOptimizedObject(typeof(IContactPickerUI), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
         { typeof(IContactPickerUI2), new Lazy <IContactPickerUI2>(() => (IContactPickerUI2)(object)new SingleInterfaceOptimizedObject(typeof(IContactPickerUI2), _inner ?? ((IWinRTObject)this).NativeObject)) },
     };
 }
 internal CompositorController(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(ICompositorController).GetHelperType()));
     _defaultLazy    = new Lazy <ICompositorController>(() => (ICompositorController) new SingleInterfaceOptimizedObject(typeof(ICompositorController), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
         { typeof(global::System.IDisposable), new Lazy <global::System.IDisposable>(() => (global::System.IDisposable)(object) new SingleInterfaceOptimizedObject(typeof(global::System.IDisposable), _inner ?? ((IWinRTObject)this).NativeObject)) },
     };
 }
예제 #32
0
        internal FieldAccessEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, Location location, IField field, IObjectReference instance)
            : base(virtualMachine, suspendPolicy, request, thread, location)
        {
            Contract.Requires<ArgumentNullException>(field != null, "field");
            Contract.Requires(field.GetIsStatic() || instance != null);

            _field = field;
            _instance = instance;
        }
 internal WalletItemSystemStore(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(IWalletItemSystemStore).GetHelperType()));
     _defaultLazy    = new Lazy <IWalletItemSystemStore>(() => (IWalletItemSystemStore) new SingleInterfaceOptimizedObject(typeof(IWalletItemSystemStore), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
         { typeof(IWalletItemSystemStore2), new Lazy <IWalletItemSystemStore2>(() => (IWalletItemSystemStore2)(object)new SingleInterfaceOptimizedObject(typeof(IWalletItemSystemStore2), _inner ?? ((IWinRTObject)this).NativeObject)) },
     };
 }
 internal PerceptionTimestamp(IObjectReference objRef)
 {
     _inner          = objRef.As(GuidGenerator.GetIID(typeof(IPerceptionTimestamp).GetHelperType()));
     _defaultLazy    = new Lazy <IPerceptionTimestamp>(() => (IPerceptionTimestamp) new SingleInterfaceOptimizedObject(typeof(IPerceptionTimestamp), _inner));
     _lazyInterfaces = new Dictionary <Type, object>()
     {
         { typeof(IPerceptionTimestamp2), new Lazy <IPerceptionTimestamp2>(() => (IPerceptionTimestamp2)(object)new SingleInterfaceOptimizedObject(typeof(IPerceptionTimestamp2), _inner ?? ((IWinRTObject)this).NativeObject)) },
     };
 }
예제 #35
0
        public JavaDebugExceptionEvent(enum_EVENTATTRIBUTES attributes, JavaDebugProgram program, IThreadReference thread, IObjectReference exceptionObject, ILocation location, ILocation catchLocation)
            : base(attributes)
        {
            Contract.Requires<ArgumentNullException>(program != null, "program");
            Contract.Requires<ArgumentNullException>(thread != null, "thread");
            Contract.Requires<ArgumentNullException>(exceptionObject != null, "exceptionObject");

            _program = program;
            _thread = thread;
            _exceptionObject = exceptionObject;
            _location = location;
            _catchLocation = catchLocation;
        }
		public void BuildContainer(IObjectReference containerRef,
		                           IObjectReference parentContainerRef,
		                           IList assemblies)
		{
			IMutablePicoContainer parent = GetInstanceFromReference(parentContainerRef);
			IMutablePicoContainer container = CreateContainer(parent, assemblies);

			// register the child in the parent so that lifecycle can be propagated down the hierarchy
			if (parent != null)
			{
				parent.UnregisterComponentByInstance(container);
				parent.RegisterComponentInstance(container, container);
			}

			ComposeContainer(container, assemblies);
			container.Start();
			containerRef.Set(container);
		}
		public void KillContainer(IObjectReference containerRef)
		{
			IMutablePicoContainer pico = GetInstanceFromReference(containerRef);

			try
			{
				if (pico != null)
				{
					pico.Stop();
					pico.Dispose();

					IMutablePicoContainer parent = pico.Parent as IMutablePicoContainer;
					if (parent != null)
					{
						parent.UnregisterComponentByInstance(pico);
					}
				}
			}
			finally
			{
				pico = null;
			}
		}
예제 #38
0
 internal MonitorWaitEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, Location location, IObjectReference @object, TimeSpan timeout)
     : base(virtualMachine, suspendPolicy, request, thread, location, @object)
 {
     _timeout = timeout;
 }
예제 #39
0
 /// <summary>
 /// Initializes a new instance of the <c>InvocationException</c> class
 /// with a specified error message.
 /// </summary>
 public InvocationException(IObjectReference exception, string message)
     : base(message)
 {
     _exception = exception;
 }
예제 #40
0
파일: OidMap.cs 프로젝트: xafdelta/xafdelta
        /// <summary>
        /// Finds the application object by known maps.
        /// </summary>
        /// <param name="objectSpace">The object space.</param>
        /// <param name="reference">The reference.</param>
        /// <returns>Application object</returns>
        private static object findApplicationObjectByKnownMaps(IObjectSpace objectSpace, IObjectReference reference)
        {
            object result = null;
            // search using known mappings
            if (reference is IPackageObjectReference)
            {
                var objRef = (IPackageObjectReference) reference;
                if (!string.IsNullOrEmpty(objRef.KnownMapping))
                {
                    var typeInfo = objectSpace.TypesInfo.FindTypeInfo(objRef.ClassName);
                    if (typeInfo != null)
                    {
                        foreach (var mappingString in objRef.KnownMapping.Split(new[] {'\n'}, StringSplitOptions.RemoveEmptyEntries))
                        {
                            var mapValues = mappingString.Split('\a');
                            if (mapValues.Length < 2) continue;

                            var refNodeId = mapValues[0];

                            if (refNodeId == XafDeltaModule.Instance.CurrentNodeId)
                                // direct search by TargetId in current database
                                result = objectSpace.GetObjectByKey(typeInfo.Type,
                                    XPWeakReference.StringToKey(mapValues[1]));
                            else
                            {
                                // search similar mapping in existing OidMaps and return its target
                                var searchCriteria =
                                    CriteriaOperator.Parse("NodeId = ? And AssemblyName = ? And ClassName = ? And ObjectId = ?",
                                                           refNodeId, reference.AssemblyName, reference.ClassName, mapValues[1]);
                                var knownMap = objectSpace.FindObject<OidMap>(searchCriteria, true);
                                if (knownMap != null)
                                    result = knownMap.TargetObject;
                            }

                            if (result != null)
                                break;
                        }
                    }
                }
            }

            return result;
        }
예제 #41
0
 public bool Equals(IObjectReference other)
 {
     throw new NotImplementedException();
 }
예제 #42
0
 /// <summary>
 /// Initializes a new instance of the <c>InvocationException</c> class
 /// with a specified error message and a reference to the inner exception that
 /// is the cause of this exception.
 /// </summary>
 public InvocationException(IObjectReference exception, string message, Exception innerException)
     : base(message, innerException)
 {
     _exception = exception;
 }
예제 #43
0
        public bool Equals(IObjectReference other)
        {
            if (object.ReferenceEquals(this, other))
                return true;

            ObjectReference objectReference = other as ObjectReference;
            if (objectReference == null)
                return false;

            if (!this.ObjectId.Equals(objectReference.ObjectId))
                return false;

            return this.VirtualMachine.Equals(objectReference.VirtualMachine);
        }
예제 #44
0
 /// <summary>
 /// Initializes a new instance of the <c>InvocationException</c> class.
 /// </summary>
 public InvocationException(IObjectReference exception)
 {
     _exception = exception;
 }
예제 #45
0
        private static bool TryGetCollectionValues(IObjectReference objectReference, out ReadOnlyCollection<IValue> values, out IType elementType)
        {
            IArrayReference arrayReference = objectReference as IArrayReference;
            if (arrayReference == null)
            {
                int size;
                if (TryGetCollectionSize(objectReference, out size))
                {
                    IClassType classType = objectReference.GetReferenceType() as IClassType;
                    if (classType != null)
                    {
                        IObjectReference collectionObject = null;

                        ReadOnlyCollection<IInterfaceType> interfaces = classType.GetInterfaces(true);
                        if (interfaces.Any(i => i.GetName() == "java.util.Collection"))
                        {
                            collectionObject = objectReference;
                        }
                        else if (interfaces.Any(i => i.GetName() == "java.util.Map"))
                        {
                            IMethod entrySetMethod = classType.GetConcreteMethod("entrySet", "()Ljava/util/Set;");
                            IStrongValueHandle<IValue> result = objectReference.InvokeMethod(null, entrySetMethod, InvokeOptions.None);
                            if (result != null)
                                collectionObject = result.Value as IObjectReference;
                        }

                        if (collectionObject != null)
                        {
                            IClassType collectionObjectType = collectionObject.GetReferenceType() as IClassType;
                            if (collectionObjectType != null)
                            {
                                IMethod toArrayMethod = collectionObjectType.GetConcreteMethod("toArray", "()[Ljava/lang/Object;");
                                IStrongValueHandle<IValue> result = collectionObject.InvokeMethod(null, toArrayMethod, InvokeOptions.None);
                                if (result != null)
                                    arrayReference = result.Value as IArrayReference;
                            }
                        }
                    }
                }
            }

            if (arrayReference != null)
            {
                values = arrayReference.GetValues();
                IArrayType arrayType = (IArrayType)arrayReference.GetReferenceType();
                elementType = arrayType.GetComponentType();
                return true;
            }

            values = null;
            elementType = null;
            return false;
        }
예제 #46
0
파일: OidMap.cs 프로젝트: xafdelta/xafdelta
        /// <summary>
        /// Finds the specified object in application database.
        /// </summary>
        /// <param name="objectSpace">The application object space.</param>
        /// <param name="reference">The reference.</param>
        /// <param name="nodeId">The replication node id.</param>
        /// <returns>Object from application database</returns>
        public static object FindApplicationObject(IObjectSpace objectSpace, IObjectReference reference, string nodeId)
        {
            if (objectSpace == null) throw new ArgumentNullException("objectSpace");
            if (reference == null) throw new ArgumentNullException("reference");
            if (nodeId == null) throw new ArgumentNullException("nodeId");

            object result;

            // search existsing OidMap
            var criteria = CriteriaOperator.Parse("NodeId = ? And AssemblyName = ? And ClassName = ? And ObjectId = ?",
                nodeId, reference.AssemblyName, reference.ClassName, reference.ObjectId);

            var mapEntry = objectSpace.FindObject<OidMap>(criteria, true);
            if (mapEntry == null)
            {
                // search using known maps
                result = findApplicationObjectByKnownMaps(objectSpace, reference);

                if (result == null && reference.ReplicationKey != null)
                {
                    Type classType = null;
                    var ti = objectSpace.TypesInfo.FindTypeInfo(reference.ClassName);
                    if(ti != null)
                        classType = ti.Type;
                    else
                    {
                        var classInfo = ((ObjectSpace) objectSpace).Session.GetClassInfo(reference.AssemblyName,
                                                                                         reference.ClassName);
                        if(classInfo != null)
                            classType = classInfo.ClassType;
                    }

                    // search using replication key
                    result = findApplicationObjectByReplicationKey(classType, reference, objectSpace);
                }

                if (result != null)
                    CreateOidMap(objectSpace, reference, nodeId, result);
            }
            else
                result = mapEntry.TargetObject;

            return result;
        }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="theDelegate">The component adapter to decorate</param>
		/// <param name="reference">Object to store the instance in. See <see cref="IObjectReference"/> for an explanation.</param>
		public CachingComponentAdapter(IComponentAdapter theDelegate, SimpleReference reference) : base(theDelegate)
		{
			instanceReference = reference;
		}
예제 #48
0
파일: OidMap.cs 프로젝트: xafdelta/xafdelta
        /// <summary>
        /// Creates the oid map.
        /// </summary>
        /// <param name="objectSpace">The object space.</param>
        /// <param name="reference">The reference.</param>
        /// <param name="nodeId">The node id.</param>
        /// <param name="appObject">The target.</param>
        /// <returns>Oid map</returns>
        public static OidMap CreateOidMap(IObjectSpace objectSpace, 
            IObjectReference reference, 
            string nodeId, object appObject)
        {
            if (objectSpace == null) throw new ArgumentNullException("objectSpace");
            if (reference == null) throw new ArgumentNullException("reference");
            if (nodeId == null) throw new ArgumentNullException("nodeId");
            if (appObject == null) throw new ArgumentNullException("appObject");

            var result = objectSpace.CreateObject<OidMap>();
            result.NodeId = nodeId;
            result.ObjectId = reference.ObjectId;
            result.ClassName = reference.ClassName;
            result.AssemblyName = reference.AssemblyName;
            result.AssemblyQualifiedName = reference.AssemblyQualifiedName;
            result.NewObject = appObject;
            result.Save();
            return result;
        }
예제 #49
0
        public void Stop(IObjectReference throwable)
        {
            ObjectReference objectReference = throwable as ObjectReference;
            if (objectReference == null || !VirtualMachine.Equals(objectReference.VirtualMachine))
                throw new VirtualMachineMismatchException();

            DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.StopThread(this.ThreadId, objectReference.ObjectId));
        }
예제 #50
0
        public void Stop(IObjectReference throwable)
        {
            Contract.Requires<ArgumentNullException>(throwable != null, "throwable");
            Contract.Requires<VirtualMachineMismatchException>(this.GetVirtualMachine().Equals(throwable.GetVirtualMachine()));

            throw new NotImplementedException();
        }
예제 #51
0
        private static bool TryGetCollectionSize(IObjectReference objectReference, out int size)
        {
            size = 0;

            IArrayReference arrayReference = objectReference as IArrayReference;
            if (arrayReference != null)
            {
                size = arrayReference.GetLength();
                return true;
            }

            IClassType classType = objectReference.GetReferenceType() as IClassType;
            if (classType == null)
                return false;

            ReadOnlyCollection<IInterfaceType> interfaces = classType.GetInterfaces(true);
            if (interfaces.Any(i => _collectionInterfaces.Contains(i.GetName())))
            {
                IMethod sizeMethod = classType.GetConcreteMethod("size", "()I");
                using (IStrongValueHandle<IValue> result = objectReference.InvokeMethod(null, sizeMethod, InvokeOptions.None))
                {
                    if (result == null)
                        return false;

                    IIntegerValue integerValue = result.Value as IIntegerValue;
                    if (integerValue != null)
                    {
                        size = integerValue.GetValue();
                        return true;
                    }
                }
            }

            return false;
        }
 internal static object GetRealObject(IObjectReference obj, StreamingContext context)
 {
     return obj.GetRealObject(context);
 }
 public void AddInstanceFilter(IObjectReference instance)
 {
     throw new NotImplementedException();
 }
예제 #54
0
파일: OidMap.cs 프로젝트: xafdelta/xafdelta
        /// <summary>
        /// Finds the application object by replication key.
        /// </summary>
        /// <param name="classType">Type of the class.</param>
        /// <param name="reference">The reference.</param>
        /// <param name="objectSpace">The object space.</param>
        /// <returns>Application object</returns>
        private static object findApplicationObjectByReplicationKey(Type classType, 
            IObjectReference reference, IObjectSpace objectSpace)
        {
            object result = null;
            var modelClass = XafDeltaModule.XafApp.FindModelClass(classType);
            if (modelClass != null && reference.ReplicationKey != null)
            {
                var replicationKeyMember = ExtensionsHelper.GetReplicationKeyMember(modelClass.TypeInfo);
                var replicationKeyIsCaseInsensitive = modelClass.ReplicationKeyIsCaseInsensitive();
                var replicationKeyIsSpaceInsensitive = modelClass.ReplicationKeyIsSpaceInsensitive();
                if (replicationKeyMember != null)
                {

                    CriteriaOperator opLeft = new OperandProperty(replicationKeyMember.Name);
                    CriteriaOperator opRight = new OperandValue(reference.ReplicationKey);

                    if (replicationKeyIsCaseInsensitive)
                    {
                        opLeft = new FunctionOperator(FunctionOperatorType.Upper, opLeft);
                        opRight = new FunctionOperator(FunctionOperatorType.Upper, opRight);
                    }

                    if (replicationKeyIsSpaceInsensitive)
                    {
                        opLeft = new FunctionOperator(FunctionOperatorType.Replace, opLeft,
                            new OperandValue(" "), new OperandValue(String.Empty));
                        opRight = new FunctionOperator(FunctionOperatorType.Replace, opRight,
                            new OperandValue(" "), new OperandValue(String.Empty));
                    }

                    var keyCriteria = new BinaryOperator(opLeft, opRight, BinaryOperatorType.Equal);
                    if(replicationKeyMember.MemberInfo.IsAliased)
                    {
                        var list = objectSpace.CreateCollection(modelClass.TypeInfo.Type);

                        result = (from c in list.Cast<object>()
                                  let objKeyValue = replicationKeyMember.MemberInfo.GetValue(c)
                                  where keysMatches(objKeyValue, reference.ReplicationKey,
                                    replicationKeyIsCaseInsensitive, replicationKeyIsSpaceInsensitive)
                                  select c).FirstOrDefault();
                    }
                    else
                        result = objectSpace.FindObject(classType, keyCriteria, true);
                }
            }
            return result;
        }
		private IMutablePicoContainer GetInstanceFromReference(IObjectReference objectReference)
		{
			return objectReference == null ? null : objectReference.Get() as IMutablePicoContainer;
		}
 internal FieldModificationEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, Location location, IField field, IObjectReference instance, IValue newValue)
     : base(virtualMachine, suspendPolicy, request, thread, location, field, instance)
 {
     _newValue = newValue;
 }