By. practices .. enterpriselibrary has found an object generator in his learning. This should be a very stable class library. Otherwise, Microsoft should not seal it so firmly, nor find it. Source code . For the purpose of learning, I used refrector to restore the headers. By the way, I can see from the browser that the headers are not small (Note: Because I just held this class library, and it is the latest version, so there is no source Code , Freedom, innovation, research, exploration ...... And terrylee told us that they finally found the source code after downloading a 2.0 location. Thank you here for choosing :). I went online to search for my work, and I finally found the heritage left by my predecessors. First, let's look at it. I think the best way to really understand it is to separate the code and find out what it is...
For more information about the positioner, seeNiwalker's "objectbuilder technology insider (1)" has already explained in detail, but I think it was a bit obscure at first and I don't understand it. Later I separated the code and understood the truth. From the text perspective, it must be very tiring. Let's first look at the class relationship diagram. I think it should be easier for people to understand the principle of the positioner.
We can see that the most original interface isIreadablelocator, We turn it into a readable locator interface. All the locator classes inherit this interface (either directly or indirectly). It inherits two interfaces: ienumerable <keyvaluepair <object, Object> and ienumerable. Read/write InterfaceIreadwritelocatorInheritanceIreadablelocator interface. Two methods add and remove are added to and remove the ireadablelocator interface, which forms a readable and writable interface.
It can be seen that the abstract base class of the readable positioner inherits the readable interface and expands the class into an abstract base class that can be read and written, and then implements their own abstract instances through readonlylocator and locator respectively. Specifically, searchmode has two values: Up and local, that is, up can be searched for objects in its parent container, while local only searches for the current location.
It is worth noting that there is a weak reference object dictionary weakrefdictionary,The positioner uses it as the internal storage structure to implement the object buffer mechanism. When separating code, I also encountered a problem. Is there a nested class formed by the compiler? This has to be studied, so we won't be embarrassed here. Well, if the senior man has studied whether he can tell the younger brother: 1 [Compilergenerated]
2 Private Sealed Class < Getenumerator > D _ 0: ienumerator < Keyvaluepair < Tkey, tvalue > , Ienumerator, idisposable
3 {
4 [Debuggerhidden]
5 Public < Getenumerator > D _ 0 ( Int <> 1 _ State );
6 Private Bool Movenext ();
7 [Debuggerhidden]
8 Void Ienumerator. Reset ();
9 Void Idisposable. Dispose ();
10
11 Keyvaluepair < Tkey, tvalue > Ienumerator < Keyvaluepair < Tkey, tvalue > . Current {[Debuggerhidden]Get;}
12 Object Ienumerator. Current {[Debuggerhidden]Get;}
13
14 Private Int <> 1 _ state;
15 Private Keyvaluepair < Tkey, tvalue > <> 2 _ current;
16 Public Weakrefdictionary < Tkey, tvalue > <> 4 _ this;
17 Public Dictionary < Tkey, weakreference > . Enumerator <> 7 _ wrap3;
18 Public Object < Innervalue > 5__2;
19 Public Keyvaluepair < Tkey, weakreference > < KVp > 52.161;
20 }
21
This kind of code has been seen before. It seems that iteration is implemented in this way, but this type seems to be unavailable to us. We have to study it in depth. At the same time, I really hope which brother can give some advice, really... let's look at other implementation methods.Niwalker's objectbuilder technology insider (1) is redundant in writing :)
the above is done through the iterator yield !!!!!