コード例 #1
0
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as MessageSourceComponent;

                if (dest != null)
                {
                    base.CopyTo(dest);
                    if (NameElement != null)
                    {
                        dest.NameElement = (Hl7.Fhir.Model.FhirString)NameElement.DeepCopy();
                    }
                    if (SoftwareElement != null)
                    {
                        dest.SoftwareElement = (Hl7.Fhir.Model.FhirString)SoftwareElement.DeepCopy();
                    }
                    if (VersionElement != null)
                    {
                        dest.VersionElement = (Hl7.Fhir.Model.FhirString)VersionElement.DeepCopy();
                    }
                    if (Contact != null)
                    {
                        dest.Contact = (Hl7.Fhir.Model.Contact)Contact.DeepCopy();
                    }
                    if (EndpointElement != null)
                    {
                        dest.EndpointElement = (Hl7.Fhir.Model.FhirUri)EndpointElement.DeepCopy();
                    }
                    return(dest);
                }
                else
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }
            }
コード例 #2
0
        /// <summary>
        /// 获取终结点地址
        /// </summary>
        /// <returns>终结点地址</returns>
        private EndpointAddress GetEndpointAddress <T>()
        {
            string configName = typeof(T).FullName;

            if (!ConfigMediator.EndpointElements.ContainsKey(configName))
            {
                throw new NullReferenceException($"名称为\"{configName}\"的终结点未配置!");
            }

            EndpointElement endpointElement = ConfigMediator.EndpointElements[configName];
            Uri             uri             = new Uri(endpointElement.Address);

            AddressHeader[] addressHeaders = null;

            if (endpointElement.HeaderProviderElement != null &&
                !string.IsNullOrWhiteSpace(endpointElement.HeaderProviderElement.Type) &&
                !string.IsNullOrWhiteSpace(endpointElement.HeaderProviderElement.Assembly))
            {
                Assembly assembly = Assembly.Load(endpointElement.HeaderProviderElement.Assembly);
                Type     type     = assembly.GetType(endpointElement.HeaderProviderElement.Type);

                if (!typeof(IHeaderProvider).IsAssignableFrom(type))
                {
                    throw new InvalidOperationException($"类型\"{type.FullName}\"未实现接口\"IHeaderProvider\"!");
                }

                IHeaderProvider headerProvider = (IHeaderProvider)Activator.CreateInstance(type);
                addressHeaders = headerProvider.GetHeaders();
            }

            EndpointAddress address = new EndpointAddress(uri, addressHeaders ?? new AddressHeader[0]);

            return(address);
        }
コード例 #3
0
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as MessageDestinationComponent;

                if (dest != null)
                {
                    base.CopyTo(dest);
                    if (NameElement != null)
                    {
                        dest.NameElement = (Hl7.Fhir.Model.FhirString)NameElement.DeepCopy();
                    }
                    if (Target != null)
                    {
                        dest.Target = (Hl7.Fhir.Model.ResourceReference)Target.DeepCopy();
                    }
                    if (EndpointElement != null)
                    {
                        dest.EndpointElement = (Hl7.Fhir.Model.FhirUri)EndpointElement.DeepCopy();
                    }
                    return(dest);
                }
                else
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }
            }
コード例 #4
0
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as ChannelComponent;

                if (dest == null)
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }

                base.CopyTo(dest);
                if (TypeElement != null)
                {
                    dest.TypeElement = (Code <Hl7.Fhir.Model.Subscription.SubscriptionChannelType>)TypeElement.DeepCopy();
                }
                if (EndpointElement != null)
                {
                    dest.EndpointElement = (Hl7.Fhir.Model.FhirUri)EndpointElement.DeepCopy();
                }
                if (PayloadElement != null)
                {
                    dest.PayloadElement = (Hl7.Fhir.Model.FhirString)PayloadElement.DeepCopy();
                }
                if (HeaderElement != null)
                {
                    dest.HeaderElement = (Hl7.Fhir.Model.FhirString)HeaderElement.DeepCopy();
                }
                return(dest);
            }
コード例 #5
0
            public override ErrorList Validate()
            {
                var result = new ErrorList();

                result.AddRange(base.Validate());

                if (NameElement != null)
                {
                    result.AddRange(NameElement.Validate());
                }
                if (SoftwareElement != null)
                {
                    result.AddRange(SoftwareElement.Validate());
                }
                if (VersionElement != null)
                {
                    result.AddRange(VersionElement.Validate());
                }
                if (Contact != null)
                {
                    result.AddRange(Contact.Validate());
                }
                if (EndpointElement != null)
                {
                    result.AddRange(EndpointElement.Validate());
                }

                return(result);
            }
