GetStaticProperty() public method

Retrieves a value from a static property by specifying a type full name and property
public GetStaticProperty ( string TypeName, string Property ) : object
TypeName string Full type name (namespace.class)
Property string Property to get value from
return object
Example #1
0
 public void SetValueFromEnum(string enumType, string enumName)
 {
     wwDotNetBridge bridge = new wwDotNetBridge();
     Value = bridge.GetStaticProperty(enumType, enumName);
 }
Example #2
0
 /// <summary>
 /// Sets the value property from a static property retrieved from .NET.
 /// Useful to transfer value in .NET that are marshalled incorrectly
 /// in FoxPro such as Enum values (that are marshalled as numbers)
 /// </summary>
 /// <param name="typeName">Full type name as a string - can also be an Enum type</param>
 /// <param name="property">The static property name</param>
 public void SetValueFromStaticProperty(string typeName,string property)
 {
     wwDotNetBridge bridge = new wwDotNetBridge();
     Value = bridge.GetStaticProperty(typeName,property);
 }
Example #3
0
        /// <summary>
        /// Assigns an enum value to the value structure. This 
        /// allows to pass enum values to methods and constructors
        /// to ensure that method signatures match properly
        /// </summary>
        /// <param name="enumValue">full type and value name. Example: System.Windows.Forms.MessageBoxOptions.OK</param>
        public void SetEnum(string enumValue)
        {
            if (string.IsNullOrEmpty(enumValue))
                throw new ArgumentNullException("Enum type is not set.");

            int at = enumValue.LastIndexOf('.');

            if (at == -1)
                throw new ArgumentException("Invalid format for enum value.");

            string type = enumValue.Substring(0, at);
            string property = enumValue.Substring(at+1);

            var bridge = new wwDotNetBridge();
            Value = bridge.GetStaticProperty(type,property);
        }