• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Globalization.Message类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Globalization.Message的典型用法代码示例。如果您正苦于以下问题:C# Message类的具体用法?C# Message怎么用?C# Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Message类属于System.Globalization命名空间,在下文中一共展示了Message类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AfterReceiveRequest

        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            var context = WebOperationContext.Current;
            if (HttpContext.Current != null && context != null && context.IncomingRequest.UriTemplateMatch != null)
            {
                var curatedFeedName = HttpContext.Current.Request.QueryString["name"];
                
                // Grab the base and request URIs
                UriBuilder baseUriBuilder = new UriBuilder(context.IncomingRequest.UriTemplateMatch.BaseUri);
                UriBuilder requestUriBuilder = new UriBuilder(context.IncomingRequest.UriTemplateMatch.RequestUri);

                // Replace Host Name
                baseUriBuilder.Host = HttpContext.Current.Request.Url.Host;
                requestUriBuilder.Host = baseUriBuilder.Host;

                // Replace "/api/v2/curated-feed" with "/api/v2/curated-feeds/[feedname]"
                baseUriBuilder.Path = RewriteUrlPath(baseUriBuilder.Path, curatedFeedName);
                requestUriBuilder.Path = RewriteUrlPath(requestUriBuilder.Path, curatedFeedName);

                // Set the matching properties on the incoming request
                OperationContext.Current.IncomingMessageProperties["MicrosoftDataServicesRootUri"] = baseUriBuilder.Uri;
                OperationContext.Current.IncomingMessageProperties["MicrosoftDataServicesRequestUri"] = requestUriBuilder.Uri;
            }

            return null;
        }
开发者ID:atrevisan,项目名称:NuGetGallery,代码行数:26,代码来源:RewriteBaseUrlMessageInspector.cs


示例2: Get

        public Message Get(Message message)
        {
            HttpRequestMessageProperty requestMessageProperty = (HttpRequestMessageProperty) message.Properties[HttpRequestMessageProperty.Name];
            HttpResponseMessageProperty responseMessageProperty = new HttpResponseMessageProperty();

            if ((requestMessageProperty != null) && IsServiceUnchanged(requestMessageProperty.Headers[JsonGlobals.IfModifiedSinceString]))
            {
                Message responseMessage = Message.CreateMessage(MessageVersion.None, string.Empty);
                responseMessageProperty.StatusCode = HttpStatusCode.NotModified;
                responseMessage.Properties.Add(HttpResponseMessageProperty.Name, responseMessageProperty);
                return responseMessage;
            }

            string proxyContent = this.GetProxyContent(UriTemplate.RewriteUri(this.endpoint.Address.Uri, requestMessageProperty.Headers[HttpRequestHeader.Host]));
            Message response = new WebScriptMetadataMessage(string.Empty, proxyContent);
            responseMessageProperty.Headers.Add(JsonGlobals.LastModifiedString, ServiceLastModifiedRfc1123String);
            responseMessageProperty.Headers.Add(JsonGlobals.ExpiresString, ServiceLastModifiedRfc1123String);
            if (AspNetEnvironment.Current.AspNetCompatibilityEnabled)
            {
                HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Public);
            }
            else
            {
                responseMessageProperty.Headers.Add(JsonGlobals.CacheControlString, JsonGlobals.publicString);
            }
            response.Properties.Add(HttpResponseMessageProperty.Name, responseMessageProperty);
            return response;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:28,代码来源:WebScriptClientGenerator.cs


示例3: ArgumentNullException

        /// <summary>
        /// Associates a local operation with the incoming method.
        /// </summary>
        /// <param name="message">The incoming <see cref="Message"/> to be associated with an operation.</param>
        /// <returns>The name of the operation to be associated with the message.</returns>
        string IDispatchOperationSelector.SelectOperation(ref Message message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            HttpRequestMessage requestMessage = message.ToHttpRequestMessage();
            if (requestMessage == null)
            {
                throw new InvalidOperationException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        SR.HttpOperationSelectorNullRequest,
                        this.GetType().Name));
            }

            string operation = this.SelectOperation(requestMessage);
            if (operation == null)
            {
                throw new InvalidOperationException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        SR.HttpOperationSelectorNullOperation,
                        this.GetType().Name));
            }

            return operation;
        }
