Example #1
0
        internal static unsafe new NodeRepairImpactDescription CreateFromNative(IntPtr nativeDescriptionPtr)
        {
            var nativeDescription = (NativeTypes.FABRIC_REPAIR_NODE_IMPACT_LIST *)nativeDescriptionPtr;
            var nativeItemArray   = (NativeTypes.FABRIC_REPAIR_NODE_IMPACT *)nativeDescription->Items;

            List <NodeImpact> impactList = new List <NodeImpact>();

            for (int i = 0; i < nativeDescription->Count; ++i)
            {
                var nativeItem = *(nativeItemArray + i);
                impactList.Add(NodeImpact.CreateFromNative(nativeItem));
            }

            NodeRepairImpactDescription description = new NodeRepairImpactDescription(impactList);

            return(description);
        }
        internal static unsafe RepairImpactDescription CreateFromNative(IntPtr nativeDescriptionPtr)
        {
            if (nativeDescriptionPtr == IntPtr.Zero)
            {
                return(null);
            }

            var nativeDescription = (NativeTypes.FABRIC_REPAIR_IMPACT_DESCRIPTION *)nativeDescriptionPtr;

            switch (nativeDescription->Kind)
            {
            case NativeTypes.FABRIC_REPAIR_IMPACT_KIND.FABRIC_REPAIR_IMPACT_KIND_NODE:
                return(NodeRepairImpactDescription.CreateFromNative(nativeDescription->Value));

            default:
                // Unknown kind; client is probably an old version. Return an empty object
                // to indicate that impact has been set but is not readable by this client.
                return(new RepairImpactDescription(RepairImpactKind.Invalid));
            }
        }