Exemple #1
0
        internal static unsafe ServicePlacementPolicyDescription CreateFromNative(IntPtr nativePtr)
        {
            ReleaseAssert.AssertIfNot(nativePtr != IntPtr.Zero, StringResources.Error_NullNativePointer);

            NativeTypes.FABRIC_SERVICE_PLACEMENT_POLICY_DESCRIPTION *casted = (NativeTypes.FABRIC_SERVICE_PLACEMENT_POLICY_DESCRIPTION *)nativePtr;
            switch (casted->Type)
            {
            case NativeTypes.FABRIC_PLACEMENT_POLICY_TYPE.FABRIC_PLACEMENT_POLICY_INVALID_DOMAIN:
                return(ServicePlacementInvalidDomainPolicyDescription.CreateFromNative(casted->Value));

            case NativeTypes.FABRIC_PLACEMENT_POLICY_TYPE.FABRIC_PLACEMENT_POLICY_REQUIRED_DOMAIN:
                return(ServicePlacementRequiredDomainPolicyDescription.CreateFromNative(casted->Value));

            case NativeTypes.FABRIC_PLACEMENT_POLICY_TYPE.FABRIC_PLACEMENT_POLICY_PREFERRED_PRIMARY_DOMAIN:
                return(ServicePlacementPreferPrimaryDomainPolicyDescription.CreateFromNative(casted->Value));

            case NativeTypes.FABRIC_PLACEMENT_POLICY_TYPE.FABRIC_PLACEMENT_POLICY_REQUIRED_DOMAIN_DISTRIBUTION:
                return(ServicePlacementRequireDomainDistributionPolicyDescription.CreateFromNative(casted->Value));

            case NativeTypes.FABRIC_PLACEMENT_POLICY_TYPE.FABRIC_PLACEMENT_POLICY_NONPARTIALLY_PLACE_SERVICE:
                return(ServicePlacementNonPartiallyPlaceServicePolicyDescription.CreateFromNative(casted->Value));

            default:
                AppTrace.TraceSource.WriteError("ServicePlacementPolicyDescription.CreateFromNative", "Invalid placement policy type {0}", casted->Type);
                break;
            }
            return(null);
        }
Exemple #2
0
        internal ServicePlacementPolicyDescription GetCopy()
        {
            ServicePlacementPolicyDescription copy;

            if (this is ServicePlacementInvalidDomainPolicyDescription)
            {
                copy = new ServicePlacementInvalidDomainPolicyDescription(this as ServicePlacementInvalidDomainPolicyDescription);
            }
            else if (this is ServicePlacementRequiredDomainPolicyDescription)
            {
                copy = new ServicePlacementRequiredDomainPolicyDescription(this as ServicePlacementRequiredDomainPolicyDescription);
            }
            else if (this is ServicePlacementPreferPrimaryDomainPolicyDescription)
            {
                copy = new ServicePlacementPreferPrimaryDomainPolicyDescription(this as ServicePlacementPreferPrimaryDomainPolicyDescription);
            }
            else if (this is ServicePlacementRequireDomainDistributionPolicyDescription)
            {
                copy = new ServicePlacementRequireDomainDistributionPolicyDescription(this as ServicePlacementRequireDomainDistributionPolicyDescription);
            }
            else
            {
                copy = new ServicePlacementNonPartiallyPlaceServicePolicyDescription(this as ServicePlacementNonPartiallyPlaceServicePolicyDescription);
            }

            return(copy);
        }
Exemple #3
0
        internal static new unsafe ServicePlacementPreferPrimaryDomainPolicyDescription CreateFromNative(IntPtr nativePtr)
        {
            ReleaseAssert.AssertIfNot(nativePtr != IntPtr.Zero, StringResources.Error_NullNativePointer);
            NativeTypes.FABRIC_PLACEMENT_POLICY_PREFERRED_PRIMARY_DOMAIN_DESCRIPTION *casted = (NativeTypes.FABRIC_PLACEMENT_POLICY_PREFERRED_PRIMARY_DOMAIN_DESCRIPTION *)nativePtr;

            var policy = new ServicePlacementPreferPrimaryDomainPolicyDescription();

            policy.DomainName = NativeTypes.FromNativeString(casted->PreferredPrimaryFaultDomain);

            return(policy);
        }
Exemple #4
0
 // Copy ctor
 internal ServicePlacementPreferPrimaryDomainPolicyDescription(ServicePlacementPreferPrimaryDomainPolicyDescription other)
     : base(other)
 {
     this.DomainName = other.DomainName;
 }