开发者ID:AlexZeitler,项目名称:WcfHttpMvcFormsAuth,代码行数:34,代码来源:HttpMessageOperationSelector.cs


示例4: HandleMessage

        public override void HandleMessage(Message message)
        {
            if (message.Name == "ASR.MainForm:updateSection")
            {
                var ctl = message.Sender as Sitecore.Web.UI.HtmlControls.Control;
                if (ctl != null)
                {
                    Sitecore.Context.ClientPage.ClientResponse.Refresh(ctl);
                }
                return;
            }
            if (message.Name.StartsWith("ASRMainFormCommand:"))
            {
                string commandname = message.Name.Substring(message.Name.IndexOf(':') + 1);
                var parameters = new NameValueCollection { { "name", commandname } };
                Sitecore.Context.ClientPage.Start(this, "RunCommand", parameters);
                return;
            }
            if (message.Name == "event:click")
            {
                var nvc = message.Sender as NameValueCollection;
                if (nvc != null)
                {
                    string eventname = nvc["__PARAMETERS"];
                    if (!string.IsNullOrEmpty(eventname))
                    {
                        HandleClickEvent(message, eventname);
                        return;
                    }
                }
            }

            base.HandleMessage(message);
        }
开发者ID:Sitecore,项目名称:AdvancedSystemReporter,代码行数:34,代码来源:ASR.cs


