StringsEx library

Discussion in 'Additional Libraries' started by agraham, Mar 24, 2008.

  1. agraham

    agraham Expert Licensed 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.
     

    Attached Files:

    Last edited: May 28, 2008
  2. Erel

    Erel Administrator Staff Member Licensed User

    Thanks Agraham.
    This is a very useful library as most programs deal with strings in one way or another.
     
  3. agraham

    agraham Expert Licensed User

    Source code for merging dll posted in original post.
     
  4. tsteward

    tsteward Active Member Licensed User

    It seems your help file is incorrect.
    Unless I am mistaken (probably I am) it should be
     
  5. agraham

    agraham Expert Licensed User

    No you are not. You are right ,the help is wrong :(
     
  6. Smee

    Smee Well-Known Member Licensed User

    :sign0060:

    This just keeps getting better and better

    Thanks for this
     
  7. mjcoon

    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.
     
  8. agraham

    agraham Expert Licensed 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.
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    You need to add 'override' to the ToString method declaration. Otherwise your ToString will not replace the base method (which is actually overloading rather than overriding).
     
  10. agraham

    agraham Expert Licensed User

    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!
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    This C# code demonstrates that in the case of hiding the base method is still accessible (and therefore returned by the Reflection call):
    Code:
    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.

            }
        }
     
  12. agraham

    agraham Expert Licensed 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!
     
Loading...