internal static unsafe new StatelessServiceTypeDescription CreateFromNative(IntPtr descriptionPtr) { NativeTypes.FABRIC_STATELESS_SERVICE_TYPE_DESCRIPTION *nativeDescription = (NativeTypes.FABRIC_STATELESS_SERVICE_TYPE_DESCRIPTION *)descriptionPtr; StatelessServiceTypeDescription description = new StatelessServiceTypeDescription(); description.ReadCommonProperties( nativeDescription->ServiceTypeName, nativeDescription->PlacementConstraints, nativeDescription->LoadMetrics, nativeDescription->Extensions); if (nativeDescription->Reserved != IntPtr.Zero) { NativeTypes.FABRIC_STATELESS_SERVICE_TYPE_DESCRIPTION_EX1 *ex1 = (NativeTypes.FABRIC_STATELESS_SERVICE_TYPE_DESCRIPTION_EX1 *)nativeDescription->Reserved; if (ex1 == null) { throw new ArgumentException(StringResources.Error_UnknownReservedType); } if (ex1->PolicyList != IntPtr.Zero) { NativeTypes.FABRIC_SERVICE_PLACEMENT_POLICY_LIST *pList = (NativeTypes.FABRIC_SERVICE_PLACEMENT_POLICY_LIST *)ex1->PolicyList; description.ParsePlacementPolicies(pList->PolicyCount, pList->Policies); } } description.UseImplicitHost = NativeTypes.FromBOOLEAN(nativeDescription->UseImplicitHost); return(description); }
internal static unsafe bool TryCreateFromNative(IntPtr descriptionPtr, out ServiceTypeDescription serviceTypeDescription) { serviceTypeDescription = null; var nativeDescription = (NativeTypes.FABRIC_SERVICE_TYPE_DESCRIPTION *)descriptionPtr; switch (nativeDescription->Kind) { case NativeTypes.FABRIC_SERVICE_KIND.FABRIC_SERVICE_KIND_STATELESS: serviceTypeDescription = StatelessServiceTypeDescription.CreateFromNative(nativeDescription->Value); break; case NativeTypes.FABRIC_SERVICE_KIND.FABRIC_SERVICE_KIND_STATEFUL: serviceTypeDescription = StatefulServiceTypeDescription.CreateFromNative(nativeDescription->Value); break; default: AppTrace.TraceSource.WriteNoise( "ServiceTypeDescription.TryCreateFromNative", "Ignoring the result with unsupported ServiceKind value {0}", (int)nativeDescription->Kind); break; } return(serviceTypeDescription != null); }