示例5: TryCreateException

        public bool TryCreateException(Message message, MessageFault fault, out Exception exception)
        {
            if (message == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
            }
            if (fault == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("fault");
            }

            bool created = this.OnTryCreateException(message, fault, out exception);

            if (created)
            {
                if (exception == null)
                {
                    string text = SR.Format(SR.FaultConverterDidNotCreateException, this.GetType().Name);
                    Exception error = new InvalidOperationException(text);
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(error);
                }
            }
            else
            {
                if (exception != null)
                {
                    string text = SR.Format(SR.FaultConverterCreatedException, this.GetType().Name);
                    Exception error = new InvalidOperationException(text, exception);
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(error);
                }
            }

            return created;
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:34,代码来源:FaultConverter.cs


示例6: SecurityHeader

        public SecurityHeader(Message message,
            string actor, bool mustUnderstand, bool relay,
            SecurityStandardsManager standardsManager, SecurityAlgorithmSuite algorithmSuite,
            MessageDirection transferDirection)
        {
            if (message == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
            }
            if (actor == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("actor");
            }
            if (standardsManager == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("standardsManager");
            }
            if (algorithmSuite == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("algorithmSuite");
            }

            _message = message;
            _actor = actor;
            _mustUnderstand = mustUnderstand;
            _relay = relay;
            _standardsManager = standardsManager;
            _algorithmSuite = algorithmSuite;
            _transferDirection = transferDirection;
        }
开发者ID:weshaggard,项目名称:wcf,代码行数:30,代码来源:SecurityHeader.cs


示例7: ApplyChannelBinding

 private void ApplyChannelBinding(Message message)
 {
     if (this.enableChannelBinding)
     {
         ChannelBindingUtility.TryAddToMessage(this.ChannelBinding, message, true);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:HttpInput.cs


示例8: should_change_message_label

            public void should_change_message_label()
            {
                var processor = new ContentBasedRouter(m => string.Format("l-{0}", ((string)m.Payload).Length).ToMessageLabel());

                var message = new Message(
                    "boo".ToMessageLabel(),
                    new Dictionary<string, object> { { "This", "That" } },
                    "Body");

                var result = processor.Apply(message).ToList();

                result.Should().HaveCount(1);
                result.Single().Label.Name.Should().Be("l-4");
                result.Single().Payload.Should().Be("Body");

                message = new Message(
                    "boo".ToMessageLabel(),
                    new Dictionary<string, object> { { "This", "That" } },
                    "Another");

                result = processor.Apply(message).ToList();

                result.Should().HaveCount(1);
                result.Single().Label.Name.Should().Be("l-7");
            }
开发者ID:mzabolotko,项目名称:Contour,代码行数:25,代码来源:PatternsSpecs.cs


示例9: PublishMessage

        /// <summary>
        /// Publishes the message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="delayMilliseconds">The delay in ms.</param>
        public void PublishMessage(Message message, int delayMilliseconds)
        {
            var messageId = message.Id;
            var deliveryTag = message.Header.Bag.ContainsKey(HeaderNames.DELIVERY_TAG) ? message.GetDeliveryTag().ToString() : null;

            var headers = new Dictionary<string, object>
            {
                { HeaderNames.MESSAGE_TYPE, message.Header.MessageType.ToString() },
                { HeaderNames.TOPIC, message.Header.Topic },
                { HeaderNames.HANDLED_COUNT, message.Header.HandledCount.ToString(CultureInfo.InvariantCulture) }
            };

            if (message.Header.CorrelationId != Guid.Empty)
                headers.Add(HeaderNames.CORRELATION_ID, message.Header.CorrelationId.ToString());

            message.Header.Bag.Each(header =>
            {
                if (!_headersToReset.Any(htr => htr.Equals(header.Key))) headers.Add(header.Key, header.Value);
            });

            if (!string.IsNullOrEmpty(deliveryTag))
                headers.Add(HeaderNames.DELIVERY_TAG, deliveryTag);

            if (delayMilliseconds > 0)
                headers.Add(HeaderNames.DELAY_MILLISECONDS, delayMilliseconds);

            _channel.BasicPublish(
                _exchangeName,
                message.Header.Topic,
                false,
                CreateBasicProperties(messageId, message.Header.TimeStamp, message.Body.BodyType, message.Header.ContentType, headers),
                message.Body.Bytes);
        }
开发者ID:iancooper,项目名称:Paramore,代码行数:38,代码来源:RmqMessagePublisher.cs


示例10: IntroduceErrorToMessage

        private void IntroduceErrorToMessage(ref Message message)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(message.GetReaderAtBodyContents());

            XmlNamespaceManager nsManager = new XmlNamespaceManager(doc.NameTable);
            nsManager.AddNamespace("tempuri", "http://tempuri.org/");
            XmlElement xNode = doc.SelectSingleNode("//tempuri:x", nsManager) as XmlElement;
            XmlText xValue = xNode.FirstChild as XmlText;
            xValue.Value = (double.Parse(xValue.Value, CultureInfo.InvariantCulture) + 1).ToString(CultureInfo.InvariantCulture);

            MemoryStream ms = new MemoryStream();
            XmlWriterSettings writerSettings = new XmlWriterSettings
            {
                CloseOutput = false,
                OmitXmlDeclaration = true,
                Encoding = Encoding.UTF8,
            };

            XmlWriter writer = XmlWriter.Create(ms, writerSettings);
            doc.WriteTo(writer);
            writer.Close();
            ms.Position = 0;
            XmlReader reader = XmlReader.Create(ms);

            Message newMessage = Message.CreateMessage(message.Version, null, reader);
            newMessage.Headers.CopyHeadersFrom(message);
            newMessage.Properties.CopyProperties(message.Properties);
            message.Close();
            message = newMessage;
        }
开发者ID:GusLab,项目名称:WCFSamples,代码行数:31,代码来源:MyInspector.cs


示例11: AppendTypeToBody

        private void AppendTypeToBody(Message message, StringBuilder bodyBuilder) {
            Type type = message.GetType();
            string typeRef = this._typeResolver.CreateTypeRef(type);

            bodyBuilder.Append(IntegerToString(typeRef.Length));
            bodyBuilder.Append(typeRef);
        }
开发者ID:julianpaulozzi,项目名称:EntityProfiler,代码行数:7,代码来源:JsonMessageSerializer.cs


示例12: AfterReceiveRequest

        /// <summary>
        /// Determines whether the requested message is JSONP. When detected
        /// changes the message to be treated by the WCF Data services Runtime 
        /// as a common JSON request and correlates the output with the requested
        /// callback.
        /// </summary>
        /// <param name="request">Requested message.</param>
        /// <param name="channel">Current client channel.</param>
        /// <param name="instanceContext">Context where the service is running.</param>
        /// <returns>Returns a correlation value indicating the requested callback (when applies).</returns>
        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            if (request.Properties.ContainsKey("UriTemplateMatchResults"))
            {
                var match = (UriTemplateMatch)request.Properties["UriTemplateMatchResults"];
                var format = match.QueryParameters["$format"];

                if ("json".Equals(format, StringComparison.InvariantCultureIgnoreCase))
                {
                    // strip out $format from the query options to avoid an error
                    // due to use of a reserved option (starts with "$")
                    match.QueryParameters.Remove("$format");

                    // replace the Accept header so that the Data Services runtime
                    // assumes the client asked for a JSON representation
                    var httpmsg = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name];
                    httpmsg.Headers["Accept"] = "application/json";

                    var callback = match.QueryParameters["$callback"];

                    if (!string.IsNullOrEmpty(callback))
                    {
                        match.QueryParameters.Remove("$callback");
                        return callback;
                    }
                }
            }

            return null;
        }
