StringsEx library

agraham

Expert
Licensed User
Longtime User
I have put all the .NET string handling that seemed relevant and that was not already implemented in B4PPC in this library. I've also provided access to a .NET StringBuilder that efficiently concatenates large numbers of strings. Help and (sort of) demo app included. Should work on .NET 1.0 and 2.0 and desktop and device.

If I have missed any string operation that anyone thinks might be useful then let me know.

EDIT :- Source code for merging dlls posted. PLace in the Basic4ppp Desktop\Libraries folder.
 

Attachments

  • StringsEx1.1.zip
    12.7 KB · Views: 717
  • StringsExSource1.1.zip
    979 bytes · Views: 408
Last edited:

Smee

Well-Known Member
Licensed User
Longtime User
:sign0060:

This just keeps getting better and better

Thanks for this
 

mjcoon

Well-Known Member
Licensed User
I've just been successfully using StringsEx.dll (v1.1).

The IDE offers StringBuilder method "ToString2" but this is not mentioned in the DLL Help.

Is it interesting? ("Dispose" isn't mentioned either but that's rather obvious.)

Cheers, Mike.
 

agraham

Expert
Licensed User
Longtime User
All .NET objects have a ToString method and many have a Dispose method.

ToString is useful on the actual .NET object on the desktop as it often returns useful information. On the device it is less useful as it usually only returns the class name for space economy reasons. However as libraries hold their underlying .NET objects (if any) as Value or ControlRef properties you can't call ToString on them in Basic4ppc except by using the Door library. The library ToString will usually only return the class name of the library object so is of little use.

Dispose, if present, is used by Basic4ppc but in general should not be used by a Basic4ppc program except perhaps on Bitmaps but now ImageLibEx makes that unnecessary.

In StringBuilder I chose to overide the default ToString to return the contents of the StringBuilder rather than the class name of the library StringBuilder object. However I didn't expect Basic4ppc to pick up the original (and I am not sure why it does) as ToString2 which just returns the class name - so no, it's not much use.

For completeness I also got the scope of the underlying "version" field wrong so it is visible to though unusable by Basic4ppc. This field is what the DllVersion property returns.
 

agraham

Expert
Licensed User
Longtime User
You need to add 'override' to the ToString method
Thanks Erel. I (wrongly) thought that hiding it would (in this case) be much the same as overriding it in that it would make the base class member invisible. As it doesn't I'm obviously missing something in my understanding of what is actually happening. Leaves to read and ponder!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This C# code demonstrates that in the case of hiding the base method is still accessible (and therefore returned by the Reflection call):
B4X:
    public class Father
    {
        public virtual void m1()
        {
            MessageBox.Show("father.m1");
        }
        public virtual void m2()
        {
            MessageBox.Show("father.m2");
        }
    }
    public class Son : Father
    {
        public void m1()
        {
            MessageBox.Show("son.m1");
        }
        public override void m2() //note the OVERRIDE here
        {
            MessageBox.Show("son.m2");
        }
        public static void Main(string[] args)
        {
            Son s = new Son();
            s.m1(); //shows son.m1
            ((Father)s).m1(); //shows father.m1, the object Son has two m1 methods.

            s.m2(); //shows son.m2
            ((Father)s).m2(); //shows son.m2 - the object Son has only one m2 method.

        }
    }
 

agraham

Expert
Licensed User
Longtime User
Ah!, thanks Erel - it's clicked now. When you reflect on it I guess you can distinguish between the non-overridden versions by looking in the two different MethodInfo.Declaringtype properties. I also guess that for the overriden version with only one MethodInfo available DeclaringType will be the "latest" override applicable to the class that you are reflecting on.

Still stuff to learn - sigh! - and I haven't even looked at C#3.0 let alone C# 4.0!
 
Top