Пример #1
0
        /// <summary>
        /// When converting a list of headers to an <see cref="ExtensibleObject"/>, this
        /// method sets the common attributes on the object.
        /// </summary>
        /// <param name="obj">The <see cref="ExtensibleObject"/> to be populated</param>
        /// <param name="headers">The <see cref="HeaderCollection"/> containing the list of headers</param>
        protected static void SetCommonAttributesFromHeaders(ExtensibleObject obj, HeaderCollection headers)
        {
            if (obj != null && headers != null)
            {
                Header hMachineName = headers.Get(Header.ORIGIN_MACHINE_NAME);
                if (hMachineName != null && !String.IsNullOrEmpty(hMachineName.Value))
                {
                    obj.machineName = hMachineName.Value;
                }

                Header hSoftwareName = headers.Get(Header.ORIGIN_SOFTWARE_NAME);
                if (hSoftwareName != null && !String.IsNullOrEmpty(hSoftwareName.Value))
                {
                    obj.softwareName = hSoftwareName.Value;
                }

                Header hSoftwareVersion = headers.Get(Header.ORIGIN_SOFTWARE_VERSION);
                if (hSoftwareVersion != null && !String.IsNullOrEmpty(hSoftwareVersion.Value))
                {
                    obj.softwareVersion = hSoftwareVersion.Value;
                }

                Header hPlatformName = headers.Get(Header.ORIGIN_PLATFORM_NAME);
                if (hPlatformName != null && !String.IsNullOrEmpty(hPlatformName.Value))
                {
                    obj.platformName = hPlatformName.Value;
                }

                Header hPlatoformVersion = headers.Get(Header.ORIGIN_PLATFORM_VERSION);
                if (hPlatoformVersion != null && !String.IsNullOrEmpty(hPlatoformVersion.Value))
                {
                    obj.platformVersion = hPlatoformVersion.Value;
                }
            }
        }
Пример #2
0
        /// <summary>

        /// When converting a list of headers to an <see cref="ExtensibleObject"/>, this

        /// method sets the custom attributes (both text and binary) on the object.

        /// </summary>

        /// <param name="obj">The <see cref="ExtensibleObject"/> to be populated</param>

        /// <param name="headers">The <see cref="HeaderCollection"/> containing the list of headers</param>

        protected static void SetCustomAttributesFromHeaders(ExtensibleObject obj, HeaderCollection headers)

        {
            if (obj != null && headers != null)

            {
                foreach (Header header in headers.CustomHeaders)

                {
                    if (header != null)

                    {
                        if (header.IsGrowlResourcePointer)

                        {
                            obj.CustomBinaryAttributes.Add(header.ActualName, header.GrowlResource);
                        }

                        else

                        {
                            obj.CustomTextAttributes.Add(header.ActualName, header.Value);
                        }
                    }
                }
            }
        }
Пример #3
0
        /// <summary>

        /// Sets the object's base class properties from the supplied header list

        /// </summary>

        /// <param name="obj">The <see cref="ExtensibleObject"/> being rehydrated</param>

        /// <param name="headers">The <see cref="HeaderCollection"/> containing the parsed header values</param>

        /// <remarks>

        /// This method should only be called from a derived class' .FromHeaders() method.

        /// It takes care of setting the Origin-* related properties, as well as any custom attributes.

        ///

        /// This method is the same as calling both SetCommonAttributesFromHeaders and

        /// SetCustomAttributesFromHeaders.

        /// </remarks>

        protected static void SetInhertiedAttributesFromHeaders(ExtensibleObject obj, HeaderCollection headers)

        {
            SetCommonAttributesFromHeaders(obj, headers);

            SetCustomAttributesFromHeaders(obj, headers);
        }