开发者ID:nuxleus,项目名称:WCFDataServicesToolkit,代码行数:40,代码来源:JsonInspector.cs


示例13: BeforeSendReply

        /// <summary>
        /// Wraps the resulting content into a JSONP callback function 
        /// extracted on the AfterReceiveReply message.
        /// </summary>
        /// <param name="reply">Outgoing response message.</param>
        /// <param name="correlationState">Correlation state returned by the AfterReceiveReply method.</param>
        public void BeforeSendReply(ref Message reply, object correlationState)
        {
            if (correlationState == null || !(correlationState is string))
                return;

            // If we have a JSONP callback then buffer the response, wrap it with the
            // callback call and then re-create the response message
            var callback = (string)correlationState;

            var reader = reply.GetReaderAtBodyContents();
            reader.ReadStartElement();

            var content = Encoding.UTF8.GetString(reader.ReadContentAsBase64());
            content = string.Format(CultureInfo.InvariantCulture, "{0}({1});", callback, content);

            var newReply = Message.CreateMessage(MessageVersion.None, string.Empty, new JsonBodyWriter(content));
            newReply.Properties.CopyProperties(reply.Properties);
            reply = newReply;

            // change response content type to text/javascript if the JSON (only done when wrapped in a callback)
            var replyProperties =
                (HttpResponseMessageProperty)reply.Properties[HttpResponseMessageProperty.Name];

            replyProperties.Headers["Content-Type"] =
                replyProperties.Headers["Content-Type"].Replace("application/json", "text/javascript");
        }
开发者ID:nuxleus,项目名称:WCFDataServicesToolkit,代码行数:32,代码来源:JsonInspector.cs


示例14: InitiatorSecureMessageDecryptor

		public InitiatorSecureMessageDecryptor (
			Message source, SecurityMessageProperty secprop, InitiatorMessageSecurityBindingSupport security)
			: base (source, security)
		{
			this.security = security;
			request_security = secprop;
		}
开发者ID:kumpera,项目名称:mono,代码行数:7,代码来源:SecureMessageDecryptor.cs


示例15: DeserializeRequest

 public void DeserializeRequest(Message message, object[] parameters)
 {
     if (message == null)
     {
         return;
     }
     WebContentFormat format;
     IDispatchMessageFormatter selectedFormatter;
     if (TryGetEncodingFormat(message, out format))
     {
         this.formatters.TryGetValue(format, out selectedFormatter);
         if (selectedFormatter == null)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperWarning(new InvalidOperationException(SR2.GetString(SR2.UnrecognizedHttpMessageFormat, format, GetSupportedFormats())));
         }
     }
     else
     {
         selectedFormatter = this.defaultFormatter;
         if (selectedFormatter == null)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperWarning(new InvalidOperationException(SR2.GetString(SR2.MessageFormatPropertyNotFound3)));
         }
     }
     selectedFormatter.DeserializeRequest(message, parameters);
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:26,代码来源:DemultiplexingDispatchMessageFormatter.cs


