internal static IntPtr ToNative(PinCollection pin, ServiceGroupDescription description) { if (description == null) { return(IntPtr.Zero); } uint length = (uint)description.MemberDescriptions.Count; var nativeDescription = new NativeTypes.FABRIC_SERVICE_GROUP_DESCRIPTION[1]; nativeDescription[0].Description = description.ServiceDescription.ToNative(pin); nativeDescription[0].MemberCount = length; var members = new NativeTypes.FABRIC_SERVICE_GROUP_MEMBER_DESCRIPTION[length]; for (int i = 0; i < length; i++) { members[i].ServiceTypeName = pin.AddBlittable(description.MemberDescriptions[i].ServiceTypeName); members[i].ServiceName = pin.AddObject(description.MemberDescriptions[i].ServiceName); var initializationData = NativeTypes.ToNativeBytes(pin, description.MemberDescriptions[i].InitializationData); members[i].InitializationDataSize = initializationData.Item1; members[i].InitializationData = initializationData.Item2; var metrics = NativeTypes.ToNativeLoadMetrics(pin, description.MemberDescriptions[i].Metrics); members[i].MetricCount = metrics.Item1; members[i].Metrics = metrics.Item2; pin.AddBlittable(members[i]); } nativeDescription[0].MemberDescriptions = pin.AddBlittable(members); return(pin.AddBlittable(nativeDescription[0])); }
internal static unsafe ServiceReplicaList CreateFromNativeList( NativeTypes.FABRIC_SERVICE_REPLICA_QUERY_RESULT_LIST *nativeList, NativeTypes.FABRIC_PAGING_STATUS *nativePagingStatus) { var retval = new ServiceReplicaList(); var nativeItemArray = (NativeTypes.FABRIC_SERVICE_REPLICA_QUERY_RESULT_ITEM *)nativeList->Items; for (int i = 0; i < nativeList->Count; ++i) { var nativeItem = *(nativeItemArray + i); var item = Replica.CreateFromNative(nativeItem); if (item != null) { retval.Add(item); } } if (nativePagingStatus != null) { retval.ContinuationToken = NativeTypes.FromNativeString(nativePagingStatus->ContinuationToken); } return(retval); }
public static bool IsValidExpression(string expression) { using (var pin = new PinCollection()) { return(NativeTypes.FromBOOLEAN(NativeCommon.FabricIsValidExpression(pin.AddBlittable(expression)))); } }
internal static unsafe RestartNodeDescriptionUsingNodeName CreateFromNative(IntPtr nativeRaw) { NativeTypes.FABRIC_RESTART_NODE_DESCRIPTION_USING_NODE_NAME native = *(NativeTypes.FABRIC_RESTART_NODE_DESCRIPTION_USING_NODE_NAME *)nativeRaw; string nodeName = NativeTypes.FromNativeString(native.NodeName); BigInteger nodeInstance = new BigInteger(native.NodeInstance); bool shouldCreateFabricDump = NativeTypes.FromBOOLEAN(native.ShouldCreateFabricDump); CompletionMode completionMode = CompletionMode.Invalid; switch (native.CompletionMode) { case NativeTypes.FABRIC_COMPLETION_MODE.FABRIC_COMPLETION_MODE_DO_NOT_VERIFY: completionMode = CompletionMode.DoNotVerify; break; case NativeTypes.FABRIC_COMPLETION_MODE.FABRIC_COMPLETION_MODE_VERIFY: completionMode = CompletionMode.Verify; break; default: completionMode = CompletionMode.Invalid; break; } return(new RestartNodeDescriptionUsingNodeName(nodeName, nodeInstance, shouldCreateFabricDump, completionMode)); }
internal static unsafe ServiceResourceIdentifier FromNative( NativeTypes.FABRIC_SECURITY_SERVICE_RESOURCE_IDENTIFIER *nativePtr) { var serviceName = NativeTypes.FromNativeUri(nativePtr->ServiceName); return(new ServiceResourceIdentifier(serviceName)); }
internal override IntPtr ToNative(PinCollection pinCollection) { string reasonToSendBack = null; if (ChaosUtility.DisableOptimizationForValidationFailedEvent) { reasonToSendBack = ChaosUtility.Decompress(this.reason); if (reasonToSendBack.Length > ChaosConstants.StringLengthLimit) { reasonToSendBack = reasonToSendBack.Substring(0, ChaosConstants.StringLengthLimit); } } else { reasonToSendBack = this.reason; } var nativeValidationFailedEvent = new NativeTypes.FABRIC_VALIDATION_FAILED_EVENT { TimeStampUtc = NativeTypes.ToNativeFILETIME(this.TimeStampUtc), Reason = pinCollection.AddObject(reasonToSendBack) }; return(pinCollection.AddBlittable(nativeValidationFailedEvent)); }
internal static unsafe StatelessService FromNative(NativeTypes.FABRIC_STATELESS_SERVICE_QUERY_RESULT_ITEM nativeStatelessServiceQueryResult) { ServiceStatus serviceStatus = ServiceStatus.Unknown; bool isServiceGroup = false; if (nativeStatelessServiceQueryResult.Reserved != IntPtr.Zero) { var nativeStatelessServiceQueryResultEx1 = (NativeTypes.FABRIC_STATELESS_SERVICE_QUERY_RESULT_ITEM_EX1 *)nativeStatelessServiceQueryResult.Reserved; if (nativeStatelessServiceQueryResultEx1 == null) { throw new ArgumentException(StringResources.Error_UnknownReservedType); } serviceStatus = (ServiceStatus)nativeStatelessServiceQueryResultEx1->ServiceStatus; if (nativeStatelessServiceQueryResultEx1->Reserved != IntPtr.Zero) { var nativeStatelessServiceQueryResultEx2 = (NativeTypes.FABRIC_STATELESS_SERVICE_QUERY_RESULT_ITEM_EX2 *)nativeStatelessServiceQueryResultEx1->Reserved; isServiceGroup = NativeTypes.FromBOOLEAN(nativeStatelessServiceQueryResultEx2->IsServiceGroup); } } return(new StatelessService( new Uri(NativeTypes.FromNativeString(nativeStatelessServiceQueryResult.ServiceName)), NativeTypes.FromNativeString(nativeStatelessServiceQueryResult.ServiceTypeName), NativeTypes.FromNativeString(nativeStatelessServiceQueryResult.ServiceManifestVersion), (HealthState)nativeStatelessServiceQueryResult.HealthState, serviceStatus, isServiceGroup)); }
/// <summary> /// <para>Encrypt text string with an X509 certificate in a file.</para> /// </summary> /// <param name="textToEncrypt"> /// <para>The text to encrypt.</para> /// </param> /// <param name="certFileName"> /// <para>The encryption certificate file path.</para> /// </param> /// <param name="algorithmOid"> /// <para>The encryption algorithm object identifier (OID).</para> /// </param> /// <returns> /// <para>The encrypted text as <see cref="System.String" />.</para> /// </returns> public static string EncryptTextByCertFile( string textToEncrypt, string certFileName, string algorithmOid) { using (PinCollection pin = new PinCollection()) { try { return(NativeTypes.FromNativeString(NativeCommon.FabricEncryptText2( pin.AddObject(textToEncrypt), pin.AddObject(certFileName), pin.AddObject(algorithmOid)))); } catch (Exception ex) { COMException comEx = Utility.TryTranslateExceptionToCOM(ex); if (comEx != null) { throw comEx; } throw; } } }
internal static new unsafe ExeHostEntryPointDescription CreateFromNative(IntPtr entryPointDescriptionPtr) { NativeTypes.FABRIC_EXEHOST_ENTRY_POINT_DESCRIPTION *nativeEntryPointDescription = (NativeTypes.FABRIC_EXEHOST_ENTRY_POINT_DESCRIPTION *)entryPointDescriptionPtr; ExeHostEntryPointDescription entryPointDescription = new ExeHostEntryPointDescription { Program = NativeTypes.FromNativeString(nativeEntryPointDescription->Program), Arguments = NativeTypes.FromNativeString(nativeEntryPointDescription->Arguments), WorkingFolder = (ExeHostWorkingFolder)nativeEntryPointDescription->WorkingFolder }; if (nativeEntryPointDescription->Reserved != IntPtr.Zero) { NativeTypes.FABRIC_EXEHOST_ENTRY_POINT_DESCRIPTION_EX1 *nativeEntryPointDescriptionEx1 = (NativeTypes.FABRIC_EXEHOST_ENTRY_POINT_DESCRIPTION_EX1 *)nativeEntryPointDescription->Reserved; entryPointDescription.PeriodicInterval = nativeEntryPointDescriptionEx1->PeriodicIntervalInSeconds; entryPointDescription.ConsoleRedirectionEnabled = NativeTypes.FromBOOLEAN(nativeEntryPointDescriptionEx1->ConsoleRedirectionEnabled); // XSD has types as int for the following fields. Also minimum limit has been set to value > 0. Hence the cast is safe. entryPointDescription.ConsoleRedirectionFileRetentionCount = (long)nativeEntryPointDescriptionEx1->ConsoleRedirectionFileRetentionCount; entryPointDescription.ConsoleRedirectionFileMaxSizeInKb = (long)nativeEntryPointDescriptionEx1->ConsoleRedirectionFileMaxSizeInKb; if (nativeEntryPointDescriptionEx1->Reserved != IntPtr.Zero) { NativeTypes.FABRIC_EXEHOST_ENTRY_POINT_DESCRIPTION_EX2 *nativeEntryPointDescriptionEx2 = (NativeTypes.FABRIC_EXEHOST_ENTRY_POINT_DESCRIPTION_EX2 *)nativeEntryPointDescriptionEx1->Reserved; entryPointDescription.IsExternalExecutable = NativeTypes.FromBOOLEAN(nativeEntryPointDescriptionEx2->IsExternalExecutable); } } return(entryPointDescription); }
public static unsafe byte[] Get_Byte(IntPtr message) { var msgBufferValue = (NativeTypes.FABRIC_MESSAGE_BUFFER *)message; // TODO: Copy shld be removed return(NativeTypes.FromNativeBytes(msgBufferValue->Buffer, msgBufferValue->BufferSize)); }
public void Serialize_MinValues() { NativeTypes nativeTypes = new NativeTypes(withMaxValues: false); string result = Serialize(nativeTypes); Assert.NotNull(result); Assert.Equal( "{ " + "\"__typeAlias\" : \"NativeTypes\", " + "\"Bool\" : false, " + "\"Byte\" : 0, " + "\"Sbyte\" : -128, " + "\"Char\" : 0, " + "\"Decimal\" : \"-79,228,162,514,264,337,593,543,950,335.00\", " + "\"Double\" : -1.7976931348623157E+308, " + "\"Float\" : -3.4028234663852886E+38, " + "\"Int\" : -2147483648, " + "\"Uint\" : NumberLong(0), " + "\"Long\" : NumberLong(\"-9223372036854775808\"), " + "\"Ulong\" : \"0\", " + "\"Short\" : -32768, " + "\"Ushort\" : 0, " + "\"String\" : \"Foo\", " + "\"DateTime\" : { " + "\"__type\" : \"System.DateTime\", " + "\"ticks\" : NumberLong(0), " + "\"dateData\" : \"0\" " + "}, " + "\"Guid\" : \"00000000-0000-0000-0000-000000000000\", " + "\"Null\" : null " + "}", result); }
public void Serialize_MaxValues() { NativeTypes nativeTypes = new NativeTypes(withMaxValues: true); string result = Serialize(nativeTypes); Assert.NotNull(result); Assert.Equal( "{ " + "\"__typeAlias\" : \"NativeTypes\", " + "\"Bool\" : true, " + "\"Byte\" : 255, " + "\"Sbyte\" : 127, " + "\"Char\" : 65535, " + "\"Decimal\" : \"79,228,162,514,264,337,593,543,950,335.00\", " + "\"Double\" : 1.7976931348623157E+308, " + "\"Float\" : 3.4028234663852886E+38, " + "\"Int\" : 2147483647, " + "\"Uint\" : NumberLong(\"4294967295\"), " + "\"Long\" : NumberLong(\"9223372036854775807\"), " + "\"Ulong\" : \"18446744073709551615\", " + "\"Short\" : 32767, " + "\"Ushort\" : 65535, " + "\"String\" : \"Foo\", " + "\"DateTime\" : { " + "\"__type\" : \"System.DateTime\", " + "\"ticks\" : NumberLong(\"3155378975999999999\"), " + "\"dateData\" : \"3155378975999999999\" " + "}, " + "\"Guid\" : \"00000000-0000-0000-0000-000000000000\", " + "\"Null\" : null " + "}", result); }
internal static unsafe ServiceType CreateFromNative( NativeTypes.FABRIC_SERVICE_TYPE_QUERY_RESULT_ITEM nativeResultItem) { ServiceTypeDescription serviceTypeDescription; if (ServiceTypeDescription.TryCreateFromNative(nativeResultItem.ServiceTypeDescription, out serviceTypeDescription)) { string serviceManifestName = null; bool isServiceGroup = false; if (nativeResultItem.Reserved != IntPtr.Zero) { var castedEx1 = (NativeTypes.FABRIC_SERVICE_TYPE_QUERY_RESULT_ITEM_EX1 *)(nativeResultItem.Reserved); serviceManifestName = NativeTypes.FromNativeString(castedEx1->ServiceManifestName); if (castedEx1->Reserved != IntPtr.Zero) { var castedEx2 = (NativeTypes.FABRIC_SERVICE_TYPE_QUERY_RESULT_ITEM_EX2 *)(castedEx1->Reserved); isServiceGroup = NativeTypes.FromBOOLEAN(castedEx2->IsServiceGroup); } } return(new ServiceType( serviceTypeDescription, NativeTypes.FromNativeString(nativeResultItem.ServiceManifestVersion), serviceManifestName, isServiceGroup)); } else { return(null); } }
internal static unsafe ServiceNotification FromNative(NativeClient.IFabricServiceNotification nativeResult) { var nativeNotification = (NativeTypes.FABRIC_SERVICE_NOTIFICATION *)nativeResult.get_Notification(); var managedNotification = new ServiceNotification(); managedNotification.ServiceName = NativeTypes.FromNativeUri(nativeNotification->ServiceName); managedNotification.PartitionId = nativeNotification->PartitionId; if (nativeNotification->EndpointCount > 0) { managedNotification.Endpoints = InteropHelpers.ResolvedServiceEndpointCollectionHelper.CreateFromNative((int)nativeNotification->EndpointCount, nativeNotification->Endpoints); } else { managedNotification.Endpoints = new List <ResolvedServiceEndpoint>(0); } var nativeVersion = nativeResult.GetVersion(); managedNotification.Version = new ServiceEndpointsVersion(nativeVersion); if (nativeNotification->PartitionInfo != IntPtr.Zero) { managedNotification.PartitionInfo = ServicePartitionInformation.FromNative(nativeNotification->PartitionInfo); } else { managedNotification.PartitionInfo = null; } GC.KeepAlive(nativeResult); return(managedNotification); }
internal static unsafe ChaosSchedule FromNative(IntPtr pointer) { var nativeSchedule = *(NativeTypes.FABRIC_CHAOS_SCHEDULE *)pointer; DateTime startDate = NativeTypes.FromNativeFILETIME(nativeSchedule.StartDate); DateTime expiryDate = NativeTypes.FromNativeFILETIME(nativeSchedule.ExpiryDate); Dictionary <string, ChaosParameters> chaosParametersDictionary = new Dictionary <string, ChaosParameters>(); var chaosParametersMap = *(NativeTypes.FABRIC_CHAOS_SCHEDULE_CHAOS_PARAMETERS_MAP *)nativeSchedule.ChaosParametersMap; var nativechaosParametersMapArrayPtr = (NativeTypes.FABRIC_CHAOS_SCHEDULE_CHAOS_PARAMETERS_MAP_ITEM *)chaosParametersMap.Items; for (int i = 0; i < chaosParametersMap.Count; i++) { var nativeItem = *(nativechaosParametersMapArrayPtr + i); var name = NativeTypes.FromNativeString(nativeItem.Name); var parameters = ChaosParameters.CreateFromNative(nativeItem.Parameters); chaosParametersDictionary.Add(name, parameters); } List <ChaosScheduleJob> jobs = new List <ChaosScheduleJob>(); var nativeJobsList = *(NativeTypes.FABRIC_CHAOS_SCHEDULE_JOB_LIST *)nativeSchedule.Jobs; var nativeJobsArrayPtr = (NativeTypes.FABRIC_CHAOS_SCHEDULE_JOB *)nativeJobsList.Items; for (int i = 0; i < nativeJobsList.Count; ++i) { var nativeItem = (nativeJobsArrayPtr + i); ChaosScheduleJob job = ChaosScheduleJob.FromNative(nativeItem); jobs.Add(job); } return(new ChaosSchedule(startDate, expiryDate, chaosParametersDictionary, jobs)); }
/// <summary> /// <para>Encrypt text string with an installed X509 certificate.</para> /// </summary> /// <param name="textToEncrypt"> /// <para>The text to encrypt.</para> /// </param> /// <param name="thumbprint"> /// <para>The thumbprint of encryption certificate.</para> /// </param> /// <param name="storeName"> /// <para>The name of certificate store, from which encryption certificate is retrieved.</para> /// </param> /// <param name="storeLocation"> /// <para>The certificate store location to retrieve encryption certificate.</para> /// </param> /// <param name="algorithmOid"> /// <para>The encryption algorithm object identifier (OID).</para> /// </param> /// <returns> /// <para>The encrypted text as <see cref="System.String" />.</para> /// </returns> public static string EncryptText( string textToEncrypt, string thumbprint, string storeName, StoreLocation storeLocation, string algorithmOid) { using (PinCollection pin = new PinCollection()) { try { return(NativeTypes.FromNativeString(NativeCommon.FabricEncryptText( pin.AddObject(textToEncrypt), pin.AddObject(thumbprint), pin.AddObject(storeName), (NativeTypes.FABRIC_X509_STORE_LOCATION)storeLocation, pin.AddObject(algorithmOid)))); } catch (Exception ex) { COMException comEx = Utility.TryTranslateExceptionToCOM(ex); if (comEx != null) { throw comEx; } throw; } } }
internal static unsafe PackageSharingPolicy FromNative(NativeTypes.FABRIC_PACKAGE_SHARING_POLICY nativeSharingPolicy) { var packageName = NativeTypes.FromNativeString(nativeSharingPolicy.PackageName); var sharingScope = (PackageSharingPolicyScope)nativeSharingPolicy.Scope; return(new PackageSharingPolicy(packageName, sharingScope)); }
internal static unsafe ConfigurationSection CreateFromNative(IntPtr nativeSectionRaw) { NativeTypes.FABRIC_CONFIGURATION_SECTION nativeSection = *(NativeTypes.FABRIC_CONFIGURATION_SECTION *)nativeSectionRaw; ConfigurationSection section = new ConfigurationSection(); string name = NativeTypes.FromNativeString(nativeSection.Name); if (string.IsNullOrEmpty(name)) { throw new ArgumentException( StringResources.Error_ConfigSectionNameNullOrEmpty, "nativeSectionRaw"); } section.Name = name; if (nativeSection.Parameters != IntPtr.Zero) { NativeTypes.FABRIC_CONFIGURATION_PARAMETER_LIST nativeSectionList = *(NativeTypes.FABRIC_CONFIGURATION_PARAMETER_LIST *)nativeSection.Parameters; for (int i = 0; i < nativeSectionList.Count; i++) { section.Parameters.Add(ConfigurationProperty.CreateFromNative(nativeSectionList.Items + (i * Marshal.SizeOf(typeof(NativeTypes.FABRIC_CONFIGURATION_PARAMETER))))); } } return(section); }
private static unsafe void ParseConfigurationPackages(NativeRuntime.IFabricCodePackageActivationContext nativeContext, ServiceManifest manifest) { IList <string> names = new List <string>(); NativeCommon.IFabricStringListResult nativeResult = nativeContext.GetConfigurationPackageNames(); uint count; IntPtr nativeNames = nativeResult.GetStrings(out count); for (int i = 0; i < count; i++) { NativeRuntime.IFabricConfigurationPackage configPackageResult = nativeContext.GetConfigurationPackage(Marshal.ReadIntPtr((IntPtr)(nativeNames + i))); NativeTypes.FABRIC_CONFIGURATION_PACKAGE_DESCRIPTION nativeDescription = *(((NativeTypes.FABRIC_CONFIGURATION_PACKAGE_DESCRIPTION *)configPackageResult.get_Description())); NativeRuntime.IFabricConfigurationPackage nativePackage = null; string packageName = NativeTypes.FromNativeString(nativeDescription.Name); using (var pin = new PinBlittable(packageName)) { nativePackage = nativeContext.GetConfigurationPackage(pin.AddrOfPinnedObject()); } manifest.ConfigurationPackages.Add(ConfigurationPackage.CreateFromNative(nativePackage)); GC.KeepAlive(configPackageResult); } GC.KeepAlive(nativeResult); }
internal static unsafe ProcessDebugParameters CreateFromNative(IntPtr nativePtr) { ReleaseAssert.AssertIfNot(nativePtr != IntPtr.Zero, "ProcessDebugParameters.CreateFromNative() has null pointer."); var nativeParameters = *((NativeTypes.FABRIC_PROCESS_DEBUG_PARAMETERS *)nativePtr); var debugParams = new ProcessDebugParameters { ExePath = NativeTypes.FromNativeString(nativeParameters.ExePath), Arguments = NativeTypes.FromNativeString(nativeParameters.Arguments), LockFile = NativeTypes.FromNativeString(nativeParameters.LockFile), WorkingFolder = NativeTypes.FromNativeString(nativeParameters.WorkingFolder), DebugParametersFile = NativeTypes.FromNativeString(nativeParameters.DebugParametersFile), EnvVars = NativeTypes.FromNativeStringPairList(nativeParameters.EnvVars), ContainerEntryPoints = NativeTypes.FromNativeStringList(nativeParameters.ContainerEntryPoints), ContainerMountedVolumes = NativeTypes.FromNativeStringList(nativeParameters.ContainerMountedVolumes), ContainerEnvironmentBlock = NativeTypes.FromNativeStringList(nativeParameters.ContainerEnvironmentBlock) }; if (nativeParameters.Reserved != null) { var nativeParametersx1 = *((NativeTypes.FABRIC_PROCESS_DEBUG_PARAMETERS_EX1 *)nativeParameters.Reserved); debugParams.ContainerLabels = NativeTypes.FromNativeStringList(nativeParametersx1.ContainerLabels); } return(debugParams); }
internal static unsafe DeployedServiceReplicaDetail CreateFromNative( NativeTypes.FABRIC_DEPLOYED_STATELESS_SERVICE_INSTANCE_DETAIL_QUERY_RESULT_ITEM nativeResultItem) { DeployedStatelessServiceInstance deployedReplicaInstance = new DeployedStatelessServiceInstance(); if (nativeResultItem.Reserved != IntPtr.Zero) { var extended1 = (NativeTypes.FABRIC_DEPLOYED_STATELESS_SERVICE_INSTANCE_DETAIL_QUERY_RESULT_ITEM_EX1 *)nativeResultItem.Reserved; var deployedServiceReplica = *(NativeTypes.FABRIC_DEPLOYED_STATELESS_SERVICE_INSTANCE_QUERY_RESULT_ITEM *)extended1->DeployedServiceReplica; deployedReplicaInstance = DeployedStatelessServiceInstance.FromNative(deployedServiceReplica); } var rv = new DeployedStatelessServiceInstanceDetail { CurrentServiceOperation = (ServiceOperationName)nativeResultItem.CurrentServiceOperation, CurrentServiceOperationStartTimeUtc = NativeTypes.FromNativeFILETIME(nativeResultItem.CurrentServiceOperationStartTimeUtc), InstanceId = nativeResultItem.InstanceId, PartitionId = nativeResultItem.PartitionId, ReportedLoad = LoadMetricReport.CreateFromNativeList((NativeTypes.FABRIC_LOAD_METRIC_REPORT_LIST *)nativeResultItem.ReportedLoad), ServiceName = new Uri(NativeTypes.FromNativeString(nativeResultItem.ServiceName)), DeployedServiceReplicaInstance = deployedReplicaInstance, }; return(rv); }
internal static unsafe ServiceCorrelationDescription CreateFromNative(IntPtr nativePtr) { ReleaseAssert.AssertIfNot(nativePtr != IntPtr.Zero, StringResources.Error_NullNativePointer); ServiceCorrelationDescription correlation = new ServiceCorrelationDescription(); NativeTypes.FABRIC_SERVICE_CORRELATION_DESCRIPTION *casted = (NativeTypes.FABRIC_SERVICE_CORRELATION_DESCRIPTION *)nativePtr; correlation.ServiceName = NativeTypes.FromNativeUri(casted->ServiceName); switch (casted->Scheme) { case NativeTypes.FABRIC_SERVICE_CORRELATION_SCHEME.FABRIC_SERVICE_CORRELATION_SCHEME_AFFINITY: correlation.Scheme = ServiceCorrelationScheme.Affinity; break; case NativeTypes.FABRIC_SERVICE_CORRELATION_SCHEME.FABRIC_SERVICE_CORRELATION_SCHEME_ALIGNED_AFFINITY: correlation.Scheme = ServiceCorrelationScheme.AlignedAffinity; break; case NativeTypes.FABRIC_SERVICE_CORRELATION_SCHEME.FABRIC_SERVICE_CORRELATION_SCHEME_NONALIGNED_AFFINITY: correlation.Scheme = ServiceCorrelationScheme.NonAlignedAffinity; break; default: AppTrace.TraceSource.WriteError("ServiceCorrelationDescription.CreateFromNative", "Invalid service correlation scheme {0}", casted->Scheme); ReleaseAssert.Failfast(string.Format(CultureInfo.CurrentCulture, StringResources.Error_InvalidServiceCorrelationScheme_Formatted, casted->Scheme)); break; } return(correlation); }
internal static unsafe StopNodeDescriptionUsingNodeName CreateFromNative(IntPtr nativeRaw) { var native = *(NativeTypes.FABRIC_STOP_NODE_DESCRIPTION_USING_NODE_NAME *)nativeRaw; string nodeName = NativeTypes.FromNativeString(native.NodeName); BigInteger nodeInstance = new BigInteger(native.NodeInstance); CompletionMode completionMode; switch (native.CompletionMode) { case NativeTypes.FABRIC_COMPLETION_MODE.FABRIC_COMPLETION_MODE_DO_NOT_VERIFY: completionMode = CompletionMode.DoNotVerify; break; case NativeTypes.FABRIC_COMPLETION_MODE.FABRIC_COMPLETION_MODE_VERIFY: completionMode = CompletionMode.Verify; break; default: completionMode = CompletionMode.Invalid; break; } return(new StopNodeDescriptionUsingNodeName(nodeName, nodeInstance, completionMode)); }
private BOOLEAN OnUpdateHelper(IntPtr sectionName, IntPtr keyName) { return(NativeTypes.ToBOOLEAN( this.updateHandler.OnUpdate( NativeTypes.FromNativeString(sectionName), NativeTypes.FromNativeString(keyName)))); }
internal IntPtr ToNative(PinCollection pinCollection) { var nativeDescription = new NativeTypes.FABRIC_APPLICATION_TYPE_PAGED_QUERY_DESCRIPTION(); nativeDescription.ApplicationTypeNameFilter = pinCollection.AddObject(this.ApplicationTypeNameFilter); // bools are not blittable (directly readable in native) nativeDescription.ExcludeApplicationParameters = NativeTypes.ToBOOLEAN(this.ExcludeApplicationParameters); nativeDescription.ContinuationToken = pinCollection.AddObject(this.ContinuationToken); nativeDescription.MaxResults = this.MaxResults; var ex1 = new NativeTypes.FABRIC_APPLICATION_TYPE_PAGED_QUERY_DESCRIPTION_EX1(); ex1.ApplicationTypeVersionFilter = pinCollection.AddObject(this.ApplicationTypeVersionFilter); var ex2 = new NativeTypes.FABRIC_APPLICATION_TYPE_PAGED_QUERY_DESCRIPTION_EX2(); ex2.ApplicationTypeDefinitionKindFilter = (UInt32)this.ApplicationTypeDefinitionKindFilter; ex2.Reserved = IntPtr.Zero; ex1.Reserved = pinCollection.AddBlittable(ex2); nativeDescription.Reserved = pinCollection.AddBlittable(ex1); return(pinCollection.AddBlittable(nativeDescription)); }
NativeCommon.IFabricAsyncOperationContext NativeTokenValidationService.IFabricTokenValidationService.BeginValidateToken(IntPtr authToken, uint timeoutInMilliseconds, NativeCommon.IFabricAsyncOperationCallback callback) { string managedToken = NativeTypes.FromNativeString(authToken); TimeSpan managedTimeout = TimeSpan.FromMilliseconds(timeoutInMilliseconds); return(Utility.WrapNativeAsyncMethodImplementation((cancellationToken) => this.ValidateTokenAsync(managedToken, managedTimeout, cancellationToken), callback, "TokenValidationServiceBroker.ValidateTokenAsync", ValidateAsyncApi)); }
internal static unsafe SecurityUserDescription CreateFromNative(IntPtr native) { var nativeDescription = (NativeTypes.FABRIC_SECURITY_USER_DESCRIPTION *)native; var name = NativeTypes.FromNativeString(nativeDescription->Name); var sid = new SecurityIdentifier(NativeTypes.FromNativeString(nativeDescription->Sid)); var nativeParentSystemGroups = (NativeTypes.FABRIC_STRING_LIST *)nativeDescription->ParentSystemGroups; var nativeParentSystemGroupsStringArray = (char **)nativeParentSystemGroups->Items; var parentSystemGroups = new ItemList <string>(); for (int i = 0; i < nativeParentSystemGroups->Count; i++) { var nativeItemPtr = (IntPtr)(nativeParentSystemGroupsStringArray + i); parentSystemGroups.Add(NativeTypes.FromNativeStringPointer(nativeItemPtr)); } var nativeParentApplicationGroups = (NativeTypes.FABRIC_STRING_LIST *)nativeDescription->ParentApplicationGroups; var nativeParentApplicationGroupsStringArray = (char **)nativeParentApplicationGroups->Items; var parentApplicationGroups = new ItemList <string>(); for (int i = 0; i < nativeParentApplicationGroups->Count; i++) { var nativeItemPtr = (IntPtr)(nativeParentApplicationGroupsStringArray + i); parentApplicationGroups.Add(NativeTypes.FromNativeStringPointer(nativeItemPtr)); } return(new SecurityUserDescription( name, sid, parentSystemGroups, parentApplicationGroups)); }
internal static unsafe ApplicationResourceIdentifier FromNative( NativeTypes.FABRIC_SECURITY_APPLICATION_RESOURCE_IDENTIFIER *nativePtr) { var applicationName = NativeTypes.FromNativeUri(nativePtr->ApplicationName); return(new ApplicationResourceIdentifier(applicationName)); }
internal IntPtr ToNative(PinCollection pinCollection) { var nativeFilter = new NativeTypes.FABRIC_PARTITION_HEALTH_STATISTICS_FILTER(); nativeFilter.ExcludeHealthStatistics = NativeTypes.ToBOOLEAN(this.ExcludeHealthStatistics); return(pinCollection.AddBlittable(nativeFilter)); }
protected void PopulateBackupPolicyFromNative(NativeBackupRestoreTypes.FABRIC_BACKUP_POLICY backupPolicy) { Name = NativeTypes.FromNativeString(backupPolicy.Name); PolicyId = backupPolicy.PolicyId; MaxIncrementalBackups = backupPolicy.MaxIncrementalBackups; StoreInformation = BackupStoreInformation.FromNative(backupPolicy.StoreInformation); }
private void UpdateValuesFromStatus(NativeTypes.MemoryStatusEx status) { TotalVirtualMemory = new IntPtr(status.TotalVirtual); AvailableVirtualMemory = new IntPtr(status.AvailVirtual); TotalPhysicalMemory = new IntPtr(status.TotalPhys); AvailablePhysicalMemory = new IntPtr(status.AvailPhys); }
internal MSSQLTypeDesc(short typeIndex, NativeTypes baseType, string name, TypeOptions options, TypeUsageInfo typeInfo) { Contract.Requires(typeIndex > 256); Contract.Requires(typeInfo != null); Id = typeIndex; BaseType = baseType; IsDerived = Id != (short) BaseType; Name = name; Options = options; TypeInfo = typeInfo; }
public MSSQLTypeDesc GetDesc(NativeTypes type) { return _nativeTypeDictionary[type]; }
internal static extern bool GlobalMemoryStatus(ref NativeTypes.MemoryStatus lpBuffer);
public static string ConvertDefault(NativeTypes type, string value) { if (string.IsNullOrEmpty(value)) { return null; } value = RemoveExcessBraces(value); switch (type) { #region DateTime case NativeTypes.SmallDateTime: case NativeTypes.DateTime: case NativeTypes.DateTime2: switch (value.ToLower()) { case "sysdatetime()": case "sysdatetimeoffset()": case "sysutcdatetime()": case "current_timestamp": case "getdate()": case "getutcdate()": return "DateTime.Now"; default: return null; } #endregion #region Bit case NativeTypes.Bit: switch (value) { case "0": return "false"; case "1": return "true"; default: return null; } #endregion #region Int case NativeTypes.Int: { int val; return !int.TryParse(value, out val) ? null : val.ToString(CultureInfo.InvariantCulture); } #endregion #region Decimal case NativeTypes.Decimal: { decimal val; return !decimal.TryParse(value, out val) ? null : val.ToString(CultureInfo.InvariantCulture); } #endregion #region Real case NativeTypes.Real: { float val; return !float.TryParse(value, out val) ? null : val.ToString(CultureInfo.InvariantCulture); } #endregion #region Float case NativeTypes.Float: { double val; return !double.TryParse(value, out val) ? null : val.ToString(CultureInfo.InvariantCulture); } #endregion #region Short case NativeTypes.SmallInt: { short val; return !short.TryParse(value, out val) ? null : val.ToString(CultureInfo.InvariantCulture); } #endregion #region Byte case NativeTypes.TinyInt: { byte val; return !byte.TryParse(value, out val) ? null : val.ToString(CultureInfo.InvariantCulture); } #endregion #region Guid case NativeTypes.UniqueIdentifier: { switch (value.ToLower()) { case "newsequentialid()": case "newid()": return "Guid.NewGuid()"; default: return null; } } #endregion #region String case NativeTypes.NChar: case NativeTypes.NVarchar: case NativeTypes.Char: case NativeTypes.Varchar: { var match = StringRegEx.Match(value); if (!match.Success) { return null; } return "\"" + match.Groups["TEXT"].Value.Replace("''", "'").Replace("\"", "\\\"") + "\""; } #endregion } return null; }
internal static extern int GetSystemMetrics(NativeTypes.SystemMetrics smIndex);