Пример #4
0
 /// <summary>
 /// Adds some custom server-specific headers to the outgoing response
 /// </summary>
 /// <param name="exObj">The <see cref="Response"/> or <see cref="Error"/> being returned</param>
 private void AddServerHeaders(ExtensibleObject exObj)
 {
     if(!exObj.CustomTextAttributes.ContainsKey("Message-Daemon"))
         exObj.CustomTextAttributes.Add("Message-Daemon", serverName);
     if(!exObj.CustomTextAttributes.ContainsKey("Timestamp"))
         exObj.CustomTextAttributes.Add("Timestamp", DateTime.Now.ToString());
 }
 /// <summary>
 /// Sets the object's base class properties from the supplied header list
 /// </summary>
 /// <param name="obj">The <see cref="ExtensibleObject"/> being rehydrated</param>
 /// <param name="headers">The <see cref="HeaderCollection"/> containing the parsed header values</param>
 /// <remarks>
 /// This method should only be called from a derived class' .FromHeaders() method.
 /// It takes care of setting the Origin-* related properties, as well as any custom attributes.
 /// 
 /// This method is the same as calling both SetCommonAttributesFromHeaders and
 /// SetCustomAttributesFromHeaders.
 /// </remarks>
 protected static void SetInhertiedAttributesFromHeaders(ExtensibleObject obj, HeaderCollection headers)
 {
     SetCommonAttributesFromHeaders(obj, headers);
     SetCustomAttributesFromHeaders(obj, headers);
 }
 /// <summary>
 /// When converting a list of headers to an <see cref="ExtensibleObject"/>, this
 /// method sets the custom attributes (both text and binary) on the object.
 /// </summary>
 /// <param name="obj">The <see cref="ExtensibleObject"/> to be populated</param>
 /// <param name="headers">The <see cref="HeaderCollection"/> containing the list of headers</param>
 protected static void SetCustomAttributesFromHeaders(ExtensibleObject obj, HeaderCollection headers)
 {
     if (obj != null && headers != null)
     {
         foreach (Header header in headers.CustomHeaders)
         {
             if (header != null)
             {
                 if (header.IsGrowlResourcePointer)
                 {
                     obj.CustomBinaryAttributes.Add(header.ActualName, header.GrowlResource);
                 }
                 else
                 {
                     obj.CustomTextAttributes.Add(header.ActualName, header.Value);
                 }
             }
         }
     }
 }
        /// <summary>
        /// When converting a list of headers to an <see cref="ExtensibleObject"/>, this
        /// method sets the common attributes on the object.
        /// </summary>
        /// <param name="obj">The <see cref="ExtensibleObject"/> to be populated</param>
        /// <param name="headers">The <see cref="HeaderCollection"/> containing the list of headers</param>
        protected static void SetCommonAttributesFromHeaders(ExtensibleObject obj, HeaderCollection headers)
        {
            if (obj != null && headers != null)
            {
                Header hMachineName = headers.Get(Header.ORIGIN_MACHINE_NAME);
                if (hMachineName != null && !String.IsNullOrEmpty(hMachineName.Value)) obj.machineName = hMachineName.Value;

                Header hSoftwareName = headers.Get(Header.ORIGIN_SOFTWARE_NAME);
                if (hSoftwareName != null && !String.IsNullOrEmpty(hSoftwareName.Value)) obj.softwareName = hSoftwareName.Value;

                Header hSoftwareVersion = headers.Get(Header.ORIGIN_SOFTWARE_VERSION);
                if (hSoftwareVersion != null && !String.IsNullOrEmpty(hSoftwareVersion.Value)) obj.softwareVersion = hSoftwareVersion.Value;

                Header hPlatformName = headers.Get(Header.ORIGIN_PLATFORM_NAME);
                if (hPlatformName != null && !String.IsNullOrEmpty(hPlatformName.Value)) obj.platformName = hPlatformName.Value;

                Header hPlatoformVersion = headers.Get(Header.ORIGIN_PLATFORM_VERSION);
                if (hPlatoformVersion != null && !String.IsNullOrEmpty(hPlatoformVersion.Value)) obj.platformVersion = hPlatoformVersion.Value;
            }
        }