Пример #1
0
        public static void ValidateCorrelationInitializer(ActivityMetadata metadata, Collection <CorrelationInitializer> correlationInitializers, bool isReply, string displayName, string operationName)
        {
            Fx.Assert(metadata != null, "cannot be null");

            if (correlationInitializers != null && correlationInitializers.Count > 0)
            {
                bool queryInitializerWithEmptyHandle = false;
                foreach (CorrelationInitializer correlation in correlationInitializers)
                {
                    if (correlation is RequestReplyCorrelationInitializer && isReply)
                    {
                        // This is a reply, so additional correlations should not have a request reply handle
                        metadata.AddValidationError(SR.ReplyShouldNotIncludeRequestReplyHandle(displayName, operationName));
                    }

                    QueryCorrelationInitializer queryCorrelation = correlation as QueryCorrelationInitializer;
                    if (queryCorrelation != null)
                    {
                        if (queryCorrelation.MessageQuerySet.Count == 0)
                        {
                            metadata.AddValidationError(SR.QueryCorrelationInitializerWithEmptyMessageQuerySet(displayName, operationName));
                        }
                    }

                    if (correlation.CorrelationHandle == null)
                    {
                        if (correlation is QueryCorrelationInitializer)
                        {
                            if (!queryInitializerWithEmptyHandle)
                            {
                                queryInitializerWithEmptyHandle = true;
                            }
                            else
                            {
                                // more than one queryInitializer present, in this case we don't permit null handle
                                metadata.AddValidationError(SR.NullCorrelationHandleInMultipleQueryCorrelation);
                            }
                        }
                        else
                        {
                            metadata.AddValidationError(SR.NullCorrelationHandleInInitializeCorrelation(correlation.GetType().Name));
                        }
                    }
                }
            }
        }