예제 #1
0
        internal static new unsafe NodeStopDescription CreateFromNative(IntPtr nativeRaw)
        {
            ReleaseAssert.AssertIfNot(nativeRaw != IntPtr.Zero, StringResources.Error_NullNativePointer);

            NativeTypes.FABRIC_NODE_STOP_DESCRIPTION native = *(NativeTypes.FABRIC_NODE_STOP_DESCRIPTION *)nativeRaw;

            Guid       operationId    = native.OperationId;
            string     nodeName       = NativeTypes.FromNativeString(native.NodeName);
            BigInteger nodeInstanceId = new BigInteger(native.NodeInstanceId);

            uint     durationInSeconds = native.StopDurationInSeconds;
            TimeSpan duration          = TimeSpan.FromSeconds(durationInSeconds);

            NodeStopDescription description = new NodeStopDescription(operationId, nodeName, nodeInstanceId, (int)duration.TotalSeconds);

            return(description);
        }
예제 #2
0
        internal static unsafe NodeTransitionDescription CreateFromNative(IntPtr native)
        {
            ReleaseAssert.AssertIfNot(native != IntPtr.Zero, StringResources.Error_NullNativePointer);

            NativeTypes.FABRIC_NODE_TRANSITION_DESCRIPTION *casted = (NativeTypes.FABRIC_NODE_TRANSITION_DESCRIPTION *)native;
            switch (casted->NodeTransitionType)
            {
            case NativeTypes.FABRIC_NODE_TRANSITION_TYPE.FABRIC_NODE_TRANSITION_TYPE_START:
                return(NodeStartDescription.CreateFromNative(casted->Value));

            case NativeTypes.FABRIC_NODE_TRANSITION_TYPE.FABRIC_NODE_TRANSITION_TYPE_STOP:
                return(NodeStopDescription.CreateFromNative(casted->Value));

            default:
                AppTrace.TraceSource.WriteError("NodeTransitionDescription.CreateFromNative", "Unknown node transition description type {0}", casted->NodeTransitionType);

                ReleaseAssert.Failfast(string.Format(CultureInfo.CurrentCulture, StringResources.Error_UnknownNodeTransitionType, casted->NodeTransitionType));
                break;
            }

            return(null);
        }