Opc.Ua.ContentFilter.ToLocalizedText C# (CSharp) Method

ToLocalizedText() private static method

Converts a value to a LocalizedText
private static ToLocalizedText ( object value, BuiltInType sourceType ) : object
value object
sourceType BuiltInType
return object
        private static object ToLocalizedText(object value, BuiltInType sourceType)
        {            
            // check for array conversions.
            Array array = value as Array;

            if (array != null)
            {
                LocalizedText[] output = new LocalizedText[array.Length];

                for (int ii = 0; ii < array.Length; ii++)
                {
                    output[ii] = (LocalizedText)Cast(array.GetValue(ii), BuiltInType.LocalizedText);
                }

                return output;
            }

            // handle for supported conversions.
            switch (sourceType)
            {
                case BuiltInType.LocalizedText:
                {
                    return (LocalizedText)value; 
                }

                case BuiltInType.String:
                {
                    return new LocalizedText((string)value);
                }
            }

            // conversion not supported.
            return null;
        }