예제 #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);
        }
예제 #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);
        }
예제 #3
0
        internal static new unsafe ServicePlacementRequiredDomainPolicyDescription CreateFromNative(IntPtr nativePtr)
        {
            ReleaseAssert.AssertIfNot(nativePtr != IntPtr.Zero, StringResources.Error_NullNativePointer);
            NativeTypes.FABRIC_PLACEMENT_POLICY_REQUIRED_DOMAIN_DESCRIPTION *casted =
                (NativeTypes.FABRIC_PLACEMENT_POLICY_REQUIRED_DOMAIN_DESCRIPTION *)nativePtr;

            var policy = new ServicePlacementRequiredDomainPolicyDescription();

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

            return(policy);
        }
예제 #4
0
 /// <summary>
 /// A copy constructor for the ServicePlacementRequiredDomainPolicyDescription class
 /// </summary>
 internal ServicePlacementRequiredDomainPolicyDescription(ServicePlacementRequiredDomainPolicyDescription other)
     : base(other)
 {
     this.DomainName = other.DomainName;
 }