コード例 #6
0
 public PrerenderSection()
 {
     IgnoreExtentions = new IgnoreExtentionsColletion();
     Crawlers         = new CrawlersColletion();
     Endpoint         = new EndpointElement {
         Url = "http://service.prerender.io"
     };
 }
コード例 #7
0
        //Private

        #region # 获取绑定实例 —— Binding GetBinding<T>()
        /// <summary>
        /// 获取绑定实例
        /// </summary>
        /// <returns>绑定实例</returns>
        private Binding GetBinding <T>()
        {
            string configName = typeof(T).FullName;

            if (!ConfigMediator.EndpointElements.ContainsKey(configName))
            {
                throw new NullReferenceException($"名称为\"{configName}\"的终结点未配置!");
            }

            EndpointElement endpointElement = ConfigMediator.EndpointElements[configName];

            if (!Constants.AvailableBindings.ContainsKey(endpointElement.Binding))
            {
                throw new InvalidOperationException($"目前不支持\"{endpointElement.Binding}\"绑定!");
            }

            Binding currentBinding = Constants.AvailableBindings[endpointElement.Binding];

            return(currentBinding);
        }
コード例 #8
0
            public override ErrorList Validate()
            {
                var result = new ErrorList();

                result.AddRange(base.Validate());

                if (NameElement != null)
                {
                    result.AddRange(NameElement.Validate());
                }
                if (Target != null)
                {
                    result.AddRange(Target.Validate());
                }
                if (EndpointElement != null)
                {
                    result.AddRange(EndpointElement.Validate());
                }

                return(result);
            }
コード例 #9
0
            public void should_read_everything()
            {
                const string config = @"<endpoints>
							<endpoint name=""tester"" connectionString=""amqp://localhost:666"">
								<incoming>
									<on key=""a"" label=""msg.a"" react=""DynamicHandler"" requiresAccept=""true"" />
									<on key=""b"" label=""msg.b"" react=""TransformB"" />
								</incoming>
								<outgoing>
									<route key=""a"" label=""msg.out.a"" persist=""true"">
										<callbackEndpoint default=""true"" />
									</route>
								</outgoing>
							</endpoint>
						</endpoints>"                        ;

                var section = new XmlEndpointsSection(config);

                section.Endpoints.Should().
                HaveCount(1);

                EndpointElement endpoint = section.Endpoints["tester"];

                endpoint.Incoming.Should().
                HaveCount(2);
                endpoint.Outgoing.Should().
                HaveCount(1);

                List <IncomingElement> incoming = endpoint.Incoming.OfType <IncomingElement>().
                                                  ToList();

                incoming[0].RequiresAccept.Should().
                BeTrue();
                incoming[1].RequiresAccept.Should().
                BeFalse();
            }
コード例 #10
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Subscription;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (NameElement != null)
            {
                dest.NameElement = (Hl7.Fhir.Model.FhirString)NameElement.DeepCopy();
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.SubscriptionState>)StatusElement.DeepCopy();
            }
            if (Topic != null)
            {
                dest.Topic = (Hl7.Fhir.Model.ResourceReference)Topic.DeepCopy();
            }
            if (Contact != null)
            {
                dest.Contact = new List <Hl7.Fhir.Model.ContactPoint>(Contact.DeepCopy());
            }
            if (EndElement != null)
            {
                dest.EndElement = (Hl7.Fhir.Model.Instant)EndElement.DeepCopy();
            }
            if (ReasonElement != null)
            {
                dest.ReasonElement = (Hl7.Fhir.Model.FhirString)ReasonElement.DeepCopy();
            }
            if (FilterBy != null)
            {
                dest.FilterBy = new List <Hl7.Fhir.Model.Subscription.FilterByComponent>(FilterBy.DeepCopy());
            }
            if (Error != null)
            {
                dest.Error = new List <Hl7.Fhir.Model.CodeableConcept>(Error.DeepCopy());
            }
            if (ChannelType != null)
            {
                dest.ChannelType = (Hl7.Fhir.Model.Coding)ChannelType.DeepCopy();
            }
            if (EndpointElement != null)
            {
                dest.EndpointElement = (Hl7.Fhir.Model.FhirUrl)EndpointElement.DeepCopy();
            }
            if (HeaderElement != null)
            {
                dest.HeaderElement = new List <Hl7.Fhir.Model.FhirString>(HeaderElement.DeepCopy());
            }
            if (HeartbeatPeriodElement != null)
            {
                dest.HeartbeatPeriodElement = (Hl7.Fhir.Model.UnsignedInt)HeartbeatPeriodElement.DeepCopy();
            }
            if (TimeoutElement != null)
            {
                dest.TimeoutElement = (Hl7.Fhir.Model.UnsignedInt)TimeoutElement.DeepCopy();
            }
            if (ContentTypeElement != null)
            {
                dest.ContentTypeElement = (Hl7.Fhir.Model.Code)ContentTypeElement.DeepCopy();
            }
            if (ContentElement != null)
            {
                dest.ContentElement = (Code <Hl7.Fhir.Model.Subscription.SubscriptionPayloadContent>)ContentElement.DeepCopy();
            }
            return(dest);
        }