示例16: TransformAndHandleFault

        private Message TransformAndHandleFault(Message message)
        {
            if (message.Headers.Action.EndsWith("/fault"))
            {
                var buffer = message.CreateBufferedCopy(int.MaxValue);

                var clonedMessage = buffer.CreateMessage();

                var reader = clonedMessage.GetReaderAtBodyContents();

                reader.Read();
                reader.Read();
                reader.Read();
                reader.Read();
                reader.Read();

                var val = reader.Value;

                if (string.IsNullOrWhiteSpace(val))
                {
                    return buffer.CreateMessage();
                }
                
                if (val == Constants.SerializationFaultCode.ToString(CultureInfo.InvariantCulture))
                {
                    var store = ObjectBuilder.GetModelStore();

                    store.RemoveAll();
                }

                return buffer.CreateMessage();
            }

            return message;
        }
开发者ID:yonglehou,项目名称:ProtoBuf.Wcf,代码行数:35,代码来源:ProtoBufMetaDataRequestChannel.cs


示例17: TryCreateFaultMessage

        public bool TryCreateFaultMessage(Exception exception, out Message message)
        {
            bool created = this.OnTryCreateFaultMessage(exception, out message);

            if (created)
            {
                if (message == null)
                {
                    string text = SR.Format(SR.FaultConverterDidNotCreateFaultMessage, this.GetType().Name);
                    Exception error = new InvalidOperationException(text);
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(error);
                }
            }
            else
            {
                if (message != null)
                {
                    string text = SR.Format(SR.FaultConverterCreatedFaultMessage, this.GetType().Name);
                    Exception error = new InvalidOperationException(text);
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(error);
                }
            }

            return created;
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:25,代码来源:FaultConverter.cs


示例18: TryCreateException

 public bool TryCreateException(Message message, MessageFault fault, out Exception exception)
 {
     if (message == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
     }
     if (fault == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("fault");
     }
     bool flag = this.OnTryCreateException(message, fault, out exception);
     if (flag)
     {
         if (exception == null)
         {
             Exception exception2 = new InvalidOperationException(System.ServiceModel.SR.GetString("FaultConverterDidNotCreateException", new object[] { base.GetType().Name }));
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception2);
         }
         return flag;
     }
     if (exception != null)
     {
         Exception exception3 = new InvalidOperationException(System.ServiceModel.SR.GetString("FaultConverterCreatedException", new object[] { base.GetType().Name }), exception);
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception3);
     }
     return flag;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:FaultConverter.cs


示例19: Send

        public Task Send(Message[] messages)
        {
            if (messages == null || messages.Length == 0)
            {
                return TaskAsyncHelper.Empty;
            }

            SqlConnection connection = null;
            try
            {
                connection = new SqlConnection(_connectionString);
                connection.Open();
                using (var cmd = new SqlCommand(_insertSql, connection))
                {
                    cmd.Parameters.AddWithValue("Payload", JsonConvert.SerializeObject(messages));

                    return cmd.ExecuteNonQueryAsync()
                        .Then(() => connection.Close()) // close the connection if successful
                        .Catch(ex => connection.Close()); // close the connection if it explodes
                }
            }
            catch (SqlException)
            {
                if (connection != null && connection.State != ConnectionState.Closed)
                {
                    connection.Close();
                }
                throw;
            }
        }
开发者ID:rustd,项目名称:SignalR,代码行数:30,代码来源:SqlSender.cs


示例20: CopyActivity

 static internal void CopyActivity(Message source, Message destination)
 {
     if (DiagnosticUtility.ShouldUseActivity)
     {
         TraceUtility.SetActivity(destination, TraceUtility.ExtractActivity(source));
     }
 }
开发者ID:weshaggard,项目名称:wcf,代码行数:7,代码来源:TraceUtility.cs



注:本文中的System.Globalization.Message类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Globalization.NumberFormatInfo类代码示例发布时间:2022-05-26
下一篇:
C# Globalization.KoreanCalendar类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap