Пример #1
0
        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);
        }
Пример #2
0
        private void CopyFrom(ServiceTypeDescription other)
        {
            // Copy basic types
            this.PlacementConstraints = other.PlacementConstraints;
            this.ServiceTypeName      = other.ServiceTypeName;

            // Create copies of reference types
            this.Policies.AddRange(other.Policies.Select(p => p.GetCopy()));

            ServiceLoadMetricDescription.CopyFrom(other.LoadMetrics, this.LoadMetrics);

            this.extensions = other.Extensions == null ? this.extensions : new Dictionary <string, string>(other.Extensions);
        }
        internal static unsafe ServiceGroupTypeDescription CreateFromNative(IntPtr descriptionPtr)
        {
            NativeTypes.FABRIC_SERVICE_GROUP_TYPE_DESCRIPTION *nativeDescription = (NativeTypes.FABRIC_SERVICE_GROUP_TYPE_DESCRIPTION *)descriptionPtr;

            ServiceGroupTypeDescription description = new ServiceGroupTypeDescription();

            description.ServiceTypeDescription = ServiceTypeDescription.CreateFromNative(nativeDescription->Description);

            bool isStateful = (description.ServiceTypeDescription.ServiceTypeKind == ServiceDescriptionKind.Stateful);

            NativeTypes.FABRIC_SERVICE_GROUP_TYPE_MEMBER_DESCRIPTION_LIST *nativeMemberList = (NativeTypes.FABRIC_SERVICE_GROUP_TYPE_MEMBER_DESCRIPTION_LIST *)nativeDescription->Members;
            for (int i = 0; i < nativeMemberList->Count; ++i)
            {
                description.Members.Add(ServiceGroupTypeMemberDescription.CreateFromNative(nativeMemberList->Items + (i * Marshal.SizeOf(typeof(NativeTypes.FABRIC_SERVICE_GROUP_TYPE_MEMBER_DESCRIPTION))), isStateful));
            }

            description.UseImplicitFactory = NativeTypes.FromBOOLEAN(nativeDescription->UseImplicitFactory);

            return(description);
        }
Пример #4
0
 /// <summary>
 /// <para>
 /// Instantiates a <see cref="System.Fabric.Description.ServiceTypeDescription" /> class with parameters from another
 /// <see cref="System.Fabric.Description.ServiceTypeDescription" /> object.
 /// </para>
 /// </summary>
 /// <param name="other">
 /// <para>The service type description from which parameters are copied.</para>
 /// </param>
 protected internal ServiceTypeDescription(ServiceTypeDescription other)
     : this(other.ServiceTypeKind)
 {
     this.CopyFrom(other);
 }