コード例 #11
0
        /// <summary>
        /// 创建gRPC信道
        /// </summary>
        /// <param name="endpoint">终结点配置</param>
        /// <returns>gRPC信道</returns>
        private static GrpcChannel CreateGrpcChannel(EndpointElement endpoint)
        {
            //读取配置文件
            EndpointConfigurationElement   endpointConfiguration   = null;
            IList <AuthInterceptorElement> authInterceptorElements = new List <AuthInterceptorElement>();

            if (!string.IsNullOrWhiteSpace(endpoint.EndpointConfiguration))
            {
                endpointConfiguration = GrpcSetting.EndpointConfigurations[endpoint.EndpointConfiguration];
            }
            if (!string.IsNullOrWhiteSpace(endpoint.AuthInterceptors))
            {
                string[] authInterceptorNames = endpoint.AuthInterceptors.Split(',');
                authInterceptorElements = GrpcSetting.AuthInterceptors.Where <KeyValuePair <string, AuthInterceptorElement> >(x => authInterceptorNames.Contains(x.Key)).Select(x => x.Value).ToList();
            }

            //构造身份凭据
            IList <CallCredentials> callCredentials = new List <CallCredentials>();

            foreach (AuthInterceptorElement authInterceptorElement in authInterceptorElements)
            {
                Assembly         assembly        = Assembly.Load(authInterceptorElement.Assembly);
                Type             type            = assembly.GetType(authInterceptorElement.Type);
                IAuthInterceptor authInterceptor = (IAuthInterceptor)Activator.CreateInstance(type);

                CallCredentials callCredential = CallCredentials.FromInterceptor(authInterceptor.AuthIntercept);
                callCredentials.Add(callCredential);
            }
            CallCredentials credentials = null;

            if (callCredentials.Count == 1)
            {
                credentials = callCredentials.Single();
            }
            if (callCredentials.Count > 1)
            {
                credentials = CallCredentials.Compose(callCredentials.ToArray());
            }

            //构造gRPC信道选项
            GrpcChannelOptions channelOptions = new GrpcChannelOptions
            {
                MaxSendMessageSize                   = endpointConfiguration?.MaxSendMessageSize,
                MaxReceiveMessageSize                = endpointConfiguration?.MaxReceiveMessageSize,
                MaxRetryAttempts                     = endpointConfiguration?.MaxRetryAttempts,
                MaxRetryBufferSize                   = endpointConfiguration?.MaxRetryBufferSize,
                MaxRetryBufferPerCallSize            = endpointConfiguration?.MaxRetryBufferPerCallSize,
                DisposeHttpClient                    = endpointConfiguration?.DisposeHttpClient ?? false,
                ThrowOperationCanceledOnCancellation = endpointConfiguration?.ThrowOperationCanceledOnCancellation ?? false
            };

            if (credentials != null)
            {
                channelOptions.Credentials = ChannelCredentials.Create(new SslCredentials(), credentials);
            }

            //创建gRPC信道
            GrpcChannel channel = GrpcChannel.ForAddress(endpoint.Address, channelOptions);

            return(channel);
        }
コード例 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AttributeIndex"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 public AttributeIndex(EndpointElement parent)
 {
     _parent = parent;
 }