Quantcast
Channel: SCN: Message List - PowerBuilder Developer Center
Viewing all articles
Browse latest Browse all 7329

Attributes in Powerbuilder Net

$
0
0

Hi,

 

I am trying to access the configSection of a web.config file using Powerbuilder.net to achieve something like this C# Example :

 

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;


namespace MyNameSpace
{
    public class MyClass : ConfigurationSection
    {
       [ConfigurationProperty("MyExampleText", DefaultValue = "Cheese", IsRequired = true)]
        public String ExampleText
        {
            get
            {
                return (String)this["MyExampleText"];
            }
            set
            {
                this["MyExampleText"] = value;
            }
        }

    }
    public static class MyClassToGetStuff
    {
        public static string GetExampleText()
        {
            var ret = (MyClass)System.Configuration.ConfigurationManager.GetSection("ServiceSettingsGroup/ServiceSettings");
            return ret.ExampleText;
        }
    }  
}

 

(Important parts of) Web.config :

  <configSections>
    <sectionGroup name="ServiceSettingsGroup">
      <section
        name="ServiceSettings"
        type="MyNameSpace.MyClass"
        allowLocation="true"
        allowDefinition="Everywhere"
          />
    </sectionGroup>
  </configSections>

  <ServiceSettingsGroup>
    <ServiceSettings MyExampleText="Not Cheese">
    </ServiceSettings>
  </ServiceSettingsGroup>

 

This way I can define a string for later use in the web.config and retrieve it by calling MyClassToGetStuff.GetExampleText().
Is there any way to achieve this or something similar in Powerbuilder.net  ?

 

I inherit from the class ConfigurationSection ( using References "System.Configuration") and add the property ExampleText.

I can define a getter und setter method for the variable but there is no possibility to add the attribute contained in the brackets.

 

Regards Christian


Viewing all articles
Browse latest Browse all 7329

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>